Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-02-26 22:53:17 +0000
committerGerrit Code Review @ Eclipse.org2016-03-02 12:24:34 +0000
commite9bbbbcbef810b952d2c98caaa18d711eabd3a7f (patch)
tree01b7698fa73401e9b7e173cfb59b6d67d6f41202 /plugins/infra/viewpoints
parent387194dfad69c05dae22afe2548109b267091ea1 (diff)
downloadorg.eclipse.papyrus-e9bbbbcbef810b952d2c98caaa18d711eabd3a7f.tar.gz
org.eclipse.papyrus-e9bbbbcbef810b952d2c98caaa18d711eabd3a7f.tar.xz
org.eclipse.papyrus-e9bbbbcbef810b952d2c98caaa18d711eabd3a7f.zip
Bug 474467: Papyrus editors title do not update when their label change
Add support for propagation of label-provider change events for labels that are dependent on other elements' labels. Implement such a dependent label for all notation views supported by the Viewpoints mechanism that have no names of their own, including * unnamed Diagrams * unnamed Tables Now that the table label provider depends on table prototypes, the broken prototype references in editor reload tests need to be updated (they were missed in the refactoring when all of the prototypes were removed from the builtin Viewpoints configuration model). Change-Id: I8a9c361129c996188f87ac2851db39e0f66f3acd
Diffstat (limited to 'plugins/infra/viewpoints')
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/.classpath16
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/.settings/org.eclipse.jdt.core.prefs6
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/META-INF/MANIFEST.MF5
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/UnavailableViewPrototype.java9
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototype.java18
-rw-r--r--plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototypeLabelProvider.java95
6 files changed, 131 insertions, 18 deletions
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/.classpath b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/.classpath
index ed2585fb3f4..f0c55498599 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/.classpath
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/.classpath
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="src-gen"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="src-gen"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/.settings/org.eclipse.jdt.core.prefs
index 4759947300a..62a08f4494d 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/.settings/org.eclipse.jdt.core.prefs
@@ -1,10 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/META-INF/MANIFEST.MF b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/META-INF/MANIFEST.MF
index 91d463d9a96..f1bbf28c833 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/META-INF/MANIFEST.MF
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/META-INF/MANIFEST.MF
@@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.107.0,4.0.0)";visibility:=reex
org.eclipse.papyrus.infra.viewpoints.iso42010;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.viewpoints.configuration;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.constraints;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.widgets;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.papyrus.infra.widgets;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.papyrus.infra.ui.emf;bundle-version="[1.2.0,2.0.0)"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
@@ -25,4 +26,4 @@ Bundle-Name: %pluginName
Bundle-ManifestVersion: 2
Bundle-Activator: org.eclipse.papyrus.infra.viewpoints.policy.Activator
Bundle-SymbolicName: org.eclipse.papyrus.infra.viewpoints.policy;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/UnavailableViewPrototype.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/UnavailableViewPrototype.java
index 663897e863a..9689ea5ad15 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/UnavailableViewPrototype.java
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/UnavailableViewPrototype.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
+ * Copyright (c) 2013, 2016 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
@@ -9,6 +8,7 @@
*
* Contributors:
* Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 474467
*
*****************************************************************************/
package org.eclipse.papyrus.infra.viewpoints.policy;
@@ -49,6 +49,11 @@ public class UnavailableViewPrototype extends ViewPrototype {
return true;
}
+ @Override
+ public boolean isUnavailable() {
+ return true;
+ }
+
/**
* @see org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototype#getImplementation()
*/
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototype.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototype.java
index 7b4ea6c23ad..e0b95afe2e4 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototype.java
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototype.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
+ * Copyright (c) 2013, 2016 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
@@ -9,6 +8,7 @@
*
* Contributors:
* Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 474467
*
*****************************************************************************/
package org.eclipse.papyrus.infra.viewpoints.policy;
@@ -158,7 +158,7 @@ public abstract class ViewPrototype {
*
* @param view
* The view for which a prototype is expected
- * @return The view's prototype
+ * @return The view's prototype, never {@code null} but possibly {@link #isUnavailable() unavailable}
*/
public static ViewPrototype get(EObject view) {
for (IViewTypeHelper helper : HELPERS) {
@@ -227,6 +227,17 @@ public abstract class ViewPrototype {
}
/**
+ * Queries whether the prototype is unavailable, effectively a <em>Null Object</em>.
+ *
+ * @return whether the prototype is a non-view prototype
+ *
+ * @since 1.2
+ */
+ public boolean isUnavailable() {
+ return false;
+ }
+
+ /**
* Gets the ID of the implementation of this prototype
*
* @return The implementation ID
@@ -419,6 +430,7 @@ public abstract class ViewPrototype {
/**
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
+ @Override
public int compare(ViewPrototype proto1, ViewPrototype proto2) {
Integer p1 = getPriority(proto1);
Integer p2 = getPriority(proto2);
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototypeLabelProvider.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototypeLabelProvider.java
new file mode 100644
index 00000000000..5e71ff35851
--- /dev/null
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/ViewPrototypeLabelProvider.java
@@ -0,0 +1,95 @@
+/*****************************************************************************
+ * Copyright (c) 2012, 2016 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
+ * 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
+ * Christian W. Damus - bug 474467
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.viewpoints.policy;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.infra.ui.emf.providers.DependentEMFLabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * A Label Provider for viewpoint-based notations.
+ *
+ * @since 1.2
+ */
+public class ViewPrototypeLabelProvider extends DependentEMFLabelProvider {
+
+ @Override
+ protected Image getImage(EObject element) {
+ Image result;
+
+ ViewPrototype proto = ViewPrototype.get(element);
+ if (proto != null) {
+ // This is shared by the Widgets plug-in activator, so don't
+ // dispose it
+ result = proto.getIcon();
+ } else {
+ result = super.getImage(element);
+ }
+
+ return result;
+ }
+
+ @Override
+ protected String getText(EObject element) {
+ // Hit the delegate to ensure that the item provider adapter is attached
+ // for notifications
+ String result = super.getText(element);
+
+ ViewPrototype proto = ViewPrototype.get(element);
+ if (!proto.isUnavailable()) {
+ EObject context = proto.getRootOf(element);
+ result = getName(element);
+
+ if ((result != null) && !result.isEmpty()) {
+ if (context != null) {
+ // In case we were deriving a label from it
+ unsubscribe(context, element);
+ }
+ } else {
+ if (context != null) {
+ String contextLabel = getText(context);
+ result = NLS.bind("({0} of {1})", proto.getLabel(), contextLabel);
+
+ // Update when the context's label changes
+ subscribe(context, element);
+ } else {
+ result = NLS.bind("({1})", proto.getLabel());
+ }
+
+ if ((result == null) || result.isEmpty()) {
+ result = "(unnamed)";
+ }
+ }
+ } // else just keep the super result
+
+ return result;
+ }
+
+ /**
+ * Attempts to infer the name of an {@code object} by looking for a string-valued
+ * attribute named "name".
+ *
+ * @param object
+ * an object
+ *
+ * @return a best-effort name for the {@code object}
+ *
+ * @see EMFCoreUtil#getName(EObject)
+ */
+ protected String getName(EObject object) {
+ return EMFCoreUtil.getName(object);
+ }
+}

Back to the top