Skip to content

Commit 7a283a0

Browse files
committed
fixes Unit property page
1 parent adb8e54 commit 7a283a0

File tree

4 files changed

+486
-401
lines changed

4 files changed

+486
-401
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<!-- definition -->
66
<groupId>org.modelio.module</groupId>
77
<artifactId>marte</artifactId>
8-
<version>4.1.03</version>
8+
<version>4.1.04</version>
99
<name>MARTEDesigner</name>
1010
<repositories>
1111
<repository>

src/main/java/org/modelio/module/marte/profile/nfps/propertys/Unit_EnumerationLiteralProperty.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ public class Unit_EnumerationLiteralProperty implements IPropertyContent {
2222
@Override
2323
public void changeProperty(final ModelElement elt, final int row, final String value) {
2424
if(row == 1){
25-
ModelUtils.manageSingleOrientedLink(elt,
26-
listBaseUnit,
27-
MARTEDesignerStereotypes.PROFILEASSOCIATION_BASEUNIT_UNIT_UNIT,
25+
ModelUtils.manageSingleOrientedLink(elt,
26+
listBaseUnit,
27+
MARTEDesignerStereotypes.PROFILEASSOCIATION_BASEUNIT_UNIT_UNIT,
2828
// MARTEDesignerTagTypes.UNIT_ENUMERATIONLITERAL_UNIT_ENUMERATIONLITERAL_BASEUNIT,
29-
value );
29+
value );
3030
}
3131
else if(row == 2){
32-
32+
3333
if (isParseable(value)) {
3434
ModelUtils.addStringValue(elt, MARTEDesignerTagTypes.UNIT_ENUMERATIONLITERAL_UNIT_ENUMERATIONLITERAL_CONVFACTOR, value);
3535
}
@@ -47,36 +47,35 @@ public void update(final ModelElement elt, final IModulePropertyTable table) {
4747
//
4848
// Unit
4949
//
50-
50+
5151
/*
5252
* baseUnit tagged value getting
5353
*/
54-
55-
// unit element List<MObject> getting
54+
5655
listBaseUnit = ModelUtils.searchElementStereotyped(EnumerationLiteral.class, MARTEDesignerStereotypes.UNIT_ENUMERATIONLITERAL);
5756
String[] tabBaseUnit = ModelUtils.createListString(listBaseUnit);
58-
String value_baseUnit = ModelUtils.getTargetDependencyNames(MARTEDesignerTagTypes.UNIT_ENUMERATIONLITERAL_UNIT_ENUMERATIONLITERAL_BASEUNIT, elt);
57+
String value_baseUnit = ModelUtils.getTargetDependencyNames(MARTEDesignerStereotypes.PROFILEASSOCIATION_BASEUNIT_UNIT_UNIT, elt);
5958
table.addProperty(MARTEResourceManager.getPropertyName(MARTEDesignerTagTypes.UNIT_ENUMERATIONLITERAL_UNIT_ENUMERATIONLITERAL_BASEUNIT),value_baseUnit, tabBaseUnit);
60-
61-
59+
60+
6261
String value_convFactor = ModelUtils.getTaggedValue(MARTEDesignerTagTypes.UNIT_ENUMERATIONLITERAL_UNIT_ENUMERATIONLITERAL_CONVFACTOR, elt);
6362
table.addProperty(MARTEResourceManager.getPropertyName(MARTEDesignerTagTypes.UNIT_ENUMERATIONLITERAL_UNIT_ENUMERATIONLITERAL_CONVFACTOR),value_convFactor);
64-
65-
63+
64+
6665
String value_offsetFactor = ModelUtils.getTaggedValue(MARTEDesignerTagTypes.UNIT_ENUMERATIONLITERAL_UNIT_ENUMERATIONLITERAL_OFFSETFACTOR, elt);
6766
table.addProperty(MARTEResourceManager.getPropertyName(MARTEDesignerTagTypes.UNIT_ENUMERATIONLITERAL_UNIT_ENUMERATIONLITERAL_OFFSETFACTOR),value_offsetFactor);
6867
}
6968

7069
/**
7170
* isParseable allows us to check the parsing of the different getting values
7271
* @param values are the different getting values
73-
*
72+
*
7473
* @return a boolean which gives the parsing of the different getting values
7574
*/
7675
@objid ("0f70baed-6139-43bf-8d9e-6a43f1f6883b")
7776
public boolean isParseable(String value) {
7877
boolean result = false;
79-
78+
8079
try {
8180
Double.parseDouble(value);
8281
result = true;

src/main/java/org/modelio/module/marte/profile/utils/LinkManager.java

Lines changed: 74 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.modelio.api.modelio.model.IUmlModel;
77
import org.modelio.metamodel.uml.infrastructure.Dependency;
88
import org.modelio.metamodel.uml.infrastructure.ModelElement;
9+
import org.modelio.metamodel.uml.infrastructure.Stereotype;
910
import org.modelio.module.marte.api.IMARTEDesignerPeerModule;
1011
import org.modelio.module.marte.impl.MARTEModule;
1112

@@ -17,15 +18,15 @@
1718
public class LinkManager {
1819
/**
1920
* Creates a dependency, if it doesn't exist, stereotyped stereotypeName between the two ModelElement i.e. source and target
20-
*
21+
*
2122
* @param source : the ModelElement which will be the source of the dependency
2223
* @param target : the ModelElement which will be the target of the dependency
2324
* @param stereotypeName : the stereotype name applicable on Dependency Metaclass
2425
*/
2526
@objid ("5f303eaf-9ebc-41d7-96c8-d1a87f2d7196")
2627
public static void setLink(ModelElement source, ModelElement target, String stereotypeName) {
2728
IUmlModel model = MARTEModule.getInstance().getModuleContext().getModelingSession().getModel();
28-
29+
2930
try {
3031
//Looking after a pre-existing stereotype
3132
boolean find = false;
@@ -36,27 +37,27 @@ public static void setLink(ModelElement source, ModelElement target, String ster
3637
break;
3738
}
3839
}
39-
40+
4041
//create the dependency if necessary
4142
if(!find)
4243
model.createDependency(source, target, IMARTEDesignerPeerModule.MODULE_NAME, stereotypeName);
43-
44+
4445
} catch (Exception e) {
4546
MARTEModule.getInstance().getModuleContext().getLogService().error(e);
4647
}
4748
}
4849

4950
/**
5051
* delete the first dependency, if exists, stereotyped stereotypeName between the two ModelElement i.e. source and target
51-
*
52+
*
5253
* @param source : the ModelElement which will be the source of the dependency
5354
* @param target : the ModelElement which will be the target of the dependency
5455
* @param stereotypeName : the stereotype name applicable on Dependency Metaclass
5556
*/
5657
@objid ("522e7d1b-789c-4b38-ac53-69c492c02736")
5758
public static void removeLink(ModelElement source, ModelElement target, String stereotypeName) {
5859
try {
59-
60+
6061
for(Dependency dp: source.getDependsOnDependency()){
6162
if(dp.isStereotyped(IMARTEDesignerPeerModule.MODULE_NAME, stereotypeName)){
6263
dp.delete();
@@ -71,28 +72,28 @@ public static void removeLink(ModelElement source, ModelElement target, String s
7172
/**
7273
* delete ALL dependencies,incoming or outgoing, stereotyped stereotypeName between the two ModelElement i.e. source and target
7374
* @param elemeznt : the ModelElement which is the source or the target of the dependencies
74-
*
75+
*
7576
* @param stereotypeName : the stereotype name applicable on Dependency Metaclass
7677
*/
7778
@objid ("0dbdb123-8b58-47cd-aaaf-aa607a280c43")
7879
public static List<ModelElement> removeAllLinks(ModelElement element, String stereotypeName) {
7980
List<ModelElement> result = new ArrayList<>();
8081
try {
81-
82+
8283
for(Dependency dp : element.getDependsOnDependency()){
8384
if(dp.isStereotyped(IMARTEDesignerPeerModule.MODULE_NAME, stereotypeName)){
8485
result.add(dp.getDependsOn());
8586
dp.delete();
8687
}
8788
}
88-
89+
8990
for(Dependency dp : element.getImpactedDependency()){
9091
if(dp.isStereotyped(IMARTEDesignerPeerModule.MODULE_NAME, stereotypeName)){
9192
result.add(dp.getImpacted());
9293
dp.delete();
9394
}
9495
}
95-
96+
9697
} catch (Exception e) {
9798
MARTEModule.getInstance().getModuleContext().getLogService().error(e);
9899
}
@@ -101,7 +102,7 @@ public static List<ModelElement> removeAllLinks(ModelElement element, String ste
101102

102103
/**
103104
* ALWAYS creates a dependency stereotyped stereotypeName between the two ModelElement i.e. source and target
104-
*
105+
*
105106
* @param source : the ModelElement which will be the source of the dependency
106107
* @param target : the ModelElement which will be the target of the dependency
107108
* @param stereotypeName : the stereotype name applicable on Dependency Metaclass
@@ -117,7 +118,7 @@ public static void addLink(ModelElement source, ModelElement target, String ster
117118

118119
/**
119120
* return the ModelElement target of the FIRST dependency stereotyped stereotypeName owned by source element
120-
*
121+
*
121122
* @param source : the ModelElement which is the source of the dependency
122123
* @param stereotypeName : the stereotype name applicable on Dependency Metaclass
123124
* @return the ModelElement target of the first dependency
@@ -129,38 +130,60 @@ public static ModelElement getTarget(ModelElement source, String stereotypeName)
129130
ModelElement element = dp.getDependsOn();
130131
if(element != null){
131132
return element;
132-
}
133+
}
133134
}
134135
}
135136
return null;
136137
}
137138

138139
/**
139140
* return the List<MObject> of ModelElement target of the dependencies stereotyped stereotypeName owned by source element
140-
*
141+
*
141142
* @param source : the ModelElement which is the source of the dependency
142143
* @param stereotypeName : the stereotype name applicable on Dependency Metaclass
143144
* @return the ArrayList<MObject> of ModelElement targets of the dependencies
144145
*/
145146
@objid ("8451ba6a-d782-42a6-97ad-08dd79263204")
146147
public static List<ModelElement> getAllTargets(ModelElement source, String stereotypeName) {
147148
List<ModelElement> result = new ArrayList<>();
148-
149+
149150
for(Dependency dp: source.getDependsOnDependency()){
150151
if(dp.isStereotyped(IMARTEDesignerPeerModule.MODULE_NAME, stereotypeName)){
151152
ModelElement element = dp.getDependsOn();
152153
if(element != null){
153154
result.add(element);
154-
}
155+
}
155156
}
156157
}
157158
return result;
158159
}
159160

161+
/**
162+
* return the List<MObject> of ModelElement target of the dependencies stereotyped stereotypeName owned by source element
163+
*
164+
* @param source : the ModelElement which is the source of the dependency
165+
* @param stereotypeName : the stereotype name applicable on Dependency Metaclass
166+
* @return the ArrayList<MObject> of ModelElement targets of the dependencies
167+
*/
168+
public static List<ModelElement> getAllTargets(ModelElement source, Stereotype stereotype) {
169+
List<ModelElement> result = new ArrayList<>();
170+
171+
for(Dependency dp: source.getDependsOnDependency()){
172+
if(dp.isStereotyped(stereotype)){
173+
ModelElement element = dp.getDependsOn();
174+
if(element != null){
175+
result.add(element);
176+
}
177+
}
178+
}
179+
return result;
180+
}
181+
182+
160183
/**
161184
* return the ModelElement source of the FIRST dependency stereotyped stereotypeName
162185
* which impact the target element
163-
*
186+
*
164187
* @param target : the ModelElement which is the source of the dependency
165188
* @param stereotypeName : the stereotype name applicable on Dependency Metaclass
166189
* @return the ModelElement source of the first dependency
@@ -172,7 +195,7 @@ public static ModelElement getSource(ModelElement target, String stereotypeName)
172195
ModelElement element = dp.getImpacted();
173196
if(element != null){
174197
return element;
175-
}
198+
}
176199
}
177200
}
178201
return null;
@@ -181,7 +204,7 @@ public static ModelElement getSource(ModelElement target, String stereotypeName)
181204
/**
182205
* return ALL the ModelElement source of ALL dependencies stereotyped stereotypeName
183206
* which impact the target element
184-
*
207+
*
185208
* @param target : the ModelElement which is the target of the dependency
186209
* @param stereotypeName : the stereotype name applicable on Dependency Metaclass
187210
* @return the List<MObject> of ModelElement source of all incoming dependencies
@@ -194,7 +217,28 @@ public static List<ModelElement> getAllSources(ModelElement target, String stere
194217
ModelElement element = dp.getImpacted();
195218
if(element != null){
196219
result.add(element);
197-
}
220+
}
221+
}
222+
}
223+
return result;
224+
}
225+
226+
/**
227+
* return ALL the ModelElement source of ALL dependencies stereotyped stereotypeName
228+
* which impact the target element
229+
*
230+
* @param target : the ModelElement which is the target of the dependency
231+
* @param stereotypeName : the stereotype applicable on Dependency Metaclass
232+
* @return the List<MObject> of ModelElement source of all incoming dependencies
233+
*/
234+
public static List<ModelElement> getAllSources(ModelElement target, final Stereotype stereotype) {
235+
List<ModelElement> result = new ArrayList<>();
236+
for(Dependency dp: target.getImpactedDependency()){
237+
if(dp.isStereotyped(stereotype)){
238+
ModelElement element = dp.getImpacted();
239+
if(element != null){
240+
result.add(element);
241+
}
198242
}
199243
}
200244
return result;
@@ -203,7 +247,7 @@ public static List<ModelElement> getAllSources(ModelElement target, String stere
203247
/**
204248
* return true if the element have a link
205249
* @param target : the ModelElement which is the target of the dependency
206-
*
250+
*
207251
* @param stereotypeName : the stereotype name applicable on Dependency Metaclass
208252
* @return the List<MObject> of ModelElement source of all incoming dependencies
209253
*/
@@ -220,7 +264,7 @@ public static boolean hasLink(ModelElement source, String stereotypeName) {
220264
@objid ("6c2a2882-4479-430f-b66b-27dcd337d4d9")
221265
public static void removeLink(ModelElement source, String stereotype) {
222266
try {
223-
267+
224268
for(Dependency dp: source.getDependsOnDependency()){
225269
if(dp.isStereotyped(IMARTEDesignerPeerModule.MODULE_NAME, stereotype)){
226270
dp.delete();
@@ -234,41 +278,41 @@ public static void removeLink(ModelElement source, String stereotype) {
234278

235279
/**
236280
* delete ALL outgoing dependencies stereotyped stereotypeName between the two ModelElement i.e. source and target
237-
*
281+
*
238282
* @param element : the ModelElement which will be the source of the dependencies
239283
* @param stereotypeName : the stereotype name applicable on Dependency Metaclass
240284
*/
241285
@objid ("5408d85c-4da5-4047-8f19-e584de5cbd63")
242286
public static void removeAllOutgoingLinks(ModelElement element, String stereotypeName) {
243287
try {
244-
288+
245289
for(Dependency dp: element.getDependsOnDependency()){
246290
if(dp.isStereotyped(IMARTEDesignerPeerModule.MODULE_NAME, stereotypeName)){
247291
dp.delete();
248292
}
249293
}
250-
294+
251295
} catch (Exception e) {
252296
MARTEModule.getInstance().getModuleContext().getLogService().error(e);
253297
}
254298
}
255299

256300
/**
257301
* delete ALL incoming dependencies stereotyped stereotypeName between the two ModelElement i.e. source and target
258-
*
302+
*
259303
* @param element : the ModelElement which will be the target of the dependencies
260304
* @param stereotypeName : the stereotype name applicable on Dependency Metaclass
261305
*/
262306
@objid ("8c648c2a-dbe3-47d8-b4c7-ae6c1a654fb8")
263307
public static void removeAllIncomingLinks(ModelElement element, String stereotypeName) {
264308
try {
265-
309+
266310
for(Dependency dp: element.getImpactedDependency()){
267311
if(dp.isStereotyped(IMARTEDesignerPeerModule.MODULE_NAME, stereotypeName)){
268312
dp.delete();
269313
}
270314
}
271-
315+
272316
} catch (Exception e) {
273317
MARTEModule.getInstance().getModuleContext().getLogService().error(e);
274318
}
@@ -277,7 +321,7 @@ public static void removeAllIncomingLinks(ModelElement element, String stereotyp
277321
/**
278322
* return true if the element have a link
279323
* @param target : the ModelElement which is the target of the dependency
280-
*
324+
*
281325
* @param stereotypeName : the stereotype name applicable on Dependency Metaclass
282326
* @return the List<MObject> of ModelElement source of all incoming dependencies
283327
*/
@@ -294,7 +338,7 @@ public static boolean hasIncomingLink(ModelElement source, String stereotypeName
294338
/**
295339
* return true if the element have a link
296340
* @param target : the ModelElement which is the target of the dependency
297-
*
341+
*
298342
* @param stereotypeName : the stereotype name applicable on Dependency Metaclass
299343
* @return the List<MObject> of ModelElement source of all incoming dependencies
300344
*/

0 commit comments

Comments
 (0)