Synchronize semantic and notation information on editor start [message #515207] |
Thu, 18 February 2010 03:23  |
Eclipse User |
|
|
|
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 #515411 is a reply to message #515348] |
Thu, 18 February 2010 12:23  |
Eclipse User |
|
|
|
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
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03310 seconds