Create papyrus model programmatically [message #1159546] |
Mon, 28 October 2013 12:08  |
Eclipse User |
|
|
|
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 #1165558 is a reply to message #1162859] |
Fri, 01 November 2013 07:19   |
Eclipse User |
|
|
|
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 08:51] by Moderator
|
|
|
Re: Create papyrus model programmatically [message #1170148 is a reply to message #1165558] |
Mon, 04 November 2013 07:45  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.06840 seconds