Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Drop on a Palette
Drop on a Palette [message #231829] Mon, 19 March 2007 09:19 Go to next message
Eclipse UserFriend
Originally posted by:


using a FlyoutPalette together with a GraphicalViewer is fairly easy.
Even dragging from the Palette on the Viewer. But how can one accomplish
the other way around? I would like to create a PaletteToolEntry, when
something is dragged from the Viewer and dropped on the Palette.

What i did was:

+ Creating my own TemplateTransferDragSourceListener to allow diffrent
models then the PaletteTemplateEntry and the
CombinedTemplateCreationEntry to be used. I added this listener to the
GraphicalViewer via "viewer.addDragSourceListener(listener)".

+ Adding a TemplateDropTargetListener to my PaletteViewer. (within my
own PaletteViewerProvider.configurePaletteViewer(PaletteViewer viewer)

Dragging works fine. But when the TransferDropTargetListener on my
PaletteViewer is asked if it is enabled it results in false. It is
because it cannot find a target EditPart.

I think the best way to solve the problem would be to add a custom
EditPolicy to the SliderPaletteEditPart which returns the target
EditPart when recieving a CreateRequest.

The Problem is: I cant get the SliderPaletteEditPart on an easy way. It
is created in PaletteEditPartFactory and actually returned by the method
"createEditPart" in it. But the calling method
(PaletteViewer.setPaletteRoot(...)) uses a local variable to store the

So... If i am on the right track: How can i add the custom EditPolicy /
get the SliderPaletteEditPart

or: Is there a diffrent way which i havnt discoverd yet?


Re: Drop on a Palette [message #231846 is a reply to message #231829] Mon, 19 March 2007 13:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by:


I got it working at last.

In the method "configurePaletteViewer" in my custom
PaletteViewerProvider i install a custom EditPolicy on the
SliderPaletteEditPart. I retrieve this EditPart by searching the viewers
RootEditPart for an instance for SliderPaletteEditPart.

To have the SliderPaletteEditPart as a child of the viewers RootEditPart
one has to call "editDomain.setPaletteRoot(...)" first. This causes a
creation of the SliderPaletteEditPart.

The custom EditPolicy returns "getHost()" when asked for the target

This solution works but I think its not the finest way.
If someone knows a better solution please tell me.


Re: Drop on a Palette [message #231853 is a reply to message #231846] Mon, 19 March 2007 13:44 Go to previous message
Eclipse UserFriend
Originally posted by:


i have to correct me a little.

This is the way it _should_ work.

Instead I created a method "postRootEditPartConfigure()" in my
PaletteViewerProvider. Which is called after I added the RootEditPart to
the EditDomain so I do:

MyPaletteViewerProvider pvp = new MyPaletteViewerProvider(editDomain);
editDomain.setPaletteRoot(new PaletteRoot);

This is needed, because the EditDomain calls the PaletteViewers
setPaletteRoot(...) method. But the "configurePaletteViewer" method in
PaletteViewerProvider is called when the object is created. So the
SliderPaletteEditPart wouldnt be there.

Sorry for beeing a little confusing.

Previous Topic:Mouse events in GraphicalViewer
Next Topic:Re: Process For Finding Out About a Project
Goto Forum:

Current Time: Tue Dec 07 19:30:59 GMT 2021

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

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

Back to the top