Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Charles David2016-08-24 09:13:07 +0000
committerPierre-Charles David2016-08-24 09:13:08 +0000
commitba672386055a90c173080f95cd673b28bc8a58dd (patch)
tree5e41b34e862991e2b6a5405a0bcd9288ca243f80
parent76df89effc160d28a2509b6f7da78261cb43b3ab (diff)
downloadorg.eclipse.sirius-b72fdf6376e1e3970b1b95106ae68aeabf06a964.tar.gz
org.eclipse.sirius-b72fdf6376e1e3970b1b95106ae68aeabf06a964.tar.xz
org.eclipse.sirius-b72fdf6376e1e3970b1b95106ae68aeabf06a964.zip
[500105] Use a single generic HierarchyLabelProvider for all VSM elementsv4.0.1
Bug: 500105 Change-Id: I0b53fe5fa13b3323a412ecab018c6380ae5d17f9 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java1
-rw-r--r--plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/properties/sections/common/AbstractEditorDialogPropertySection.java6
-rw-r--r--plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/common/AbstractEditorDialogWithListPropertySection.java7
-rw-r--r--plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/business/internal/dialect/HierarchyLabelTableProvider.java90
-rw-r--r--plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/business/internal/dialect/TableDialectUIServices.java89
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/CustomizationPropertySectionsTests.java53
-rw-r--r--plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/business/internal/dialect/HierarchyLabelTreeProvider.java79
-rw-r--r--plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/business/internal/dialect/TreeDialectUIServices.java15
-rw-r--r--plugins/org.eclipse.sirius.ui/plugin.properties1
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/internal/dialect/HierarchyLabelProvider.java117
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/viewpoint/provider/Messages.java3
11 files changed, 189 insertions, 272 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java
index f0efdbb7d1..ae708496ca 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/business/internal/dialect/DiagramDialectUIServices.java
@@ -103,6 +103,7 @@ import org.eclipse.sirius.ui.business.api.dialect.ExportFormat.ExportDocumentFor
import org.eclipse.sirius.ui.business.api.session.SessionEditorInput;
import org.eclipse.sirius.ui.business.api.viewpoint.ViewpointSelectionCallback;
import org.eclipse.sirius.ui.business.internal.commands.ChangeViewpointSelectionCommand;
+import org.eclipse.sirius.ui.business.internal.dialect.HierarchyLabelProvider;
import org.eclipse.sirius.ui.tools.api.actions.export.SizeTooLargeException;
import org.eclipse.sirius.viewpoint.DRepresentation;
import org.eclipse.sirius.viewpoint.DRepresentationElement;
diff --git a/plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/properties/sections/common/AbstractEditorDialogPropertySection.java b/plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/properties/sections/common/AbstractEditorDialogPropertySection.java
index d8ea2fed9c..3fdf9cc4a2 100644
--- a/plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/properties/sections/common/AbstractEditorDialogPropertySection.java
+++ b/plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/properties/sections/common/AbstractEditorDialogPropertySection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2016 THALES GLOBAL SERVICES.
* 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
@@ -31,7 +31,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.sirius.common.ui.tools.api.dialog.FeatureEditorDialog;
import org.eclipse.sirius.editor.properties.ViewpointPropertySheetPage;
-import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager;
+import org.eclipse.sirius.ui.business.internal.dialect.HierarchyLabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.SelectionAdapter;
@@ -155,7 +155,7 @@ public abstract class AbstractEditorDialogPropertySection extends AbstractViewpo
ILabelProvider labelProvider = propertyDescriptor.getLabelProvider();
// Start of user code getLabelProvider
if (getSelection() instanceof TreeSelection) {
- labelProvider = DialectUIManager.INSTANCE.getHierarchyLabelProvider(labelProvider);
+ labelProvider = new HierarchyLabelProvider(labelProvider);
}
// End of user code getLabelProvider
return labelProvider;
diff --git a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/common/AbstractEditorDialogWithListPropertySection.java b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/common/AbstractEditorDialogWithListPropertySection.java
index a0026515d7..2c68cfd655 100644
--- a/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/common/AbstractEditorDialogWithListPropertySection.java
+++ b/plugins/org.eclipse.sirius.editor/src/org/eclipse/sirius/editor/properties/sections/common/AbstractEditorDialogWithListPropertySection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 - 2010 THALES GLOBAL SERVICES.
+ * Copyright (c) 2007, 2016 THALES GLOBAL SERVICES.
* 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
@@ -26,6 +26,7 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.sirius.common.ui.tools.api.dialog.FeatureEditorDialog;
import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager;
import org.eclipse.sirius.ui.business.api.featureExtensions.FeatureExtensionsUIManager;
+import org.eclipse.sirius.ui.business.internal.dialect.HierarchyLabelProvider;
import org.eclipse.sirius.viewpoint.provider.ViewpointItemProviderAdapterFactory;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -97,7 +98,9 @@ public abstract class AbstractEditorDialogWithListPropertySection extends Abstra
*/
protected ILabelProvider getLabelProvider() {
AdapterFactoryLabelProvider labelProvider = new AdapterFactoryLabelProvider(getAdapterFactory());
- return DialectUIManager.INSTANCE.getHierarchyLabelProvider(labelProvider);
+ // Start of user code getLabelProvider
+ return new HierarchyLabelProvider(labelProvider);
+ // End of user code getLabelProvider
}
/**
diff --git a/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/business/internal/dialect/HierarchyLabelTableProvider.java b/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/business/internal/dialect/HierarchyLabelTableProvider.java
deleted file mode 100644
index 0899736df1..0000000000
--- a/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/business/internal/dialect/HierarchyLabelTableProvider.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2015 THALES GLOBAL SERVICES.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.sirius.table.ui.business.internal.dialect;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.sirius.business.api.query.IdentifiedElementQuery;
-import org.eclipse.sirius.table.metamodel.table.description.TableDescription;
-import org.eclipse.sirius.table.metamodel.table.description.TableMapping;
-import org.eclipse.sirius.table.metamodel.table.description.TableNavigationDescription;
-import org.eclipse.sirius.table.metamodel.table.provider.Messages;
-import org.eclipse.sirius.viewpoint.description.Group;
-import org.eclipse.sirius.viewpoint.description.IdentifiedElement;
-import org.eclipse.sirius.viewpoint.description.RepresentationExtensionDescription;
-import org.eclipse.sirius.viewpoint.description.tool.ToolEntry;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * A label provider for mappings to display their hierarchy.
- *
- * @author jdupont
- */
-public class HierarchyLabelTableProvider extends LabelProvider {
-
- private static final String DELIMITER = " > "; //$NON-NLS-1$
-
- private ILabelProvider wrappedProvider;
-
- /**
- * Create a new instance with wrapped label provider as base type.
- *
- * @param wrappedLabelProvider
- * the wrapped label provider
- */
- public HierarchyLabelTableProvider(final ILabelProvider wrappedLabelProvider) {
- this.wrappedProvider = wrappedLabelProvider;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
- */
- @Override
- public Image getImage(final Object element) {
- return wrappedProvider != null ? wrappedProvider.getImage(element) : super.getImage(element);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
- */
- @Override
- public String getText(final Object element) {
- if (element instanceof TableMapping || element instanceof TableDescription || element instanceof TableNavigationDescription || element instanceof ToolEntry) {
- final IdentifiedElement mapping = (IdentifiedElement) element;
- String text = mapping.getName();
- EObject container = mapping.eContainer();
- while (container != null && !(container instanceof Group)) {
- text = getLabel(container) + DELIMITER + text;
- container = container.eContainer();
- }
- return text;
- }
- return wrappedProvider != null ? wrappedProvider.getText(element) : super.getText(element);
- }
-
- private String getLabel(final EObject eObject) {
-
- String label = null;
-
- if (eObject instanceof IdentifiedElement) {
- label = new IdentifiedElementQuery((IdentifiedElement) eObject).getLabel();
- } else if (eObject instanceof RepresentationExtensionDescription) {
- label = ((RepresentationExtensionDescription) eObject).getName();
- }
- return label != null ? label : Messages.HierarchyLabelTableProvider_elementWithoutName;
- }
-
-}
diff --git a/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/business/internal/dialect/TableDialectUIServices.java b/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/business/internal/dialect/TableDialectUIServices.java
index 2f38a9bc02..dd1dcdba4c 100644
--- a/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/business/internal/dialect/TableDialectUIServices.java
+++ b/plugins/org.eclipse.sirius.table.ui/src/org/eclipse/sirius/table/ui/business/internal/dialect/TableDialectUIServices.java
@@ -62,6 +62,7 @@ import org.eclipse.sirius.ui.business.api.dialect.DialectUIServices;
import org.eclipse.sirius.ui.business.api.dialect.ExportFormat;
import org.eclipse.sirius.ui.business.api.dialect.ExportFormat.ExportDocumentFormat;
import org.eclipse.sirius.ui.business.api.session.SessionEditorInput;
+import org.eclipse.sirius.ui.business.internal.dialect.HierarchyLabelProvider;
import org.eclipse.sirius.viewpoint.DRepresentation;
import org.eclipse.sirius.viewpoint.DRepresentationElement;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
@@ -85,9 +86,7 @@ import com.google.common.collect.Sets;
* @author lredor
*/
public class TableDialectUIServices implements DialectUIServices {
- /**
- * {@inheritDoc}
- */
+
@Override
public IEditorPart openEditor(Session session, DRepresentation dRepresentation, IProgressMonitor monitor) {
IEditorPart editorPart = null;
@@ -137,10 +136,6 @@ public class TableDialectUIServices implements DialectUIServices {
return editorPart;
}
- /**
- *
- * {@inheritDoc}
- */
@Override
public Collection<CommandParameter> provideNewChildDescriptors() {
final Collection<CommandParameter> newChilds = new ArrayList<CommandParameter>();
@@ -149,10 +144,6 @@ public class TableDialectUIServices implements DialectUIServices {
return newChilds;
}
- /**
- *
- * {@inheritDoc}
- */
@Override
public Collection<CommandParameter> provideRepresentationCreationToolDescriptors(final Object feature) {
final Collection<CommandParameter> newChilds = new ArrayList<CommandParameter>();
@@ -162,10 +153,6 @@ public class TableDialectUIServices implements DialectUIServices {
return newChilds;
}
- /**
- *
- * {@inheritDoc}
- */
@Override
public Collection<CommandParameter> provideRepresentationNavigationToolDescriptors(final Object feature) {
final Collection<CommandParameter> newChilds = new ArrayList<CommandParameter>();
@@ -175,10 +162,6 @@ public class TableDialectUIServices implements DialectUIServices {
return newChilds;
}
- /**
- *
- * {@inheritDoc}
- */
@Override
public AdapterFactory createAdapterFactory() {
final ComposedAdapterFactory factory = new ComposedAdapterFactory();
@@ -187,22 +170,11 @@ public class TableDialectUIServices implements DialectUIServices {
return factory;
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.sirius.ui.business.api.dialect.DialectUIServices#canHandleEditor(org.eclipse.ui.IEditorPart)
- */
@Override
public boolean canHandleEditor(final IEditorPart editorPart) {
return editorPart instanceof AbstractDTableEditor;
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.sirius.ui.business.api.dialect.DialectUIServices#closeEditor(org.eclipse.ui.IEditorPart,
- * boolean)
- */
@Override
public boolean closeEditor(final IEditorPart editorPart, final boolean save) {
final boolean result = true;
@@ -220,12 +192,6 @@ public class TableDialectUIServices implements DialectUIServices {
return result;
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.sirius.ui.business.api.dialect.DialectUIServices#isRepresentationManagedByEditor(org.eclipse.sirius.viewpoint.DRepresentation,
- * org.eclipse.ui.IEditorPart)
- */
@Override
public boolean isRepresentationManagedByEditor(final DRepresentation representation, final IEditorPart editorPart) {
boolean isRepresentationManagedByEditor = false;
@@ -238,12 +204,6 @@ public class TableDialectUIServices implements DialectUIServices {
return isRepresentationManagedByEditor;
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.sirius.ui.business.api.dialect.DialectUIServices#isRepresentationDescriptionManagedByEditor(org.eclipse.sirius.viewpoint.description.RepresentationDescription,
- * org.eclipse.ui.IEditorPart)
- */
@Override
public boolean isRepresentationDescriptionManagedByEditor(final RepresentationDescription representationDescription, final IEditorPart editor) {
if (editor instanceof AbstractDTableEditor) {
@@ -274,31 +234,16 @@ public class TableDialectUIServices implements DialectUIServices {
return representation instanceof TableDescription;
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.sirius.ui.business.api.dialect.DialectUIServices#canHandle(org.eclipse.sirius.viewpoint.description.RepresentationExtensionDescription)
- * )
- */
@Override
public boolean canHandle(final RepresentationExtensionDescription description) {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean canExport(ExportFormat format) {
return format.getDocumentFormat().equals(ExportDocumentFormat.CSV);
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.sirius.ui.business.api.dialect.DialectUIServices#export(org.eclipse.sirius.viewpoint.DRepresentation,
- * org.eclipse.sirius.business.api.session.Session)
- */
@Override
public void export(final DRepresentation representation, final Session session, final IPath path, final ExportFormat exportFormat, final IProgressMonitor monitor) {
String content = null;
@@ -310,9 +255,6 @@ public class TableDialectUIServices implements DialectUIServices {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public String getEditorName(DRepresentation representation) {
String editorName = representation.getName();
@@ -322,36 +264,22 @@ public class TableDialectUIServices implements DialectUIServices {
return editorName;
}
- /**
- * {@inheritDoc}
- */
@Override
public Collection<CommandParameter> provideTools(EObject context) {
return Lists.newArrayList();
}
- /**
- * {@inheritDoc}
- */
@Override
public Collection<CommandParameter> provideAdditionalMappings(EObject object) {
return Lists.newArrayList();
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.sirius.ui.business.api.dialect.DialectUIServices#getHierarchyLabelProvider(ILabelProvider)
- */
@Override
public ILabelProvider getHierarchyLabelProvider(ILabelProvider labelProvider) {
- return new HierarchyLabelTableProvider(labelProvider);
+ return new HierarchyLabelProvider(labelProvider);
}
- /**
- * {@inheritDoc}
- */
@Override
public void setSelection(DialectEditor dialectEditor, List<DRepresentationElement> selection) {
if (dialectEditor instanceof DTableEditor && dialectEditor instanceof IViewerProvider) {
@@ -368,11 +296,6 @@ public class TableDialectUIServices implements DialectUIServices {
setSelection(dialectEditor, selection);
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.sirius.ui.business.api.dialect.DialectUIServices#getSelection(org.eclipse.sirius.ui.business.api.dialect.DialectEditor)
- */
@Override
public Collection<DSemanticDecorator> getSelection(DialectEditor editor) {
Collection<DSemanticDecorator> selection = Sets.newLinkedHashSet();
@@ -388,12 +311,6 @@ public class TableDialectUIServices implements DialectUIServices {
return selection;
}
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.sirius.ui.business.api.dialect.DialectUIServices#completeToolTipText(String,
- * EObject, EStructuralFeature)
- */
@Override
public String completeToolTipText(String toolTipText, EObject eObject, EStructuralFeature feature) {
return toolTipText;
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/CustomizationPropertySectionsTests.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/CustomizationPropertySectionsTests.java
index 1f07927063..da9f7e8f12 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/CustomizationPropertySectionsTests.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/CustomizationPropertySectionsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 2016 THALES GLOBAL SERVICES.
* 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
@@ -21,6 +21,9 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.sirius.diagram.description.AdditionalLayer;
import org.eclipse.sirius.diagram.description.DiagramDescription;
import org.eclipse.sirius.diagram.description.style.StylePackage;
@@ -29,6 +32,7 @@ import org.eclipse.sirius.tests.support.api.EclipseTestsSupportHelper;
import org.eclipse.sirius.tests.support.api.TestsUtil;
import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusHelper;
import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
+import org.eclipse.sirius.ui.business.internal.dialect.HierarchyLabelProvider;
import org.eclipse.sirius.ui.tools.api.views.modelexplorerview.IModelExplorerView;
import org.eclipse.sirius.viewpoint.description.Customization;
import org.eclipse.sirius.viewpoint.description.EAttributeCustomization;
@@ -42,6 +46,7 @@ import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@@ -152,8 +157,16 @@ public class CustomizationPropertySectionsTests extends AbstractContentAssistTes
SWTBotButton appliedOnButton = propertiesBot.bot().button(0);
appliedOnButton.click();
SWTBotShell appliedOnSelectorShell = bot.activeShell();
- assertEquals("The left list of available elements should be of 3, for the begin/center/end edge style description", 3, appliedOnSelectorShell.bot().table(0).rowCount());
- assertEquals("The right list of selected elements should be of 3", 3, appliedOnSelectorShell.bot().table(1).rowCount());
+ SWTBot appliedOnSelectorShellBot = appliedOnSelectorShell.bot();
+ SWTBotTable table1 = appliedOnSelectorShellBot.table(0);
+ assertEquals("The left list of available elements should be of 3, for the begin/center/end edge style description", 3, table1.rowCount());
+ SWTBotTable table2 = appliedOnSelectorShellBot.table(1);
+ assertEquals("The right list of selected elements should be of 3", 3, table2.rowCount());
+ AdapterFactoryLabelProvider wrappedProvider = new AdapterFactoryLabelProvider(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE));
+ ILabelProvider labelProvider = new HierarchyLabelProvider(wrappedProvider);
+ assertEquals(labelProvider.getText(eAttributeCustomization.getAppliedOn().get(0)), table2.getTableItem(0).getText());
+ assertEquals(labelProvider.getText(eAttributeCustomization.getAppliedOn().get(1)), table2.getTableItem(1).getText());
+ assertEquals(labelProvider.getText(eAttributeCustomization.getAppliedOn().get(2)), table2.getTableItem(2).getText());
appliedOnSelectorShell.close();
// Test that without attributeName we have 5 style description elements
@@ -162,16 +175,21 @@ public class CustomizationPropertySectionsTests extends AbstractContentAssistTes
appliedOnButton.setFocus();
appliedOnButton.click();
appliedOnSelectorShell = bot.activeShell();
+ appliedOnSelectorShellBot = appliedOnSelectorShell.bot();
assertEquals("The left list of available elements should be of 5, i.e. all available style description elements", 5, appliedOnSelectorShell.bot().table(0).rowCount());
- assertEquals("The right list of selected elements should be of 3", 3, appliedOnSelectorShell.bot().table(1).rowCount());
+ table2 = appliedOnSelectorShellBot.table(1);
+ assertEquals("The right list of selected elements should be of 3", 3, table2.rowCount());
+ assertEquals(labelProvider.getText(eAttributeCustomization.getAppliedOn().get(0)), table2.getTableItem(0).getText());
+ assertEquals(labelProvider.getText(eAttributeCustomization.getAppliedOn().get(1)), table2.getTableItem(1).getText());
+ assertEquals(labelProvider.getText(eAttributeCustomization.getAppliedOn().get(2)), table2.getTableItem(2).getText());
appliedOnSelectorShell.close();
+ labelProvider.dispose();
}
/**
* Test appliedOn and referenceName sections.
*/
public void testEReferenceCustomization() {
-
if (TestsUtil.shouldSkipUnreliableTests()) {
return;
}
@@ -210,8 +228,15 @@ public class CustomizationPropertySectionsTests extends AbstractContentAssistTes
SWTBotButton appliedOnButton = propertiesBot.bot().button(0);
appliedOnButton.click();
SWTBotShell appliedOnSelectorShell = bot.activeShell();
- assertEquals("The left list of available elements should be empty because we have already selected elements selectionnable", 0, appliedOnSelectorShell.bot().table(0).rowCount());
- assertEquals("The right list of selected elements should be of 3", 3, appliedOnSelectorShell.bot().table(1).rowCount());
+ SWTBot appliedOnSelectorShellBot = appliedOnSelectorShell.bot();
+ assertEquals("The left list of available elements should be empty because we have already selected elements selectionnable", 0, appliedOnSelectorShellBot.table(0).rowCount());
+ SWTBotTable table2 = appliedOnSelectorShellBot.table(1);
+ assertEquals("The right list of selected elements should be of 3", 3, table2.rowCount());
+ AdapterFactoryLabelProvider wrappedProvider = new AdapterFactoryLabelProvider(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE));
+ ILabelProvider labelProvider = new HierarchyLabelProvider(wrappedProvider);
+ assertEquals(labelProvider.getText(eReferenceCustomization.getAppliedOn().get(0)), table2.getTableItem(0).getText());
+ assertEquals(labelProvider.getText(eReferenceCustomization.getAppliedOn().get(1)), table2.getTableItem(1).getText());
+ assertEquals(labelProvider.getText(eReferenceCustomization.getAppliedOn().get(2)), table2.getTableItem(2).getText());
appliedOnSelectorShell.close();
// Test that without attributeName we have 5 style description elements
@@ -220,9 +245,15 @@ public class CustomizationPropertySectionsTests extends AbstractContentAssistTes
appliedOnButton.setFocus();
appliedOnButton.click();
appliedOnSelectorShell = bot.activeShell();
- assertEquals("The left list of available elements should be of 5, i.e. all available style description elements", 5, appliedOnSelectorShell.bot().table(0).rowCount());
- assertEquals("The right list of selected elements should be of 3", 3, appliedOnSelectorShell.bot().table(1).rowCount());
+ appliedOnSelectorShellBot = appliedOnSelectorShell.bot();
+ assertEquals("The left list of available elements should be of 5, i.e. all available style description elements", 5, appliedOnSelectorShellBot.table(0).rowCount());
+ table2 = appliedOnSelectorShellBot.table(1);
+ assertEquals("The right list of selected elements should be of 3", 3, table2.rowCount());
+ assertEquals(labelProvider.getText(eReferenceCustomization.getAppliedOn().get(0)), table2.getTableItem(0).getText());
+ assertEquals(labelProvider.getText(eReferenceCustomization.getAppliedOn().get(1)), table2.getTableItem(1).getText());
+ assertEquals(labelProvider.getText(eReferenceCustomization.getAppliedOn().get(2)), table2.getTableItem(2).getText());
appliedOnSelectorShell.close();
+ labelProvider.dispose();
}
/**
@@ -243,8 +274,8 @@ public class CustomizationPropertySectionsTests extends AbstractContentAssistTes
reuseButton.click();
SWTBotShell reuseSelectorShell = bot.activeShell();
- assertEquals("The left list of available elements should have only one style customization available because we have already selected the other one", 1, reuseSelectorShell.bot().table(0)
- .rowCount());
+ assertEquals("The left list of available elements should have only one style customization available because we have already selected the other one", 1,
+ reuseSelectorShell.bot().table(0).rowCount());
assertEquals("The right list of selected elements should be of 1", 1, reuseSelectorShell.bot().table(1).rowCount());
reuseSelectorShell.close();
diff --git a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/business/internal/dialect/HierarchyLabelTreeProvider.java b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/business/internal/dialect/HierarchyLabelTreeProvider.java
deleted file mode 100644
index 3f0d6ca171..0000000000
--- a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/business/internal/dialect/HierarchyLabelTreeProvider.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2015 THALES GLOBAL SERVICES.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.sirius.tree.ui.business.internal.dialect;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.sirius.business.api.query.IdentifiedElementQuery;
-import org.eclipse.sirius.tree.description.TreeDescription;
-import org.eclipse.sirius.tree.description.TreeMapping;
-import org.eclipse.sirius.tree.description.TreeNavigationDescription;
-import org.eclipse.sirius.tree.ui.provider.Messages;
-import org.eclipse.sirius.viewpoint.description.Group;
-import org.eclipse.sirius.viewpoint.description.IdentifiedElement;
-import org.eclipse.sirius.viewpoint.description.RepresentationExtensionDescription;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * A label provider for mappings to display their hierarchy.
- *
- * @author jdupont
- */
-public class HierarchyLabelTreeProvider extends LabelProvider {
-
- private static final String DELIMITER = " > "; //$NON-NLS-1$
-
- private ILabelProvider wrappedProvider;
-
- /**
- * Create a new instance with wrapped label provider as base type.
- *
- * @param wrappedLabelProvider
- * the wrapped label provider
- */
- public HierarchyLabelTreeProvider(final ILabelProvider wrappedLabelProvider) {
- this.wrappedProvider = wrappedLabelProvider;
- }
-
- @Override
- public Image getImage(final Object element) {
- return wrappedProvider != null ? wrappedProvider.getImage(element) : super.getImage(element);
- }
-
- @Override
- public String getText(final Object element) {
- if (element instanceof TreeMapping || element instanceof TreeDescription || element instanceof TreeNavigationDescription) {
- final IdentifiedElement mapping = (IdentifiedElement) element;
- String text = mapping.getName();
- EObject container = mapping.eContainer();
- while (container != null && !(container instanceof Group)) {
- text = getLabel(container) + DELIMITER + text;
- container = container.eContainer();
- }
- return text;
- }
- return wrappedProvider != null ? wrappedProvider.getText(element) : super.getText(element);
- }
-
- private String getLabel(final EObject eObject) {
-
- String label = null;
-
- if (eObject instanceof IdentifiedElement) {
- label = new IdentifiedElementQuery((IdentifiedElement) eObject).getLabel();
- } else if (eObject instanceof RepresentationExtensionDescription) {
- label = ((RepresentationExtensionDescription) eObject).getName();
- }
- return label != null ? label : Messages.HierarchyLabelTreeProvider_elementWithoutName;
- }
-
-}
diff --git a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/business/internal/dialect/TreeDialectUIServices.java b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/business/internal/dialect/TreeDialectUIServices.java
index 013344d5b4..4cd4666a8d 100644
--- a/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/business/internal/dialect/TreeDialectUIServices.java
+++ b/plugins/org.eclipse.sirius.tree.ui/src/org/eclipse/sirius/tree/ui/business/internal/dialect/TreeDialectUIServices.java
@@ -52,6 +52,7 @@ import org.eclipse.sirius.ui.business.api.dialect.DialectEditor;
import org.eclipse.sirius.ui.business.api.dialect.DialectUIServices;
import org.eclipse.sirius.ui.business.api.dialect.ExportFormat;
import org.eclipse.sirius.ui.business.api.session.SessionEditorInput;
+import org.eclipse.sirius.ui.business.internal.dialect.HierarchyLabelProvider;
import org.eclipse.sirius.viewpoint.DRepresentation;
import org.eclipse.sirius.viewpoint.DRepresentationElement;
import org.eclipse.sirius.viewpoint.DSemanticDecorator;
@@ -74,6 +75,7 @@ import com.google.common.collect.Sets;
* @author pcdavid
*/
public class TreeDialectUIServices implements DialectUIServices {
+
@Override
public boolean canHandle(DRepresentation representation) {
return representation instanceof DTree;
@@ -232,7 +234,7 @@ public class TreeDialectUIServices implements DialectUIServices {
@Override
public ILabelProvider getHierarchyLabelProvider(ILabelProvider currentLabelProvider) {
- return new HierarchyLabelTreeProvider(currentLabelProvider);
+ return new HierarchyLabelProvider(currentLabelProvider);
}
@Override
@@ -271,6 +273,17 @@ public class TreeDialectUIServices implements DialectUIServices {
return toolTipText;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.sirius.ui.business.api.dialect.DialectUIServices#completeToolTipText(String,
+ * EObject)
+ * @deprecated this method has not access to the feature of eObject. This is
+ * supported in
+ * org.eclipse.sirius.tree.ui.business.internal.dialect
+ * .TreeDialectUIServices.completeToolTipText(String, EObject,
+ * EStructuralFeature)
+ */
@Deprecated
@Override
public String completeToolTipText(String toolTipText, EObject eObject) {
diff --git a/plugins/org.eclipse.sirius.ui/plugin.properties b/plugins/org.eclipse.sirius.ui/plugin.properties
index e01abd7bef..64c9b4dd30 100644
--- a/plugins/org.eclipse.sirius.ui/plugin.properties
+++ b/plugins/org.eclipse.sirius.ui/plugin.properties
@@ -160,6 +160,7 @@ FilteredCommonTree_refreshFilterJob = Refresh Filter
GenericInitialObjectPage_containerLabel = &Model Object
GenericInitialObjectPage_encodingLabel = &XML Encoding
GenericModelCreationPage_fileExtensionError = The file name must end in .{0}
+HierarchyLabelProvider_elementWihtoutNameLabel = Element whithout name
LoadEMFResourceRunnableWithProgress_loadResourceTask = Loading resource
LogThroughActiveDialectEditorLogListener_permissionError = Permission Issue
MarkerDeletionJob_name = Remove modeling marker
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/internal/dialect/HierarchyLabelProvider.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/internal/dialect/HierarchyLabelProvider.java
new file mode 100644
index 0000000000..6f13774db6
--- /dev/null
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/business/internal/dialect/HierarchyLabelProvider.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.ui.business.internal.dialect;
+
+import java.util.LinkedList;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.sirius.business.api.query.IdentifiedElementQuery;
+import org.eclipse.sirius.viewpoint.description.IdentifiedElement;
+import org.eclipse.sirius.viewpoint.description.RepresentationExtensionDescription;
+import org.eclipse.sirius.viewpoint.provider.Messages;
+import org.eclipse.swt.graphics.Image;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+
+/**
+ * A {@link LabelProvider} to display Sirius model description element in a
+ * hierarchical way.
+ *
+ * @author <a href="mailto:esteban.dugueperoux@obeo.fr">Esteban Dugueperoux</a>
+ * @author pcdavid
+ */
+public class HierarchyLabelProvider extends LabelProvider {
+
+ private static final String DELIMITER = " > "; //$NON-NLS-1$
+
+ private ILabelProvider wrappedProvider;
+
+ /**
+ * Create a new instance with wrapped label provider as base type.
+ *
+ * @param wrappedProvider
+ * the wrapped {@link ILabelProvider}
+ */
+ public HierarchyLabelProvider(ILabelProvider wrappedProvider) {
+ this.wrappedProvider = wrappedProvider;
+ }
+
+ @Override
+ public Image getImage(final Object element) {
+ return wrappedProvider != null ? wrappedProvider.getImage(element) : super.getImage(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof EObject && handles((EObject) element)) {
+ LinkedList<String> segments = Lists.newLinkedList();
+ for (EObject current = (EObject) element; current != null; current = current.eContainer()) {
+ segments.addFirst(getLabel(current));
+ }
+ return Joiner.on(getDelimiter()).join(segments);
+ }
+ return wrappedProvider != null ? wrappedProvider.getText(element) : super.getText(element);
+ }
+
+ /**
+ * Tests whether this HierarchyLabelProvider can handle the specified
+ * element. If not, the plain label from the wrapped provider will be used.
+ *
+ * @param element
+ * the element to test.
+ * @return <code>true</code> if this provider can handl the element.
+ */
+ protected boolean handles(EObject element) {
+ return true;
+ }
+
+ /**
+ * The delimiter to use between the segments of the hierarchy.
+ *
+ * @return the delimiter to use.
+ */
+ protected String getDelimiter() {
+ return DELIMITER;
+ }
+
+ /**
+ * The label to use for null elements.
+ *
+ * @return the label to use for null elements.
+ */
+ protected String getDefaultLabel() {
+ return Messages.HierarchyLabelProvider_elementWihtoutNameLabel;
+ }
+
+ private String getLabel(EObject eObject) {
+ String label = getDefaultLabel();
+ if (eObject instanceof IdentifiedElement) {
+ label = new IdentifiedElementQuery((IdentifiedElement) eObject).getLabel();
+ } else if (eObject instanceof RepresentationExtensionDescription) {
+ label = ((RepresentationExtensionDescription) eObject).getName();
+ } else {
+ label = wrappedProvider.getText(eObject);
+ }
+ return label;
+ }
+
+ @Override
+ public void dispose() {
+ if (wrappedProvider != null) {
+ wrappedProvider.dispose();
+ wrappedProvider = null;
+ }
+ super.dispose();
+ }
+}
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/viewpoint/provider/Messages.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/viewpoint/provider/Messages.java
index 314ab2b198..9e748bd8ac 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/viewpoint/provider/Messages.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/viewpoint/provider/Messages.java
@@ -464,6 +464,9 @@ public final class Messages {
public static String GenericModelCreationPage_fileExtensionError;
@TranslatableMessage
+ public static String HierarchyLabelProvider_elementWihtoutNameLabel;
+
+ @TranslatableMessage
public static String LoadEMFResourceRunnableWithProgress_loadResourceTask;
@TranslatableMessage

Back to the top