Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » generating a graphical representation of a gmf model
generating a graphical representation of a gmf model [message #427126] Tue, 03 February 2009 05:10 Go to next message
Brice Laurel is currently offline Brice LaurelFriend
Messages: 72
Registered: July 2009
Member
Hi list,

I have a rcp application which is generated from his EMF's model. I want
to add to this application a plugin (a wizard) which generate the same
model. But I don't konow 2 things :

1 - if I use the generating code to do what I want (I don't think it is a
good idea). and you ?
2 - if I use the standard model (I have the .ecore file of this
application), I think this idea is good. I reflect on this since several
weeks but I don't know how I can operate on this model programmaically :
- Can I have an instance of this model and how ?
- Can I add an element on this and how ?
- How can I display this as the same way in the initial rcp
application ?

Thanks in advance for your help.
Re: generating a graphical representation of a gmf model [message #427135 is a reply to message #427126] Tue, 03 February 2009 13:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Brice,

Comments below.

Brice Laurel wrote:
> Hi list,
>
> I have a rcp application which is generated from his EMF's model. I
> want to add to this application a plugin (a wizard) which generate the
> same model. But I don't konow 2 things :
>
> 1 - if I use the generating code to do what I want (I don't think it
> is a good idea). and you ?
I'm not sure I follow. EMF does generate a wizard to create an instance
of the model...
> 2 - if I use the standard model (I have the .ecore file of this
> application), I think this idea is good. I reflect on this since
> several weeks but I don't know how I can operate on this model
> programmaically : - Can I have an instance of this model and how ?
You mean read the Ecore file in and manipulate it? Basically all models
are loaded the same way via a resource set.
> - Can I add an element on this and how ?
> - How can I display this as the same way in the initial rcp
> application ?
I'm quite confused on what you're trying to do. I'm not even sure which
meta level you're really referring to. For example, the tutorials all
use a Library model, so you end up with a Library.ecore, the Ecore model
of a library, and then you create instances like my.library, which are
library instances. All these things are models but whether you are
talking about manipulating Library.ecore or my.library makes quite a
difference in how I answer.
>
> Thanks in advance for your help.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: generating a graphical representation of a gmf model [message #427139 is a reply to message #427135] Tue, 03 February 2009 15:23 Go to previous messageGo to next message
Brice Laurel is currently offline Brice LaurelFriend
Messages: 72
Registered: July 2009
Member
Hello Ed,

I am talking about manipulating my.library.

Now I create a simple plugin with a wizard which have only one page. When
I click on finish's button, I want to display my.library on the
eclipse'editor.
I write the code below in my performFinish'method. But it do nothing. I
don't understand how ?


@Override
public boolean performFinish() {
// TODO Auto-generated method stub

//initialize model and dependencies
ForumPackageImpl.init();

//retrieve the default forum factory singleton
ForumFactory factory = ForumFactory.eINSTANCE;

Forum forum = factory.createForum();
forum.setDescription("programmatic forum example");


URI fileURI = URI.createFileURI("model/forum.ecore");
Resource resource = new XMIResourceFactoryImpl().createResource(fileURI);
resource.getContents().add(forum);
try{
resource.save(Collections.EMPTY_MAP);
}catch(Exception e){
e.printStackTrace();
}

return true;
}

Thanks for your help.
Re: generating a graphical representation of a gmf model [message #427141 is a reply to message #427139] Tue, 03 February 2009 19:10 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33218
Registered: July 2009
Senior Member
Brice,

Comments below.

Brice Laurel wrote:
> Hello Ed,
>
> I am talking about manipulating my.library.
>
> Now I create a simple plugin with a wizard which have only one page.
> When I click on finish's button, I want to display my.library on the
> eclipse'editor.
> I write the code below in my performFinish'method. But it do nothing.
> I don't understand how ?
>
>
> @Override
> public boolean performFinish() {
> // TODO Auto-generated method stub
>
> //initialize model and dependencies
> ForumPackageImpl.init();
We generally use the idiom ForumPackage.eINSTANCE.eClass() for this, but
given you're running in Eclipse, this should be completely redundant.
>
> //retrieve the default forum factory singleton
> ForumFactory factory = ForumFactory.eINSTANCE;
>
> Forum forum = factory.createForum();
> forum.setDescription("programmatic forum example");
>
>
> URI fileURI = URI.createFileURI("model/forum.ecore");
Why are you creating a resource with a name that implies it will contain
Ecore instances? This relative URI will be relative to the current
working directory of the running application, which seems unlikely to be
a good idea.
> Resource resource = new
> XMIResourceFactoryImpl().createResource(fileURI);
> resource.getContents().add(forum);
> try{
> resource.save(Collections.EMPTY_MAP);
> }catch(Exception e){
> e.printStackTrace();
> }
>
> return true;
> }
Try invoking "Generate Test Code" and looking at the generated *.tests
project's ForumExample.java for a better idea of how to create a new
instance.
>
> Thanks for your help.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:How to create ecore model if my model classes reffering to other *.jar ?
Next Topic:IMarker and IResource
Goto Forum:
  


Current Time: Tue Sep 24 18:59:16 GMT 2024

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

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

Back to the top