diff options
| author | jmallet | 2017-04-19 09:17:50 +0000 |
|---|---|---|
| committer | Pierre-Charles David | 2017-05-03 14:03:04 +0000 |
| commit | 963e69ff690434ab445a5cbbed88e606b7e47d6f (patch) | |
| tree | aef8b533b96bade8adf0f6ca8e26d66d265d8a37 | |
| parent | a93e7e38e7c2f1988921e19fac7c7d492f4293ff (diff) | |
| download | org.eclipse.sirius-963e69ff690434ab445a5cbbed88e606b7e47d6f.tar.gz org.eclipse.sirius-963e69ff690434ab445a5cbbed88e606b7e47d6f.tar.xz org.eclipse.sirius-963e69ff690434ab445a5cbbed88e606b7e47d6f.zip | |
[512623] Make filter and layer items in toolBar translatable.
Filter and Layer items are now translate during creation of contribution
item for diagram toolBar.
Bug: 512623
Change-Id: Ia4fdd79d1d3bc894087cdfe5e7328f914bea1e2b
Signed-off-by: jmallet <jessy.mallet@obeo.fr>
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
7 files changed, 101 insertions, 6 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/FiltersContributionItem.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/FiltersContributionItem.java index 01693a830f..f347eb521d 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/FiltersContributionItem.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/FiltersContributionItem.java @@ -21,6 +21,7 @@ import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.sirius.business.api.query.IdentifiedElementQuery; +import org.eclipse.sirius.common.tools.api.util.MessageTranslator; import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.description.DiagramDescription; import org.eclipse.sirius.diagram.description.concern.ConcernDescription; @@ -87,7 +88,8 @@ public class FiltersContributionItem extends AbstractMenuContributionItem { private void addFilterMenuItem(IMenuManager manager, final FilterDescription filter) { final boolean isActive = isActive(filter); - IAction action = new Action(new IdentifiedElementQuery(filter).getLabel(), IAction.AS_CHECK_BOX) { + final String nameEntry = MessageTranslator.INSTANCE.getMessage(filter, new IdentifiedElementQuery(filter).getLabel()); + IAction action = new Action(nameEntry, IAction.AS_CHECK_BOX) { @Override public void run() { final Runnable change = new ChangeFilterActivation(part, diagram, filter, !isActive); diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/LayersContribution.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/LayersContribution.java index 0743d935fa..67faec4553 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/LayersContribution.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/LayersContribution.java @@ -22,6 +22,7 @@ import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.sirius.business.api.query.IdentifiedElementQuery; +import org.eclipse.sirius.common.tools.api.util.MessageTranslator; import org.eclipse.sirius.common.tools.api.util.StringUtil; import org.eclipse.sirius.common.ui.tools.api.util.ImageProvider; import org.eclipse.sirius.diagram.DDiagram; @@ -147,7 +148,8 @@ public class LayersContribution extends AbstractMenuContributionItem { } private void addLayerMenuItem(IMenuManager manager, final Layer layer) { - IAction action = new LayersActivationAction(new IdentifiedElementQuery(layer).getLabel(), IAction.AS_CHECK_BOX, diagram, layer); + final String nameEntry = MessageTranslator.INSTANCE.getMessage(layer, new IdentifiedElementQuery(layer).getLabel()); + IAction action = new LayersActivationAction(nameEntry, IAction.AS_CHECK_BOX, diagram, layer); // Warning : doesn't work in gtk if (!StringUtil.isEmpty(layer.getIcon())) { action.setImageDescriptor(ImageProvider.getImageDescriptor(layer.getIcon())); @@ -168,7 +170,8 @@ public class LayersContribution extends AbstractMenuContributionItem { if (endUserDoc != null && endUserDoc.trim().length() > 0) { return endUserDoc; } - return new IdentifiedElementQuery(layer).getLabel(); + final String nameEntry = MessageTranslator.INSTANCE.getMessage(layer, new IdentifiedElementQuery(layer).getLabel()); + return nameEntry; } /** diff --git a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/SWTBotUtils.java b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/SWTBotUtils.java index 09a8fe2ed6..1ac0e385d8 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/SWTBotUtils.java +++ b/plugins/org.eclipse.sirius.tests.swtbot.support/src/org/eclipse/sirius/tests/swtbot/support/utils/SWTBotUtils.java @@ -17,6 +17,8 @@ import java.util.concurrent.TimeUnit; import org.eclipse.gef.GraphicalEditPart; import org.eclipse.gef.palette.PaletteEntry; +import org.eclipse.jface.bindings.keys.KeyStroke; +import org.eclipse.jface.bindings.keys.ParseException; import org.eclipse.sirius.business.api.metamodel.helper.FontFormatHelper; import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor; import org.eclipse.sirius.tests.swtbot.support.utils.menu.SWTBotContextMenu; @@ -44,7 +46,9 @@ import org.eclipse.swtbot.swt.finder.results.Result; import org.eclipse.swtbot.swt.finder.results.VoidResult; import org.eclipse.swtbot.swt.finder.results.WidgetResult; import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; import org.eclipse.swtbot.swt.finder.widgets.TimeoutException; @@ -652,6 +656,37 @@ public final class SWTBotUtils { } /** + * Checks that the tools bar contribution items label are displayed as expected. + * The toolBar contribution is identified by its toolTip given in parameter. + * + * @param editor + * the current {@link SWTBotSiriusDiagramEditor} + * @param toolTip + * toolTip of the toolBar contribution to check + * @param labelsToCheck + * the label to check in the toolBar + */ + public static void checkLabelsInDiagramToolBar(SWTBotSiriusDiagramEditor editor, String toolTip, List<String> labelsToCheck) { + if (labelsToCheck.isEmpty()) { + return; + } + final SWTBotToolbarDropDownButton toolMenuButton = editor.bot().toolbarDropDownButtonWithTooltip(toolTip); + List<? extends SWTBotMenu> menuItems = toolMenuButton.menuItems(WidgetMatcherFactory.widgetOfType(MenuItem.class)); + for (SWTBotMenu menuItem : menuItems) { + if (labelsToCheck.contains(menuItem.getText())) { + labelsToCheck.remove(menuItem.getText()); + } + } + Assert.assertTrue("The following menu items have not been found in the " + toolTip + " toolBars contribution : " + + labelsToCheck, labelsToCheck.isEmpty()); + try { + toolMenuButton.pressShortcut(KeyStroke.getInstance("ESC")); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } + + /** * Validate that each of the given label are available among contextual menus. * * @param display diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/internationalization/bugzilla459993.odesign b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/internationalization/bugzilla459993.odesign index e4c1233b93..fc9b91b828 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/internationalization/bugzilla459993.odesign +++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/internationalization/bugzilla459993.odesign @@ -1,7 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> -<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:description_2="http://www.eclipse.org/sirius/tree/description/1.0.0" xmlns:description_3="http://www.eclipse.org/sirius/table/description/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:tool="http://www.eclipse.org/sirius/diagram/description/tool/1.1.0" xmlns:tool_1="http://www.eclipse.org/sirius/description/tool/1.1.0" name="bugzilla459993" version="11.0.0.201601261200"> +<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:description_2="http://www.eclipse.org/sirius/tree/description/1.0.0" xmlns:description_3="http://www.eclipse.org/sirius/table/description/1.1.0" xmlns:filter="http://www.eclipse.org/sirius/diagram/description/filter/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:tool="http://www.eclipse.org/sirius/diagram/description/tool/1.1.0" xmlns:tool_1="http://www.eclipse.org/sirius/description/tool/1.1.0" name="bugzilla459993" version="12.0.0.2017041100"> <ownedViewpoints name="bugzilla459993" label="%bugzillaId" modelFileExtension="ecore"> <ownedRepresentations xsi:type="description_1:DiagramDescription" name="bugzilla459993Diag" label="%bugzillaDiag" domainClass="EPackage" enablePopupBars="true"> + <filters xsi:type="filter:CompositeFilterDescription" name="filterPackage" label="%filterLabel"> + <filters xsi:type="filter:MappingFilter" mappings="//@ownedViewpoints[name='bugzilla459993']/@ownedRepresentations[name='bugzilla459993Diag']/@defaultLayer/@containerMappings[name='EPackage']"/> + </filters> <defaultLayer name="Default"> <nodeMappings/> <containerMappings name="EPackage" detailDescriptions="//@ownedViewpoints[name='bugzilla459993']/@ownedRepresentations[name='bugzilla459993Diag']/@defaultLayer/@toolSections.0/@ownedTools[name='CreateDiag']" semanticCandidatesExpression="feature:eSubpackages" domainClass="EPackage"> @@ -53,6 +56,16 @@ </ownedTools> </toolSections> </defaultLayer> + <additionalLayers name="layerTest" label="%layerLabel"> + <containerMappings name="EPackage" detailDescriptions="//@ownedViewpoints[name='bugzilla459993']/@ownedRepresentations[name='bugzilla459993Diag']/@defaultLayer/@toolSections.0/@ownedTools[name='CreateDiag']" semanticCandidatesExpression="feature:eSubpackages" domainClass="EPackage"> + <style xsi:type="style:FlatContainerStyleDescription" borderSizeComputationExpression="1" backgroundStyle="Liquid"> + <borderColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='dark_blue']"/> + <labelColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='dark_blue']"/> + <backgroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='white']"/> + <foregroundColor xsi:type="description:SystemColor" href="environment:/viewpoint#//@systemColors/@entries[name='red']"/> + </style> + </containerMappings> + </additionalLayers> </ownedRepresentations> <ownedRepresentations xsi:type="description_2:TreeDescription" name="bugzilla459993Tree" label="%bugzillaTree" domainClass="EPackage"> <subItemMappings name="EPackageTree" domainClass="EPackage" semanticCandidatesExpression="feature:eSubpackages" reusedTreeItemMappings="//@ownedViewpoints[name='bugzilla459993']/@ownedRepresentations[name='bugzilla459993Tree']/@subItemMappings[name='EPackageTree']"> diff --git a/plugins/org.eclipse.sirius.tests.swtbot/plugin.properties b/plugins/org.eclipse.sirius.tests.swtbot/plugin.properties index 325f0122e7..5450c55ad3 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/plugin.properties +++ b/plugins/org.eclipse.sirius.tests.swtbot/plugin.properties @@ -25,4 +25,6 @@ SelectedValues=This is the selected values! popupMenu=Bugzilla 459993 Popup menu operationAction1=Bugzilla 459993 Operation 1 operationAction2=Bugzilla 459993 Operation 2 -nameFeature=Name
\ No newline at end of file +nameFeature=Name +filterLabel=This is a filter +layerLabel=This is a layer
\ No newline at end of file diff --git a/plugins/org.eclipse.sirius.tests.swtbot/plugin_fr.properties b/plugins/org.eclipse.sirius.tests.swtbot/plugin_fr.properties index ee2816c763..6876a3731c 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/plugin_fr.properties +++ b/plugins/org.eclipse.sirius.tests.swtbot/plugin_fr.properties @@ -23,4 +23,6 @@ SelectedValues=Voici les valeurs sélectionnées! popupMenu=Bugzilla 459993 Menu popup operationAction1=Bugzilla 459993 Opération 1 operationAction2=Bugzilla 459993 Opération 2 -nameFeature=Nom
\ No newline at end of file +nameFeature=Nom +filterLabel=Voici un filtre +layerLabel=Voici un layer
\ No newline at end of file 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..8e120e28c8 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 @@ -84,6 +84,10 @@ public class SiriusInternationalizationTest extends AbstractSiriusSwtBotGefTestC private static final String OPERATION_ACTION2_LABEL_ENG = "Bugzilla 459993 Operation 2"; + private static final String TOOL_FILTERS_LABEL_ENG = "This is a filter"; + + private static final String TOOL_LAYERS_LABEL_ENG = "This is a layer"; + // Labels coming from the plugin_fr.properties file private static final String TOOL_SELECTED_VALUES_LABEL_FR = "Voici le choix des valeurs!"; @@ -117,6 +121,10 @@ public class SiriusInternationalizationTest extends AbstractSiriusSwtBotGefTestC private static final String VIEWPOINT_ID = "bugzilla459993"; + private static final String TOOL_FILTERS_LABEL_FR = "Voici un filtre"; + + private static final String TOOL_LAYERS_LABEL_FR = "Voici un layer"; + // Id of tools as set in the odesign private static final String TOOL2_LABEL = "%SelectionWizard"; @@ -131,6 +139,10 @@ public class SiriusInternationalizationTest extends AbstractSiriusSwtBotGefTestC private static final String FILE_DIR = "/"; + private static final String FILTERS = "Filters"; + + private static final String LAYERS = "Layers"; + private UIResource sessionAirdResource; private UILocalSession localSession; @@ -285,6 +297,12 @@ 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(); + labelsToCheck.add(getToolFilterLabel()); + SWTBotUtils.checkLabelsInDiagramToolBar(editor, FILTERS, labelsToCheck); // Check SelectionWizard label and use tool editor.activateTool(TOOL2_LABEL); @@ -326,6 +344,12 @@ public class SiriusInternationalizationTest extends AbstractSiriusSwtBotGefTestC SWTBotUtils.checkContextualMenus(bot.getDisplay(), editor.getDiagramEditPart().getViewer().getControl(), contextMenusToCheck); checkLabelsInModelExplorerView(getDiagramDescriptionLabel()); + + // Check that labels in the layers tool are properly displayed and internationalized + editor.click(100, 100); + labelsToCheck = Lists.newArrayList(); + labelsToCheck.add(getToolLayerLabel()); + SWTBotUtils.checkLabelsInDiagramToolBar(editor, LAYERS, labelsToCheck); } /** @@ -552,6 +576,20 @@ public class SiriusInternationalizationTest extends AbstractSiriusSwtBotGefTestC Assert.assertEquals("There should be 1 activated viewpoint", 1, localSession.getOpenedSession().getSelectedViewpoints(false).size()); } + private String getToolFilterLabel() { + if ("en".equals(selected_language)) { + return TOOL_FILTERS_LABEL_ENG; + } + return TOOL_FILTERS_LABEL_FR; + } + + private String getToolLayerLabel() { + if ("en".equals(selected_language)) { + return TOOL_LAYERS_LABEL_ENG; + } + return TOOL_LAYERS_LABEL_FR; + } + private String getToolSelectedValuesLabel() { if ("en".equals(selected_language)) { return TOOL_SELECTED_VALUES_LABEL_ENG; |
