Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Barbin2017-11-16 13:06:36 +0000
committerFlorian Barbin2017-11-17 13:29:28 +0000
commit467a61c65a6a04fb01bd3ddd603aa664737cf627 (patch)
tree890dc936b80dff8d5588027b4e42144e0f026b17
parent27eb220747c6d036ba207a717a4ae203f140cf32 (diff)
downloadorg.eclipse.sirius-467a61c65a6a04fb01bd3ddd603aa664737cf627.tar.gz
org.eclipse.sirius-467a61c65a6a04fb01bd3ddd603aa664737cf627.tar.xz
org.eclipse.sirius-467a61c65a6a04fb01bd3ddd603aa664737cf627.zip
[522368] Fixes duplicated palette elements after a reload
* Use the tool section id instead of its label to retrieve the paletteEntry. * Complete existing test. Bug: 522368 Change-Id: Id42bf615dd87d72079ba195a4c0a169c77767862 Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/palette/PaletteManagerImpl.java3
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SiriusInternationalizationTest.java42
2 files changed, 31 insertions, 14 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/palette/PaletteManagerImpl.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/palette/PaletteManagerImpl.java
index 6bb33bdb5d..cc3a495765 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/palette/PaletteManagerImpl.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/palette/PaletteManagerImpl.java
@@ -339,8 +339,7 @@ public class PaletteManagerImpl implements PaletteManager {
updateFilters(session, new DiagramComponentizationManager().getAllToolEntries(session.getSelectedViewpoints(false), section));
}
for (final ToolSection section : new DiagramComponentizationManager().getRootPaletteSections(session.getSelectedViewpoints(false), description)) {
- Option<SectionPaletteDrawer> paletteEntry = getPaletteEntry(paletteRoot, MessageTranslator.INSTANCE.getMessage(section, new IdentifiedElementQuery(section).getLabel()),
- SectionPaletteDrawer.class);
+ Option<SectionPaletteDrawer> paletteEntry = getPaletteEntry(paletteRoot, PaletteManagerImpl.getToolSectionId(section), SectionPaletteDrawer.class);
if (!paletteEntry.some()) {
final PaletteContainer container = PaletteManagerImpl.createPaletteDrawner(section);
updateContainer(session, dDiagram, container, new DiagramComponentizationManager().getAllToolEntries(session.getSelectedViewpoints(false), section));
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SiriusInternationalizationTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SiriusInternationalizationTest.java
index 6353468d4b..adc8be392d 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SiriusInternationalizationTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/SiriusInternationalizationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016 Obeo.
+ * Copyright (c) 2016, 2017 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
@@ -22,9 +22,16 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.sirius.business.api.componentization.ViewpointRegistry;
import org.eclipse.sirius.common.tools.api.util.MessageTranslator;
import org.eclipse.sirius.common.tools.internal.resource.ResourceSyncClientNotifier;
+import org.eclipse.sirius.diagram.ui.tools.internal.palette.SiriusPaletteViewer;
import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase;
import org.eclipse.sirius.tests.swtbot.support.api.business.UILocalSession;
import org.eclipse.sirius.tests.swtbot.support.api.business.UIProject;
@@ -248,8 +255,8 @@ public class SiriusInternationalizationTest extends AbstractSiriusSwtBotGefTestC
}
/**
- * The scenario uses a custom odesign and the plugin.properties in order to
- * test the localization of VSM texts on a Diagram.
+ * The scenario uses a custom odesign and the plugin.properties in order to test the localization of VSM texts on a
+ * Diagram.
*
* @param locale
* the {@link Locale} to use in the scenario
@@ -326,11 +333,23 @@ public class SiriusInternationalizationTest extends AbstractSiriusSwtBotGefTestC
SWTBotUtils.checkContextualMenus(bot.getDisplay(), editor.getDiagramEditPart().getViewer().getControl(), contextMenusToCheck);
checkLabelsInModelExplorerView(getDiagramDescriptionLabel());
+
+ // Bug 522368 test that there is no duplicated entries in the palette after an external modification.
+ URI ecoreURI = URI.createPlatformResourceURI(getProjectName() + "/" + MODEL, false);
+ Resource resource = new ResourceSetImpl().getResource(ecoreURI, true);
+ EPackage ePackage = (EPackage) resource.getContents().get(0);
+ ePackage.getEAnnotations().add(EcoreFactory.eINSTANCE.createEAnnotation());
+ PaletteRoot paletteRoot = ((SiriusPaletteViewer) editor.getPaletteRootEditPartBot().part().getViewer()).getPaletteRoot();
+ int before = paletteRoot.getChildren().size();
+ resource.save(Collections.emptyMap());
+ SWTBotUtils.waitAllUiEvents();
+ int after = paletteRoot.getChildren().size();
+ assertEquals("The number of elements in the palette should be the same after a refresh following an external modification.", before, after);
}
/**
- * The scenario uses a custom odesign and the plugin.properties in order to
- * test the localization of VSM texts on a Tree.
+ * The scenario uses a custom odesign and the plugin.properties in order to test the localization of VSM texts on a
+ * Tree.
*
* @param locale
* {@link Locale} to use in the current scenario.
@@ -376,8 +395,8 @@ public class SiriusInternationalizationTest extends AbstractSiriusSwtBotGefTestC
}
/**
- * The scenario uses a custom odesign and the plugin.properties in order to
- * test the localization of VSM texts on an Edition Table.
+ * The scenario uses a custom odesign and the plugin.properties in order to test the localization of VSM texts on an
+ * Edition Table.
*
* @param locale
* {@link Locale} to use in the current scenario.
@@ -421,8 +440,8 @@ public class SiriusInternationalizationTest extends AbstractSiriusSwtBotGefTestC
}
/**
- * The scenario uses a custom odesign and the plugin.properties in order to
- * test the localization of VSM texts on an Cross Table.
+ * The scenario uses a custom odesign and the plugin.properties in order to test the localization of VSM texts on an
+ * Cross Table.
*
* @param locale
* {@link Locale} to use in the current scenario.
@@ -467,9 +486,8 @@ public class SiriusInternationalizationTest extends AbstractSiriusSwtBotGefTestC
}
/**
- * Validate that the Viewpoint and Representation Description are displayed
- * with localization in the Model Explorer view under the
- * representations.aird file
+ * Validate that the Viewpoint and Representation Description are displayed with localization in the Model Explorer
+ * view under the representations.aird file
*
* @param representationDescriptionLabel
* expected {@link RepresentationDescription} label

Back to the top