| 
| Creating elements in GMF outside of the current editor [message #216794] | Thu, 29 January 2009 22:27  |  | 
| Eclipse User  |  |  |  |  | Hi, 
 I am trying to automatically create elements in my model, directly from
 selecting an element in the GMF editor. This works fine for elements
 that can be displayed in the editor itself (as following from the GMF
 Tutorial):
 
 CreateElementCommand cc = getDiagramCreateNodeCommand(new
 CreateElementRequest(getEditingDomain(), container,
 getDiagramEditType(eClass)), eClass );
 
 getDiagramEditType() gets the IElementType from the current GMF editor
 for the given eClass (taken from XXXPackage.eINSTANCE).
 
 However, I now want to create elements outside of the current GMF
 editor, that can't be displayed in the current editor. (I am using
 diagram partitioning.) Obviously I don't want the element displayed, but
 I want it created in the model.
 
 I cannot use the code above, because the current editor has no knowledge
 of the other elements in the model, and fails with an invalid operation
 error.
 
 If I import another editor and use its IElementType in the original
 editors' code, I get a NullPointerException.
 
 I cannot use EMF directly with GMF running, because I need write access,
 and I get a transaction exception.
 
 Any ideas?
 
 Thanks!
 Jevon
 |  |  |  | 
|  | 
| 
| Re: Creating elements in GMF outside of the current editor [message #217034 is a reply to message #216976] | Sun, 01 February 2009 19:27  |  | 
| Eclipse User  |  |  |  |  | Hi Alex, 
 Thanks for your help! After subclassing AbstractTransactionalCommand,
 the command works exactly as desired.
 
 Thanks!
 Jevon
 
 Alex Shatalin wrote:
 > Hello Jevon,
 >
 >> I cannot use EMF directly with GMF running, because I need write
 >> access, and I get a transaction exception.
 > Try subclassing AbstractTransactionalCommand.
 >
 > -----------------
 > Alex Shatalin
 >
 >
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.04258 seconds