Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Synchronize semantic and notation information on editor start
Synchronize semantic and notation information on editor start [message #515207] Thu, 18 February 2010 08:23 Go to next message
Martin Fluegge is currently offline Martin FlueggeFriend
Messages: 141
Registered: July 2009
Senior Member
Hi@all,

when I use the generated EMF tree-based Editor to add an element to the semantic model and then start the GMF-editor the newly created element is not show in the diagram. However, when I add a new element to the diagram, a new View will be created for the previously created semantic element. So the appropriate action seems to be there. But unfortunately did not find it.
How can I invoke this action on diagram start? Or is this even a bug?

Maybe some else faced this problem before, but unfortunately I could find a solution anywhere.

Thank in advance.

Cheers,

Martin
Re: Synchronize semantic and notation information on editor start [message #515348 is a reply to message #515207] Thu, 18 February 2010 14:35 Go to previous messageGo to next message
Sven Krause is currently offline Sven KrauseFriend
Messages: 119
Registered: July 2009
Senior Member
Hi Martin,

Does this effect happend only after a fresh workbench restart and is
gone, when you used the gmf editor at least once before editing the
model with the emf editor?

If yes:

override the getFactoryHint(IAdaptable elementAdapter) within your
specific CanonicalEditPolicys

/**
* @generated
*/
@Override
protected String getFactoryHint(IAdaptable elementAdapter) {
CanonicalElementAdapter element =
(CanonicalElementAdapter) elementAdapter;
int visualID = YourVisualIDRegistry.getNodeVisualID(
(View) getHost().getModel(),
(EObject) element.getRealObject());
return YourVisualIDRegistry.getType(visualID);
}

or better customimze the template:

templates/gmf/xpt/diagram/updater/containerBaseCanonicalMeth ods.xpt

::

«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel
«IMPORT 'http://www.eclipse.org/emf/2002/GenModel

«EXTENSION xpt::diagram::updater::Utils»



«DEFINE getDefaultFactoryHint FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected String getDefaultFactoryHint() {
return null;
}

«EXPAND xpt::Common::generatedMemberComment»
@Override
protected String getFactoryHint(org.eclipse.core.runtime.IAdaptable
elementAdapter) {
CanonicalElementAdapter element = (CanonicalElementAdapter)
elementAdapter;
int visualID =
«EXPAND
xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall FOR
getDiagram()»((org.eclipse.gmf.runtime.notation.View)
getHost().getModel(), (org.eclipse.emf.ecore.EObject)
element.getRealObject());
return «EXPAND typeMethodCall FOR getDiagram()»(visualID);
}
«ENDDEFINE»

«DEFINE typeMethodCall FOR
gmfgen::GenDiagram»«getVisualIDRegistryQualifiedClassName( )».getType«ENDDEFINE»

::

Cheers
Sven
Re: Synchronize semantic and notation information on editor start [message #515411 is a reply to message #515348] Thu, 18 February 2010 17:23 Go to previous message
Martin Fluegge is currently offline Martin FlueggeFriend
Messages: 141
Registered: July 2009
Senior Member
Hi Sven,

thanks for the quick response.

And yes, that was the problem and overriding the factoryHint solved it ;)

Thanks again.

Cheers,

Martin


Sven Krause schrieb:
> Hi Martin,
>
> Does this effect happend only after a fresh workbench restart and is
> gone, when you used the gmf editor at least once before editing the
> model with the emf editor?
>
> If yes:
>
> override the getFactoryHint(IAdaptable elementAdapter) within your
> specific CanonicalEditPolicys
>
> /**
> * @generated
> */
> @Override
> protected String getFactoryHint(IAdaptable elementAdapter) {
> CanonicalElementAdapter element =
> (CanonicalElementAdapter) elementAdapter;
> int visualID = YourVisualIDRegistry.getNodeVisualID(
> (View) getHost().getModel(),
> (EObject) element.getRealObject());
> return YourVisualIDRegistry.getType(visualID);
> }
>
> or better customimze the template:
>
> templates/gmf/xpt/diagram/updater/containerBaseCanonicalMeth ods.xpt
>
> ::
>
> «IMPORT 'http://www.eclipse.org/gmf/2009/GenModel
> «IMPORT 'http://www.eclipse.org/emf/2002/GenModel
>
> «EXTENSION xpt::diagram::updater::Utils»
>
>
>
> «DEFINE getDefaultFactoryHint FOR gmfgen::GenContainerBase-»
> «EXPAND xpt::Common::generatedMemberComment»
> protected String getDefaultFactoryHint() {
> return null;
> }
>
> «EXPAND xpt::Common::generatedMemberComment»
> @Override
> protected String getFactoryHint(org.eclipse.core.runtime.IAdaptable
> elementAdapter) {
> CanonicalElementAdapter element = (CanonicalElementAdapter)
> elementAdapter;
> int visualID =
> «EXPAND
> xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall FOR
> getDiagram()»((org.eclipse.gmf.runtime.notation.View)
> getHost().getModel(), (org.eclipse.emf.ecore.EObject)
> element.getRealObject());
> return «EXPAND typeMethodCall FOR getDiagram()»(visualID);
> }
> «ENDDEFINE»
>
> «DEFINE typeMethodCall FOR
> gmfgen::GenDiagram»«getVisualIDRegistryQualifiedClassName( )».getType«ENDDEFINE»
>
>
> ::
>
> Cheers
> Sven
>
>
Previous Topic:Why PropertySheetPage doesn't work for my GMF plugin?
Next Topic:Disable UUIDs?
Goto Forum:
  


Current Time: Sun Sep 20 09:14:21 GMT 2020

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

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

Back to the top