Skip to content

Project_context_service

Antonin Abhervé edited this page Sep 3, 2020 · 1 revision

Project context service

Modelio v4.0

The Project context service can be used to get information about the project opened in Modelio:
– the Project context service interface is IProjectStructure.
– the IProjectStructure instance can be obtained from the IModuleContext of the module.

Available data is represented by the following diagram:

fig 1

The following code snippet lists the Project context available data.

 1IModule myModule = MyModule.getInstance();
 2IProjectContext project = myModule.getModuleContext().getProjectStructure();
 3
 4System.out.println("Current project:");
 5System.out.println("  name = " + project.getName());
 6System.out.println("  path = " + project.getPath());
 7
 8// Display the modules of the project
 9for (IModuleStructure module : project.getModules() ) {
10   System.out.printf("  %s %s\n", module.getName(), module.getVersion());
11}
12
13// Display the model fragments
14for (IFragmentStructure fragment : project.getfragments() ) {
15   System.out.printf("  %s %s %s\n", fragment.getName(), fragment.getType(), fragment.getRemoteLocation());
16}

line 1: Get the unique instance of our module
line 2: Get the IProjectContext instance from the module context
lines 5,6,10,15: Use the different accessors to retrieve the information about the project

Clone this wiki locally