diff options
author | Christian W. Damus | 2016-02-26 22:53:17 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-03-02 12:24:34 +0000 |
commit | e9bbbbcbef810b952d2c98caaa18d711eabd3a7f (patch) | |
tree | 01b7698fa73401e9b7e173cfb59b6d67d6f41202 /plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus | |
parent | 387194dfad69c05dae22afe2548109b267091ea1 (diff) | |
download | org.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/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus')
-rw-r--r-- | plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableLabelProvider.java | 112 |
1 files changed, 8 insertions, 104 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableLabelProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableLabelProvider.java index 794a90418a7..f5383eecc89 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableLabelProvider.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/TableLabelProvider.java @@ -1,5 +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
@@ -8,17 +8,16 @@ *
* Contributors:
* Juan Cadavid (CEA LIST) juan.cadavid@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 474467
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.provider;
-import java.util.Collection;
-
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider;
-import org.eclipse.papyrus.infra.ui.emf.providers.EMFLabelProvider;
-import org.eclipse.papyrus.infra.widgets.Activator;
+import org.eclipse.papyrus.infra.viewpoints.policy.ViewPrototypeLabelProvider;
import org.eclipse.swt.graphics.Image;
/**
@@ -26,74 +25,16 @@ import org.eclipse.swt.graphics.Image; * This labelprovider provides icon and text for tables to display them in treeviewer AND in the property view
*
*/
-public class TableLabelProvider extends EMFLabelProvider implements IFilteredLabelProvider {
+public class TableLabelProvider extends ViewPrototypeLabelProvider implements IFilteredLabelProvider {
- /**
- *
- * @see org.eclipse.papyrus.infra.ui.emf.providers.EMFLabelProvider#getText(java.lang.Object)
- *
- * @param table
- * @return
- */
- @Override
- public String getText(Object table) {
- if (table instanceof IStructuredSelection) {
- return super.getText((IStructuredSelection) table);
- }
-
- Object el = EMFHelper.getEObject(table);
-
- if (el instanceof Table) {
- return ((Table) el).getName();
- }
- return ""; //$NON-NLS-1$
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.ui.emf.providers.EMFLabelProvider#getImage(java.lang.Object)
- *
- * @param table
- * @return
- */
- @Override
- public Image getImage(Object table) {
- if (table instanceof IStructuredSelection) {
- return getImage(((IStructuredSelection) table));
- }
-
- table = EMFHelper.getEObject(table);
-
- if (table instanceof Table) {
- final String iconPath = getIcon((Table) table);
- if (iconPath != null) {
- return Activator.getDefault().getImage(iconPath);
- }
- }
- return null;
- }
-
- protected String getIcon(Table table) {
- if (table == null || table.getTableConfiguration() == null || table.getTableConfiguration().getIconPath() == null) {
- return null;
- }
- return table.getTableConfiguration().getIconPath();
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider#accept(java.lang.Object)
- *
- * @param object
- * @return
- */
@Override
public boolean accept(Object object) {
if (object instanceof IStructuredSelection) {
return accept((IStructuredSelection) object);
}
- return EMFHelper.getEObject(object) instanceof Table;
+ boolean result = EMFHelper.getEObject(object) instanceof Table;
+ return result;
}
/**
@@ -101,7 +42,7 @@ public class TableLabelProvider extends EMFLabelProvider implements IFilteredLab * @param selection
* a selection
* @return
- * <code>true</code> if all elements in the selection are accepted
+ * <code>true</code> if all elements in the selection are accepted
*/
protected boolean accept(final IStructuredSelection selection) {
for (final Object current : selection.toList()) {
@@ -112,43 +53,6 @@ public class TableLabelProvider extends EMFLabelProvider implements IFilteredLab return true;
}
- /**
- *
- * @see org.eclipse.papyrus.infra.ui.emf.providers.EMFLabelProvider#hasCommonImage(java.util.Collection)
- *
- * @param objects
- * @return
- * <code>true</code> if all selected table have the same icon
- */
- @Override
- protected boolean hasCommonImage(Collection<?> objects) {
- String iconPath = null;
- for (Object current : objects) {
- if (!(current instanceof Table)) {
- return false;
- }
-
- String icon = getIcon((Table) current);
- if (icon == null && iconPath != null) {
- return false;
- }
-
- if (iconPath == null) {
- iconPath = icon;
- } else if (!iconPath.equals(icon)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.ui.emf.providers.EMFLabelProvider#getNonCommonIcon(java.lang.Object)
- *
- * @param commonObject
- * @return
- */
@Override
protected Image getNonCommonIcon(final Object commonObject) {
return org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(org.eclipse.papyrus.infra.nattable.Activator.PLUGIN_ID, "/icons/table.gif");
|