Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2017-01-10 22:21:02 +0000
committerChristian W. Damus2017-01-11 20:25:21 +0000
commitb11a01a8767d3f249f987ba2f37fa1057558d4ac (patch)
treeb5e95a8802d6edcf3cbf88353b8d15cb1ce9ddfa
parente9681e32513f31e5666731cdfbe9542f3091d73f (diff)
downloadorg.eclipse.papyrus-rt-b11a01a8767d3f249f987ba2f37fa1057558d4ac.tar.gz
org.eclipse.papyrus-rt-b11a01a8767d3f249f987ba2f37fa1057558d4ac.tar.xz
org.eclipse.papyrus-rt-b11a01a8767d3f249f987ba2f37fa1057558d4ac.zip
Bug 467545: [UML-RT] PapyrusRT shall provide a UML specific implementation to support redefinition
Address code review comments: * making use of the existing validator mechanism in the Properties View ModelElement API to get kind validators for ports and capsule-parts in the refactored common UI for RT kind enumeration properties * using the façade name property for all named elements that have façades * fixing problem of the Properties view remembering the previous selected element when changing the selection to another instance of of the same UML-RT concept (e.g., from an RT port to another RT port) https://bugs.eclipse.org/bugs/show_bug.cgi?id=467545 Change-Id: I71fdf17a77cb6c3204a405a20bf84f56acf8a437
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/MultipleProtocol.xwt19
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/MultipleRTMessageSet.xwt17
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleCapsulePart.xwt3
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleProtocolMessage.xwt2
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleRTPort.xwt3
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/uml-rt.ctx30
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/RTStereotypeModelElement.java28
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTExtModelElement.java17
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTFacadeModelElement.java31
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTFacadeModelElementFactory.java21
-rw-r--r--plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/RTKindEnumPropertyEditor.java43
-rw-r--r--tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/resource/modelelement/model.uml17
-rw-r--r--tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/src/org/eclipse/papyrusrt/umlrt/tooling/ui/tests/modelelement/ModelElementTest.java160
13 files changed, 260 insertions, 131 deletions
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/MultipleProtocol.xwt b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/MultipleProtocol.xwt
index e0f0c6853..58a47121f 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/MultipleProtocol.xwt
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/MultipleProtocol.xwt
@@ -1,27 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Composite xmlns:x="http://www.eclipse.org/xwt" xmlns="http://www.eclipse.org/xwt/presentation"
- xmlns:ppe="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets"
- xmlns:umlrt="clr-namespace:org.eclipse.papyrusrt.umlrt.tooling.ui.widgets"
xmlns:j="clr-namespace:java.lang"
xmlns:ppel="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets.layout">
<Composite.layout>
<ppel:PropertiesLayout></ppel:PropertiesLayout>
</Composite.layout>
- <Composite>
- <Composite.layout>
- <ppel:PropertiesLayout></ppel:PropertiesLayout>
- </Composite.layout>
- <ppe:StringEditor input="{Binding}" property="UML:NamedElement:name"></ppe:StringEditor>
- </Composite>
- <Composite>
- <Composite.layout>
- <ppel:PropertiesLayout numColumns="3"></ppel:PropertiesLayout>
- </Composite.layout>
- <ppe:MultiReference input="{Binding}"
- property="UMLRealTimeExt:Protocol:Outgoing" customLabel="Out protocol message"></ppe:MultiReference>
- <ppe:MultiReference input="{Binding}"
- property="UMLRealTimeExt:Protocol:Incoming" customLabel="In protocol message"></ppe:MultiReference>
- <ppe:MultiReference input="{Binding}"
- property="UMLRealTimeExt:Protocol:InOut" customLabel="InOut protocol message"></ppe:MultiReference>
- </Composite>
</Composite> \ No newline at end of file
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/MultipleRTMessageSet.xwt b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/MultipleRTMessageSet.xwt
index bc97d7385..addc728a2 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/MultipleRTMessageSet.xwt
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/MultipleRTMessageSet.xwt
@@ -1,23 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Composite xmlns:x="http://www.eclipse.org/xwt" xmlns:j="clr-namespace:java.lang"
- xmlns:ppe="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets"
- xmlns="http://www.eclipse.org/xwt/presentation"
+ xmlns:j="clr-namespace:java.lang"
xmlns:ppel="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets.layout">
<Composite.layout>
<ppel:PropertiesLayout></ppel:PropertiesLayout>
</Composite.layout>
- <Composite>
- <Composite.layout>
- <ppel:PropertiesLayout numColumns="1"></ppel:PropertiesLayout>
- </Composite.layout>
- <ppe:EnumCombo input="{Binding}"
- property="UMLRealTime:RTMessageSet:rtMsgKind" customLabel="Protocol Message Kind"></ppe:EnumCombo>
- </Composite>
- <Composite>
- <Composite.layout>
- <ppel:PropertiesLayout></ppel:PropertiesLayout>
- </Composite.layout>
- <ppe:MultiReference input="{Binding}"
- property="UML:Interface:ownedOperation" customLabel="Protocol Messages"></ppe:MultiReference>
- </Composite>
</Composite> \ No newline at end of file
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleCapsulePart.xwt b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleCapsulePart.xwt
index 356900f8e..79532a0d3 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleCapsulePart.xwt
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleCapsulePart.xwt
@@ -14,7 +14,7 @@
<Composite.layout>
<ppel:PropertiesLayout></ppel:PropertiesLayout>
</Composite.layout>
- <ppe:StringEditor input="{Binding}" property="UMLRealTimeExt:RTNamedElement:name"></ppe:StringEditor>
+ <ppe:StringEditor input="{Binding}" property="UMLRTFacade:CapsulePart:name"></ppe:StringEditor>
<ppumlrt:CapsulePartTypeEditor
customLabel="Capsule" property="UMLRealTimeExt:Property:type" input="{Binding}"></ppumlrt:CapsulePartTypeEditor>
</Composite>
@@ -24,7 +24,6 @@
</Composite.layout>
<ppumlrt:RTKindEnumPropertyEditor
property="UMLRealTime:CapsulePart:kind"
- utilsClass="utils:CapsulePartUtils"
enumType="utils:CapsulePartKindEnum"
input="{Binding}">
</ppumlrt:RTKindEnumPropertyEditor>
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleProtocolMessage.xwt b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleProtocolMessage.xwt
index 3915b04a1..311916715 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleProtocolMessage.xwt
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleProtocolMessage.xwt
@@ -12,7 +12,7 @@
<Composite.layout>
<ppel:PropertiesLayout></ppel:PropertiesLayout>
</Composite.layout>
- <ppe:StringEditor input="{Binding}" property="UML:NamedElement:name"
+ <ppe:StringEditor input="{Binding}" property="UMLRTFacade:ProtocolMessage:name"
customLabel="Name"></ppe:StringEditor>
<widgetrt:RTNatTableMultiReferencePropertyEditor
input="{Binding}"
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleRTPort.xwt b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleRTPort.xwt
index fb4595131..55277c5eb 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleRTPort.xwt
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/ui/SingleRTPort.xwt
@@ -13,7 +13,7 @@
<Composite.layout>
<ppel:PropertiesLayout></ppel:PropertiesLayout>
</Composite.layout>
- <ppe:StringEditor input="{Binding}" property="UMLRealTimeExt:RTNamedElement:name"></ppe:StringEditor>
+ <ppe:StringEditor input="{Binding}" property="UMLRTFacade:Port:name"></ppe:StringEditor>
<ppumlrt:RTPortTypeEditor input="{Binding}"
customLabel="Protocol" property="UMLRealTimeExt:Port:type"></ppumlrt:RTPortTypeEditor>
</Composite>
@@ -23,7 +23,6 @@
</Composite.layout>
<ppumlrt:RTKindEnumPropertyEditor
property="UMLRealTime:RTPort:kind"
- utilsClass="utils:RTPortUtils"
enumType="utils:RTPortKindEnum"
input="{Binding}">
</ppumlrt:RTKindEnumPropertyEditor>
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/uml-rt.ctx b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/uml-rt.ctx
index a0933282d..96f95f6fe 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/uml-rt.ctx
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.properties/propertyView/UML-RT/uml-rt.ctx
@@ -741,16 +741,12 @@
name="Port">
<supertypes
href="ppe:/context/org.eclipse.papyrus.uml.properties/Model/UML/UML.ctx#_690ylaDJEeSZxfCXzZz3-w"/>
- <supertypes
- href="#_8fNAkMCgEeaQF9hkPG_edQ"/>
</elements>
<elements
xmi:id="UMLRealTimeExtCapsulePartElement"
name="Property">
<supertypes
href="ppe:/context/org.eclipse.papyrus.uml.properties/Model/UML/UML.ctx#_690yG6DJEeSZxfCXzZz3-w"/>
- <supertypes
- href="#_8fNAkMCgEeaQF9hkPG_edQ"/>
</elements>
<elements
xmi:id="_DC_ID_Trigger"
@@ -824,16 +820,6 @@
<supertypes
href="ppe:/context/org.eclipse.papyrus.uml.properties/Model/UML/UML.ctx#_690yiKDJEeSZxfCXzZz3-w"/>
</elements>
- <elements
- xmi:id="_8fNAkMCgEeaQF9hkPG_edQ"
- name="RTNamedElement">
- <properties
- xmi:id="_8fNAkcCgEeaQF9hkPG_edQ"
- name="name"
- description="The name of the NamedElement."/>
- <supertypes
- href="ppe:/context/org.eclipse.papyrus.uml.properties/Model/UML/UML.ctx#_690xk6DJEeSZxfCXzZz3-w"/>
- </elements>
<modelElementFactory
href="ppe:/environment/org.eclipse.papyrusrt.umlrt.tooling.ui/environment/Environment.xmi#//@modelElementFactories.0"/>
</dataContexts>
@@ -868,6 +854,10 @@
description="The owned and inherited in-out messages."/>
</elements>
<elements
+ xmi:id="_UqpaUNguEeabDsC0rhZnQA"
+ name="ProtocolMessage"
+ supertypes="_jcwws89jEeaEDpYjmvVhPA"/>
+ <elements
xmi:id="_jcwwsc9jEeaEDpYjmvVhPA"
name="Capsule"
supertypes="_jcwws89jEeaEDpYjmvVhPA">
@@ -894,6 +884,18 @@
description="The owned and inherited connectors."/>
</elements>
<elements
+ xmi:id="_P74lINguEeabDsC0rhZnQA"
+ name="Port"
+ supertypes="_jcwws89jEeaEDpYjmvVhPA"/>
+ <elements
+ xmi:id="_Sp64sNguEeabDsC0rhZnQA"
+ name="CapsulePart"
+ supertypes="_jcwws89jEeaEDpYjmvVhPA"/>
+ <elements
+ xmi:id="_Xao1sNguEeabDsC0rhZnQA"
+ name="Connector"
+ supertypes="_jcwws89jEeaEDpYjmvVhPA"/>
+ <elements
xmi:id="_jcwws89jEeaEDpYjmvVhPA"
name="NamedElement">
<properties
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/RTStereotypeModelElement.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/RTStereotypeModelElement.java
index c18d57b25..a0dbef003 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/RTStereotypeModelElement.java
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/RTStereotypeModelElement.java
@@ -21,6 +21,8 @@ import java.util.Map;
import org.eclipse.core.databinding.observable.ChangeEvent;
import org.eclipse.core.databinding.observable.IChangeListener;
import org.eclipse.core.databinding.observable.IObservable;
+import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.runtime.Status;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.domain.EditingDomain;
@@ -33,6 +35,7 @@ import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.StaticContentProvider;
import org.eclipse.papyrus.uml.properties.modelelement.StereotypeModelElement;
import org.eclipse.papyrusrt.umlrt.core.utils.CapsulePartKindEnum;
+import org.eclipse.papyrusrt.umlrt.core.utils.CapsulePartUtils;
import org.eclipse.papyrusrt.umlrt.core.utils.IRealTimeConstants;
import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum;
import org.eclipse.papyrusrt.umlrt.core.utils.RTPortUtils;
@@ -42,6 +45,7 @@ import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.PortRegistrationType;
import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.RTPort;
import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.UMLRealTimePackage;
import org.eclipse.papyrusrt.umlrt.tooling.ui.Activator;
+import org.eclipse.papyrusrt.umlrt.tooling.ui.databinding.CompositeValidator;
import org.eclipse.papyrusrt.umlrt.tooling.ui.internal.modelelement.ChangeListenerUtils;
import org.eclipse.papyrusrt.umlrt.tooling.ui.widgets.CapsulePartKindObservableValue;
import org.eclipse.papyrusrt.umlrt.tooling.ui.widgets.PortRTKindObservableValue;
@@ -164,6 +168,30 @@ public class RTStereotypeModelElement extends StereotypeModelElement {
return provider;
}
+ @Override
+ public IValidator getValidator(String propertyPath) {
+ // Include inherited validator(s), also
+ IValidator result = super.getValidator(propertyPath);
+
+ if (IRealTimeConstants.KIND.equals(propertyPath)) {
+ result = CompositeValidator.of(result, enumValue -> {
+ if ((source instanceof RTPort) && (enumValue instanceof RTPortKindEnum)) {
+ if (RTPortUtils.isKindEditable(((RTPort) source).getBase_Port(), (RTPortKindEnum) enumValue)) {
+ return Status.OK_STATUS;
+ }
+ } else if ((source instanceof CapsulePart) && (enumValue instanceof CapsulePartKindEnum)) {
+ if (CapsulePartUtils.isKindEditable(((CapsulePart) source).getBase_Property(), (CapsulePartKindEnum) enumValue)) {
+ return Status.OK_STATUS;
+ }
+ }
+
+ return Status.CANCEL_STATUS;
+ });
+ }
+
+ return result;
+ }
+
/**
* {@inheritDoc}
*/
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTExtModelElement.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTExtModelElement.java
index ae46754c0..0a154210e 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTExtModelElement.java
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTExtModelElement.java
@@ -75,7 +75,6 @@ import org.eclipse.papyrusrt.umlrt.tooling.ui.internal.modelelement.NullReferenc
import org.eclipse.papyrusrt.umlrt.tooling.ui.widgets.CapsulePartTypeValueFactory;
import org.eclipse.papyrusrt.umlrt.tooling.ui.widgets.PropertyReplicationObservableValue;
import org.eclipse.papyrusrt.umlrt.tooling.ui.widgets.RTPortTypeValueFactory;
-import org.eclipse.papyrusrt.umlrt.uml.UMLRTCapsulePart;
import org.eclipse.papyrusrt.umlrt.uml.UMLRTPort;
import org.eclipse.papyrusrt.umlrt.uml.UMLRTProtocol;
import org.eclipse.uml2.uml.Package;
@@ -274,9 +273,6 @@ public class UMLRTExtModelElement extends UMLModelElement {
if (IRealTimeConstants.PROPERTY_REPLICATION.equals(propertyPath)) {
editable = true;
- } else if (feature == UMLPackage.Literals.NAMED_ELEMENT__NAME) {
- // Cannot redefine the name
- editable = !port.isInherited();
} else if (feature == UMLPackage.Literals.PORT__IS_CONJUGATED) {
if (isSystemProtocol || port.isInherited()) {
// disable if typed with system protocol Bug#483636.
@@ -312,18 +308,7 @@ public class UMLRTExtModelElement extends UMLModelElement {
// Rules defined by the Client
else if (source instanceof Property) {
- UMLRTCapsulePart capsulePart = UMLRTCapsulePart.getInstance((Property) source);
-
- if (capsulePart != null) {
- if (feature == UMLPackage.Literals.NAMED_ELEMENT__NAME) {
- // Cannot redefine the name
- editable = !capsulePart.isInherited();
- } else {
- editable = true;
- }
- } else {
- editable = super.isFeatureEditable(propertyPath);
- }
+ editable = super.isFeatureEditable(propertyPath);
} else if (source instanceof Parameter) {
editable = super.isFeatureEditable(propertyPath);
} else if (source instanceof Package) {
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTFacadeModelElement.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTFacadeModelElement.java
index 87a2a8c7f..4174995fd 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTFacadeModelElement.java
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTFacadeModelElement.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2016 Christian W. Damus and others.
+ * Copyright (c) 2016, 2017 Christian W. Damus and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -70,7 +70,7 @@ public class UMLRTFacadeModelElement extends UMLModelElement {
private static final String IN_OUT = "InOut"; //$NON-NLS-1$
- private UMLRTNamedElement element;
+ UMLRTNamedElement element;
/**
* Initializes me with my {@code source} element.
@@ -246,27 +246,32 @@ public class UMLRTFacadeModelElement extends UMLModelElement {
return result;
}
- // @Override
- // public boolean forceRefresh(String propertyPath) {
- // return true;
- // }
-
@Override
protected boolean isFeatureEditable(String propertyPath) {
- // So far, I only provide editable properties
- return true;
+ boolean result = true;
+
+ switch (propertyPath) {
+ case NAME:
+ // Cannot redefine the name of an inherited element
+ result = !element.isInherited();
+ break;
+ }
+
+ return result;
}
@Override
public boolean getDirectCreation(String propertyPath) {
boolean result;
- EStructuralFeature feature = getFeature(propertyPath);
- if (feature == UMLPackage.Literals.ENCAPSULATED_CLASSIFIER__OWNED_PORT) {
- // It isn't EMF-ishly a containment, but it subsets a containment
+ switch (propertyPath) {
+ case PORT:
+ // EncapsulatedClassifier::ownedPort isn't EMF-ishly a containment, but it subsets a containment
result = true;
- } else {
+ break;
+ default:
result = super.getDirectCreation(propertyPath);
+ break;
}
return result;
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTFacadeModelElementFactory.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTFacadeModelElementFactory.java
index beaecdb62..1d03b99ce 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTFacadeModelElementFactory.java
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTFacadeModelElementFactory.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2016 Christian W. Damus and others.
+ * Copyright (c) 2016, 2017 Christian W. Damus and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -46,4 +46,23 @@ public class UMLRTFacadeModelElementFactory extends UMLModelElementFactory {
return result;
}
+ @Override
+ protected void updateModelElement(UMLModelElement modelElement, Object newSourceElement) {
+ super.updateModelElement(modelElement, newSourceElement);
+
+ EObject eObject = EMFHelper.getEObject(newSourceElement);
+ UMLRTNamedElement element = null;
+ if (eObject instanceof NamedElement) {
+ element = UMLRTFactory.create((NamedElement) eObject);
+ }
+ if (element == null) {
+ throw new IllegalArgumentException("Cannot resolve UMLRTNamedElement selection: " + newSourceElement);
+ }
+
+ updateFacadeModelElement((UMLRTFacadeModelElement) modelElement, element);
+ }
+
+ public static void updateFacadeModelElement(UMLRTFacadeModelElement modelElement, UMLRTNamedElement newElement) {
+ modelElement.element = newElement;
+ }
}
diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/RTKindEnumPropertyEditor.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/RTKindEnumPropertyEditor.java
index 8c69f0cce..be3d52358 100644
--- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/RTKindEnumPropertyEditor.java
+++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/RTKindEnumPropertyEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014, 2016 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2014, 2017 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -13,9 +13,7 @@
*****************************************************************************/
package org.eclipse.papyrusrt.umlrt.tooling.ui.widgets;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.papyrus.infra.properties.ui.modelelement.ModelElement;
import org.eclipse.papyrus.infra.properties.ui.widgets.AbstractPropertyEditor;
import org.eclipse.papyrus.uml.properties.modelelement.UMLModelElement;
@@ -35,8 +33,6 @@ public class RTKindEnumPropertyEditor extends AbstractPropertyEditor {
protected int numColumns = -1;
- protected Method isEditableMethod;
-
protected Class<? extends Enum<?>> enumType;
/**
@@ -62,29 +58,7 @@ public class RTKindEnumPropertyEditor extends AbstractPropertyEditor {
}
public Class<? extends Enum<?>> getEnumType() {
- return (enumType == null) ? null : enumType;
- }
-
- public void setUtilsClass(Class<?> utilsClass) {
- for (Method next : utilsClass.getDeclaredMethods()) {
- if (next.getName().equals("isKindEditable")
- && Modifier.isStatic(next.getModifiers())
- && (next.getParameterTypes().length == 2)
- && next.getParameterTypes()[1].isEnum()) {
-
- isEditableMethod = next;
-
- if ((input != null) && (propertyPath != null)) {
- // Read-only states may have changed
- applyReadOnly(readOnly);
- }
- break;
- }
- }
- }
-
- public Class<?> getUtilsClass() {
- return (isEditableMethod == null) ? null : isEditableMethod.getDeclaringClass();
+ return enumType;
}
/**
@@ -123,12 +97,11 @@ public class RTKindEnumPropertyEditor extends AbstractPropertyEditor {
protected boolean isKindEditable(Element element, Enum<?> enumValue) {
boolean result = true;
- if (isEditableMethod != null) {
- try {
- result = (Boolean) isEditableMethod.invoke(null, element, enumValue);
- } catch (Exception e) {
- Activator.log.error("Failed to determine validity of enum value; probable properties view configuration fault", e); //$NON-NLS-1$
- }
+ try {
+ IStatus status = getValidator().validate(enumValue);
+ result = (status == null) || (status.getSeverity() < IStatus.ERROR);
+ } catch (Exception e) {
+ Activator.log.error("Failed to determine validity of enum value; probable properties view configuration fault", e); //$NON-NLS-1$
}
return result;
diff --git a/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/resource/modelelement/model.uml b/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/resource/modelelement/model.uml
index 4677a75f4..91868e8f8 100644
--- a/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/resource/modelelement/model.uml
+++ b/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/resource/modelelement/model.uml
@@ -132,16 +132,26 @@
</packagedElement>
<packagedElement xmi:type="uml:Package" xmi:id="_CVjz8ID7EeaFAPnQW2yTGQ" name="Protocol2">
<packagedElement xmi:type="uml:Collaboration" xmi:id="_CRiPkID7EeaFAPnQW2yTGQ" name="Protocol2">
+ <generalization xmi:id="_5-xl4NgzEeabDsC0rhZnQA" general="_5K7XsJTqEeW50dEfV7kAUw"/>
<interfaceRealization xmi:id="_CV5yMID7EeaFAPnQW2yTGQ" client="_CRiPkID7EeaFAPnQW2yTGQ" supplier="_CV2H0ID7EeaFAPnQW2yTGQ" contract="_CV2H0ID7EeaFAPnQW2yTGQ"/>
<interfaceRealization xmi:id="_CWDjMID7EeaFAPnQW2yTGQ" client="_CRiPkID7EeaFAPnQW2yTGQ" supplier="_CWAf4ID7EeaFAPnQW2yTGQ" contract="_CWAf4ID7EeaFAPnQW2yTGQ"/>
</packagedElement>
- <packagedElement xmi:type="uml:Interface" xmi:id="_CV2H0ID7EeaFAPnQW2yTGQ" name="Protocol2"/>
- <packagedElement xmi:type="uml:Interface" xmi:id="_CV8OcID7EeaFAPnQW2yTGQ" name="Protocol2~"/>
+ <packagedElement xmi:type="uml:Interface" xmi:id="_CV2H0ID7EeaFAPnQW2yTGQ" name="Protocol2">
+ <generalization xmi:id="_8OLcsNgzEeabDsC0rhZnQA" general="_5LIMAJTqEeW50dEfV7kAUw"/>
+ </packagedElement>
+ <packagedElement xmi:type="uml:Interface" xmi:id="_CV8OcID7EeaFAPnQW2yTGQ" name="Protocol2~">
+ <generalization xmi:id="_9zcxYNgzEeabDsC0rhZnQA" general="_5LcVEJTqEeW50dEfV7kAUw"/>
+ </packagedElement>
<packagedElement xmi:type="uml:Usage" xmi:id="_CV_RwID7EeaFAPnQW2yTGQ" client="_CRiPkID7EeaFAPnQW2yTGQ" supplier="_CV8OcID7EeaFAPnQW2yTGQ"/>
<packagedElement xmi:type="uml:AnyReceiveEvent" xmi:id="_CV_40ID7EeaFAPnQW2yTGQ" name="*"/>
- <packagedElement xmi:type="uml:Interface" xmi:id="_CWAf4ID7EeaFAPnQW2yTGQ" name="Protocol2IO"/>
+ <packagedElement xmi:type="uml:Interface" xmi:id="_CWAf4ID7EeaFAPnQW2yTGQ" name="Protocol2IO">
+ <generalization xmi:id="__jOs8NgzEeabDsC0rhZnQA" general="_5LmtIJTqEeW50dEfV7kAUw"/>
+ </packagedElement>
<packagedElement xmi:type="uml:Usage" xmi:id="_CWFYYID7EeaFAPnQW2yTGQ" client="_CRiPkID7EeaFAPnQW2yTGQ" supplier="_CWAf4ID7EeaFAPnQW2yTGQ"/>
</packagedElement>
+ <packagedElement xmi:type="uml:Class" xmi:id="_yTzeQNgzEeabDsC0rhZnQA" name="Subcapsule">
+ <generalization xmi:id="_0pJlANgzEeabDsC0rhZnQA" general="_uujC8JTrEeW50dEfV7kAUw"/>
+ </packagedElement>
<profileApplication xmi:id="_0paUUJTqEeW50dEfV7kAUw">
<eAnnotations xmi:id="_0pcwkJTqEeW50dEfV7kAUw" source="http://www.eclipse.org/uml2/2.0.0/UML">
<references xmi:type="ecore:EPackage" href="http://www.eclipse.org/papyrus/umlrt#/"/>
@@ -201,4 +211,5 @@
<UMLRTStateMachines:RTRegion xmi:id="_3qClALAkEeaAyq05NkOz7g" base_Region="_3p8eYLAkEeaAyq05NkOz7g"/>
<UMLRTStateMachines:RTPseudostate xmi:id="_3qLu8LAkEeaAyq05NkOz7g" base_Pseudostate="_3qHdgLAkEeaAyq05NkOz7g"/>
<UMLRTStateMachines:RTState xmi:id="_5XXCcLAkEeaAyq05NkOz7g" base_State="_5XT_ILAkEeaAyq05NkOz7g"/>
+ <UMLRealTime:Capsule xmi:id="_3ukd0NgzEeabDsC0rhZnQA" base_Class="_yTzeQNgzEeabDsC0rhZnQA"/>
</xmi:XMI>
diff --git a/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/src/org/eclipse/papyrusrt/umlrt/tooling/ui/tests/modelelement/ModelElementTest.java b/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/src/org/eclipse/papyrusrt/umlrt/tooling/ui/tests/modelelement/ModelElementTest.java
index 78c7a1a30..fbe2aa990 100644
--- a/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/src/org/eclipse/papyrusrt/umlrt/tooling/ui/tests/modelelement/ModelElementTest.java
+++ b/tests/junit/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui.tests/src/org/eclipse/papyrusrt/umlrt/tooling/ui/tests/modelelement/ModelElementTest.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014, 2016 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2014, 2017 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -14,6 +14,9 @@
*****************************************************************************/
package org.eclipse.papyrusrt.umlrt.tooling.ui.tests.modelelement;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.eclipse.papyrusrt.junit.matchers.StatusMatchers.hasSeverity;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.instanceOf;
@@ -23,19 +26,26 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
import java.util.Collection;
+import java.util.Objects;
import java.util.Optional;
+import java.util.stream.Stream;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.papyrus.infra.properties.ui.modelelement.ModelElement;
import org.eclipse.papyrus.infra.widgets.util.IPapyrusConverter;
import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest;
+import org.eclipse.papyrus.junit.utils.rules.AnnotationRule;
import org.eclipse.papyrus.junit.utils.rules.ModelSetFixture;
import org.eclipse.papyrus.junit.utils.rules.PluginResource;
import org.eclipse.papyrusrt.junit.rules.ElementTypesRule;
@@ -46,11 +56,11 @@ import org.eclipse.papyrusrt.umlrt.core.utils.IRealTimeConstants;
import org.eclipse.papyrusrt.umlrt.core.utils.ProtocolUtils;
import org.eclipse.papyrusrt.umlrt.core.utils.RTPortKindEnum;
import org.eclipse.papyrusrt.umlrt.core.utils.RTPortUtils;
+import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.UMLRealTimePackage;
import org.eclipse.papyrusrt.umlrt.tooling.ui.modelelement.RTStereotypeModelElement;
import org.eclipse.papyrusrt.umlrt.tooling.ui.modelelement.UMLRTExtModelElement;
import org.eclipse.papyrusrt.umlrt.tooling.ui.modelelement.UMLRTFacadeModelElement;
import org.eclipse.papyrusrt.umlrt.uml.UMLRTCapsulePart;
-import org.eclipse.papyrusrt.umlrt.uml.UMLRTClassifier;
import org.eclipse.papyrusrt.umlrt.uml.UMLRTFactory;
import org.eclipse.papyrusrt.umlrt.uml.UMLRTNamedElement;
import org.eclipse.papyrusrt.umlrt.uml.UMLRTPort;
@@ -66,6 +76,7 @@ import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.StateMachine;
import org.eclipse.uml2.uml.Transition;
import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.util.UMLUtil;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.ClassRule;
@@ -82,6 +93,7 @@ public class ModelElementTest extends AbstractPapyrusTest {
protected static Class capsule;
protected static Class connectedCapsule;
protected static Class libraryCapsule;
+ protected static Class subcapsule;
protected static Port capsule_externalBehavior;
protected static Port capsule_internalBehavior;
@@ -112,6 +124,10 @@ public class ModelElementTest extends AbstractPapyrusTest {
protected static Port libraryCapsule_legacySpp;
protected static Collaboration protocol1;
+ protected static Collaboration protocol2;
+ protected static Interface protocol2In;
+ protected static Interface protocol2Out;
+ protected static Interface protocol2InOut;
protected static Interface protocol1In;
protected static Interface protocol1Out;
protected static Interface protocol1InOut;
@@ -153,6 +169,9 @@ public class ModelElementTest extends AbstractPapyrusTest {
protected static final String TRANSITION_KIND_MESSAGE = "Kind must be enabled";
@ClassRule
+ public static final TestRule elementTypes = new ElementTypesRule();
+
+ @ClassRule
public final static ModelSetFixture modelSetFixture = new UMLRTModelSetFixture();
// Some of the observables tested herein are exercised and, therefore, must
@@ -160,9 +179,8 @@ public class ModelElementTest extends AbstractPapyrusTest {
@Rule
public final TestRule uiThread = new UIThreadRule(true);
- @ClassRule
- public static final TestRule elementTypes = new ElementTypesRule();
-
+ @Rule
+ public final AnnotationRule<ModelElementKind> modelElementKind = AnnotationRule.create(ModelElementFactory.class, ModelElementKind.UML);
@BeforeClass
public static void initModelElements() throws Exception {
@@ -173,6 +191,8 @@ public class ModelElementTest extends AbstractPapyrusTest {
Assert.assertNotNull(connectedCapsule);
libraryCapsule = (Class) modelSetFixture.getModel().getMember("LibraryCapsule");
Assert.assertNotNull(libraryCapsule);
+ subcapsule = (Class) modelSetFixture.getModel().getMember("Subcapsule");
+ Assert.assertNotNull(subcapsule);
// ports
capsule_externalBehavior = capsule.getOwnedPort("externalBehavior", null);
@@ -234,6 +254,9 @@ public class ModelElementTest extends AbstractPapyrusTest {
protocol1 = (Collaboration) modelSetFixture.getModel().getNestedPackage("Protocol1")
.getOwnedType("Protocol1", false, UMLPackage.Literals.COLLABORATION, false);
assertThat("Protocol1 not found in test model", protocol1, notNullValue());
+ protocol2 = (Collaboration) modelSetFixture.getModel().getNestedPackage("Protocol2")
+ .getOwnedType("Protocol2", false, UMLPackage.Literals.COLLABORATION, false);
+ assertThat("Protocol2 not found in test model", protocol2, notNullValue());
protocol1In = ProtocolUtils.getMessageSetIn(protocol1);
assertThat("Protocol1 IN message-set not found in test model", protocol1In, notNullValue());
greetIn = protocol1In.getOperation("greet", null, null);
@@ -246,6 +269,12 @@ public class ModelElementTest extends AbstractPapyrusTest {
assertThat("Protocol1 INOUT message-set not found in test model", protocol1InOut, notNullValue());
exchangeInOut = protocol1InOut.getOperation("exchange", null, null);
assertThat("Protocol1 INOUT message 'exchange' not found in test model", exchangeInOut, notNullValue());
+ protocol2In = ProtocolUtils.getMessageSetIn(protocol2);
+ assertThat("Protocol2 IN message-set not found in test model", protocol2In, notNullValue());
+ protocol2Out = ProtocolUtils.getMessageSetOut(protocol2);
+ assertThat("Protocol2 OUT message-set not found in test model", protocol2Out, notNullValue());
+ protocol2InOut = ProtocolUtils.getMessageSetInOut(protocol2);
+ assertThat("Protocol2 INOUT message-set not found in test model", protocol2InOut, notNullValue());
statemachine = (StateMachine) capsule.getOwnedBehaviors().get(0);
Assert.assertNotNull(statemachine);
@@ -722,27 +751,85 @@ public class ModelElementTest extends AbstractPapyrusTest {
}
@UIThread
+ @ModelElementFactory(ModelElementKind.FACADE)
@Test
public void capsuleNameProperty() {
assertNameProperty(capsule);
}
+ @ModelElementFactory(ModelElementKind.FACADE)
@Test
public void capsuleNameValidation() {
assertNameValidation(capsule, "ConnectedCapsule");
}
+ @ModelElementFactory(ModelElementKind.FACADE)
+ @Test
+ public void capsuleNameEditable() {
+ assertNameEditable(capsule, true);
+ assertNameEditable(subcapsule, true);
+ }
+
+ @ModelElementFactory(ModelElementKind.FACADE)
+ @Test
+ public void portNameEditable() {
+ assertNameEditable(connectedCapsule_externalBehavior, true);
+ }
+
+ @ModelElementFactory(ModelElementKind.FACADE)
+ @Test
+ public void inheritedPortNameNotEditable() {
+ assertNameEditable(subcapsule.getMember(connectedCapsule_externalBehavior.getName()), false);
+ }
+
+ @ModelElementFactory(ModelElementKind.FACADE)
+ @Test
+ public void capsulePartNameEditable() {
+ assertNameEditable(connectedCapsule_capsule, true);
+ }
+
+ @ModelElementFactory(ModelElementKind.FACADE)
+ @Test
+ public void inheritedCapsulePartNameNotEditable() {
+ assertNameEditable(subcapsule.getMember(connectedCapsule_capsule.getName()), false);
+ }
+
+ @ModelElementFactory(ModelElementKind.FACADE)
@UIThread
@Test
public void protocolNameProperty() {
assertNameProperty(protocol1);
}
+ @ModelElementFactory(ModelElementKind.FACADE)
@Test
public void protocolNameValidation() {
assertNameValidation(protocol1, "Protocol2");
}
+ @ModelElementFactory(ModelElementKind.FACADE)
+ @Test
+ public void protocolNameEditable() {
+ assertNameEditable(protocol1, true);
+ assertNameEditable(protocol2, true);
+ }
+
+ @ModelElementFactory(ModelElementKind.FACADE)
+ @Test
+ public void protocolMessageNameEditable() {
+ assertNameEditable(greetIn, true);
+ assertNameEditable(replyOut, true);
+ assertNameEditable(exchangeInOut, true);
+ }
+
+ @ModelElementFactory(ModelElementKind.FACADE)
+ @Test
+ public void inheritedProtocolMessageNameNotEditable() {
+ assertNameEditable(protocol2In.getMember(greetIn.getName()), false);
+ assertNameEditable(protocol2Out.getMember(replyOut.getName()), false);
+ assertNameEditable(protocol2InOut.getMember(exchangeInOut.getName()), false);
+ }
+
@UIThread
@Test
public void protocolMessageParameterNameProperty() {
@@ -775,6 +862,7 @@ public class ModelElementTest extends AbstractPapyrusTest {
}
@UIThread
+ @ModelElementFactory(ModelElementKind.FACADE)
@Test
public void capsulePortsProperty() {
ModelElement modelElement = modelElement(capsule);
@@ -784,6 +872,7 @@ public class ModelElementTest extends AbstractPapyrusTest {
}
@UIThread
+ @ModelElementFactory(ModelElementKind.FACADE)
@Test
public void capsuleCapsulePartsProperty() {
ModelElement modelElement = modelElement(connectedCapsule);
@@ -793,6 +882,7 @@ public class ModelElementTest extends AbstractPapyrusTest {
}
@UIThread
+ @ModelElementFactory(ModelElementKind.FACADE)
@Test
public void protocolInMessagesProperty() {
ModelElement modelElement = modelElement(protocol1);
@@ -802,6 +892,7 @@ public class ModelElementTest extends AbstractPapyrusTest {
}
@UIThread
+ @ModelElementFactory(ModelElementKind.FACADE)
@Test
public void protocolOutMessagesProperty() {
ModelElement modelElement = modelElement(protocol1);
@@ -811,6 +902,7 @@ public class ModelElementTest extends AbstractPapyrusTest {
}
@UIThread
+ @ModelElementFactory(ModelElementKind.FACADE)
@Test
public void protocolInOutMessagesProperty() {
ModelElement modelElement = modelElement(protocol1);
@@ -849,14 +941,37 @@ public class ModelElementTest extends AbstractPapyrusTest {
assertThat("No error on blank name", validator.validate(" "), hasSeverity(IStatus.ERROR));
}
+ void assertNameEditable(NamedElement element, boolean expected) {
+ ModelElement modelElement = modelElement(element);
+ assertThat("Incorrect editability of name", modelElement.isEditable("name"), is(expected));
+ }
+
ModelElement modelElement(NamedElement element) {
ModelElement result;
- UMLRTNamedElement facade = UMLRTFactory.create(element);
- if (facade instanceof UMLRTClassifier) {
- result = new UMLRTFacadeModelElement(facade);
- } else {
+ switch (modelElementKind.get()) {
+ case UML:
result = new UMLRTExtModelElement(element, modelSetFixture.getEditingDomain());
+ break;
+ case PROFILE:
+ @SuppressWarnings("unchecked")
+ RTStereotypeModelElement stereotype = Stream.of(UMLRealTimePackage.Literals.CAPSULE, UMLRealTimePackage.Literals.PROTOCOL,
+ UMLRealTimePackage.Literals.RT_PORT, UMLRealTimePackage.Literals.CAPSULE_PART,
+ UMLRealTimePackage.Literals.RT_CONNECTOR,
+ UMLRealTimePackage.Literals.RT_MESSAGE_SET, UMLRealTimePackage.Literals.PROTOCOL_CONTAINER)
+ .map(eclass -> UMLUtil.getStereotypeApplication(element, (java.lang.Class<? extends EObject>) eclass.getInstanceClass()))
+ .filter(Objects::nonNull)
+ .map(appl -> new RTStereotypeModelElement(appl, UMLUtil.getStereotype(appl), modelSetFixture.getEditingDomain()))
+ .findAny()
+ .orElseThrow(() -> new AssertionError("No UML-RT stereotype applied to " + element));
+ result = stereotype;
+ break;
+ case FACADE:
+ result = new UMLRTFacadeModelElement(UMLRTFactory.create(element));
+ break;
+ default:
+ fail("Invalid model element kind: " + modelElementKind.get());
+ throw new Error(); // Make the compiler happy
}
return result;
@@ -873,4 +988,31 @@ public class ModelElementTest extends AbstractPapyrusTest {
return find(collection, type, name)
.orElseThrow(() -> new AssertionError(String.format("%s not found: %s", type.getSimpleName(), name)));
}
+
+ //
+ // Nested types
+ //
+
+ /**
+ * Enumeration of the kinds of model elements covered by this test suite.
+ */
+ public static enum ModelElementKind {
+ /** The normal UML-ish model element. */
+ UML,
+ /** A model element for the stereotype application from the UML-RT profile, specifically. */
+ PROFILE,
+ /** The model element for the UML-RT façades. */
+ FACADE;
+ }
+
+ /**
+ * Annotates tests to indicate the kind of model element to create.
+ * The default is the normal UML-ish model element.
+ */
+ @Retention(RUNTIME)
+ @Target({ TYPE, METHOD })
+ public static @interface ModelElementFactory {
+ ModelElementKind value() default ModelElementKind.UML;
+ }
+
}

Back to the top