Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Combining EMF- and GMF-generated Editor.How do I pass selections between them?
Combining EMF- and GMF-generated Editor.How do I pass selections between them? [message #45578] Tue, 12 September 2006 02:58 Go to next message
Eclipse UserFriend
Hi

as I posted in :
http://www.eclipse.org/newsportal/article.php?id=622&gro up=eclipse.modeling.gmf#622

I want to use both editors (emf generated + gmf generated) together with
the same underlying model. I generated both of them and they work perfect
on their own. each editor writes his own files and can open an dedit
themŽ. The only difference between these two generated editors is that the
gmf-editor uses only a part (subtree) of the model, the emf-generated uses
the whole model.
I managed to hook a double-click-action to the emf-editor, so that i get
the rootobject of the subtree when I double-click it in the treeview of
the emf-editor. code follows:

private void hookDoubleClickAction() {
final Action doubleClickAction;
doubleClickAction = new Action() {
public void run() {
ISelection selection = selectionViewer.getSelection();
if(((IStructuredSelection)selection).getFirstElement() instanceof
DelegatingWrapperItemProvider){
DelegatingWrapperItemProvider obj =
(DelegatingWrapperItemProvider)((IStructuredSelection)select ion).getFirstElement();
Object value = obj.getValue();
if(value instanceof SequenceType){
//TODO add functionality here to open clicked Sequence in graphical
editor.
}//if
}//if
}//run()
};

My Question is, how to get this selection into the graphical-gmf-editor? I
tried to use methods in the generated ??InitDiagramFileAction.java of the
gmf-editor, but I didn't manage to open the gmf-editor with the selection
of the emf-editor. The other thing is, the emf-editor wraps the treeItems
with a DelegatingWrapperItemProvider. The EObjects of the model are only
the values of the wrapperobjects. I think the gmf-editor cannot understand
a selection of wrapperobjects, so I need to unwrap the EObjects first?
In ??InitDiagramFileAction the gmf-editor allways wants to use fileInput
and not a stream or selection. Are there any other input-possibilities for
editors?

My second Question is: do I need the editingDomain from the emf-editor to
put to the gmf-editor or do I need a special editingDomain for the
gmf-editor? I think they should be the same, as the editingDomain tracks
changes in the underlying model, right??

Does anyone have any idea how to manage the connection of the two
generated editors?? I am allready too blind to see any new possibilities,
cause i worked to long on this.

Any help appreciated!!
Many thanks in advance
Alex
Re: Combining EMF- and GMF-generated Editor.How do I pass selections between them? [message #45921 is a reply to message #45578] Tue, 12 September 2006 06:18 Go to previous messageGo to next message
Eclipse UserFriend
Hello Alex,

> a selection of wrapperobjects, so I need to unwrap the EObjects first?
There was a problem in 1.0 release in InitDiagramFileAction. It was fixed,
so if you update to 1.0.1 or 2.0 you'll se different code generated for this
action. Hope, it'll help you to create new diagram. In general you are working
in correct direction - you should just duplicate the locig from ??InitDiagramFileAction
and make it working without additional dialogs.

-----------------
Alex Shatalin
Error after update gmf-build [message #46072 is a reply to message #45921] Tue, 12 September 2006 08:11 Go to previous messageGo to next message
Eclipse UserFriend
Thanks alex for your post,

I tried to update the gmf-build, and regenerate ma diagrammodelcode, but
all I got was two errors (stack follows).

error 1
--------------------------
eclipse.buildId=M20060629-1905
java.version=1.5.0_07
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
Command-line arguments: -os win32 -ws win32 -arch x86

Error
Tue Sep 12 14:06:48 CEST 2006
org/eclipse/gmf/internal/common/migrate/ModelLoadHelper

java.lang.NoClassDefFoundError:
org/eclipse/gmf/internal/common/migrate/ModelLoadHelper
at
org.eclipse.gmf.internal.codegen.popup.actions.ExecuteTempla tesAction.loadGenModel(ExecuteTemplatesAction.java:176)
at
org.eclipse.gmf.internal.codegen.popup.actions.ExecuteTempla tesAction.run(ExecuteTemplatesAction.java:67)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:254)
at
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:539)
at
org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:488)
at
org.eclipse.jface.action.ActionContributionItem$5.handleEven t(ActionContributionItem.java:400)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2968)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1914)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:419)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:95)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:78)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
---------------------------

