|
|
|
Re: generating a graphical representation of a gmf model [message #427141 is a reply to message #427139] |
Tue, 03 February 2009 19:10 |
Ed Merks 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/
|
|
|
Powered by
FUDForum. Page generated in 0.04055 seconds