diff options
author | Nicolas FAUVERGUE | 2015-02-20 10:49:46 +0000 |
---|---|---|
committer | Nicolas FAUVERGUE | 2015-02-20 10:49:46 +0000 |
commit | 568f62cac13d9b4eecf5508171dc0e8ae4ccd491 (patch) | |
tree | eb55eb8675340ded433c9d87f03931d53746973d | |
parent | 868221f36466e44f61af60d32eaa141058617367 (diff) | |
download | org.eclipse.papyrus-568f62cac13d9b4eecf5508171dc0e8ae4ccd491.tar.gz org.eclipse.papyrus-568f62cac13d9b4eecf5508171dc0e8ae4ccd491.tar.xz org.eclipse.papyrus-568f62cac13d9b4eecf5508171dc0e8ae4ccd491.zip |
458260: [Table 2] Formatting of typed elements in 'reference' cells
https://bugs.eclipse.org/bugs/show_bug.cgi?id=458260
Change-Id: I40af26099cbcb05202fa4e653353640423444fc6
Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
3 files changed, 272 insertions, 170 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF index 19c6bb9099f..6965b33e8bf 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF @@ -1,79 +1,80 @@ -Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.infra.nattable,
- org.eclipse.papyrus.infra.nattable.accumulator,
- org.eclipse.papyrus.infra.nattable.advice,
- org.eclipse.papyrus.infra.nattable.celleditor,
- org.eclipse.papyrus.infra.nattable.celleditor.config,
- org.eclipse.papyrus.infra.nattable.command,
- org.eclipse.papyrus.infra.nattable.comparator,
- org.eclipse.papyrus.infra.nattable.configuration,
- org.eclipse.papyrus.infra.nattable.converter,
- org.eclipse.papyrus.infra.nattable.copy,
- org.eclipse.papyrus.infra.nattable.dataprovider,
- org.eclipse.papyrus.infra.nattable.dialog,
- org.eclipse.papyrus.infra.nattable.display.converter,
- org.eclipse.papyrus.infra.nattable.export,
- org.eclipse.papyrus.infra.nattable.filter,
- org.eclipse.papyrus.infra.nattable.filter.configuration,
- org.eclipse.papyrus.infra.nattable.filter.validator,
- org.eclipse.papyrus.infra.nattable.formatter,
- org.eclipse.papyrus.infra.nattable.handler,
- org.eclipse.papyrus.infra.nattable.helper.advice,
- org.eclipse.papyrus.infra.nattable.layer,
- org.eclipse.papyrus.infra.nattable.layerstack,
- org.eclipse.papyrus.infra.nattable.listener,
- org.eclipse.papyrus.infra.nattable.manager,
- org.eclipse.papyrus.infra.nattable.manager.axis,
- org.eclipse.papyrus.infra.nattable.manager.cell,
- org.eclipse.papyrus.infra.nattable.manager.table,
- org.eclipse.papyrus.infra.nattable.messages,
- org.eclipse.papyrus.infra.nattable.nattableconfiguration,
- org.eclipse.papyrus.infra.nattable.painter,
- org.eclipse.papyrus.infra.nattable.parsers,
- org.eclipse.papyrus.infra.nattable.paste,
- org.eclipse.papyrus.infra.nattable.preferences,
- org.eclipse.papyrus.infra.nattable.provider,
- org.eclipse.papyrus.infra.nattable.reorder,
- org.eclipse.papyrus.infra.nattable.selection,
- org.eclipse.papyrus.infra.nattable.sort,
- org.eclipse.papyrus.infra.nattable.tester,
- org.eclipse.papyrus.infra.nattable.tree,
- org.eclipse.papyrus.infra.nattable.utils,
- org.eclipse.papyrus.infra.nattable.widget,
- org.eclipse.papyrus.infra.nattable.wizard,
- org.eclipse.papyrus.infra.nattable.wizard.pages
-Require-Bundle: org.eclipse.papyrus.infra.widgets;bundle-version="1.1.0",
- org.eclipse.core.runtime,
- org.eclipse.emf.transaction,
- org.eclipse.emf.ecore,
- org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.7.0",
- org.eclipse.emf.edit,
- org.eclipse.papyrus.infra.core.log;bundle-version="1.1.0",
- org.eclipse.swt,
- org.eclipse.papyrus.infra.emf;bundle-version="1.1.0",
- org.eclipse.papyrus.infra.core;bundle-version="1.1.0",
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.1.0",
- org.eclipse.papyrus.infra.nattable.model;bundle-version="1.1.0",
- org.eclipse.papyrus.infra.tools;bundle-version="1.1.0",
- org.eclipse.emf.edit.ui,
- org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.1.0",
- org.eclipse.nebula.widgets.nattable.core;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.core.expressions,
- org.eclipse.papyrus.infra.services.edit;bundle-version="1.1.0",
- org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="1.1.0",
- com.google.guava;bundle-version="11.0.0",
- org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.1.0",
- org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="1.1.0",
- org.eclipse.nebula.widgets.nattable.extension.glazedlists;bundle-version="[1.2.0,2.0.0)",
- ca.odell.glazedlists;bundle-version="1.9.0",
- org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.1.0"
-Bundle-Vendor: %Bundle-Vendor
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.1.0.qualifier
-Bundle-Name: %Bundle-Name
-Bundle-Activator: org.eclipse.papyrus.infra.nattable.Activator
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.infra.nattable;singleton:=tru
- e
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Bundle-Description: %pluginDescription
+Manifest-Version: 1.0 +Export-Package: org.eclipse.papyrus.infra.nattable, + org.eclipse.papyrus.infra.nattable.accumulator, + org.eclipse.papyrus.infra.nattable.advice, + org.eclipse.papyrus.infra.nattable.celleditor, + org.eclipse.papyrus.infra.nattable.celleditor.config, + org.eclipse.papyrus.infra.nattable.command, + org.eclipse.papyrus.infra.nattable.comparator, + org.eclipse.papyrus.infra.nattable.configuration, + org.eclipse.papyrus.infra.nattable.converter, + org.eclipse.papyrus.infra.nattable.copy, + org.eclipse.papyrus.infra.nattable.dataprovider, + org.eclipse.papyrus.infra.nattable.dialog, + org.eclipse.papyrus.infra.nattable.display.converter, + org.eclipse.papyrus.infra.nattable.export, + org.eclipse.papyrus.infra.nattable.filter, + org.eclipse.papyrus.infra.nattable.filter.configuration, + org.eclipse.papyrus.infra.nattable.filter.validator, + org.eclipse.papyrus.infra.nattable.formatter, + org.eclipse.papyrus.infra.nattable.handler, + org.eclipse.papyrus.infra.nattable.helper.advice, + org.eclipse.papyrus.infra.nattable.layer, + org.eclipse.papyrus.infra.nattable.layerstack, + org.eclipse.papyrus.infra.nattable.listener, + org.eclipse.papyrus.infra.nattable.manager, + org.eclipse.papyrus.infra.nattable.manager.axis, + org.eclipse.papyrus.infra.nattable.manager.cell, + org.eclipse.papyrus.infra.nattable.manager.table, + org.eclipse.papyrus.infra.nattable.messages, + org.eclipse.papyrus.infra.nattable.nattableconfiguration, + org.eclipse.papyrus.infra.nattable.painter, + org.eclipse.papyrus.infra.nattable.parsers, + org.eclipse.papyrus.infra.nattable.paste, + org.eclipse.papyrus.infra.nattable.preferences, + org.eclipse.papyrus.infra.nattable.provider, + org.eclipse.papyrus.infra.nattable.reorder, + org.eclipse.papyrus.infra.nattable.selection, + org.eclipse.papyrus.infra.nattable.sort, + org.eclipse.papyrus.infra.nattable.tester, + org.eclipse.papyrus.infra.nattable.tree, + org.eclipse.papyrus.infra.nattable.utils, + org.eclipse.papyrus.infra.nattable.widget, + org.eclipse.papyrus.infra.nattable.wizard, + org.eclipse.papyrus.infra.nattable.wizard.pages +Require-Bundle: org.eclipse.papyrus.infra.widgets;bundle-version="1.1.0", + org.eclipse.core.runtime, + org.eclipse.emf.transaction, + org.eclipse.emf.ecore, + org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.7.0", + org.eclipse.emf.edit, + org.eclipse.papyrus.infra.core.log;bundle-version="1.1.0", + org.eclipse.swt, + org.eclipse.papyrus.infra.emf;bundle-version="1.1.0", + org.eclipse.papyrus.infra.core;bundle-version="1.1.0", + org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.1.0", + org.eclipse.papyrus.infra.nattable.model;bundle-version="1.1.0", + org.eclipse.papyrus.infra.tools;bundle-version="1.1.0", + org.eclipse.emf.edit.ui, + org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.1.0", + org.eclipse.nebula.widgets.nattable.core;bundle-version="[1.2.0,2.0.0)", + org.eclipse.core.expressions, + org.eclipse.papyrus.infra.services.edit;bundle-version="1.1.0", + org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="1.1.0", + com.google.guava;bundle-version="11.0.0", + org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.1.0", + org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="1.1.0", + org.eclipse.nebula.widgets.nattable.extension.glazedlists;bundle-version="[1.2.0,2.0.0)", + ca.odell.glazedlists;bundle-version="1.9.0", + org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.1.0", + org.eclipse.uml2.uml +Bundle-Vendor: %Bundle-Vendor +Bundle-ActivationPolicy: lazy +Bundle-Version: 1.1.0.qualifier +Bundle-Name: %Bundle-Name +Bundle-Activator: org.eclipse.papyrus.infra.nattable.Activator +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: org.eclipse.papyrus.infra.nattable;singleton:=tru + e +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-Description: %pluginDescription diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/GenericCellLabelProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/GenericCellLabelProvider.java index dc0ec6f15fd..0263be3a8d7 100644 --- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/GenericCellLabelProvider.java +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/GenericCellLabelProvider.java @@ -1,91 +1,152 @@ -/*****************************************************************************
- * Copyright (c) 2013 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.nattable.provider;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
-import org.eclipse.papyrus.infra.nattable.utils.Constants;
-import org.eclipse.papyrus.infra.nattable.utils.ILabelProviderCellContextElementWrapper;
-import org.eclipse.papyrus.infra.nattable.utils.ILabelProviderContextElementWrapper;
-import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
-
-/**
- * The generic label provider for the cells
- *
- * @author Vincent Lorenzo
- *
- */
-public class GenericCellLabelProvider extends AbstractNattableCellLabelProvider {
-
- /**
- * Limit the number of displayed elements for collections
- */
- public static final int MAX_DISPLAYED_ELEMENTS = 10;
-
- /**
- *
- * @see org.eclipse.papyrus.infra.nattable.provider.AbstractNattableCellLabelProvider#accept(java.lang.Object)
- *
- * @param element
- * @return
- * <code>true</code> if the element is an instance of {@link ILabelProviderContextElementWrapper} and if the cell represents an {@link EStructuralFeature} of an {@link EObject}
- */
- @Override
- public boolean accept(Object element) {
- return element instanceof ILabelProviderCellContextElementWrapper;
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.nattable.provider.AbstractNattableCellLabelProvider#getText(java.lang.Object)
- *
- * @param element
- * @return
- */
- @Override
- public String getText(Object element) {
- final ILabelProviderCellContextElementWrapper contextElement = (ILabelProviderCellContextElementWrapper) element;
- final IConfigRegistry registry = ((ILabelProviderContextElementWrapper) element).getConfigRegistry();
- Object value = contextElement.getObject();
- final StringBuffer label = new StringBuffer();
- final LabelProviderService service = getLabelProviderService(registry);
- if (value instanceof Collection<?>) {
- Iterator<?> iter = ((Collection<?>) value).iterator();
- label.append(Constants.BEGIN_OF_COLLECTION);
- int i = 1;
- while (iter.hasNext()) {
- if (i > MAX_DISPLAYED_ELEMENTS) {
- label.append(Constants.BIG_COLLECTION);
- break;
- }
-
- Object current = iter.next();
- label.append(service.getLabelProvider(current).getText(current));
- if (iter.hasNext()) {
- label.append(Constants.SEPARATOR);
- }
- i++;
- }
-
- label.append(Constants.END_OF_COLLECTION);
- } else {
- label.append(service.getLabelProvider(value).getText(value));
- }
- return label.toString();
- }
-}
+/***************************************************************************** + * Copyright (c) 2013 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: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 458260 + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.nattable.provider; + +import java.util.Collection; +import java.util.Iterator; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; +import org.eclipse.papyrus.infra.nattable.utils.Constants; +import org.eclipse.papyrus.infra.nattable.utils.ILabelProviderCellContextElementWrapper; +import org.eclipse.papyrus.infra.nattable.utils.ILabelProviderContextElementWrapper; +import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService; + +/** + * The generic label provider for the cells + * + * @author Vincent Lorenzo + * + */ +public class GenericCellLabelProvider extends AbstractNattableCellLabelProvider { + + /** + * Limit the number of displayed elements for collections + */ + public static final int MAX_DISPLAYED_ELEMENTS = 10; + + /** + * + * @see org.eclipse.papyrus.infra.nattable.provider.AbstractNattableCellLabelProvider#accept(java.lang.Object) + * + * @param element + * @return + * <code>true</code> if the element is an instance of {@link ILabelProviderContextElementWrapper} and if the cell represents an {@link EStructuralFeature} of an {@link EObject} + */ + @Override + public boolean accept(Object element) { + return element instanceof ILabelProviderCellContextElementWrapper; + } + + /** + * + * @see org.eclipse.papyrus.infra.nattable.provider.AbstractNattableCellLabelProvider#getText(java.lang.Object) + * + * @param element + * @return + */ + @Override + public String getText(Object element) { + final ILabelProviderCellContextElementWrapper contextElement = (ILabelProviderCellContextElementWrapper) element; + final IConfigRegistry registry = ((ILabelProviderContextElementWrapper) element).getConfigRegistry(); + final Object value = contextElement.getObject(); + final LabelProviderService service = getLabelProviderService(registry); + return getText(service, value); + } + + /** + * Get the text for the value. + * + * @param service The label provider service. + * @param value The value to parse. + * @return The string representing the object. + */ + protected String getText(LabelProviderService service, Object value){ + final StringBuffer label = new StringBuffer(); + if (value instanceof Collection<?>) { + label.append(getCollectionText(service, (Collection<?>)value)); + } else { + label.append(service.getLabelProvider(value).getText(value)); + } + return label.toString(); + } + + /** + * This allow to manage if the hooks of collection will be displayed or not. + * + * @return <code>false</code> + */ + private boolean isDisplayCollectionHooks(){ + // This allow to manage if the hooks of collection will be displayed or not + // This will be managed by preference later + return false; + } + + /** + * This allow to manage if the big collection display will be added. + * + * @return <code>false</code> + */ + private boolean isDisplayBigCollection(){ + // This allow to manage if the big collection display will be added or not + // This will be managed by preference later + return false; + } + + /** + * Get the text for the collection object. + * + * @param service The label provider service. + * @param value The value to parse. + * @return The string representing the object. + */ + protected String getCollectionText(LabelProviderService service, Collection<?> value){ + final StringBuffer label = new StringBuffer(); + Iterator<?> iter = ((Collection<?>) value).iterator(); + if(isDisplayCollectionHooks()) + label.append(Constants.BEGIN_OF_COLLECTION); + int i = 1; + while (iter.hasNext()) { + if (i > MAX_DISPLAYED_ELEMENTS) { + if(isDisplayBigCollection()) + label.append(Constants.BIG_COLLECTION); + break; + } + + Object current = iter.next(); + label.append(getElementText(service, current)); + if (iter.hasNext()) { + label.append(Constants.SEPARATOR); + } + i++; + } + + if(isDisplayCollectionHooks()) + label.append(Constants.END_OF_COLLECTION); + return label.toString(); + } + + /** + * Get the text for the element. + * + * @param service The label provider service. + * @param value The value to parse. + * @return The string representing the object. + */ + protected String getElementText(LabelProviderService service, Object value){ + return service.getLabelProvider(value).getText(value); + } +} diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/UMLTypedElementCellLabelProvider.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/UMLTypedElementCellLabelProvider.java new file mode 100644 index 00000000000..0e297a26e2a --- /dev/null +++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/UMLTypedElementCellLabelProvider.java @@ -0,0 +1,40 @@ +/***************************************************************************** + * Copyright (c) 2015 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: + * Nicolas FAUVERGUE - Initial API and implementation & Bug 458260 + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.nattable.provider; + +import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService; +import org.eclipse.uml2.uml.TypedElement; + +/** + * The cell label provider for the UML typed elements. + * + * @author Nicolas FAUVERGUE + */ +public class UMLTypedElementCellLabelProvider extends GenericCellLabelProvider{ + + /** + * @see org.eclipse.papyrus.infra.nattable.provider.GenericCellLabelProvider#getSingleText(org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService, java.lang.Object) + * + * Manage the typed element. + * {@inheritDoc} + */ + @Override + protected String getElementText(LabelProviderService service, Object value){ + if(value instanceof TypedElement){ + return ((TypedElement) value).getName(); + } + return super.getElementText(service, value); + } + +} |