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: till.tillamma.de

Hello,

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)
method)

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
EditPart.

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?

Thanks,

Till
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: till.tillamma.de

Ok,

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
EditPart.

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

Thanks,

Till
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: till.tillamma.de

hmpf

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);
pvp.postRootEditPartConfigure();

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.

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


Current Time: Wed Dec 01 10:11:26 GMT 2021

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

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

Back to the top