Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Gabel2016-07-07 03:58:06 -0400
committerBenoit Maggi2016-07-19 04:13:51 -0400
commit0d658d357627ad0c0e7b3267f76c8d20a38c7caa (patch)
tree9c290dd5b78beca921d2d6092fa2c3cd2e24907a /plugins/sysml
parent8aaf7228249a0b62841ded51dbffbf0a90124542 (diff)
downloadorg.eclipse.papyrus-0d658d357627ad0c0e7b3267f76c8d20a38c7caa.tar.gz
org.eclipse.papyrus-0d658d357627ad0c0e7b3267f76c8d20a38c7caa.tar.xz
org.eclipse.papyrus-0d658d357627ad0c0e7b3267f76c8d20a38c7caa.zip
Bug 497455: [SysML] Matchers improvements for Property sub-classes
Change-Id: Ic2f165489d00629be061c483b9ed9fc0fcb46422 Signed-off-by: Sebastien Gabel <sebastien.gabel@esterel-technologies.com>
Diffstat (limited to 'plugins/sysml')
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConstraintPropertyMatcher.java80
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPropertyMatcher.java80
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/PartPropertyMatcher.java101
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ReferencePropertyMatcher.java101
4 files changed, 196 insertions, 166 deletions
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConstraintPropertyMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConstraintPropertyMatcher.java
index 676cc0ed6b0..df073aa055e 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConstraintPropertyMatcher.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ConstraintPropertyMatcher.java
@@ -1,36 +1,44 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- *****************************************************************************/
-package org.eclipse.papyrus.sysml.service.types.matcher;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
-import org.eclipse.papyrus.sysml.constraints.ConstraintProperty;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.util.UMLUtil;
-
-/**
- * Test if current {@link Property} is a {@link ConstraintProperty}
- */
-public class ConstraintPropertyMatcher implements IElementMatcher {
-
- public boolean matches(EObject eObject) {
-
- boolean isMatch = false;
- if (eObject instanceof Property) {
-
- Property element = (Property) eObject;
- if (UMLUtil.getStereotypeApplication(element, ConstraintProperty.class) != null) {
- isMatch = true;
- }
- }
- return isMatch;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2010, 2016 CEA LIST, Esterel technologies SAS and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ * Alain Le Guennec (Esterel technologies SAS) - Bug 497455
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.service.types.matcher;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
+import org.eclipse.papyrus.sysml.constraints.ConstraintProperty;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+/**
+ * Test if current {@link Property} is a {@link ConstraintProperty}
+ */
+public class ConstraintPropertyMatcher implements IElementMatcher {
+
+ public boolean matches(EObject eObject) {
+
+ boolean isMatch = false;
+ if (eObject instanceof Property) {
+
+ Property element = (Property) eObject;
+ Type type = element.getType();
+ // A ConstraintProperty is necessarily typed by a ConstraintBlock which must be a Class.
+ if (type instanceof Class && UMLUtil.getStereotypeApplication(element, ConstraintProperty.class) != null) {
+ isMatch = true;
+ }
+ }
+ return isMatch;
+ }
+
+}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPropertyMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPropertyMatcher.java
index 38c9ff296e5..d275b7603f3 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPropertyMatcher.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/FlowPropertyMatcher.java
@@ -1,36 +1,44 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- *****************************************************************************/
-package org.eclipse.papyrus.sysml.service.types.matcher;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
-import org.eclipse.papyrus.sysml.portandflows.FlowProperty;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.util.UMLUtil;
-
-/**
- * Test if current {@link Property} is a {@link FlowProperty}
- */
-public class FlowPropertyMatcher implements IElementMatcher {
-
- public boolean matches(EObject eObject) {
-
- boolean isFlowProperty = false;
- if (eObject instanceof Property) {
-
- Property element = (Property) eObject;
- if (UMLUtil.getStereotypeApplication(element, FlowProperty.class) != null) {
- isFlowProperty = true;
- }
- }
- return isFlowProperty;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2010, 2016 CEA LIST, Esterel technologies SAS and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ * Alain Le Guennec (Esterel technologies SAS) - Bug 497455
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.service.types.matcher;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
+import org.eclipse.papyrus.sysml.portandflows.FlowProperty;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Interface;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+/**
+ * Test if current {@link Property} is a {@link FlowProperty}
+ */
+public class FlowPropertyMatcher implements IElementMatcher {
+
+ public boolean matches(EObject eObject) {
+
+ boolean isFlowProperty = false;
+ if (eObject instanceof Property) {
+
+ Property element = (Property) eObject;
+ Element owner = (Element) element.eContainer();
+ if ((owner == null || owner instanceof Interface || owner instanceof Class) && UMLUtil.getStereotypeApplication(element, FlowProperty.class) != null) {
+ isFlowProperty = true;
+ }
+ }
+ return isFlowProperty;
+ }
+
+}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/PartPropertyMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/PartPropertyMatcher.java
index b0828daa4bf..b5c8fcd79ea 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/PartPropertyMatcher.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/PartPropertyMatcher.java
@@ -1,47 +1,54 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- *****************************************************************************/
-package org.eclipse.papyrus.sysml.service.types.matcher;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
-import org.eclipse.papyrus.sysml.blocks.Block;
-import org.eclipse.uml2.uml.AggregationKind;
-import org.eclipse.uml2.uml.Port;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.util.UMLUtil;
-
-/**
- * Test if current {@link Property} is a {@link Block} Part
- */
-public class PartPropertyMatcher implements IElementMatcher {
-
- /**
- * {@inheritDoc}
- */
- public boolean matches(EObject eObject) {
-
- boolean isMatch = false;
- if ((eObject instanceof Property) && !(eObject instanceof Port)) {
-
- Property element = (Property) eObject;
-
- // The property is necessary a composition and has a type
- if ((element.getType() != null) && (element.getAggregation() == AggregationKind.COMPOSITE_LITERAL)) {
-
- // Moreover its type has to be a Block
- if (UMLUtil.getStereotypeApplication(element.getType(), Block.class) != null) {
- isMatch = true;
- }
- }
- }
- return isMatch;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2010, 2016 CEA LIST, Esterel technologies SAS and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ * Alain Le Guennec (Esterel technologies SAS) - Bug 497455
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.service.types.matcher;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
+import org.eclipse.papyrus.sysml.blocks.Block;
+import org.eclipse.uml2.uml.AggregationKind;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+/**
+ * Test if current {@link Property} is a {@link Block} Part
+ */
+public class PartPropertyMatcher implements IElementMatcher {
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches(EObject eObject) {
+
+ boolean isMatch = false;
+ if ((eObject instanceof Property) && !(eObject instanceof Port)) {
+
+ Property element = (Property) eObject;
+
+ // The property is necessary a composition and has a type
+ Type type = element.getType();
+ if ((type != null) && (element.getAggregation() == AggregationKind.COMPOSITE_LITERAL)) {
+
+ // Moreover its type has to be a Block
+ if (type instanceof Class && UMLUtil.getStereotypeApplication(type, Block.class) != null) {
+ isMatch = true;
+ }
+ }
+ }
+ return isMatch;
+ }
+
+}
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ReferencePropertyMatcher.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ReferencePropertyMatcher.java
index 604574d1a6f..bddd9226b79 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ReferencePropertyMatcher.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/matcher/ReferencePropertyMatcher.java
@@ -1,47 +1,54 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- *****************************************************************************/
-package org.eclipse.papyrus.sysml.service.types.matcher;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
-import org.eclipse.papyrus.sysml.blocks.Block;
-import org.eclipse.uml2.uml.AggregationKind;
-import org.eclipse.uml2.uml.Port;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.util.UMLUtil;
-
-/**
- * Test if current {@link Property} is a {@link Block} Reference
- */
-public class ReferencePropertyMatcher implements IElementMatcher {
-
- /**
- * {@inheritDoc}
- */
- public boolean matches(EObject eObject) {
-
- boolean isMatch = false;
- if ((eObject instanceof Property) && !(eObject instanceof Port)) {
-
- Property element = (Property) eObject;
-
- // The property is not a composition and has a type
- if ((element.getType() != null) && (element.getAggregation() != AggregationKind.COMPOSITE_LITERAL)) {
-
- // Moreover its type has to be a Block
- if (UMLUtil.getStereotypeApplication(element.getType(), Block.class) != null) {
- isMatch = true;
- }
- }
- }
- return isMatch;
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2010, 2016 CEA LIST, Esterel technologies SAS and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ * Alain Le Guennec (Esterel technologies SAS) - Bug 497455
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.sysml.service.types.matcher;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.emf.type.core.IElementMatcher;
+import org.eclipse.papyrus.sysml.blocks.Block;
+import org.eclipse.uml2.uml.AggregationKind;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Port;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+/**
+ * Test if current {@link Property} is a {@link Block} Reference
+ */
+public class ReferencePropertyMatcher implements IElementMatcher {
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean matches(EObject eObject) {
+
+ boolean isMatch = false;
+ if ((eObject instanceof Property) && !(eObject instanceof Port)) {
+
+ Property element = (Property) eObject;
+
+ // The property is not a composition and has a type
+ Type type = element.getType();
+ if ((type != null) && (element.getAggregation() != AggregationKind.COMPOSITE_LITERAL)) {
+
+ // Moreover its type has to be a Block
+ if (type instanceof Class && UMLUtil.getStereotypeApplication(type, Block.class) != null) {
+ isMatch = true;
+ }
+ }
+ }
+ return isMatch;
+ }
+
+}

Back to the top