Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » several mappings for single ecore class
several mappings for single ecore class [message #539966] Mon, 14 June 2010 13:04 Go to next message
emil salageanu is currently offline emil salageanuFriend
Messages: 94
Registered: June 2010
Location: Nice, France
Member
Hello guys,

I have been looking for several hours now for a solution for this problem.

Here it is, shortly:

I need to generate something like:

....
....
   <task> 
      <pre> 
            <script> .... </script>
       </pre> 
      <post>
            <script> ... </script>
     <post> 
   <task>  
...
...


So I will need 2 tools to create "script" elements: one to create "pre" script, and another to create "post" script.
I defined to figures and 2 creation tools.

In my *.gmfmap file, I wrote 2 Node Mappings for my ecore type "script":

    one mapping for task.pre:Script
    one mapping for task.post:Script


Here's a piece of the *.gmfmap file:
<ownedChild>
          <domainMetaElement
              href="SchedDev.ecore#//TaskType"/>
          <tool
              xsi:type="gmftool:CreationTool"
              href="SchedDev.gmftool#//@palette/@tools.0/@tools.2"/>
          <diagramNode
              href="SchedDev.gmfgraph#TaskType"/>
          <children>
            <containmentFeature
                href="SchedDev.ecore#//TaskType/pre"/>
            <ownedChild>
              <domainMetaElement
                  href="SchedDev.ecore#//Script"/>
              <tool
                  xsi:type="gmftool:CreationTool"
                  href="SchedDev.gmftool#//@palette/@tools.0/@tools.5"/>
              <diagramNode
                  href="SchedDev.gmfgraph#preNode"/>
            </ownedChild>
          </children>
          <children>
            <containmentFeature
                href="SchedDev.ecore#//TaskType/post"/>
            <ownedChild>
              <domainMetaElement
                  href="SchedDev.ecore#//Script"/>
              <tool
                  xsi:type="gmftool:CreationTool"
                  href="SchedDev.gmftool#//@palette/@tools.0/@tools.6"/>
              <diagramNode
                  href="SchedDev.gmfgraph#postNode"/>
            </ownedChild>
          </children>
        </ownedChild>


The problem ithat, when I try to create the "post" script element, I have an exception:
Caused by: org.eclipse.core.runtime.AssertionFailedException: null argument:failed to create a view (I put the ful lstack at the end of the message).

I think it might be related to this tip: http://wiki.eclipse.org/GMF_Tips#Different_Figures_for_one_E core_class

At least this is all I could find by googleizing the problem. But it is not the same case (i have different roles of the same ecore class).

Please help.

PS. Full stacktrace:

rg.eclipse.core.commands.ExecutionException: While executing the operation, an exception occurred
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:519)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack.execute(DiagramCommandStack.java:206)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack.execute(DiagramCommandStack.java:169)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack.execute(DiagramCommandStack.java:156)
	at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTool.java:399)
	at org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(AbstractTool.java:411)
	at org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool.performCreation(CreationTool.java:133)
	at org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTool.java:178)
	at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java:1064)
	at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:263)
	at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseReleased(DomainEventDispatcher.java:374)
	at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(LightweightSystem.java:538)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:207)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1176)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3493)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3112)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: org.eclipse.core.runtime.AssertionFailedException: null argument:failed to create a view
	at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
	at org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand.doExecuteWithResult(CreateCommand.java:99)
	at org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand.doExecute(AbstractTransactionalCommand.java:247)
	at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
	at org.eclipse.gmf.runtime.common.core.command.CompositeCommand.doExecuteWithResult(CompositeCommand.java:403)
	at org.eclipse.gmf.runtime.common.core.command.AbstractCommand.execute(AbstractCommand.java:135)
	at org.eclipse.gmf.runtime.common.core.command.CompositeCommand.doExecuteWithResult(CompositeCommand.java:403)
	at org.eclipse.gmf.runtime.common.core.command.AbstractCommand.execute(AbstractCommand.java:135)
	at org.eclipse.gmf.runtime.common.core.command.CompositeCommand.doExecuteWithResult(CompositeCommand.java:403)
	at org.eclipse.gmf.runtime.common.core.command.AbstractCommand.execute(AbstractCommand.java:135)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:511)
	... 37 more











Re: several mappings for single ecore class [message #539970 is a reply to message #539966] Mon, 14 June 2010 13:17 Go to previous messageGo to next message
emil salageanu is currently offline emil salageanuFriend
Messages: 94
Registered: June 2010
Location: Nice, France
Member
My problem is exactly the one described at
http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg18980.html

The thing is that I have 2 different containment features defined for the 2 mapings. Do I need to change my ecore model in order to add a "type" attribute ? (this information is already availble via the containment feature).

Thank in advance for any clue ...
Re: several mappings for single ecore class [message #540005 is a reply to message #539966] Mon, 14 June 2010 14:54 Go to previous messageGo to next message
emil salageanu is currently offline emil salageanuFriend
Messages: 94
Registered: June 2010
Location: Nice, France
Member
Well, adding an attribute makes the editor work. (solution described here: http://wiki.eclipse.org/GMF_Tips#Different_Figures_for_one_E core_class).

But this CANNOT be a solution. At this point I have something like:
   <task>
        <pre type"pre">
               <script> .. </script>
        </pre> 
        <post type"post">
               <script> .. </script>
        </post> 
   </task> 

 

Should I, instead of adding the attribute, put a condition on the containment feature ? (but the containment feature is already defined). If yes, someone know how would that look like in ocl ?


Please ....






[Updated on: Mon, 14 June 2010 14:57]

Report message to a moderator

solution found [message #540307 is a reply to message #539966] Tue, 15 June 2010 15:13 Go to previous message
emil salageanu is currently offline emil salageanuFriend
Messages: 94
Registered: June 2010
Location: Nice, France
Member
I found a solution for the issue described above.

I'll write it here hoping that someone will take advantage of my several hours of searching the solution.

Id did it in java altough it is possible to do it in OCL.
I think the problem is rather important so, if someone could add the OCL solution to this topic it might be good for the GMF comunity. I'll stick to java Smile

So, let me rephrase the problem :

We need to use the same ECORE class with different creation tools.
We have an Ecore class Task, referencing class Script twice: via EReference "pre" and "post".
We have one graphical node and two creation tools (PRE and POST) in tooling model.

Solution:
We create, in the *.gmfmap file, 2 mappings:

one mapping for task.pre:Script
one mapping for task.post:Script

For each NodeMapping (script/pre and script/post), we add a java constraint. No need to fill-in the body.

When we generate the code, in the diagram.part.XXXVisualIDRegistry.java file we have 2 methods looking like this:

private static boolean isModelElement_XXXX(ModelElement domainElement)


We need to add a condition on the containment feature:

private static boolean isScript_3009(Script domainElement) {
		
	EReference ref = domainElement.eContainmentFeature();
	if (ref.getName()=="post")
		{
		    return true;
		}
		else
	    return false;
	}


You can also take a look at
http://wiki.eclipse.org/GMF_Constraints

This is it. Now it works.

Although I'll stick to the java solution anywats (i'm more confident) I'm curios to see the OCL solution.

[Updated on: Tue, 15 June 2010 15:14]

Report message to a moderator

Previous Topic:Exceptions with Palette since 3.6 RC3
Next Topic:OCL cannot find feature in link target constraint body
Goto Forum:
  


Current Time: Tue May 28 14:24:43 GMT 2024

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

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

Back to the top