Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Double-click on palette entry
Double-click on palette entry [message #207541] Tue, 17 January 2006 15:13 Go to next message
Eclipse UserFriend
Originally posted by: marian.schedenig.gft.com

Hi,

I have a palette containing several entries using a custom CreationTool
subclass. At the moment, this allows creating the respective elements in
the graphical editor using either drag and drop or by clicking on the
tool and then clicking at the desired location in the editor.

What I need now is an additional option which automatically creates the
respective element at my current caret location when I *double-click* on
a palette entry. I suppose I'll do this either by creating the necessary
command directly in the tool or by sending a request to the editor. My
problem is catching the double-click, however. I've found a few threads
about palette double-clicks through Google, but none of them seemed to
contain a working solution.

Any pointers?

Thx,
Marian.
Re: Double-click on palette entry [message #208023 is a reply to message #207541] Wed, 25 January 2006 11:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marian.schedenig.gft.com

Marian Schedenig schrieb:
> What I need now is an additional option which automatically creates the
> respective element at my current caret location when I *double-click* on
> a palette entry.

Ok, I figured it out. Here's what I'm doing:

In my editor, I override createPartControl(). After calling the super
method, I get the palette viewer from the domain. I get its root edit
part and loop through all its children. On those whose model is my
custom creation entry, I get the figure, cast it to Clickable and add an
action listener.

In the listener, I get the current system time
(System.currentTimeMillis()) and compare it to the last time the same
listener instance was called. If it is smaller than a specific number
(in my current case, 250), I assume that a double click has occured.

Of course, this is insensitive to the system's double click delay
setting, but it's better than nothing, and the only working solution
I've been able to come up with. I originally tried to do it with mouse
listeners, but I would only receive the double click event when I also
caught the button up and button down events and marked them as already
handled. Of course, this also causes the tool entries to stop working as
expected, so I ended up doing it the way described above.

Until a better solution comes along, I expect this'll do just fine.

Marian.
Re: Double-click on palette entry [message #209544 is a reply to message #208023] Thu, 16 February 2006 07:21 Go to previous message
Dazhen Gao is currently offline Dazhen GaoFriend
Messages: 21
Registered: July 2009
Junior Member
I don't know your detail requirement.But in my product , custom need to
double click the palette view entry to create a new item in the editor;
code like this:
In the GraphicalEditorWithFlyoutPalette class (I think you can overwrite )
protected PaletteViewerProvider createPaletteViewerProvider( )
{
return new PaletteViewerProvider( getEditDomain( ) ) {

protected void configurePaletteViewer( final PaletteViewer viewer )
{
//add the mouse listener
viewer.getControl( ).addMouseListener( new MouseListener( ) {

//deal with double click
public void mouseDoubleClick( MouseEvent e )
{
//find the editpart
EditPart editPart = viewer.findObjectAt( new Point( e.x,
e.y ) );
//the model, my model is ReportCombinedTemplateCreationEntry , your model
may be CombinedTemplateCreationEntry
ReportCombinedTemplateCreationEntry entry = null;
if ( editPart != null
&& editPart.getModel( ) instanceof
ReportCombinedTemplateCreationEntry )
{
entry = (ReportCombinedTemplateCreationEntry) editPart.getModel( );
}
if ( entry == null )
return;
// use the create tool to create the new item,your tool may be the
CreationTool.


ReportCreationTool tool = (ReportCreationTool) entry.createTool( );

final EditDomain domain = UIUtil.getLayoutEditPartViewer( )
.getEditDomain( );
tool.setEditDomain( domain );
tool.setViewer( UIUtil.getLayoutEditPartViewer( ) );
tool.performCreation( UIUtil.getCurrentEditPart( ) );

Display.getCurrent( ).asyncExec( new Runnable( ) {

public void run( )
{
domain.loadDefaultTool( );
}
} );
//do other thing
}

can help you?
"Marian Schedenig" <marian.schedenig@gft.com> wrote in message
news:dr7p1i$ta3$1@utils.eclipse.org...
> Marian Schedenig schrieb:
>> What I need now is an additional option which automatically creates the
>> respective element at my current caret location when I *double-click* on
>> a palette entry.
>
> Ok, I figured it out. Here's what I'm doing:
>
> In my editor, I override createPartControl(). After calling the super
> method, I get the palette viewer from the domain. I get its root edit part
> and loop through all its children. On those whose model is my custom
> creation entry, I get the figure, cast it to Clickable and add an action
> listener.
>
> In the listener, I get the current system time
> (System.currentTimeMillis()) and compare it to the last time the same
> listener instance was called. If it is smaller than a specific number (in
> my current case, 250), I assume that a double click has occured.
>
> Of course, this is insensitive to the system's double click delay setting,
> but it's better than nothing, and the only working solution I've been able
> to come up with. I originally tried to do it with mouse listeners, but I
> would only receive the double click event when I also caught the button up
> and button down events and marked them as already handled. Of course, this
> also causes the tool entries to stop working as expected, so I ended up
> doing it the way described above.
>
> Until a better solution comes along, I expect this'll do just fine.
>
> Marian.
Previous Topic:Delete in context menu won't work
Next Topic:DirectedGraph connection routing
Goto Forum:
  


Current Time: Thu Mar 28 23:08:42 GMT 2024

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

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

Back to the top