diff options
| author | Laurent Redor | 2016-12-09 14:44:55 +0000 |
|---|---|---|
| committer | Laurent Redor | 2016-12-16 16:43:34 +0000 |
| commit | fe01975a4198728263873ddbaf597c2581d673f1 (patch) | |
| tree | 6602e75345eda13ae4321b016ddd9605bb7da2d3 | |
| parent | 3fd8d8a3b2606504707a6dea9ff8bde138afe9e5 (diff) | |
| download | org.eclipse.sirius-fe01975a4198728263873ddbaf597c2581d673f1.tar.gz org.eclipse.sirius-fe01975a4198728263873ddbaf597c2581d673f1.tar.xz org.eclipse.sirius-fe01975a4198728263873ddbaf597c2581d673f1.zip | |
[509364] Have "fonts and colors" properties available on edge name
With this commit, the "Font and Colors" section is now available in tab
"Appearance" of properties view when an edge name is selected.
Bug: 509364
Change-Id: Id50a99d3d1550f4e331ce92c16e660d5d08bb434
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
5 files changed, 86 insertions, 6 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/plugin.xml b/plugins/org.eclipse.sirius.diagram.ui/plugin.xml index 013db0a820..a2254546e1 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/plugin.xml +++ b/plugins/org.eclipse.sirius.diagram.ui/plugin.xml @@ -701,6 +701,11 @@ class="org.eclipse.sirius.diagram.ui.tools.internal.properties.LabelColorAndFontPropertySection" tab="property.tab.AppearancePropertySection"> </propertySection> + <propertySection id="property.section.DEdgeNameAppearancePropertySection" + filter="org.eclipse.sirius.diagram.ui.tools.internal.properties.filter.DEdgeNamePropertyFilter" + class="org.eclipse.sirius.diagram.ui.tools.internal.properties.LabelColorAndFontPropertySection" + tab="property.tab.AppearancePropertySection"> + </propertySection> <propertySection id="property.section.RulerGridPropertySection" filter="org.eclipse.gmf.runtime.diagram.ui.properties.filters.DiagramEditPartPropertySectionFilter" class="org.eclipse.gmf.runtime.diagram.ui.properties.sections.grid.RulerGridPropertySection" diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/LabelColorAndFontPropertySection.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/LabelColorAndFontPropertySection.java index 685f9eec55..d1461e5c7c 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/LabelColorAndFontPropertySection.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/LabelColorAndFontPropertySection.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 THALES GLOBAL SERVICES and others. + * Copyright (c) 2015, 2016 THALES GLOBAL SERVICES 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 @@ -33,6 +33,8 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter; import org.eclipse.sirius.diagram.business.api.query.EObjectQuery; +import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramEdgeEditPart; +import org.eclipse.sirius.diagram.ui.internal.edit.parts.AbstractDEdgeNameEditPart; import org.eclipse.sirius.diagram.ui.internal.refresh.diagram.ViewPropertiesSynchronizer; import org.eclipse.sirius.diagram.ui.provider.DiagramUIPlugin; import org.eclipse.sirius.diagram.ui.provider.Messages; @@ -70,12 +72,12 @@ public class LabelColorAndFontPropertySection extends ColorsAndFontsPropertySect protected Button resetStylePropertiesToDefaultValuesButton; /** - * button to set back the view to default color. + * button to set the font underlined. */ private Button fontUnderlineButton; /** - * button to set back the view to default color. + * button to set the font strike trough. */ private Button fontStrikeThroughButton; @@ -239,7 +241,14 @@ public class LabelColorAndFontPropertySection extends ColorsAndFontsPropertySect while (it.hasNext()) { Object selectionItem = it.next(); if (transformSelection(selectionItem) != null) { - newSelection.add(selectionItem); + if (selectionItem instanceof AbstractDEdgeNameEditPart) { + // If the selection is an AbstractDEdgeNameEditPart, we + // consider its parent as the PropertySection is not + // really coded for NameEditPart. + newSelection.add(((AbstractDEdgeNameEditPart) selectionItem).getParent()); + } else { + newSelection.add(selectionItem); + } } } composite.setVisible(!newSelection.isEmpty()); @@ -303,6 +312,13 @@ public class LabelColorAndFontPropertySection extends ColorsAndFontsPropertySect fontStrikeThroughButton.setSelection(striked); fontStrikeThroughButton.setEnabled(!isReadOnly); } + if (ep instanceof AbstractDiagramEdgeEditPart) { + // Even if the selection considered is + // AbstractDiagramEdgeEditPart instead of original + // AbstractDEdgeNameEditPart, the line color must + // not be enabled. + lineColorButton.setEnabled(false); + } } } }); diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/filter/DEdgeNamePropertyFilter.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/filter/DEdgeNamePropertyFilter.java new file mode 100644 index 0000000000..4651a1b8fe --- /dev/null +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/properties/filter/DEdgeNamePropertyFilter.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.diagram.ui.tools.internal.properties.filter; + +import org.eclipse.jface.viewers.IFilter; +import org.eclipse.sirius.diagram.ui.internal.edit.parts.AbstractDEdgeNameEditPart; + +/** + * Filter for the edge name section. + * + * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> + */ +public class DEdgeNamePropertyFilter implements IFilter { + + @Override + public boolean select(Object object) { + return object instanceof AbstractDEdgeNameEditPart; + } +} diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractRefreshWithCustomizedStyleTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractRefreshWithCustomizedStyleTest.java index 4530414f6d..90324e9da1 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractRefreshWithCustomizedStyleTest.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/AbstractRefreshWithCustomizedStyleTest.java @@ -447,7 +447,19 @@ public abstract class AbstractRefreshWithCustomizedStyleTest extends AbstractSir // Step 5: Reopen diagram editor.close(); editor = (SWTBotSiriusDiagramEditor) openRepresentation(SessionManager.INSTANCE.getSessions().iterator().next(), representationDescriptionName, representationName, DDiagram.class); - selectedEditPart = editor.getEditPart(editor.getBounds(selectedEditPart).getCenter(), selectedEditPart.part().getClass()); + if (DEdgeEditPart.class.isInstance(selectedEditPart.part())) { + // Select the corresponding DEdge in the new editor + Edge gmfEdge = (Edge) ((DEdgeEditPart) selectedEditPart.part()).getModel(); + DEdge dEdge = (DEdge) gmfEdge.getElement(); + selectedEditPart = editor.getEditPart(dEdge.getName(), DEdgeEditPart.class); + } else if (DEdgeNameEditPart.class.isInstance(selectedEditPart.part())) { + // Select the corresponding DEdge name in the new editor + Node gmfNode = (Node) ((DEdgeNameEditPart) selectedEditPart.part()).getModel(); + DEdge dEdge = (DEdge) gmfNode.getElement(); + selectedEditPart = editor.getEditPart(dEdge.getName(), DEdgeNameEditPart.class); + } else { + selectedEditPart = editor.getEditPart(editor.getBounds(selectedEditPart).getCenter(), selectedEditPart.part().getClass()); + } selectedEditPart.select(); propertiesBot = selectAppearanceTab(); buttonFromAppearanceSectionToTest = propertiesBot.buttonInGroup(buttonToToggleGroupName, buttonToToggleIndexInGroup); @@ -611,7 +623,19 @@ public abstract class AbstractRefreshWithCustomizedStyleTest extends AbstractSir // Step 5: Reopen diagram editor.close(); editor = (SWTBotSiriusDiagramEditor) openRepresentation(SessionManager.INSTANCE.getSessions().iterator().next(), representationDescriptionName, representationName, DDiagram.class); - selectedEditPart = editor.getEditPart(editor.getBounds(selectedEditPart).getCenter(), selectedEditPart.part().getClass()); + if (DEdgeEditPart.class.isInstance(selectedEditPart.part())) { + // Select the corresponding DEdge in the new editor + Edge gmfEdge = (Edge) ((DEdgeEditPart) selectedEditPart.part()).getModel(); + DEdge dEdge = (DEdge) gmfEdge.getElement(); + selectedEditPart = editor.getEditPart(dEdge.getName(), DEdgeEditPart.class); + } else if (DEdgeNameEditPart.class.isInstance(selectedEditPart.part())) { + // Select the corresponding DEdge name in the new editor + Node gmfNode = (Node) ((DEdgeNameEditPart) selectedEditPart.part()).getModel(); + DEdge dEdge = (DEdge) gmfNode.getElement(); + selectedEditPart = editor.getEditPart(dEdge.getName(), DEdgeNameEditPart.class); + } else { + selectedEditPart = editor.getEditPart(editor.getBounds(selectedEditPart).getCenter(), selectedEditPart.part().getClass()); + } selectedEditPart.select(); propertiesBot = selectAppearanceTab(); buttonFromAppearanceSectionToTest = propertiesBot.toggleButtonInGroup(buttonToToggleGroupName, buttonToToggleIndexInGroup); diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/LabelFontModificationsTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/LabelFontModificationsTest.java index 2df91e6fbb..6b5c241e63 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/LabelFontModificationsTest.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/LabelFontModificationsTest.java @@ -166,6 +166,8 @@ public class LabelFontModificationsTest extends AbstractFontModificationTest { doTestChangeLabelColorFromAppearanceSection("myAttribute", DNodeListElementEditPart.class); doTestChangeLabelColorFromAppearanceSection("myPackage", DNodeContainerEditPart.class); doTestChangeLabelColorFromAppearanceSection("myPackage2", DNodeContainer2EditPart.class); + doTestChangeLabelColorFromAppearanceSection("[0..1] newEReference1", DEdgeEditPart.class); + doTestChangeLabelColorFromAppearanceSection("[0..1] newEReference1", DEdgeNameEditPart.class); } /** @@ -371,6 +373,8 @@ public class LabelFontModificationsTest extends AbstractFontModificationTest { doTestBoldFromAppearanceSection("myAttribute", DNodeListElementEditPart.class); doTestBoldFromAppearanceSection("myPackage", DNodeContainerEditPart.class); doTestBoldFromAppearanceSection("myPackage2", DNodeContainer2EditPart.class); + doTestBoldFromAppearanceSection("[0..1] newEReference1", DEdgeEditPart.class); + doTestBoldFromAppearanceSection("[0..1] newEReference1", DEdgeNameEditPart.class); } /** @@ -397,6 +401,8 @@ public class LabelFontModificationsTest extends AbstractFontModificationTest { doTestItalicFromAppearanceSection("myAttribute", DNodeListElementEditPart.class); doTestItalicFromAppearanceSection("myPackage", DNodeContainerEditPart.class); doTestItalicFromAppearanceSection("myPackage2", DNodeContainer2EditPart.class); + doTestItalicFromAppearanceSection("[0..1] newEReference1", DEdgeEditPart.class); + doTestItalicFromAppearanceSection("[0..1] newEReference1", DEdgeNameEditPart.class); } /** @@ -475,6 +481,8 @@ public class LabelFontModificationsTest extends AbstractFontModificationTest { doTestItalicAndBoldFromAppearanceSection("myAttribute", DNodeListElementEditPart.class); doTestItalicAndBoldFromAppearanceSection("myPackage", DNodeContainerEditPart.class); doTestItalicAndBoldFromAppearanceSection("myPackage2", DNodeContainer2EditPart.class); + doTestItalicAndBoldFromAppearanceSection("[0..1] newEReference1", DEdgeEditPart.class); + doTestItalicAndBoldFromAppearanceSection("[0..1] newEReference1", DEdgeNameEditPart.class); } /** |
