Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-06-29 08:19:05 +0000
committercletavernie2012-06-29 08:19:05 +0000
commit07de3953701d29a105312dbcde5064c258a63fe8 (patch)
tree886c967ade6d769103b28128b006797d473d6e64
parentb3fc0265ac0f30659e12144d71e42159c12a203c (diff)
downloadorg.eclipse.papyrus-07de3953701d29a105312dbcde5064c258a63fe8.tar.gz
org.eclipse.papyrus-07de3953701d29a105312dbcde5064c258a63fe8.tar.xz
org.eclipse.papyrus-07de3953701d29a105312dbcde5064c258a63fe8.zip
269494: Manage application of stereotype properties as other element in the diagram
https://bugs.eclipse.org/bugs/show_bug.cgi?id=269494 Improve the label of the AppliedStereotypeProperty in the properties view
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/infra/gmfdiag/widgets/editors/ColorPickerEditor.java3
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF1
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/providers/AppliedStereotypePropertyLabelProvider.java62
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/plugin.xml4
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/AppliedStereotypePropertyFilteredLabelProvider.java47
5 files changed, 116 insertions, 1 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/infra/gmfdiag/widgets/editors/ColorPickerEditor.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/infra/gmfdiag/widgets/editors/ColorPickerEditor.java
index 96631ce2265..d209d44d2ba 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/infra/gmfdiag/widgets/editors/ColorPickerEditor.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.widgets/src/org/eclipse/papyrus/infra/gmfdiag/widgets/editors/ColorPickerEditor.java
@@ -183,11 +183,12 @@ public class ColorPickerEditor extends AbstractValueEditor implements IChangeLis
@Override
public void setReadOnly(boolean readOnly) {
+ colorPicker.setEnabled(false);
}
@Override
public boolean isReadOnly() {
- return false;
+ return colorPicker.isEnabled();
}
@Override
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF
index 4b2981e1b40..f31baec7d7c 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF
+++ b/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF
@@ -13,6 +13,7 @@ Export-Package: org.eclipse.papyrus.uml.profile,
org.eclipse.papyrus.uml.profile.constraints,
org.eclipse.papyrus.uml.profile.definition,
org.eclipse.papyrus.uml.profile.preference,
+ org.eclipse.papyrus.uml.profile.providers,
org.eclipse.papyrus.uml.profile.structure,
org.eclipse.papyrus.uml.profile.tree,
org.eclipse.papyrus.uml.profile.tree.objects,
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/providers/AppliedStereotypePropertyLabelProvider.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/providers/AppliedStereotypePropertyLabelProvider.java
new file mode 100644
index 00000000000..7213dec6608
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/providers/AppliedStereotypePropertyLabelProvider.java
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.profile.providers;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.papyrus.uml.profile.structure.AppliedStereotypeProperty;
+import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+
+public class AppliedStereotypePropertyLabelProvider extends UMLLabelProvider {
+
+ @Override
+ public String getText(Object element) {
+ AppliedStereotypeProperty stereotypeProperty = resolveAppliedStereotypeProperty(element);
+ if(stereotypeProperty != null) {
+ return super.getText(stereotypeProperty.getStereotypeProperty());
+ }
+
+ return super.getText(element);
+ }
+
+
+ @Override
+ public Image getImage(Object element) {
+ AppliedStereotypeProperty stereotypeProperty = resolveAppliedStereotypeProperty(element);
+ if(stereotypeProperty != null) {
+ return super.getImage(stereotypeProperty.getStereotypeProperty());
+ }
+
+ return super.getImage(element);
+ }
+
+
+ /**
+ * Tries to adapt the given element to an AppliedStereotypeProperty, and returns it
+ *
+ * @param element
+ * @return
+ * The adapted AppliedStereotypeProperty, or null
+ */
+ protected AppliedStereotypeProperty resolveAppliedStereotypeProperty(Object element) {
+ if(element instanceof AppliedStereotypeProperty) {
+ return (AppliedStereotypeProperty)element;
+ }
+
+ if(element instanceof IAdaptable) {
+ return (AppliedStereotypeProperty)((IAdaptable)element).getAdapter(AppliedStereotypeProperty.class);
+ }
+
+ return null;
+ }
+}
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/plugin.xml b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/plugin.xml
index 02e46b63930..b0f766ae991 100644
--- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/plugin.xml
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/plugin.xml
@@ -55,6 +55,10 @@
labelProvider="org.eclipse.papyrus.uml.properties.providers.UMLFilteredLabelProvider"
priority="50">
</labelProvider>
+ <labelProvider
+ labelProvider="org.eclipse.papyrus.uml.properties.providers.AppliedStereotypePropertyFilteredLabelProvider"
+ priority="45">
+ </labelProvider>
</extension>
<extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/AppliedStereotypePropertyFilteredLabelProvider.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/AppliedStereotypePropertyFilteredLabelProvider.java
new file mode 100644
index 00000000000..947e65e6b43
--- /dev/null
+++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/providers/AppliedStereotypePropertyFilteredLabelProvider.java
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.properties.providers;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.widgets.providers.IFilteredLabelProvider;
+import org.eclipse.papyrus.uml.profile.providers.AppliedStereotypePropertyLabelProvider;
+
+
+public class AppliedStereotypePropertyFilteredLabelProvider extends AppliedStereotypePropertyLabelProvider implements IFilteredLabelProvider {
+
+ public boolean accept(Object element) {
+ if(element instanceof IStructuredSelection) {
+ return accept((IStructuredSelection)element);
+ }
+
+ return resolveAppliedStereotypeProperty(element) != null;
+ }
+
+ public boolean accept(IStructuredSelection selection) {
+ if(selection.isEmpty()) {
+ return false;
+ }
+
+ Iterator<?> iterator = selection.iterator();
+ while(iterator.hasNext()) {
+ Object element = iterator.next();
+ if(!accept(element)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+}

Back to the top