Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Generate diagram code programmatically
Generate diagram code programmatically [message #235936] Fri, 10 July 2009 10:53 Go to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Hi there,

Does anyone can give me a name of a GMF class (if it exists) that can be
used to start my implementation in order to generate the diagram code
programmatically from JAva?

Thanks,

Achilleas
Re: Generate diagram code programmatically [message #235943 is a reply to message #235936] Fri, 10 July 2009 10:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aurelien.pupier.esial.net

Achilleas a écrit :
>
> Hi there,
>
> Does anyone can give me a name of a GMF class (if it exists) that can be
> used to start my implementation in order to generate the diagram code
> programmatically from JAva?
>
> Thanks,
>
> Achilleas
>

Hi Achilleas,

Perhaps org.eclipse.gmf.codegen.util.Generator

Aurelien Pupier
Re: Generate diagram code programmatically [message #235950 is a reply to message #235943] Fri, 10 July 2009 11:19 Go to previous messageGo to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Hi Pupier,

From the search and the attempts I am doing to accomplish the generation I
also reached the same conclusion. Actually I am trying to do it like this:

GmfGenGenerator gmfgenerator = new GmfGenGenerator();

CodegenEmitters emitters = new CodegenEmitters(true, null, false);

Generator gen = new Generator(gmfgenerator, emitters);

The problem is that I don't find any way to access the gmfgen model
through these classes. So there is no possibility to generate anything
without at least having access to the generation model:)

Thanks for the suggestion,

Achilleas.
Re: Generate diagram code programmatically [message #235957 is a reply to message #235950] Fri, 10 July 2009 11:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aurelien.pupier.esial.net

Achilleas a écrit :
>
> Hi Pupier,
>
> From the search and the attempts I am doing to accomplish the
> generation I also reached the same conclusion. Actually I am trying to
> do it like this:
>
> GmfGenGenerator gmfgenerator = new GmfGenGenerator();
>
> CodegenEmitters emitters = new CodegenEmitters(true, null, false);
>
> Generator gen = new Generator(gmfgenerator, emitters);
>
> The problem is that I don't find any way to access the gmfgen model
> through these classes. So there is no possibility to generate anything
> without at least having access to the generation model:)
>
> Thanks for the suggestion,
>
> Achilleas.
>


Access to the genmodel instance seems to be the problem ^^

In the plug-in of Peter Nehrer ( http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg18284.html) :

private Diagnostic loadGenModel() {
ResourceSet srcResSet = new ResourceSetImpl();
srcResSet.getURIConverter().getURIMap().putAll(EcorePlugin.c omputePlatformURIMap());
ModelLoadHelper loadHelper = new ModelLoadHelper(srcResSet, genModelURI);
Object root = loadHelper.getContentsRoot();
if (root instanceof GenDiagram)
genModel = ((GenDiagram) root).getEditorGen();
else if (root instanceof GenEditorGenerator)
genModel = (GenEditorGenerator) root;

if (genModel != null && genModel.getDomainGenModel() != null)
genModel.getDomainGenModel().reconcile();

return loadHelper.getDiagnostics();
}


But it doesn't work for me : http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg18902.html
Re: Generate diagram code programmatically [message #235974 is a reply to message #235957] Fri, 10 July 2009 11:57 Go to previous messageGo to next message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Thanks for the tip. I am actually kind of confused with the names used.

My impression (if I am correct) is that the loadGenModel method and
specifically the GenModel class refer to the domain model (i.e.
"something.genmodel") that is used to generate the model, edit and editor
projects.

I don't think it refers to the GmfGen model (i.e. "something.gmfgen").
WHat do you think on that? Since the code that you posted has to do with
the GenModel!

In an initial attempt of mine I tried to do something like the following
since I did not have any inputs where to start.

GenModel gmfgenmodel = tgmfgen.findGenmodel();
gmfgenmodel.setCanGenerate(true);

// Create the generator and set the model-level input object.
Generator generator = new Generator();
generator.setInput(gmfgenmodel);

// Generator model code.
generator.generate(gmfgenmodel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE,
new BasicMonitor.Printing(System.out));

But this was generating the model project not the gmf diagram project.
Maybe I am mistaken but that is my understanding.

Achilleas
Re: Generate diagram code programmatically [message #235981 is a reply to message #235974] Fri, 10 July 2009 12:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aurelien.pupier.esial.net

This is a multi-part message in MIME format.
--------------010907010502080501060205
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Achilleas a
Re: Generate diagram code programmatically [message #236014 is a reply to message #235981] Fri, 10 July 2009 13:52 Go to previous message
Achilleas is currently offline AchilleasFriend
Messages: 88
Registered: July 2009
Member
Hi again Pupier,

Your tips were very useful and with the Java file that you send me I was
able to modify it and generate the diagram code succesfully from the
created gmfgen file.

I have made some changes to the code as follows:

1. The createGenerator method was changed as follows:

private Generator createGenerator() {
CodegenEmitters emitters = new CodegenEmitters(true, null,
false);
return new Generator(getGenModel(), emitters);
}

2. I have changed the access of the doRun method to protected instead of
private; so that I can call it from my package.

3. I have made an instance of the GenerateDiagramCodeOperation class, set
the gmfgen uri and called the doRun method!!

Thanks for the initial tips,

Achilleas
Previous Topic:Dynamic message while defining Audit Rules
Next Topic:Partial mapping of ecore to gmftool
Goto Forum:
  


Current Time: Tue Apr 07 05:06:02 GMT 2020

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

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

Back to the top