Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Create papyrus model programmatically
Create papyrus model programmatically [message #1159546] Mon, 28 October 2013 16:08 Go to next message
Kostas Triantafyllidis is currently offline Kostas TriantafyllidisFriend
Messages: 15
Registered: November 2012
Junior Member
Hello all,

The last week i am trying to create classDiagrams based on UML (actually i need to generate the di and the notation files). The latter is possible to be done from GUI by right clicking on the UML file and then press new Papyrus model. The latter creates an association between the UML model and the di file generated. Then the user can drag and drop the classes into class diagrams that he creates.

However, i would like to perform the above mentioned task automatically through java code (programmatically). I have searched the forum but i did not find a relevant thread. So, I am asking for your help. I have already downloaded the source code of papyrus in order to check the classes into the code. Actually as far as i can imagine i will need 3 crucial methods. The first method should be the creation of di and nontation file corresponding to a given UML file (path of the file). The second method should be the creation of papyrus class diagrams and the third the save of the papyrus model to a specific project/path.
What I am asking is in which package should I search for the 1st, 2nd and 3rd functionality? I have searched into the infa.core plugin and i think that this is the main plugin of the papyrus. Am i right? Which packages should i check to implement the needed code?
Moreover, as far as in understood from the source code, the code is based on the creation of an eclipse plugin and thus some code especially methods based on paths (IPath, IFile) may not be functional when developing a java application. Do you think that this could impose a problem?

Thanks for your time!
Re: Create papyrus model programmatically [message #1159564 is a reply to message #1159546] Mon, 28 October 2013 16:21 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi,


Papyrus has not been designed as a Standalone Java application. So, nothing will work outside Eclipse.

You should download the tests sources (On Git: tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests)

It contains some minimum code samples to create or load Papyrus models/diagrams/editors programmatically


Regards,
Camille


Camille Letavernier
Re: Create papyrus model programmatically [message #1160735 is a reply to message #1159564] Tue, 29 October 2013 10:13 Go to previous messageGo to next message
Kostas Triantafyllidis is currently offline Kostas TriantafyllidisFriend
Messages: 15
Registered: November 2012
Junior Member
Thank you for your instant reply. I have managed to download the tests folder for the Papyrus 0.9. Since that the test folder consists as well a plugin, is there any easy way to execute them? For instance I have implemented a popup menu plugin from where I call the required methods. But this is not the ideal way to debug the code, since that for each change I make I have to export the plugin and then close eclipse and copy the plugin into the plugin folder and then fire the eclipse up again. Is there any easier way to do that?

I have to mention that I have tried to use the debug as an Eclipse application but this does not work, producing an error (The application could not run etc. This is not a problem of the plugin but a problem of the eclipse since that I am facing the same problem even with a template plugin.)

Thank you for your help.

Regards,
Kostas

[Updated on: Wed, 30 October 2013 16:13]

Report message to a moderator

Re: Create papyrus model programmatically [message #1162801 is a reply to message #1160735] Wed, 30 October 2013 16:29 Go to previous messageGo to next message
Kostas Triantafyllidis is currently offline Kostas TriantafyllidisFriend
Messages: 15
Registered: November 2012
Junior Member
So my question can be summarized into: "Is there any easy way to execute a plugin into eclipse like an ordinary java application?"
I am sorry for asking again but I want to make more clear what I am asking. I have searched through the web but I did not find such a solution.
Re: Create papyrus model programmatically [message #1162859 is a reply to message #1159546] Wed, 30 October 2013 17:19 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Quote:
I have to mention that I have tried to use the debug as an Eclipse application but this does not work, producing an error (The application could not run etc. This is not a problem of the plugin but a problem of the eclipse since that I am facing the same problem even with a template plugin.)


That's basically what every Eclipse developers do. So, this is not an Eclipse problem. It might be worth investigating on your error.

For example, if you are running Papyrus in debug mode, you need at least 512 MB of PermGen memory (The default is 256 MB and is not sufficient).

I use the following VM arguments in Debug mode for Eclipse applications:

-Dosgi.requiredJavaVersion=1.6 -Xms40m -Xmx1024m -XX:MaxPermSize=512M



Regards,
Camille


Camille Letavernier
Re: Create papyrus model programmatically [message #1165558 is a reply to message #1162859] Fri, 01 November 2013 11:19 Go to previous messageGo to next message
Kostas Triantafyllidis is currently offline Kostas TriantafyllidisFriend
Messages: 15
Registered: November 2012
Junior Member
Thanks for your reply. It seems that it works fine, since that I have downloaded a fresh copy of eclipse Juno. Actually this is the first plugin that I am programming and as a result I am not familiar with the IFiles, IProjects etc and I am facing some basic problems.
My problem is the following: I have a project into the workspace called UML_model. I want to create a papyrus model based on this model. So, I think that the appropriate class to use is the "InitModelWizard" and using init method I expect to receive the associated papyrus model. Am I right? If I am wrong please correct me.
So, the arguments that the "init" methods takes are of the types "workbench" and the "IStructuredSelection". In the place of the IStructuredSelection I would like to use a static path (workspace/UML_model/model.uml), but I do not how. The code I am using is :

IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("UML_model");
IFile file = project.getFile("/model.uml");
InitModelWizard new_papy = new InitModelWizard();
IStructuredSelection kos = (IStructuredSelection) file;
new_papy.init(PlatformUI.getWorkbench(), kos);

I receive an exception that the casting of the IFile to the IStructuredSelection is not possible.
Do you know any way to cast a model path, file to an IStructuredSelection path?

Regards,
Kostas

[Updated on: Fri, 01 November 2013 12:51]

Report message to a moderator

Re: Create papyrus model programmatically [message #1170148 is a reply to message #1165558] Mon, 04 November 2013 12:45 Go to previous message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi Kostas,


First, a Wizard is a graphical element, so it is not designed to be used programmatically. Depending on the implementation, it may or may not work as expected.

Then, for your selection:

IStructuredSelection selection = new StructuredSelection(file);



Regards,
Camille


Camille Letavernier
Previous Topic:Cannot display icons for specialized stereotype
Next Topic:Model broken, how to fix
Goto Forum:
  


Current Time: Fri Apr 19 07:35:07 GMT 2024

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

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

Back to the top