Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2015-02-11 12:18:45 -0500
committerNicolas FAUVERGUE2015-02-11 12:18:45 -0500
commitc89fa60d018cc673e324c6de0c7f3cf8c6927d25 (patch)
treecbd700ba74a5f35bdfc86e3a05b6ff23eeaff33d
parent113be48f219a313ac655768867cfc2c83b7db86f (diff)
downloadorg.eclipse.papyrus-c89fa60d018cc673e324c6de0c7f3cf8c6927d25.tar.gz
org.eclipse.papyrus-c89fa60d018cc673e324c6de0c7f3cf8c6927d25.tar.xz
org.eclipse.papyrus-c89fa60d018cc673e324c6de0c7f3cf8c6927d25.zip
458260: [Table 2] Formatting of typed elements in 'reference' cells
https://bugs.eclipse.org/bugs/show_bug.cgi?id=458260 Change-Id: Ie36dd81e8e5b61dbbb7a6ff329a5a3be7da330ed Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF110
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/GenericCellLabelProvider.java243
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/UMLTypedElementCellLabelProvider.java40
3 files changed, 247 insertions, 146 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 3adf716cb33..0df810bd327 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,55 +1,55 @@
-Manifest-Version: 1.0
-Require-Bundle: org.eclipse.papyrus.infra.widgets;bundle-version="1.0.2",
- 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.0.2",
- org.eclipse.swt,
- org.eclipse.papyrus.infra.emf;bundle-version="1.0.2",
- org.eclipse.papyrus.infra.core;bundle-version="1.0.2",
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.2",
- org.eclipse.papyrus.infra.nattable.model;bundle-version="1.0.2",
- org.eclipse.papyrus.infra.tools;bundle-version="1.0.2",
- org.eclipse.emf.edit.ui,
- org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.2",
- org.eclipse.nebula.widgets.nattable.core;bundle-version="[1.1.0,
- 2.0.0)",
- org.eclipse.core.expressions,
- org.eclipse.papyrus.infra.services.edit;bundle-version="1.0.2",
- org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="1.0.2",
- org.apache.commons.lang,
- com.google.guava;bundle-version="11.0.0",
- org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.0.2",
- org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="1.0.2"
-Export-Package: org.eclipse.papyrus.infra.nattable,
- org.eclipse.papyrus.infra.nattable.celleditor,
- org.eclipse.papyrus.infra.nattable.celleditor.config,
- org.eclipse.papyrus.infra.nattable.command,
- org.eclipse.papyrus.infra.nattable.configuration,
- org.eclipse.papyrus.infra.nattable.dataprovider,
- org.eclipse.papyrus.infra.nattable.handler,
- org.eclipse.papyrus.infra.nattable.layerstack,
- org.eclipse.papyrus.infra.nattable.listener,
- 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.paste,
- org.eclipse.papyrus.infra.nattable.preferences,
- org.eclipse.papyrus.infra.nattable.provider,
- org.eclipse.papyrus.infra.nattable.reorder,
- org.eclipse.papyrus.infra.nattable.tester,
- org.eclipse.papyrus.infra.nattable.utils,
- org.eclipse.papyrus.infra.nattable.widget
-Bundle-Vendor: %Bundle-Vendor
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.0.2.qualifier
-Bundle-Name: %Bundle-Name
-Bundle-ManifestVersion: 2
-Bundle-Activator: org.eclipse.papyrus.infra.nattable.Activator
-Bundle-SymbolicName: org.eclipse.papyrus.infra.nattable;singleton:=true
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.papyrus.infra.widgets;bundle-version="1.0.2",
+ 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.0.2",
+ org.eclipse.swt,
+ org.eclipse.papyrus.infra.emf;bundle-version="1.0.2",
+ org.eclipse.papyrus.infra.core;bundle-version="1.0.2",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.2",
+ org.eclipse.papyrus.infra.nattable.model;bundle-version="1.0.2",
+ org.eclipse.papyrus.infra.tools;bundle-version="1.0.2",
+ org.eclipse.emf.edit.ui,
+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.2",
+ org.eclipse.nebula.widgets.nattable.core;bundle-version="[1.1.0,2.0.0)",
+ org.eclipse.core.expressions,
+ org.eclipse.papyrus.infra.services.edit;bundle-version="1.0.2",
+ org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="1.0.2",
+ org.apache.commons.lang,
+ com.google.guava;bundle-version="11.0.0",
+ org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.0.2",
+ org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="1.0.2",
+ org.eclipse.uml2.uml;bundle-version="5.0.1"
+Export-Package: org.eclipse.papyrus.infra.nattable,
+ org.eclipse.papyrus.infra.nattable.celleditor,
+ org.eclipse.papyrus.infra.nattable.celleditor.config,
+ org.eclipse.papyrus.infra.nattable.command,
+ org.eclipse.papyrus.infra.nattable.configuration,
+ org.eclipse.papyrus.infra.nattable.dataprovider,
+ org.eclipse.papyrus.infra.nattable.handler,
+ org.eclipse.papyrus.infra.nattable.layerstack,
+ org.eclipse.papyrus.infra.nattable.listener,
+ 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.paste,
+ org.eclipse.papyrus.infra.nattable.preferences,
+ org.eclipse.papyrus.infra.nattable.provider,
+ org.eclipse.papyrus.infra.nattable.reorder,
+ org.eclipse.papyrus.infra.nattable.tester,
+ org.eclipse.papyrus.infra.nattable.utils,
+ org.eclipse.papyrus.infra.nattable.widget
+Bundle-Vendor: %Bundle-Vendor
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 1.0.2.qualifier
+Bundle-Name: %Bundle-Name
+Bundle-ManifestVersion: 2
+Bundle-Activator: org.eclipse.papyrus.infra.nattable.Activator
+Bundle-SymbolicName: org.eclipse.papyrus.infra.nattable;singleton:=true
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
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..76dcb74290b 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);
+ }
+} \ No newline at end of file
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);
+ }
+
+}

Back to the top