Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Tools Palette elements directly from Java
Tools Palette elements directly from Java [message #894555] Mon, 09 July 2012 15:08 Go to next message
Tomas T is currently offline Tomas TFriend
Messages: 6
Registered: July 2012
Junior Member
Hi GMF experts,

I have just started to play with GMF framework and I have few questions:

I have created a dummy plugin that has several elements in tools palette and they can be added into graphical diagram and linked together with connection element from tools palette. All this was generated by using eclipse GMF plugin.

As I see, all elements types and element types binding are listed in generated plugin.xml under:
org.eclipse.gmf.runtime.emf.type.core.elementTypes
and
org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings
Additionally, modelling assistant provider is registered in org.eclipse.gmf.runtime.emf.ui.modelingAssistantProviders extension point
and view provider is registered under:
org.eclipse.gmf.runtime.diagram.core.viewProviders


My question would be:
Is it possible to add new elements directly from Java code without using data information from plugin.xml?
To be more clear:
How can I add new element type to org.eclipse.gmf.runtime.emf.type.core.elementTypes from Java?
How can I add new element type binding to org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings from Java?
How can I add EditPart implementation for that new element to registered modelling assistant from Java?
How can I add semantic hint for newly created element into registered view provider from Java?

Thanks in advance.



Re: Tools Palette elements directly from Java [message #894703 is a reply to message #894555] Tue, 10 July 2012 08:15 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

do you simply want to execute the code that is executed by GMF when you select a tool from the palete and click on the diagram? To do so you should have a look at CreateUnspecifiedTypeRequest
(http://publib.boulder.ibm.com/infocenter/rsmhelp/v7r0m0/index.jsp?topic=/org.eclipse.gmf.doc/reference/api/runtime/org/eclipse/gmf/runtime/diagram/ui/requests/CreateUnspecifiedTypeRequest.html)

Ralph
Re: Tools Palette elements directly from Java [message #894810 is a reply to message #894703] Tue, 10 July 2012 15:35 Go to previous messageGo to next message
Tomas T is currently offline Tomas TFriend
Messages: 6
Registered: July 2012
Junior Member
Thanks, I will take a look at it.

What I'm trying to do is that I have added a new element into Tools palette by modifying generated TestPaletteFactory class. Now, when I run plugin, I can see that newly created element in Tools palette but I can't add it to diagram. The question is how can I make it work without touching plugin.xml file.

I will take a look at your suggested CreateUnspecifiedTypeRequest but in case you have additional information to the problem I have then I would be grateful to know that.
Re: Tools Palette elements directly from Java [message #894946 is a reply to message #894810] Wed, 11 July 2012 08:23 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

what is your use case for manually editing generated code? Maybe there is a more efficient way to solve your problem.

Ralph
Re: Tools Palette elements directly from Java [message #895073 is a reply to message #894946] Wed, 11 July 2012 15:30 Go to previous messageGo to next message
Tomas T is currently offline Tomas TFriend
Messages: 6
Registered: July 2012
Junior Member
My use case would be:

Allow users create custom elements in the diagram using wizard. So in the beginning user has a basic set of available elements but I would like to allow them creating their own custom elements. From the GUI point of view, user will be asked to specify name of the new element, icons and maybe some additional information and after that plugin will generate some jar file (still not decided) that will be added into plugin directory. After eclipse restart, user will be able to use that new element in the diagram. The place I'm analyzing now is where I should change the code in order to read that information from generated jar files and how should I add new elements into diagram on plugin startup. Of course, after that it should be possible to link predefined elements with new ones.
Re: Tools Palette elements directly from Java [message #895300 is a reply to message #895073] Thu, 12 July 2012 12:06 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

if I am right you are interested in such a thing? http://code.google.com/a/eclipselabs.org/p/melanie/wiki/FirstSteps#Create_Domain-specific_Language

Ralph
Re: Tools Palette elements directly from Java [message #896091 is a reply to message #895300] Tue, 17 July 2012 08:52 Go to previous messageGo to next message
Tomas T is currently offline Tomas TFriend
Messages: 6
Registered: July 2012
Junior Member
Hi,

I was away for one week and only today found time to check your provided link. After checking that video I can tell that it's not what I'm looking for. I want to create a much more simple plugin.
As shown in the picture:
http:// www.javaexpress.pl /static/images/JeP_04_2009_06_GMF_6.png
There are 3 elements in the tools palette:
1) manager
2) Developer
3) Manager managed developers (connection)

So I would like to add for example "Tester" element into tools palette in runtime using some wizard. After that I will have 4 elements in the palette:
1) manager
2) Developer
3) Manager managed developers (connection)
4) Tester

The question is how to achieve this?
Re: Tools Palette elements directly from Java [message #896180 is a reply to message #896091] Tue, 17 July 2012 13:59 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

I think the first thing to ask is how you would like to have tester represented in your meta-model? It sounds to me that you are speaking of extending the meta-model at runtime and create an editor for this. Is this right?

Ralph
Re: Tools Palette elements directly from Java [message #896902 is a reply to message #896180] Fri, 20 July 2012 11:12 Go to previous messageGo to next message
Tomas T is currently offline Tomas TFriend
Messages: 6
Registered: July 2012
Junior Member
In my meta-model I will have one Base element: BaseEmployee that will have an attribute: type which will tell what type of employee is this. So basically I will re-use the same object underneath. But visually it should look like a separate element in the palette and diagram.

So from my point of view it's possible to work around without extending meta-model in the runtime and reuse existing.
Re: Tools Palette elements directly from Java [message #896904 is a reply to message #896902] Fri, 20 July 2012 11:25 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

ok that is very close to what I do in my modeling environment. However I distinct between a ontological and linguistic type. From the linguistic point of view which is implemented in EMF everything is of instance of meta-class clabject everything else is done by code.

What I could remcoment you is to create a model for configuration. Out of this model you dynamically manipulate the palete.

Take a look at the manage palate method in this template which shows how to manipulate the palette by code:

http://code.google.com/a/eclipselabs.org/p/melanie/source/browse/de.uni_mannheim.informatik.swt.models.gmf/templates/aspects/xpt/editor/Editor.xpt

Additionally you would need to interpret at runtime a model describing how the view should look like. Here these two templates should be a good starting point:

updateDSLRenderingView in http://code.google.com/a/eclipselabs.org/p/melanie/source/browse/de.uni_mannheim.informatik.swt.models.gmf/templates/aspects/diagram/editparts/LinkEditPart.xpt

and

updateDSL in http://code.google.com/a/eclipselabs.org/p/melanie/source/browse/de.uni_mannheim.informatik.swt.models.gmf/templates/aspects/diagram/editparts/NodeEditPart.xpt

for interpreting a model and create a figure out of it this java class should be a good starting point

http://code.google.com/a/eclipselabs.org/p/melanie/source/browse/de.uni_mannheim.informatik.swt.mlm.visualization.service/src/de/uni_mannheim/informatik/swt/plm/visualization/service/VisualModelToFigureTransfomator.java

I hope this helps you further.

Ralph
Re: Tools Palette elements directly from Java [message #897202 is a reply to message #896904] Mon, 23 July 2012 07:01 Go to previous message
Tomas T is currently offline Tomas TFriend
Messages: 6
Registered: July 2012
Junior Member
Hi,


Thanks, this looks promising.
Previous Topic:Problem understanding diagram partitioning
Next Topic:diagram editor for dynamic objects
Goto Forum:
  


Current Time: Thu Mar 28 14:30:38 GMT 2024

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

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

Back to the top