Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Custom commands for palette icons
Custom commands for palette icons [message #716428] Wed, 17 August 2011 07:38 Go to next message
Eclipse UserFriend
Hi all,

can someone advice me with what is the best way to assign custom command to palette icon?

Thanks a lot.

J

[Updated on: Wed, 17 August 2011 07:38] by Moderator

Re: Custom commands for palette icons [message #716710 is a reply to message #716428] Thu, 18 August 2011 03:42 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

what do you want to do with this command? Try to customize the corresponding CreateXXXCommand in your generated plugin.

Ralph
Re: Custom commands for palette icons [message #716716 is a reply to message #716710] Thu, 18 August 2011 04:11 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ralph,

Its not that easy. The thing I am trying to do is that i dynamically, based on external file, render my custom palette and I need to assign each button with specific command, that creates certain figures. I need to pass some params along my command and than use ElementInitializers to create custom figures.

Jan

[Updated on: Thu, 18 August 2011 04:12] by Moderator

Re: Custom commands for palette icons [message #716767 is a reply to message #716716] Thu, 18 August 2011 07:43 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I basically do the same that you do. For me it works like this:

I create different palette entries for the same semantic model element. In the id I encode something like markerThatItIsSomethingSpecial.Name.MoreInformation. This informatation I ask for in the method that sets up the semanic element in the ElementInitializer. For this you need to query the palette for the active tool and get its id. Then I setup the semantic element. In the edipart of the semantic element I place some code to manipulate the figure based on properties of the semantic model. You can do this in methods like addNotify, the constructor of the figure, updateConnections, handleNotification or whatever suits your needs. This works very well in my case. Just manipulating the figure is not the best thing but I do not get managed to create EditParts that are not backed up by a semantic element. Maybe you have an idea on this.

Ralph
Re: Custom commands for palette icons [message #717961 is a reply to message #716767] Mon, 22 August 2011 16:17 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I am trying to get the active tool in ElementInitializers.

I am able to get tool via:
IEditorPart iep = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
DiagramDocumentEditor dde = (DiagramDocumentEditor)iep;
Tool t = dde.getDiagramGraphicalViewer().getEditDomain().getActiveTool();


But Tool does not have getId(). So I am not sure if i have the right approach. How do u get the id of the active palette tool?

Thanks in advance...

J
Re: Custom commands for palette icons [message #718055 is a reply to message #717961] Tue, 23 August 2011 02:39 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I use the following code:

getEditDomain().getPaletteViewer()..getActiveTool().getId()


I use getEditDomain() which returns a default edit domain. You should be able to cast you EditDomain into a DefaultEditDomain, too.

Ralph
Re: Custom commands for palette icons [message #718101 is a reply to message #718055] Tue, 23 August 2011 05:11 Go to previous messageGo to next message
Eclipse UserFriend
Great tip... that did it. Thanks

Have you or anyone experienced problems when adding diagram elements through element initializers? My problem is that whenever i create more then one child element, it disrespect my EAST/WEST alignment on its parent figure... any ideas?

Interesting thing is, that it doesnt happen when I add only one item through the initializer...

Jan

[Updated on: Tue, 23 August 2011 05:16] by Moderator

Re: Custom commands for palette icons [message #718370 is a reply to message #718101] Wed, 24 August 2011 02:38 Go to previous message
Eclipse UserFriend
Hi,

I did not experience this problem yet. Maybe you open a own thread on this (I think you did so in the past) or report it as bug to see if it is a bug or expected behaviour.

Ralph
Previous Topic:Centering a label horizontally and vertically
Next Topic:Installing GMF SDK under Indigo
Goto Forum:
  


Current Time: Wed Jul 23 22:27:55 EDT 2025

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

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

Back to the top