Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeremie.tatibouet2019-10-23 10:46:05 -0400
committervincent lorenzo2019-10-28 04:42:03 -0400
commite6fc91b261a298add9a5a2bef7577a14f8189920 (patch)
tree636ee5d469a34fd3468c78768b8eb3e99132b705 /plugins/uml
parentcce96d31c17230de99b785889cbf470d06ad24d4 (diff)
downloadorg.eclipse.papyrus-e6fc91b261a298add9a5a2bef7577a14f8189920.tar.gz
org.eclipse.papyrus-e6fc91b261a298add9a5a2bef7577a14f8189920.tar.xz
org.eclipse.papyrus-e6fc91b261a298add9a5a2bef7577a14f8189920.zip
Bug 552355: architecture context related views
Change-Id: I16fb1d02a874cda0e13e2f470b26b244beca45c3 Signed-off-by: jeremie.tatibouet <jeremie.tatibouet@cea.fr>
Diffstat (limited to 'plugins/uml')
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF5
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/Environment.xmi3
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml2
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/constraints/IsValidArchitectureContext.java91
4 files changed, 98 insertions, 3 deletions
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
index 2d5bfdf62c0..a2145a130c0 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF
@@ -38,10 +38,11 @@ Require-Bundle: org.eclipse.papyrus.uml.profile;bundle-version="[3.0.0,4.0.0)";v
org.eclipse.papyrus.uml.internationalization.utils;bundle-version="[1.0.0,2.0.0)",
org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)",
org.eclipse.papyrus.uml.tools;bundle-version="[4.0.0,5.0.0)",
- org.eclipse.papyrus.uml.types.core;bundle-version="[4.0.0,5.0.0)"
+ org.eclipse.papyrus.uml.types.core;bundle-version="[4.0.0,5.0.0)",
+ org.eclipse.papyrus.infra.architecture;bundle-version="[2.0.0,3.0.0)"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.papyrus.uml.properties.constraints"
-Bundle-Version: 3.4.100.qualifier
+Bundle-Version: 3.5.0.qualifier
Bundle-Name: %pluginName
Bundle-Localization: plugin
Bundle-Activator: org.eclipse.papyrus.uml.properties.Activator
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/Environment.xmi b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/Environment.xmi
index abb51dbf026..b5db4b6a198 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/Environment.xmi
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/Environment.xmi
@@ -18,6 +18,9 @@
<constraintTypes
label="Is Profile Applied"
constraintClass="org.eclipse.papyrus.uml.properties.constraints.IsProfileAppliedConstraint"/>
+ <constraintTypes
+ label="Is Valid Architecture Context"
+ constraintClass="org.eclipse.papyrus.uml.properties.constraints.IsValidArchitectureContext"/>
<modelElementFactories
name="UML Specific Factory"
factoryClass="org.eclipse.papyrus.uml.properties.modelelement.UMLEditorFactory"/>
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml
index fae7a8f754d..2b71f0e47ef 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml
@@ -8,6 +8,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.properties</artifactId>
- <version>3.4.100-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/constraints/IsValidArchitectureContext.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/constraints/IsValidArchitectureContext.java
new file mode 100644
index 00000000000..03731883a90
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/constraints/IsValidArchitectureContext.java
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * Copyright (c) 2019 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Jeremie TATIBOUET (CEA LIST) <jeremie.tatibouet@cea.fr>
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.properties.constraints;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.papyrus.infra.architecture.ArchitectureDescriptionUtils;
+import org.eclipse.papyrus.infra.constraints.SimpleConstraint;
+import org.eclipse.papyrus.infra.constraints.constraints.AbstractConstraint;
+import org.eclipse.papyrus.infra.constraints.constraints.Constraint;
+import org.eclipse.papyrus.infra.core.architecture.merged.MergedArchitectureContext;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.emf.edit.domain.PapyrusTransactionalEditingDomain;
+import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * @since 3.5
+ */
+public class IsValidArchitectureContext extends AbstractConstraint {
+
+ private final static String ARCHITECTURE_CONTEXT_PROPERTY_NAME = "architectureContext"; //$NON-NLS-1$
+
+ /**
+ * Architecture context ID in which this constraint returns true
+ */
+ protected String expectedArchitectureContextId;
+
+ /**
+ * @see org.eclipse.papyrus.infra.constraints.constraints.AbstractConstraint#setDescriptor(org.eclipse.papyrus.infra.constraints.SimpleConstraint)
+ *
+ * Read the value defined for the property ARCHITECTURE_CONTEXT_PROPERTY_NAME
+ */
+ @Override
+ protected void setDescriptor(SimpleConstraint descriptor) {
+ expectedArchitectureContextId = getValue(ARCHITECTURE_CONTEXT_PROPERTY_NAME);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.constraints.constraints.AbstractConstraint#match(java.lang.Object)
+ *
+ * If the selection is a UML element and the edition occurs in the expected architecture
+ * context then return true; false otherwise.
+ */
+ @Override
+ protected boolean match(Object selection) {
+ boolean match = false;
+ Element element = UMLUtil.resolveUMLElement(selection);
+ if (element != null) {
+ EditingDomain domain = UMLUtil.resolveEditingDomain(element);
+ if (domain instanceof PapyrusTransactionalEditingDomain) {
+ ArchitectureDescriptionUtils adUtils = new ArchitectureDescriptionUtils(
+ (ModelSet) ((PapyrusTransactionalEditingDomain) domain).getResourceSet());
+ MergedArchitectureContext architectureContext = adUtils.getArchitectureContext();
+ if (architectureContext != null) {
+ match = architectureContext.getId().equals(expectedArchitectureContextId);
+ }
+ }
+ }
+ return match;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.constraints.constraints.AbstractConstraint#equivalent(org.eclipse.papyrus.infra.constraints.constraints.Constraint)
+ *
+ * Two constraints can only be equivalent if (1) they designate the same object or (2) they are different object of the same type with equal values for their properties
+ */
+ @Override
+ protected boolean equivalent(Constraint constraint) {
+ boolean equivalent = this == constraint;
+ if (!equivalent) {
+ if (constraint != null && constraint instanceof IsValidArchitectureContext) {
+ equivalent = expectedArchitectureContextId.equals(((IsValidArchitectureContext) constraint).expectedArchitectureContextId);
+ }
+ }
+ return equivalent;
+ }
+
+}

Back to the top