Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Custom commands for palette icons
Custom commands for palette icons [message #716428] Wed, 17 August 2011 11:38 Go to next message
janpojer is currently offline janpojerFriend
Messages: 40
Registered: July 2011
Member
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 11:38]

Report message to a moderator

Re: Custom commands for palette icons [message #716710 is a reply to message #716428] Thu, 18 August 2011 07:42 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
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 08:11 Go to previous messageGo to next message
janpojer is currently offline janpojerFriend
Messages: 40
Registered: July 2011
Member
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 08:12]

Report message to a moderator

Re: Custom commands for palette icons [message #716767 is a reply to message #716716] Thu, 18 August 2011 11:43 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
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 20:17 Go to previous messageGo to next message
janpojer is currently offline janpojerFriend
Messages: 40
Registered: July 2011
Member
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 06:39 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
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 09:11 Go to previous messageGo to next message
janpojer is currently offline janpojerFriend
Messages: 40
Registered: July 2011
Member
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 09:16]

Report message to a moderator

Re: Custom commands for palette icons [message #718370 is a reply to message #718101] Wed, 24 August 2011 06:38 Go to previous message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
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: Fri Apr 19 14:48:47 GMT 2024

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

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

Back to the top