Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Object creation with DnD from the palette prevent direct edit
Object creation with DnD from the palette prevent direct edit [message #249686] Mon, 20 July 2009 14:58
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
Hi all,

I have a simple graphical editor to help the creation and edition of a
xml file of our specific format. It uses pretty much everything in gef,
creation of object, connection, anchor points, etc.

Today, I wanted to add the ability for the user to create a new object
using the DnD facility of the palette. Previously, a user had to click
on the palette then click in the editor, which then launched the command
to create the object in the model. It also launched the direct edit of
the newly created object to cut down operations done by the user (so the
user doesn't have to select then click the object to activate direct
edit). Everything worked fine.

Now, when the user creates the same object using the DnD facility, the
user cannot directly start typing the new value because of an
inconsistent state of the keyboard focus. The TextCellEditor doesn't
have the keyboard focus, so user input is not directed to it. Also, this
leaves the CellEditor open when it should be closed because it doesn't
have the focus.

I've tried pinning down the problem and I think I might have found it.
When using point-and-click to create the object, it is the CreationTool
class that handles the mouse down event. When mouse down happens, it
calls the performCreation() method which execute the creation command
(in my case it's a compound command which creates the model object then
start direct edit) then select the new object by calling
selectAddedObject(EditPartViewer).
When using DnD to create the object, it is the
TemplateTransferDropTargetListener class that handles the drop event.
When the drop happens, the method handleDrop() is called by the super
class, AbstractTransferDropTargetListener, which is overridden to select
the created object. The base handleDrop execute the creation command as
the CreationTool does. The extended method select the new object by
calling selectAddedObject() which is a copy of the previous method. If
you look closely at the two methods, there is a difference: the second
one calls
viewer.getControl().forceFocus();
and the first one doesn't. I think this call is the problem.

As a test, I copied the TemplateTransferDropTargetListener and removed
that call. Everything seems to work fine now when using the DnD. So, I'm
wondering if this is valid enough to open a bug to change this behavior
or is there a reason behind that call that I'm unaware of?

I'm using Gef 3.5.
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Previous Topic:Automatically resize client area when moving editpart
Next Topic:Label parallel to Connection
Goto Forum:
  


Current Time: Tue Apr 23 13:18:10 GMT 2024

Powered by FUDForum. Page generated in 0.02812 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top