diff options
| author | Florian Barbin | 2017-11-16 13:06:36 +0000 |
|---|---|---|
| committer | Florian Barbin | 2017-11-17 10:50:18 +0000 |
| commit | 1d23debd5bce13e9298e2e77c469a276d23c0671 (patch) | |
| tree | c8d711a952cdbefec2c7e9a8e822017200219f34 | |
| parent | 641c44b9275f78ce9ed31b72fabe0bdf44ff100e (diff) | |
| download | org.eclipse.sirius-1d23debd5bce13e9298e2e77c469a276d23c0671.tar.gz org.eclipse.sirius-1d23debd5bce13e9298e2e77c469a276d23c0671.tar.xz org.eclipse.sirius-1d23debd5bce13e9298e2e77c469a276d23c0671.zip | |
[527397] Fixes duplicated palette elements after a reload
* Use the tool section id instead of its label to retrieve the
paletteEntry.
* Complete existing test.
Bug: 527397
Change-Id: Id42bf615dd87d72079ba195a4c0a169c77767862
Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
2 files changed, 33 insertions, 15 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 5b563033dc..ab579f40cb 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 @@ -331,8 +331,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 8e120e28c8..4025b84c81 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; @@ -260,8 +267,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 @@ -297,7 +304,7 @@ public class SiriusInternationalizationTest extends AbstractSiriusSwtBotGefTestC labelsToCheck.add(TOOL2_LABEL); labelsToCheck.add(TOOL3_LABEL); SWTBotUtils.checkLabelsInPalette(editor, labelsToCheck); - + // Check that labels in the filters tool are properly displayed and internationalized editor.click(100, 100); labelsToCheck = Lists.newArrayList(); @@ -350,11 +357,24 @@ public class SiriusInternationalizationTest extends AbstractSiriusSwtBotGefTestC labelsToCheck = Lists.newArrayList(); labelsToCheck.add(getToolLayerLabel()); SWTBotUtils.checkLabelsInDiagramToolBar(editor, LAYERS, labelsToCheck); + + // 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. @@ -400,8 +420,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. @@ -445,8 +465,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. @@ -491,9 +511,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 |
