Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-09-05 21:08:19 +0000
committerCamille Letavernier2014-09-08 13:13:55 +0000
commit8f326427a8dca490bebf6ff96010ff36fe9ed1b8 (patch)
treeef94b568ab61f7b3f7695fd3a6c592d2e8d6b668 /plugins/infra
parentc53e3dfd6cc0e8a03c5e435dad88bcc1fba58f2c (diff)
downloadorg.eclipse.papyrus-8f326427a8dca490bebf6ff96010ff36fe9ed1b8.tar.gz
org.eclipse.papyrus-8f326427a8dca490bebf6ff96010ff36fe9ed1b8.tar.xz
org.eclipse.papyrus-8f326427a8dca490bebf6ff96010ff36fe9ed1b8.zip
441227: [Properties view] Create New Property view tabs not working
https://bugs.eclipse.org/bugs/show_bug.cgi?id=441227 It is not currently feasible to apply stereotypes to elements that are new and not yet attached to the model. So, define a new properties-view constraint to test for the selection being attached to a resource and constrain the SingleElement section of the Profile tab accordingly. In testing, an NPE was encountered when a disposed Stereotype Applications table responded to changes in the stereotypes applied to an element in the dialog. That is fixed by detecting the disposed widget and removing the callback. Change-Id: I5116c00a881306cffd086c6c5fce0ad35733aaff
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.constraints/Model/ConstraintEnvironment.xmi32
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/AttachedToResourceConstraint.java56
2 files changed, 81 insertions, 7 deletions
diff --git a/plugins/infra/org.eclipse.papyrus.infra.constraints/Model/ConstraintEnvironment.xmi b/plugins/infra/org.eclipse.papyrus.infra.constraints/Model/ConstraintEnvironment.xmi
index ad420a9045d..652e46f32b6 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.constraints/Model/ConstraintEnvironment.xmi
+++ b/plugins/infra/org.eclipse.papyrus.infra.constraints/Model/ConstraintEnvironment.xmi
@@ -1,9 +1,27 @@
<?xml version="1.0" encoding="ASCII"?>
-<environment:ConstraintEnvironment xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:environment="http://www.eclipse.org/papyrus/constraints/environment/0.9">
- <constraintTypes label="EMF Instance Of" constraintClass="org.eclipse.papyrus.infra.constraints.constraints.EMFInstanceOfConstraint"/>
- <constraintTypes label="True constraint" constraintClass="org.eclipse.papyrus.infra.constraints.constraints.TrueConstraint"/>
- <constraintTypes label="EMF Query" constraintClass="org.eclipse.papyrus.infra.constraints.constraints.EMFQueryConstraint"/>
- <constraintTypes label="Java Instance Of" constraintClass="org.eclipse.papyrus.infra.constraints.constraints.JavaInstanceOf"/>
- <constraintTypes label="Java Query" constraintClass="org.eclipse.papyrus.infra.constraints.constraints.JavaQueryConstraint"/>
- <constraintTypes label="Has EAnnotation" constraintClass="org.eclipse.papyrus.infra.constraints.constraints.HasEAnnotationConstraint"/>
+<environment:ConstraintEnvironment
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:environment="http://www.eclipse.org/papyrus/constraints/environment/0.9">
+ <constraintTypes
+ label="EMF Instance Of"
+ constraintClass="org.eclipse.papyrus.infra.constraints.constraints.EMFInstanceOfConstraint"/>
+ <constraintTypes
+ label="True constraint"
+ constraintClass="org.eclipse.papyrus.infra.constraints.constraints.TrueConstraint"/>
+ <constraintTypes
+ label="EMF Query"
+ constraintClass="org.eclipse.papyrus.infra.constraints.constraints.EMFQueryConstraint"/>
+ <constraintTypes
+ label="Java Instance Of"
+ constraintClass="org.eclipse.papyrus.infra.constraints.constraints.JavaInstanceOf"/>
+ <constraintTypes
+ label="Java Query"
+ constraintClass="org.eclipse.papyrus.infra.constraints.constraints.JavaQueryConstraint"/>
+ <constraintTypes
+ label="Has EAnnotation"
+ constraintClass="org.eclipse.papyrus.infra.constraints.constraints.HasEAnnotationConstraint"/>
+ <constraintTypes
+ label="Attached to Resource"
+ constraintClass="org.eclipse.papyrus.infra.constraints.constraints.AttachedToResourceConstraint"/>
</environment:ConstraintEnvironment>
diff --git a/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/AttachedToResourceConstraint.java b/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/AttachedToResourceConstraint.java
new file mode 100644
index 00000000000..5859aac77fd
--- /dev/null
+++ b/plugins/infra/org.eclipse.papyrus.infra.constraints/src/org/eclipse/papyrus/infra/constraints/constraints/AttachedToResourceConstraint.java
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST 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
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.constraints.constraints;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+
+/**
+ * A properties view constraint that matches objects that are attached to some resource.
+ */
+public class AttachedToResourceConstraint extends AbstractConstraint {
+
+ /**
+ * Initializes me.
+ */
+ public AttachedToResourceConstraint() {
+ super();
+ }
+
+ @Override
+ protected boolean match(Object selection) {
+ boolean result = false;
+
+ EObject object = EMFHelper.getEObject(selection);
+
+ if (object != null) {
+ result = object.eResource() != null;
+ }
+
+ return result;
+ }
+
+ @Override
+ protected boolean equivalent(Constraint constraint) {
+ if (this == constraint) {
+ return true;
+ }
+ return constraint instanceof AttachedToResourceConstraint;
+ }
+
+ @Override
+ public String toString() {
+ return "AttachedToResourceConstraint"; //$NON-NLS-1$
+ }
+}

Back to the top