error2
---------------------------
eclipse.buildId=M20060629-1905
java.version=1.5.0_07
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
Command-line arguments: -os win32 -ws win32 -arch x86

Error
Tue Sep 12 14:06:48 CEST 2006
Unhandled event loop exception

I don't know what to do, have I done something wrong with the update or
what is this error?

Please help
Thanks Alex
Re: Error after update gmf-build [message #46132 is a reply to message #46072] Tue, 12 September 2006 08:23 Go to previous messageGo to next message
Eclipse UserFriend
Hello Alex,

I can suggest you to use 1.0.1 builds – this branch is a bit more stable
then 2.0 and install everything from scratch (upon newly installed Eclipse)
– seems like you have some problems with updating plugins.
Just today I’ve installed M20060831 (1.0.1) build and everything looks working
stable.

-----------------
Alex Shatalin
Re: Error after update gmf-build [message #46219 is a reply to message #46132] Tue, 12 September 2006 08:38 Go to previous messageGo to next message
Eclipse UserFriend
thanks Alex,

I just updated a new installed eclipse. now everything is fine.
I can go on with my actual work (combining the editors)

Thanks again for your brilliant work in this newsgroup!!

Greets Alex
New GMF-versio but noc changes n InitDiagramFileAction!? [message #46918 is a reply to message #45921] Wed, 13 September 2006 04:51 Go to previous messageGo to next message
Eclipse UserFriend
Hi Alex,

I updated the gmf and then regenerated my diagram-editor. After the
generation I compared the old YYInitDiagramFileAction with the new
generated InitDiagramFileAction-class, but nothing was changed!!
Allthough I deleted the old Init..Action.java there were no changes to the
old file!
Could you please be so nice and post the source of this file so that I can
compare it to mine??

This would be very nice of you

Thanks Alex Haag
Re: New GMF-versio but noc changes n InitDiagramFileAction!? [message #47039 is a reply to message #46918] Wed, 13 September 2006 07:13 Go to previous messageGo to next message
Eclipse UserFriend
Hello Alex,

The changes was made in ??NewDiagramFileWizard referenced from the corresponding
action (with tree-viewer for the model inside). In particular, in the following
method:

/**
* @generated
*/
public void selectionChanged(SelectionChangedEvent event) {
myDiagramRoot = null;
if (event.getSelection() instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection.size() == 1) {
Object selectedElement = selection.getFirstElement();
if (selectedElement instanceof IWrapperItemProvider) {
selectedElement = ((IWrapperItemProvider) selectedElement).getValue();
}
if (selectedElement instanceof FeatureMap.Entry) {
selectedElement = ((FeatureMap.Entry) selectedElement).getValue();
}
if (selectedElement instanceof EObject) {
myDiagramRoot = (EObject) selectedElement;
}
}
}
setPageComplete(validatePage());
}

-----------------
Alex Shatalin
GMF-Editor will open, but there are no initial contents in it! [message #47694 is a reply to message #47039] Thu, 14 September 2006 03:10 Go to previous messageGo to next message
Eclipse UserFriend
Hello again,

I managed to add the action to my EMF-Editor that opens the GMF-Editor.
Still with Dialogs, but it works.
My problem now is, that I can't get the initial contents into my
GMF-Editor.

Any ideas how to put the subtree of the selection into the GMF-Editor? I
know that initialContent can be put to GMF-Editor-file by overriding
getInitialContents() from
org.eclipse.ui.dialogs.WizardNewFileCreationPage, but there needs to be an
Inputstream returned and all I got is the StructuredSelection (part in the
EMF-Editor-Tree I clicked on) and my xml-file with the whole model.

Is there a simple way to generate an InputStream out of the
StructuredSelection? or will I have to do it by myself by generating
ObjectOtput/-Input from all Items in the StucturedSelection?

Thanks for any ideas

Greets Alex
Re: GMF-Editor will open, but there are no initial contents in it! [message #47824 is a reply to message #47694] Thu, 14 September 2006 05:44 Go to previous messageGo to next message
Eclipse UserFriend
Hello Alex,

What are you going to put into the diagram file as an initial content? By
default generated ???NewDiagramFileWizard creates empty file with passed
empty initial content and I'm thinking on removing this logic and just creating
new diagram file using EMF Resources API. The next step is to create Diagram
and associate it with the selected model element. Automatic update process
(??CanonicalEditPolicy) will fill diagram with all the corresponding diagram
elements on opening.
If you are going to put some content into the diagram file on creation time,
I suggest you to modify generated ???NewDiagramFileWizard and perform corresponding
actions in the same place where Diagram instance is created. But it’s really
interesting what are you going to store in diagram files – if this is a common
case we can think of providing corresponding methods in generated code.

-----------------
Alex Shatalin
Problem solved. [message #48561 is a reply to message #47824] Fri, 15 September 2006 03:41 Go to previous messageGo to next message
Eclipse UserFriend
Hi Alex

Alex Shatalin wrote:
> Automatic update process
> (??CanonicalEditPolicy) will fill diagram with all the corresponding diagram
> elements on opening.

This was the hint I was looking for!!
As I had to build a workaround in order to be able to draw connections in
the GMF-Editor, my underlying model has two places to store nodes in an
sequence(*Schema shown below).
One way (the original) all nodes reside in a flowtag below the sequence
and the nodes have stored their outgoing edges in their layout-tag.
As it was impossible to build a functional graphical editor with this,
each Sequence became a List with all Nodes residing in the Sequence and a
List with all Edges.
The EMF-Editor only fills the flow, so that when I pass the selection from
the EMF- to the GMF-Editor, the lists allNodes and AllEdges are empty.
Thats why I thought I needed initialContent when I build up my diagram. I
was wrong!! After I populated the Lists, the Nodes and Egdes were drawn
just like I wanted to have it.

Thanks for all your help, maybe when I'm finished with this project I can
try to contribute some concepts, if they are worth it!!

Greets Alex

(*) Schema excerpt comes here:
<package>
<module>
<sequence>
<flow>
...some nodes with layout and egdes<!--EMF-Treeeditor populates
this part of the file-->
</flow>
<allNodes.../><!-- new in Model(workaround) only GMF-Editor needs
it-->
<allEdges.../><!-- new in Model(workaround) only GMF-Editor needs
it-->
</sequence>
</module>
</package>
Re: GMF-Editor will open, but there are no initial contents in it! [message #48742 is a reply to message #47824] Fri, 15 September 2006 06:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: 5d5.mail.ru

I'm just thinking about two cases:

- What if my diagram is not "synchronized"; I mean canonical edit policy
is disabled and I handle notation model updates by myself. It could be a
requirement to edit graphical presentation independently (to some extent
of course ))) ).

- We support design only diagrams (editor without domain model); see
org.eclipse.gmf.examples.design2d; what if I'd like to provide some
initial content there?

Alex Shatalin wrote:
> Hello Alex,
>
> What are you going to put into the diagram file as an initial content?
> By default generated ???NewDiagramFileWizard creates empty file with
> passed empty initial content and I'm thinking on removing this logic and
> just creating new diagram file using EMF Resources API. The next step is
> to create Diagram and associate it with the selected model element.
> Automatic update process (??CanonicalEditPolicy) will fill diagram with
> all the corresponding diagram elements on opening.
> If you are going to put some content into the diagram file on creation
> time, I suggest you to modify generated ???NewDiagramFileWizard and
> perform corresponding actions in the same place where Diagram instance
> is created. But it’s really interesting what are you going to store in
> diagram files – if this is a common case we can think of providing
> corresponding methods in generated code.
>
> -----------------
> Alex Shatalin
>
>
Re: GMF-Editor will open, but there are no initial contents in it! [message #48889 is a reply to message #48742] Fri, 15 September 2006 07:05 Go to previous message
Eclipse UserFriend
Hello Dmitry,

> - What if my diagram is not "synchronized"; I mean canonical edit
> policy is disabled and I handle notation model updates by myself. It
> could be a requirement to edit graphical presentation independently
> (to some extent of course ))) ).
In this case generated ??NewDiagramFileWizard will contain additional method
performing diagram content initialization. This method will be called just
after new diagram creation.

> - We support design only diagrams (editor without domain model); see
> org.eclipse.gmf.examples.design2d; what if I'd like to provide some
> initial content there?
The same method (initDiagramContents) could be generated for pure design
diagrams with empty body. Then users will be able to perform diagram initialization
by adding “@generated NOT” and specifying the body for this method. If this
sounds useful you can submit corresponding request.

-----------------
Alex Shatalin
Previous Topic:GMF Issue
Next Topic:Can not view .ecore_diagram in editor but see in outline
Goto Forum:
  


Current Time: Thu May 08 03:31:10 EDT 2025

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

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

Back to the top