49
49
50
50
/**
51
51
* This class represents the life of SysMl module
52
- *
52
+ *
53
53
* @author ebrosse
54
54
*/
55
55
56
56
public class SysMLSession extends DefaultModuleLifeCycleHandler {
57
-
57
+
58
58
private SysMLModelChangeHandler modelChangeHandler = null ;
59
59
60
60
/**
61
61
* Constructor
62
62
* @author ebrosse
63
- *
63
+ *
64
64
* @param module : the SysML Mdac
65
65
*/
66
-
66
+
67
67
public SysMLSession (SysMLModule module ) {
68
68
super (module );
69
69
}
70
70
71
-
71
+
72
72
@ Override
73
73
public boolean start () throws ModuleException {
74
74
/*
@@ -80,29 +80,29 @@ public boolean start() throws ModuleException {
80
80
// Display the copyright
81
81
// SysMLInfo cannot be used in this operation, because there is a Java
82
82
// error when the MDAC is deployed
83
- SysMLModule .logService .info ("Modelio/" + this .module .getName () + " " + completeVersion + " - Copyright 2011-2015 Modeliosoft " );
84
-
83
+ SysMLModule .logService .info ("Modelio/" + this .module .getName () + " " + completeVersion + " - Copyright 2011-2023 Docaposte " );
84
+
85
85
IModelingSession session = this .module .getModuleContext ().getModelingSession ();
86
86
this .modelChangeHandler = new SysMLModelChangeHandler ();
87
87
session .addModelHandler (this .modelChangeHandler );
88
-
88
+
89
89
installStyles ();
90
90
installRamc ();
91
91
return super .start ();
92
92
}
93
93
94
-
94
+
95
95
@ Override
96
96
public void stop () throws ModuleException {
97
97
this .module .getModuleContext ().getModelingSession ().removeModelHandler (this .modelChangeHandler );
98
98
this .modelChangeHandler = null ;
99
99
super .stop ();
100
100
}
101
101
102
-
102
+
103
103
private void installRamc () {
104
104
Path mdaplugsPath = this .module .getModuleContext ().getConfiguration ().getModuleResourcesPath ();
105
-
105
+
106
106
final IModelComponentService modelComponentService = SysMLModule .getInstance ().getModuleContext ().getModelioServices ().getModelComponentService ();
107
107
for (IModelComponentDescriptor mc : modelComponentService .getModelComponents ()) {
108
108
if (mc .getName ().equals ("SIDefinitions" )) {
@@ -114,29 +114,29 @@ private void installRamc() {
114
114
}
115
115
}
116
116
}
117
-
117
+
118
118
// No ramc found, deploy it
119
119
modelComponentService .deployModelComponent (new File (mdaplugsPath .resolve ("res" + File .separator + "ramc" + File .separator + "SIDefinitions.ramc" ).toString ()), new NullProgressMonitor ());
120
120
}
121
121
122
-
122
+
123
123
private void installStyles () {
124
124
Path mdaplugsPath = this .module .getModuleContext ().getConfiguration ().getModuleResourcesPath ();
125
-
125
+
126
126
SysMLModule .getInstance ().getModuleContext ().getModelioServices ().getDiagramService ().registerStyle ("sysml" , "default" , new File (mdaplugsPath .resolve ("res" + File .separator + "style" + File .separator + "sysml.style" ).toString ()));
127
-
127
+
128
128
SysMLModule .getInstance ().getModuleContext ().getModelioServices ().getDiagramService ().registerStyle ("sysmlinternal" , "default" , new File (mdaplugsPath .resolve ("res" + File .separator + "style" + File .separator + "sysmlinternal.style" ).toString ()));
129
-
129
+
130
130
SysMLModule .getInstance ().getModuleContext ().getModelioServices ().getDiagramService ().registerStyle ("sysmlpackage" , "default" , new File (mdaplugsPath .resolve ("res" + File .separator + "style" + File .separator + "sysmlpackage.style" ).toString ()));
131
131
}
132
132
133
-
133
+
134
134
@ Override
135
135
public boolean select () throws ModuleException {
136
136
return super .select ();
137
137
}
138
138
139
-
139
+
140
140
@ Override
141
141
public void upgrade (Version oldVersion , Map <String , String > oldParameters ) {
142
142
Version lastVersion = new Version ("2.1.10" );
@@ -146,30 +146,30 @@ public void upgrade(Version oldVersion, Map<String, String> oldParameters) {
146
146
for (MObject existingPort : existingPorts ) {
147
147
if (existingPort instanceof Port ) {
148
148
Port currentPort = (Port ) existingPort ;
149
-
149
+
150
150
Stereotype flowPortSter = session .getMetamodelExtensions ().getStereotype (ISysMLPeerModule .MODULE_NAME , SysMLStereotypes .FLOWPORT , SysMLModule .getInstance ().getModuleContext ().getModelioServices ().getMetamodelService ().getMetamodel ().getMClass (Port .class ));
151
-
151
+
152
152
if (currentPort .isStereotyped (ISysMLPeerModule .MODULE_NAME , SysMLStereotypes .FLOWIN )) {
153
-
153
+
154
154
Stereotype flowINSter = session .getMetamodelExtensions ().getStereotype (ISysMLPeerModule .MODULE_NAME , SysMLStereotypes .FLOWIN , SysMLModule .getInstance ().getModuleContext ().getModelioServices ().getMetamodelService ().getMetamodel ().getMClass (Port .class ));
155
155
currentPort .setDirection (PortOrientation .IN );
156
156
currentPort .getExtension ().remove (flowINSter );
157
-
157
+
158
158
} else if (currentPort .isStereotyped (ISysMLPeerModule .MODULE_NAME , SysMLStereotypes .FLOWOUT )) {
159
-
159
+
160
160
Stereotype flowOUTSter = session .getMetamodelExtensions ().getStereotype (ISysMLPeerModule .MODULE_NAME , SysMLStereotypes .FLOWOUT , SysMLModule .getInstance ().getModuleContext ().getModelioServices ().getMetamodelService ().getMetamodel ().getMClass (Port .class ));
161
161
currentPort .setDirection (PortOrientation .OUT );
162
162
currentPort .getExtension ().remove (flowOUTSter );
163
-
163
+
164
164
} else if (currentPort .isStereotyped (ISysMLPeerModule .MODULE_NAME , SysMLStereotypes .FLOWINOUT )) {
165
-
165
+
166
166
Stereotype flowINOUTSter = session .getMetamodelExtensions ().getStereotype (ISysMLPeerModule .MODULE_NAME , SysMLStereotypes .FLOWINOUT , SysMLModule .getInstance ().getModuleContext ().getModelioServices ().getMetamodelService ().getMetamodel ().getMClass (Port .class ));
167
167
currentPort .setDirection (PortOrientation .INOUT );
168
168
currentPort .getExtension ().remove (flowINOUTSter );
169
169
}
170
-
170
+
171
171
currentPort .getExtension ().add (flowPortSter );
172
-
172
+
173
173
}
174
174
}
175
175
}
0 commit comments