Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Multiple ecore and one editor
Multiple ecore and one editor [message #160166] Wed, 14 November 2007 02:59 Go to next message
Eclipse UserFriend
Originally posted by: smjo85.gmail.com

Hi!

I have to create one GMF editor, where the input is two languages (e.g.
UML and ER in Ecore), and I need to map UML to ER. So my problem is, how
can I solve, that one GMF editor creates three XML files (UML, ER, MAP)?

Thanks,
John Smith
Re: Multiple ecore and one editor [message #160756 is a reply to message #160166] Thu, 15 November 2007 13:40 Go to previous messageGo to next message
Eclipse UserFriend
Hello John,

You have to modify diagram element creation commands and put newly created
elements into appropriate containers. For example, then you create enw UMLClass
on your diagram corresponding create command should take care on attaching
new object to the corresponding EMF resource (???.uml2)

-----------------
Alex Shatalin
Re: Multiple ecore and one editor [message #160887 is a reply to message #160756] Fri, 16 November 2007 07:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smjo85.gmail.com

Hello Alex,

I would like to ask you some additional help.

I have three ecores as input:
- uml.ecore: UML class diagram
- rdbms.ecore: Relational DataBase table
- uml2rdbms.ecore: Map UML to RDBMS (it references to the two ecores).

I have one XML file (default.uml2rdbms) as GMF output.
What I need is three XML files as GMF output.

So what files are needed to be modified?
I have three folders:
uml2rdbms
uml2rdbms.edit
uml2rdbms.diagram
And what lines are needed to be modified?

John Smith
Re: Multiple ecore and one editor [message #160925 is a reply to message #160887] Fri, 16 November 2007 08:28 Go to previous messageGo to next message
Eclipse UserFriend
Hello John,

Imagine you should put "UMLClass" created on your disagram into separate
uml.ecore file. In this case you should modify generated UMLClassItemSemanticEditPolicy.
In this class you have to override doDefaultElementCreation() method calling
super.doDefaultElementCreation() first and then storing result of the parent
method execution in the proper place in uml.ecore resource. For example,
in uml.ecore contains UMLPackage then you should load this package into your
command and then call myUMLPackage.getUMLClasses().add(result).

-----------------
Alex Shatalin
Re: Multiple ecore and one editor [message #161030 is a reply to message #160925] Sat, 17 November 2007 02:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smjo85.gmail.com

Hello Alex,

Firstly thanks for your answers. I have found this solution not so general
(e.g., ER instead of RDBMS), so I think:

The GMF standard editor generator is
only capable of generating model editors for a single language.
Therefore, I plan to extend the standard editor generator
of GMF to support the generation of a mapping editor. This
extended generator should take two language definitions (e.g.,
UML and ER) and the mapping language as input and should
produce a mapping editor which is capable of defining domain
models in both languages and also to map the model elements
of the domain model.

So I have er.gmfmap, uml.gmfmap, and finally I need three
XML files: er, uml, map using ONE editor.
How can I solve the finally part of this task?

John Smith
Re: Multiple ecore and one editor [message #162590 is a reply to message #161030] Sun, 25 November 2007 04:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smjo85.gmail.com

Hello Alex,

My ecore files:

mindmap.ecore:
- Top
- xref: X
- yref: Y

x.ecore:
- XTop
- xref: X
-X

y.ecore:
- YTop
- yref: Y
-Y
(I have annotations too)

I would like to modify the GMF editor: create more than one XML file.
(if I click X in the diagram, create XML file containing X,
if I click Y in the diagram, create XML file containing Y)

You adviced me to modify XItemSemanticEditPolicy.java:

public class XItemSemanticEditPolicy extends
MindmapBaseItemSemanticEditPolicy {
protected Command getDestroyElementCommand(DestroyElementRequest req) {
CompoundCommand cc = getDestroyEdgesCommand();
addDestroyShortcutsCommand(cc);
View view = (View) getHost().getModel();
if (view.getEAnnotation("Shortcut") != null) { //$NON-NLS-1$
req.setElementToDestroy(view);
}
cc.add(getGEFWrapper(new DestroyElementCommand(req)));
return cc.unwrap();
}
}

The above file is the original.

You wrote about super.doDefaultElementCreation(), XTop.getX().add(result),
but I did not find none of them in this source code, and I do not know how
modify the code.

Can you help me?

John
Re: Multiple ecore and one editor [message #162674 is a reply to message #162590] Mon, 26 November 2007 06:32 Go to previous messageGo to next message
Eclipse UserFriend
Hello John,

> You adviced me to modify XItemSemanticEditPolicy.java:

It was a mistake. ;-( You should modify generated "XCreateCommand.java".
The rest looks correct.
Sorry for this mess with the file names.

-----------------
Alex Shatalin
Re: Multiple ecore and one editor [message #162847 is a reply to message #162674] Tue, 27 November 2007 11:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smjo85.gmail.hu

Hello Alex,

You know I have 3 ecores:

mindmap.ecore with mindmap package:
Top
xref: X
yref: Y

x.ecore with x package:
XTop
xref: X
X

y.ecore is similar to x.ecore

You adviced me to modify XCreateCommand.java:

public class XCreateCommand extends CreateElementCommand {
public XCreateCommand(CreateElementRequest req) {
super(req);
}
protected EObject getElementToEdit() {
EObject container = ((CreateElementRequest) getRequest())
.getContainer();
if (container instanceof View) {
container = ((View) container).getElement();
}
return container;
}
protected EClass getEClassToEdit() {
return MindmapPackage.eINSTANCE.getTop();
}
}

You said that I have to delete doDefaultElementCreation() method calling
super.doDefaultElementCreation(), but this method is not found in this
java file.

And you also said that I have to create XPackage.getXTop().add(result),
but where should I put it?

(I use GMF 2.0)

Regards,
John
Re: Multiple ecore and one editor [message #163017 is a reply to message #162847] Wed, 28 November 2007 07:26 Go to previous messageGo to next message
Eclipse UserFriend
Hello John,

> You adviced me to modify XCreateCommand.java:
>
> public class XCreateCommand extends CreateElementCommand {

You are right - in your case XCreateCommand class contains no doDefaultElementCreation()
method. This means CreateElementCommand.doDefaultElementCreation() implementation
used:

protected EObject doDefaultElementCreation() {
EReference containment = getContainmentFeature();
EClass eClass = getElementType().getEClass();
if (containment != null) {
EObject element = getElementToEdit();
if (element != null)
return EMFCoreUtil.create(element, containment, eClass);
}
return null;
}

I'm suggesting you to override this method in XCreateCommand and place custom
code there. EMFCoreUtil.create(element, containment, eClass) call is responsible
for creating new instance of "eClass" EClass and adding this instance into
"containment" containment reference of "element" EObject. Instead you should
locate proper EMF resource here, create new instance of "eClass" EClass,
add it into this resource and create non-containment reference from "element"
to this newly created instance. Or you can try using cross resource containment
EMF feature to let "element" contain this new instance stored in a separate
EMF resource.

-----------------
Alex Shatalin
Re: Multiple ecore and one editor [message #163034 is a reply to message #163017] Wed, 28 November 2007 09:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smjo85.gmail.com

Hello Alex,

Thank you all the helps you gave me. I am beginner in GMF, but I would
like to reach my destination (multiple model creation). You could help me
a lot if you could write the proper modification of the XCreateCommand.
After that I will be able to apply this knowledge to other part of the
editor (e.g. Y).

Thanks,
John
Re: Multiple ecore and one editor [message #163106 is a reply to message #163034] Wed, 28 November 2007 10:36 Go to previous messageGo to next message
Eclipse UserFriend
Hello John,

I suggest you to read some documentation about EMF resource creating/saving
first.

In general I suppose you can write something like:

protected EObject doDefaultElementCreation() {
Top top = (Top) getElementToEdit();
X newX = XFactory.eINSTANCE.createX();
URI xResourceURI = URI.createURI("<properXResourceURI>");
Resource xResource = top.eResource().getResourceSet().createResource(xResourceURI );
xResource.getContents().add(newX);
top.setXref(newX);
return newX;
}

-----------------
Alex Shatalin
Re: Multiple ecore and one editor [message #163155 is a reply to message #163106] Wed, 28 November 2007 13:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smjo85.gmail.com

Hello Alex,

I use the following imports:
import org.eclipse.emf.ecore.resource.*;
import org.eclipse.gmf.examples.x.*;
(the ecore file is in "org.eclipse ..." package)
import org.eclipse.emf.common.util.*;

Is it good?

And this is what you sent - modified:
protected EObject doDefaultElementCreation() {
XTop top = (XTop) getElementToEdit();
X newX = XFactory.eINSTANCE.createX();
URI xResourceURI = URI.createURI("x");
Resource xResource =
top.eResource().getResourceSet().createResource(xResourceURI );
xResource.getContents().add(newX);
top.setXref(newX);
return newX;
}

XTop does not have setXref, but getXref
... createURI("x") is good (in ecore: Ns URI: x)?

regards,
John
Re: Multiple ecore and one editor [message #163302 is a reply to message #163155] Thu, 29 November 2007 09:37 Go to previous messageGo to next message
Eclipse UserFriend
Hello John,

> Is it good?
Looks like.

> XTop does not have setXref, but getXref
then use "getxref().add(newX );

> .. createURI("x") is good (in ecore: Ns URI: x)?
This is a URI or the resource you are going to open (not Ns URI property
of your meta-model).

BTW, I suggest you to study EMF first - before starting to implement this
task.

-----------------
Alex Shatalin
Re: Multiple ecore and one editor [message #163352 is a reply to message #163302] Thu, 29 November 2007 13:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smjo85.gmail.com

Hello John,

You are very kind to help me and others.

I put this method in the XCreateCommand class:

protected EObject doDefaultElementCreation() {
XTop top = (XTop) getElementToEdit();
X newX = XFactory.eINSTANCE.createX();
URI xResourceURI = URI.createURI("x.xmi");
Resource xResource =
top.eResource().getResourceSet().createResource(xResourceURI );
xResource.getContents().add(newX);
top.getXref().add(newX);
return newX;
}

When I start a new Eclipse instance and I click X and I would like to add
it to the diagram, but nothing happens (when I let the mouse, no rectangle
is drawn). There is no XMI file for X, but the not modified Y operates.

I would like to ask you the above modified method correct or new code is
needed?

Thanks,
John
Re: Multiple ecore and one editor [message #163359 is a reply to message #163352] Thu, 29 November 2007 14:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smjo85.gmail.com

Hello Alex,

You are very kind to help me and others.

I put this method in the XCreateCommand class:

protected EObject doDefaultElementCreation() {
XTop top = (XTop) getElementToEdit();
X newX = XFactory.eINSTANCE.createX();
URI xResourceURI = URI.createURI("x.xmi");
Resource xResource =
top.eResource().getResourceSet().createResource(xResourceURI );
xResource.getContents().add(newX);
top.getXref().add(newX);
return newX;
}

When I start a new Eclipse instance and I click X and I would like to add
it to the diagram, but nothing happens (when I let the mouse, no rectangle
is drawn). There is no XMI file for X, but the not modified Y operates.

I would like to ask you the above modified method correct or new code is
needed?

Thanks,
John
Re: Multiple ecore and one editor [message #163462 is a reply to message #163359] Fri, 30 November 2007 08:33 Go to previous messageGo to next message
Eclipse UserFriend
Hello John,

I did not tried this code by myself, but it looks like it should work. I
suggest you to debug X element creation by placing a break-point into doDefaultElementCreation()
body. BTW, do you have any exceptions in .log file?

-----------------
Alex Shatalin
Re: Multiple ecore and one editor [message #163504 is a reply to message #163462] Fri, 30 November 2007 10:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smjo85.gmail.com

Hello Alex,

Yes, I have exceptions:
-org.eclipse.core.commands.ExecutionException: While executing the
operation, an exception occurred
-Caused by: java.lang.ClassCastException:
org.eclipse.gmf.examples.mindmap.impl.TopImpl cannot be cast to
org.eclipse.gmf.examples.x.XTop

If you send me your e-mail address, I can send you the editor
(to solve this GMF problem would be important for me)
My e-mail address: smjo85@gmail.com (waiting for your e-mail address)

Thanks for all the helps,
John
Re: Multiple ecore and one editor [message #163816 is a reply to message #163504] Mon, 03 December 2007 10:55 Go to previous messageGo to next message
Eclipse UserFriend
Hello John,

> -Caused by: java.lang.ClassCastException:
> org.eclipse.gmf.examples.mindmap.impl.TopImpl cannot be cast to
> org.eclipse.gmf.examples.x.XTop
Then it looks like you should change

XTop top = (XTop) getElementToEdit();

to

org.eclipse.gmf.examples.mindmap.Top top = (org.eclipse.gmf.examples.mindmap.Top)
getElementToEdit();

(wrong element used for your diagram).

> If you send me your e-mail address, I can send you the editor
> (to solve this GMF problem would be important for me)
It looks like not a GMF problem - it looks like a problem with implementing
custom code working with GMF. ;-)
Once more - I suggest you to read documentation and try to understand what's
going on in your application and I'll be able to provide you with the suggestions
ant try to answer your questions here.

-----------------
Alex Shatalin
Re: Multiple ecore and one editor [message #163864 is a reply to message #163816] Mon, 03 December 2007 11:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smjo85.gmail.com

Hello Alex,

There is no more error in the diagram, but a new XMI serialization is not
created for X.

Hello,
John
Re: Multiple ecore and one editor [message #163892 is a reply to message #163864] Mon, 03 December 2007 11:47 Go to previous messageGo to next message
Eclipse UserFriend
Hello John,

> There is no more error in the diagram, but a new XMI serialization is
> not created for X.
Corresponding resource should be saved to disk on pressing "save" in the
editor. Did you tried that?

In addition - any exceptions in the log? Can you debug this command to ensure
proper element was created and attached to the new resource?

-----------------
Alex Shatalin
Re: Multiple ecore and one editor [message #163911 is a reply to message #163892] Mon, 03 December 2007 13:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smjo85.gmail.com

Hello Alex,

The diagram do not contain "save", but I saved it using Eclipse, so the
only one default.mindmap is modified according to the editor, but there is
no default.x

There is no exception in the log.

The method is:

protected EObject doDefaultElementCreation() {
org.eclipse.gmf.examples.mindmap.Top top =
(org.eclipse.gmf.examples.mindmap.Top) getElementToEdit();
X newX = XFactory.eINSTANCE.createX();
URI xResourceURI = URI.createURI("x.xmi");
Resource xResource =
top.eResource().getResourceSet().createResource(xResourceURI );
xResource.getContents().add(newX);
top.getXref().add(newX);
return newX;
}

I use org.eclipse.gmf.examples package - see the method.
Is URI.createURI("x.xmi") what the file will be created? (default.x)
but "org.eclipse.gmf.examples.default.x" do not operate also.

And when I start a new Eclipse, and go to New, Example ask only one name:
default.mindmap and the diagram name. And there is no file for X when I
start
it, only the mindmap. When I click to X, X create in mindmap, not in X.

Thanks,
John
Re: Multiple ecore and one editor [message #164046 is a reply to message #163911] Tue, 04 December 2007 06:00 Go to previous messageGo to next message
Eclipse UserFriend
Hello John,

> The diagram do not contain "save", but I saved it using Eclipse, so
I meant Ctrl+S or menu item you used.

> top.getXref().add(newX);
is "xref" a containment reference or not? Each element can have only one
container, so you can remove newly added element from the resource on setting
this reference if "containment" property was set to "true" for "xref" in
your <mapping>.ecore model.

> Is URI.createURI("x.xmi") what the file will be created? (default.x)
In this case "x.xmi" file should be created. This file will be located in
the currently active ("default") folder on your computer. If you wish to
locate this file in some proper place you should take care of it - construct
proper URI based on top.eResource().getURI() probably..

> default.mindmap and the diagram name. And there is no file for X when
Do you have .editor plugin generated for x.ecore? BTW, it looks not necessary
- AFAIU, you should have map diagram and should be able to create X directly
from this diagram.

-----------------
Alex Shatalin
Re: Multiple ecore and one editor [message #164118 is a reply to message #164046] Tue, 04 December 2007 07:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smjo85.gmail.com

Hello Alex,

"xref" is a containment reference

// URI xResourceURI = URI.createURI("default.x");
URI xResourceURI = top.eResource().getURI();
Using this, an error occur
org.eclipse.emf.common.util.BasicEList$BasicIndexOutOfBounds Exception:
index=0, size=0

I have no .editor plugin generated for x.ecore
I have ecore, graphdef, map .editor

I add my emailaddress: smjo85ATgmailDOTcom.
I would be happy, if you can send me a minimal (e.g. x, mindmap) editor.
The online debug is a hard and long process.

Thanks,
John
Re: Multiple ecore and one editor [message #164125 is a reply to message #164118] Tue, 04 December 2007 07:54 Go to previous messageGo to next message
Eclipse UserFriend
Hello John,

> "xref" is a containment reference
Then you should make this reference non-containment. As i described in EMF
each object can be contained in only one place - either Resoruce or container.
Newly created X will be removed from the resource on calling top.getXref().add(newX).
Or you can try using EMF cross-resource containment feature.

> // URI xResourceURI = URI.createURI("default.x");
> URI xResourceURI = top.eResource().getURI();
> Using this, an error occur
> org.eclipse.emf.common.util.BasicEList$BasicIndexOutOfBounds Exception:
> index=0, size=0
Can you post full stacktrace here?

-----------------
Alex Shatalin
Re: Multiple ecore and one editor [message #164206 is a reply to message #164125] Tue, 04 December 2007 09:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: smjo85.gmail.com

Hello Alex,

In the org.eclipse.gmf.examples.mindmap I have 3 ecores and 1 genmodel:

mindmap (this is a package)
- Top
- xref: X (1)
- yref: Y

x (this is a package)
- XTop
- xref: X (2)
- X

if (1) containment, but (2) no -> no error
if (1) not containment, but (2) yes -> error when I create gmfgen: Top
level node 'Containment Feature' must be available in the diagram 'Domain
Element' or its super-class
if (1) containment, and (2) too -> no error

I tried everything but creating the 2 XMI serializations do not operate.

Can you create an editor seeing how the serialization operates?

Thanks,
John
Re: Multiple ecore and one editor [message #164214 is a reply to message #164206] Tue, 04 December 2007 10:02 Go to previous messageGo to next message
Eclipse UserFriend
Hello John,

> mindmap (this is a package)
> - Top
> - xref: X (1)
> - yref: Y
> x (this is a package)
> - XTop
> - xref: X (2)
> - X

So, AFAIU you are going to create model instance looks like this:

resource.mingmap
Top1
reference to X1

resource.x
XTop1
X1 (referenced by Top1)

In this case (2) should be containment, but (1) - not.

> if (1) not containment, but (2) yes -> error when I create gmfgen: Top
> level node 'Containment Feature' must be available in the diagram
> 'Domain Element' or its super-class
You can ignore this message because you are customizing generated ???CreateCommand
in any case - you will throw away incorrectly generated/incompilable code.

-----------------
Alex Shatalin
Re: Multiple ecore and one editor [message #164235 is a reply to message #164214] Tue, 04 December 2007 11:05 Go to previous message
Eclipse UserFriend
Originally posted by: smjo85.gmail.com

Hello Alex,

I tried everything to reach my destination (multiple serialization), but
it do not want to work. If you have a little time and do a similar editor
and send me (smjo85ATgmailDOTcom) I would be really happy.

Thanks for all the help,
John
Previous Topic:class model contains a collection of itself
Next Topic:Questions and thought about Shared editing domain
Goto Forum:
  


Current Time: Tue Oct 28 06:44:47 EDT 2025

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

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

Back to the top