Some helpful tips for working with GMF.

  1. GMF Troubleshooting
  2. GMF Troubleshooting 2
  3. GMF Troubleshooting 3
  4. GMF Troubleshooting 4
  5. GMF Troubleshooting 5
  6. GMF Troubleshooting 6
  7. GMF Troubleshooting 7
  8. GMF Troubleshooting 8
  9. GMF Troubleshooting 9
  10. GMF Troubleshooting 10

I have duplicate project navigator listings for a given model file (right).

You have more than one plugin trying to generate the Project Navigator items; set .gmfgen > Editor > Navigator > Generate Domain Model Navigator for one of your editors to false.


When trying to create this:

root
  foo.1
  foo.2
  bar from:foo.1 to:foo.2

I get this:

root
  foo.1
    bar to:foo.2
  foo.2

This happens when the link you specify does not have two features that it links together, only one.

  1. Look into your .gmfmap file at the relevant link: Both “Source Feature” and “Target Feature” items should be selected.
  2. Also check your .gmfgen: Gen Editor > Diagram > Link > Link Model Facet should also have “Source Meat Feature” and “Target Meta Feature” set.

One of my tool palette icons does not display anything except a little red square. OR I get an exception similar to this when opening up a diagram:

java.lang.NullPointerException at diagram.providers.Uml3ElementTypes.getElement(XYZElementTypes.java:175) at diagram.providers.Uml3ElementTypes.getImageDescriptor(XYZElementTypes.java:151) at diagram.part.Uml3PaletteFactory.createComponent1CreationTool(XYZPaletteFactory.java:51) at diagram.part.Uml3PaletteFactory.createModel1Group(XYZPaletteFactory.java:34) ...

Edit your .gmfgen file manually, and look for Tool Entry_s in _Gen Editor > Gen Diagram > Palette > Tool Group. If the parameters “largeIconPath” or “smallIconPath” are there, but empty, you could get this error message. Delete these attributes manually. (I guess there’s no way to specify null in EMF editors huh.) You can also try deleting and re-generating the diagram code again.


Change the location of the wizard in the “Create New” dialog

Try .gmfgen > Gen Editor > Gen Diagram, property Editor.Creation Wizard Category ID. (untested)


Disable the “Outline View” of an editor

Add this code to the getAdapter() method of diagram.part.FooDiagramEditor (ref):

public Object getAdapter(Class type) {
  if (type == IContentOutlinePage.class) {
     return null;
  }
...

When trying to create an editor for a model with subclassed elements, the following exception is thrown when creating a subclassed element:

org.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:205) ... Caused by: org.eclipse.jface.util.Assert$AssertionFailedException: null argument;failed to create a view at org.eclipse.jface.util.Assert.isNotNull(Assert.java:153) at org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand.doExecuteWithResult(CreateCommand.java:99) ...

This can occur when the .gmfmap doesn’t know where the subclassed element should map to: should it map to the superclass or the subclass?

The solution is to add OCL to the superclass mapping (ref and ocl ref) like so:

not self.oclIsTypeOf(SubclassName)


Could not initialize class org.eclipse.gmf.internal.bridge.trace.TracePackage$Literals

You have an invalid or incomplete installation of GMF (I got this error when I was running a 2007 GMF with a 2008 GMF plugin still installed). Either reinstall GMF or go through the Manage Configuration to disable those plugins not necessary.


Converting GEF Commands into GMF Commands

ICommand _org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack_.getICommand(org.eclipse.gef.commands.Command command);


I can’t get an edge/connection to appear between two shortcut elements (In particular, when using GMF Diagram Partitioning.)

This is entirely possible! Refer to the code below. But I had a lot of problems trying to get it to work - turns out that, because I had two different plugins generated from the same model, the Connection model element referred to the wrong package (foo.component.* instead of foo.wire.*).

  1. http://iaml.svn.sourceforge.net/viewvc/iaml/trunk/examples/gmf/CreateMissingNavigateWireShortcutsCommand.java?view=markup

When trying to generate my .gmfmap, my concrete nodes that subclass abstract supertypes which are contained in the root object are not displayed in the .gmfmap wizard!

This can happen when, for example, you want:

- Root
  - children: Element
- abstract Element
- Page <- Element
- Form <- Element

In this case, in the .gmfmap editor where you select the nodes and links to generate, you may only see the option for the Page node and not for the Form node.

This is (somewhat) natural, because the wizard only knows how to generate the code for one of these element containers. You will need to edit the .gmfmap manually and add the new element by yourself, with an OCL constraint.

See http://wiki.eclipse.org/GMF_Tutorial_Part_2#Link_Constraints for adding constraints to the .gmfmap model.