From b72f6e424c3be34c86a9c77ed0adb2eaa7713fd1 Mon Sep 17 00:00:00 2001 From: Phillipus Date: Thu, 21 Nov 2024 08:53:05 +0000 Subject: [PATCH] Support Line Style on diagram objects --- .../factory/CanvasStickyUIProvider.java | 1 + .../canvas/figures/CanvasBlockFigure.java | 2 + com.archimatetool.editor/plugin.xml | 12 +- .../DiagramModelObjectLineStyleCommand.java | 40 +++++ .../editor/diagram/commands/Messages.java | 2 + .../diagram/commands/messages.properties | 1 + .../AbstractDiagramModelObjectFigure.java | 27 +++ .../figures/AbstractFigureDelegate.java | 8 + .../figures/EllipseFigureDelegate.java | 2 + .../figures/RectangleFigureDelegate.java | 2 + .../RoundedRectangleFigureDelegate.java | 2 + .../figures/diagram/DiagramImageFigure.java | 2 + .../diagram/figures/diagram/GroupFigure.java | 2 + .../diagram/figures/diagram/NoteFigure.java | 1 + .../elements/AbstractMotivationFigure.java | 2 + .../figures/elements/GroupingFigure.java | 5 +- .../diagram/sketch/figures/StickyFigure.java | 2 + .../diagram/tools/FormatPainterTool.java | 11 ++ .../propertysections/LineOpacitySection.java | 103 ------------ .../editor/propertysections/LineSection2.java | 155 ++++++++++++++++++ .../propertysections/LineStyleComposite.java | 147 +++++++++++++++++ .../editor/propertysections/Messages.java | 8 + .../propertysections/messages.properties | 4 + .../AbstractGraphicalObjectUIProvider.java | 20 +++ .../diagram/DiagramImageUIProvider.java | 3 +- .../factory/elements/GroupingUIProvider.java | 10 ++ .../factory/sketch/SketchActorUIProvider.java | 3 +- .../model/IDiagramModelObject.java | 18 ++ .../model/impl/DiagramModelObject.java | 10 ++ ...bstractGraphicalObjectUIProviderTests.java | 8 + .../AllArchiMateElementUIProviderTests.java | 32 ++++ .../DiagramModelImageUIProviderTests.java | 14 ++ .../DiagramModelReferenceUIProviderTests.java | 10 ++ .../ui/factory/GroupUIProviderTests.java | 13 ++ .../ui/factory/NoteUIProviderTests.java | 13 ++ .../factory/SketchStickyUIProviderTests.java | 13 ++ .../model/impl/DiagramModelObjectTests.java | 7 + 37 files changed, 600 insertions(+), 115 deletions(-) create mode 100644 com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/DiagramModelObjectLineStyleCommand.java delete mode 100644 com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineOpacitySection.java create mode 100644 com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineSection2.java create mode 100644 com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineStyleComposite.java diff --git a/com.archimatetool.canvas/src/com/archimatetool/canvas/factory/CanvasStickyUIProvider.java b/com.archimatetool.canvas/src/com/archimatetool/canvas/factory/CanvasStickyUIProvider.java index 576c56627..449117a3b 100644 --- a/com.archimatetool.canvas/src/com/archimatetool/canvas/factory/CanvasStickyUIProvider.java +++ b/com.archimatetool.canvas/src/com/archimatetool/canvas/factory/CanvasStickyUIProvider.java @@ -62,6 +62,7 @@ public ImageDescriptor getImageDescriptor() { public boolean shouldExposeFeature(String featureName) { if(featureName == IArchimatePackage.Literals.LINE_OBJECT__LINE_COLOR.getName() || featureName == IArchimatePackage.Literals.LINE_OBJECT__LINE_WIDTH.getName() || + featureName == IDiagramModelObject.FEATURE_LINE_STYLE || featureName == IDiagramModelObject.FEATURE_DERIVE_ELEMENT_LINE_COLOR || featureName == IDiagramModelObject.FEATURE_GRADIENT) { return false; diff --git a/com.archimatetool.canvas/src/com/archimatetool/canvas/figures/CanvasBlockFigure.java b/com.archimatetool.canvas/src/com/archimatetool/canvas/figures/CanvasBlockFigure.java index e2bb77d6e..b1ce6bb87 100644 --- a/com.archimatetool.canvas/src/com/archimatetool/canvas/figures/CanvasBlockFigure.java +++ b/com.archimatetool.canvas/src/com/archimatetool/canvas/figures/CanvasBlockFigure.java @@ -162,6 +162,8 @@ private void drawFigure(Graphics graphics, Color background) { // Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill setLineWidth(graphics, bounds); + setLineStyle(graphics); + graphics.setBackgroundColor(background); graphics.fillRectangle(bounds); diff --git a/com.archimatetool.editor/plugin.xml b/com.archimatetool.editor/plugin.xml index cbfd28d39..e12938c0c 100644 --- a/com.archimatetool.editor/plugin.xml +++ b/com.archimatetool.editor/plugin.xml @@ -431,13 +431,13 @@ = IDiagramModelObject.LINE_STYLE_SOLID && style <= IDiagramModelObject.LINE_STYLE_DOTTED; + } + + /** + * Get the default line style for the IDiagramModelObject + * This can be either IDiagramModelObject.LINE_STYLE_SOLID or IDiagramModelObject.LINE_STYLE_DASHED + */ + private static int getDefaultLineStyle(IDiagramModelObject dmo) { + return (int)ObjectUIFactory.INSTANCE.getProvider(dmo).getDefaultFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE); + } +} \ No newline at end of file diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/Messages.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/Messages.java index f9e4011f3..90aaddd5b 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/Messages.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/Messages.java @@ -43,6 +43,8 @@ public class Messages extends NLS { public static String DiagramModelObjectAlphaCommand_0; + public static String DiagramModelObjectLineStyleCommand_0; + public static String DiagramModelObjectOutlineAlphaCommand_0; public static String FillColorCommand_0; diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/messages.properties b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/messages.properties index acdfef599..c501673eb 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/messages.properties +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/messages.properties @@ -23,6 +23,7 @@ CreateDiagramObjectCommand_0=Create {0} DeleteBendpointCommand_0=Remove Bendpoint DiagramModelObjectAlphaCommand_0=Change Opacity +DiagramModelObjectLineStyleCommand_0=Change Line Style DiagramModelObjectOutlineAlphaCommand_0=Change Opacity FillColorCommand_0=Change Fill Colour diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigure.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigure.java index bd6db9993..00ba6d5fb 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigure.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractDiagramModelObjectFigure.java @@ -25,6 +25,7 @@ import com.archimatetool.editor.ui.FontFactory; import com.archimatetool.editor.ui.ImageFactory; import com.archimatetool.editor.ui.factory.IGraphicalObjectUIProvider; +import com.archimatetool.editor.ui.factory.IObjectUIProvider; import com.archimatetool.editor.ui.factory.ObjectUIFactory; import com.archimatetool.editor.utils.StringUtils; import com.archimatetool.model.IArchimateElement; @@ -142,6 +143,27 @@ protected void setDisabledState(Graphics graphics) { //graphics.setLineStyle(SWT.LINE_DASH); //graphics.setLineDash(new int[] { 4, 3 }); } + + /** + * Set the line style + * @param graphics + */ + protected void setLineStyle(Graphics graphics) { + double scale = Math.min(FigureUtils.getFigureScale(this), 1.0); // only scale below 1.0 + + switch(getLineStyle()) { + case IDiagramModelObject.LINE_STYLE_SOLID: + default: + graphics.setLineStyle(Graphics.LINE_SOLID); + break; + case IDiagramModelObject.LINE_STYLE_DASHED: + graphics.setLineDash(new float[] { (float)(8 * scale), (float)(4 * scale) }); + break; + case IDiagramModelObject.LINE_STYLE_DOTTED: + graphics.setLineDash(new float[] { (float)(2 * scale), (float)(4 * scale) }); + break; + } + } /** * Set the UI @@ -247,6 +269,11 @@ protected int getLineWidth() { return fDiagramModelObject.getLineWidth(); } + protected int getLineStyle() { + IObjectUIProvider provider = ObjectUIFactory.INSTANCE.getProvider(getDiagramModelObject()); + return provider != null && provider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE) instanceof Integer val ? val : IDiagramModelObject.LINE_STYLE_SOLID; + } + @Override public void updateIconImage() { if(getIconicDelegate() != null) { diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractFigureDelegate.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractFigureDelegate.java index 90b315c84..96dc34cf4 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractFigureDelegate.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/AbstractFigureDelegate.java @@ -129,6 +129,14 @@ protected void setLineWidth(Graphics graphics, int lineWidth, Rectangle bounds) getOwner().setLineWidth(graphics, lineWidth, bounds); } + /** + * Set line style + * @param graphics + */ + protected void setLineStyle(Graphics graphics) { + getOwner().setLineStyle(graphics); + } + /** * Apply a gradient to the given Graphics instance and bounds using current fill color, alpha and gradient settings */ diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/EllipseFigureDelegate.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/EllipseFigureDelegate.java index 7c7a0c1b3..9c91125ea 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/EllipseFigureDelegate.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/EllipseFigureDelegate.java @@ -34,6 +34,8 @@ public void drawFigure(Graphics graphics) { // Line Width setLineWidth(graphics, bounds); + setLineStyle(graphics); + graphics.setAlpha(getAlpha()); if(!isEnabled()) { diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/RectangleFigureDelegate.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/RectangleFigureDelegate.java index 48e101ae2..8217407cc 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/RectangleFigureDelegate.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/RectangleFigureDelegate.java @@ -33,6 +33,8 @@ public void drawFigure(Graphics graphics) { // Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill setLineWidth(graphics, bounds); + + setLineStyle(graphics); graphics.setAlpha(getAlpha()); diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/RoundedRectangleFigureDelegate.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/RoundedRectangleFigureDelegate.java index 5bfddb925..368276d99 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/RoundedRectangleFigureDelegate.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/RoundedRectangleFigureDelegate.java @@ -38,6 +38,8 @@ public void drawFigure(Graphics graphics) { // Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill setLineWidth(graphics, bounds); + + setLineStyle(graphics); graphics.setAlpha(getAlpha()); diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/DiagramImageFigure.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/DiagramImageFigure.java index 5e1671867..ea18e069e 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/DiagramImageFigure.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/DiagramImageFigure.java @@ -105,6 +105,8 @@ protected void paintFigure(Graphics graphics) { // Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill setLineWidth(graphics, bounds); + setLineStyle(graphics); + if(fImage != null) { // Faster but no transparency if(useScaledImage) { diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/GroupFigure.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/GroupFigure.java index 50cfd174c..88d134fdc 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/GroupFigure.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/GroupFigure.java @@ -57,6 +57,8 @@ protected void drawFigure(Graphics graphics) { // Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill setLineWidth(graphics, bounds); + setLineStyle(graphics); + graphics.setAlpha(getAlpha()); if(getDiagramModelObject().getBorderType() == IDiagramModelGroup.BORDER_TABBED) { diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/NoteFigure.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/NoteFigure.java index 56b54e9c0..72a236816 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/NoteFigure.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/NoteFigure.java @@ -116,6 +116,7 @@ protected void paintFigure(Graphics graphics) { // Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill if(getDiagramModelObject().getBorderType() != IDiagramModelNote.BORDER_NONE) { setLineWidth(graphics, bounds); + setLineStyle(graphics); } // Fill diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/elements/AbstractMotivationFigure.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/elements/AbstractMotivationFigure.java index cef3eb625..0d7f4071b 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/elements/AbstractMotivationFigure.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/elements/AbstractMotivationFigure.java @@ -44,6 +44,8 @@ protected void drawFigure(Graphics graphics) { // Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill setLineWidth(graphics, bounds); + + setLineStyle(graphics); PointList points = new PointList(); points.addPoint(bounds.x + FLANGE, bounds.y); diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/elements/GroupingFigure.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/elements/GroupingFigure.java index 5e8331980..ebd4c7787 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/elements/GroupingFigure.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/elements/GroupingFigure.java @@ -61,10 +61,7 @@ protected void drawFigure(Graphics graphics) { // Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill setLineWidth(graphics, bounds); - // Scale line dashes below 1.0 - double scale = Math.min(FigureUtils.getGraphicsScale(graphics), 1.0); - - graphics.setLineDash(new float[] { (float)(8 * scale), (float)(4 * scale) }); + setLineStyle(graphics); graphics.setBackgroundColor(getFillColor()); graphics.setForegroundColor(getLineColor()); diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/sketch/figures/StickyFigure.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/sketch/figures/StickyFigure.java index 2831535ed..66caf75d9 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/sketch/figures/StickyFigure.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/sketch/figures/StickyFigure.java @@ -50,6 +50,8 @@ protected void drawFigure(Graphics graphics) { // Set line width here so that the whole figure is constrained, otherwise SVG graphics will have overspill setLineWidth(graphics, bounds); + + setLineStyle(graphics); graphics.setBackgroundColor(getFillColor()); diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/tools/FormatPainterTool.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/tools/FormatPainterTool.java index 9f768a186..ccc662ed6 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/tools/FormatPainterTool.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/tools/FormatPainterTool.java @@ -19,6 +19,7 @@ import com.archimatetool.editor.diagram.commands.ConnectionLineTypeCommand; import com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand; import com.archimatetool.editor.diagram.commands.DiagramModelObjectAlphaCommand; +import com.archimatetool.editor.diagram.commands.DiagramModelObjectLineStyleCommand; import com.archimatetool.editor.diagram.commands.DiagramModelObjectOutlineAlphaCommand; import com.archimatetool.editor.diagram.commands.FillColorCommand; import com.archimatetool.editor.diagram.commands.FontColorCommand; @@ -112,6 +113,8 @@ CompoundCommand createCommand(IDiagramModelComponent targetComponent) { CompoundCommand result = new CompoundCommand(Messages.FormatPainterTool_0); IDiagramModelComponent sourceComponent = FormatPainterInfo.INSTANCE.getSourceComponent(); + + IObjectUIProvider sourceUIProvider = ObjectUIFactory.INSTANCE.getProvider(sourceComponent); IObjectUIProvider targetUIProvider = ObjectUIFactory.INSTANCE.getProvider(targetComponent); // IFontAttribute @@ -212,6 +215,14 @@ CompoundCommand createCommand(IDiagramModelComponent targetComponent) { result.add(cmd); } + // Line Style + if(targetUIProvider != null && sourceUIProvider != null && targetUIProvider.shouldExposeFeature(IDiagramModelObject.FEATURE_LINE_STYLE)) { + cmd = new DiagramModelObjectLineStyleCommand(target, (int)sourceUIProvider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE)); + if(cmd.canExecute()) { + result.add(cmd); + } + } + // Gradient if(targetUIProvider != null && targetUIProvider.shouldExposeFeature(IDiagramModelObject.FEATURE_GRADIENT)) { cmd = new FeatureCommand("", target, IDiagramModelObject.FEATURE_GRADIENT, source.getGradient(), IDiagramModelObject.FEATURE_GRADIENT_DEFAULT); //$NON-NLS-1$ diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineOpacitySection.java b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineOpacitySection.java deleted file mode 100644 index ac8fa424c..000000000 --- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineOpacitySection.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * This program and the accompanying materials - * are made available under the terms of the License - * which accompanies this distribution in the file LICENSE.txt - */ -package com.archimatetool.editor.propertysections; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.commands.Command; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.PlatformUI; - -import com.archimatetool.editor.diagram.commands.DiagramModelObjectOutlineAlphaCommand; -import com.archimatetool.model.IArchimatePackage; -import com.archimatetool.model.IDiagramModelObject; - - - -/** - * Property Section for Line Opacity - * - * @author Phillip Beauvoir - */ -public class LineOpacitySection extends AbstractECorePropertySection { - - private static final String HELP_ID = "com.archimatetool.help.elementPropertySection"; //$NON-NLS-1$ - - /** - * Filter to show or reject this section depending on input value - */ - public static class Filter extends ObjectFilter { - @Override - public boolean isRequiredType(Object object) { - return object instanceof IDiagramModelObject dmo && shouldExposeFeature(dmo, IDiagramModelObject.FEATURE_LINE_ALPHA); - } - - @Override - public Class getAdaptableType() { - return IDiagramModelObject.class; - } - } - - private OpacityComposite fOpacityComposite; - - @Override - protected void createControls(Composite parent) { - fOpacityComposite = new OpacityComposite(this, parent, Messages.LineOpacitySection_0) { - @Override - Command getCommand(IDiagramModelObject dmo, int newValue) { - return new DiagramModelObjectOutlineAlphaCommand(dmo, newValue); - } - - @Override - int getValue() { - IDiagramModelObject lastSelected = (IDiagramModelObject)getFirstSelectedObject(); - return lastSelected.getLineAlpha(); - } - - @Override - boolean isValidObject(EObject eObject) { - return getFilter().isRequiredType(eObject); - } - }; - - // Help ID - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID); - } - - @Override - protected void notifyChanged(Notification msg) { - Object feature = msg.getFeature(); - - if(isFeatureNotification(msg, IDiagramModelObject.FEATURE_LINE_ALPHA)) { - if(!fIsExecutingCommand) { - update(); - } - } - else if(feature == IArchimatePackage.Literals.LOCKABLE__LOCKED) { - update(); - } - } - - @Override - protected void update() { - fOpacityComposite.updateControl(); - } - - @Override - protected IObjectFilter getFilter() { - return new Filter(); - } - - @Override - public void dispose() { - super.dispose(); - - if(fOpacityComposite != null) { - fOpacityComposite.dispose(); - fOpacityComposite = null; - } - } -} diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineSection2.java b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineSection2.java new file mode 100644 index 000000000..72c801bb0 --- /dev/null +++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineSection2.java @@ -0,0 +1,155 @@ +/** + * This program and the accompanying materials + * are made available under the terms of the License + * which accompanies this distribution in the file LICENSE.txt + */ +package com.archimatetool.editor.propertysections; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.commands.Command; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.PlatformUI; + +import com.archimatetool.editor.diagram.commands.DiagramModelObjectOutlineAlphaCommand; +import com.archimatetool.model.IArchimatePackage; +import com.archimatetool.model.IDiagramModelObject; + + + +/** + * Property Section for Line Opacity and Line Style + * + * @author Phillip Beauvoir + */ +public class LineSection2 extends AbstractMultiControlSection { + + private static final String HELP_ID = "com.archimatetool.help.elementPropertySection"; //$NON-NLS-1$ + + /** + * Filter to show or reject this section depending on input value + */ + public static class Filter extends ObjectFilter { + @Override + public boolean isRequiredType(Object object) { + return object instanceof IDiagramModelObject dmo && + (shouldExposeFeature(dmo, IDiagramModelObject.FEATURE_LINE_ALPHA) || + shouldExposeFeature(dmo, IDiagramModelObject.FEATURE_LINE_STYLE)); + } + + @Override + public Class getAdaptableType() { + return IDiagramModelObject.class; + } + } + + private OpacityComposite opacityComposite; + private LineStyleComposite linestyleComposite; + + @Override + protected void createControls(Composite parent) { + init(parent, 2); + + // Help ID + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID); + } + + @Override + protected void notifyChanged(Notification msg) { + Object feature = msg.getFeature(); + + if(isFeatureNotification(msg, IDiagramModelObject.FEATURE_LINE_ALPHA)) { + if(!fIsExecutingCommand) { + updateOpacityControl(); + } + } + else if(isFeatureNotification(msg, IDiagramModelObject.FEATURE_LINE_STYLE)) { + updateLineStyleControl(); + } + else if(feature == IArchimatePackage.Literals.LOCKABLE__LOCKED) { + update(); + } + } + + @Override + protected void update() { + updateOpacityControl(); + updateLineStyleControl(); + } + + private void updateOpacityControl() { + boolean show = shouldShowControl(IDiagramModelObject.FEATURE_LINE_ALPHA); + + if(show) { + if(opacityComposite == null) { + opacityComposite = new OpacityComposite(this, parentComposite, Messages.LineOpacitySection_0) { + @Override + Command getCommand(IDiagramModelObject dmo, int newValue) { + return new DiagramModelObjectOutlineAlphaCommand(dmo, newValue); + } + + @Override + int getValue() { + IDiagramModelObject lastSelected = (IDiagramModelObject)getFirstSelectedObject(); + return lastSelected.getLineAlpha(); + } + + @Override + boolean isValidObject(EObject eObject) { + return getFilter().shouldExposeFeature(eObject, IDiagramModelObject.FEATURE_LINE_ALPHA); + } + }; + + // If we're showing the LineStyleComposite move the OpacityComposite above/before it + if(linestyleComposite != null) { + opacityComposite.getComposite().moveAbove(linestyleComposite.getComposite()); + layout(); + } + } + + opacityComposite.updateControl(); + } + else if(opacityComposite != null) { + opacityComposite.dispose(); + opacityComposite = null; + layout(); + } + } + + private void updateLineStyleControl() { + boolean show = shouldShowControl(IDiagramModelObject.FEATURE_LINE_STYLE); + + if(show) { + if(linestyleComposite == null) { + linestyleComposite = new LineStyleComposite(this, parentComposite); + layout(); + } + linestyleComposite.updateControl(); + } + else if(linestyleComposite != null) { + linestyleComposite.dispose(); + linestyleComposite = null; + layout(); + } + } + + @Override + protected IObjectFilter getFilter() { + return new Filter(); + } + + @Override + public void dispose() { + super.dispose(); + + if(opacityComposite != null) { + opacityComposite.dispose(); + opacityComposite = null; + } + + if(linestyleComposite != null) { + linestyleComposite.dispose(); + linestyleComposite = null; + } + } +} diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineStyleComposite.java b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineStyleComposite.java new file mode 100644 index 000000000..d667883b9 --- /dev/null +++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineStyleComposite.java @@ -0,0 +1,147 @@ +/** + * This program and the accompanying materials + * are made available under the terms of the License + * which accompanies this distribution in the file LICENSE.txt + */ +package com.archimatetool.editor.propertysections; + +import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.commands.CompoundCommand; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Menu; + +import com.archimatetool.editor.diagram.commands.DiagramModelObjectLineStyleCommand; +import com.archimatetool.editor.ui.IArchiImages; +import com.archimatetool.editor.ui.factory.ObjectUIFactory; +import com.archimatetool.model.IDiagramModelObject; + + + +/** + * Diagram Object Line Style Composite + * + * @author Phillip Beauvoir + */ +class LineStyleComposite { + + private Button button; + private AbstractECorePropertySection section; + private Composite composite; + + LineStyleComposite(AbstractECorePropertySection section, Composite parent) { + this.section = section; + composite = section.createComposite(parent, 2, false); + createControls(composite); + } + + Composite getComposite() { + return composite; + } + + private void createControls(Composite parent) { + section.createLabel(parent, Messages.LineStyleComposite_0, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER); + + button = section.getWidgetFactory().createButton(parent, null, SWT.PUSH); + button.setLayoutData(GridDataFactory.swtDefaults().hint(50, SWT.DEFAULT).create()); // a bit more width + + button.addSelectionListener(widgetSelectedAdapter(event -> { + MenuManager menuManager = new MenuManager(); + + menuManager.add(createAction(Messages.LineStyleComposite_1, IDiagramModelObject.LINE_STYLE_SOLID, IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.LINE_SOLID))); + menuManager.add(createAction(Messages.LineStyleComposite_2, IDiagramModelObject.LINE_STYLE_DASHED, IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.LINE_DASHED))); + menuManager.add(createAction(Messages.LineStyleComposite_3, IDiagramModelObject.LINE_STYLE_DOTTED, IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.LINE_DOTTED))); + + Menu menu = menuManager.createContextMenu(button.getShell()); + Rectangle buttonBounds = button.getBounds(); + Point p = button.getParent().toDisplay(buttonBounds.x, buttonBounds.y + buttonBounds.height); + menu.setLocation(p); + menu.setVisible(true); + })); + } + + private IAction createAction(String text, final int value, final ImageDescriptor imageDesc) { + IAction action = new Action(text, IAction.AS_RADIO_BUTTON) { + @Override + public void run() { + CompoundCommand result = new CompoundCommand(); + + for(EObject object : section.getEObjects()) { + if(isValidObject(object) && object instanceof IDiagramModelObject dmo) { + Command cmd = new DiagramModelObjectLineStyleCommand(dmo, value); + if(cmd.canExecute()) { + result.add(cmd); + } + } + } + + section.executeCommand(result.unwrap()); + } + + @Override + public ImageDescriptor getImageDescriptor() { + return imageDesc; + } + }; + + int lineStyle = getLineStyle((IDiagramModelObject)section.getFirstSelectedObject()); + action.setChecked(lineStyle == value); + + return action; + } + + /** + * In case of multi-selection we should check this + */ + private boolean isValidObject(EObject eObject) { + return section.isAlive(eObject) && + section.getFilter().shouldExposeFeature(eObject, IDiagramModelObject.FEATURE_LINE_STYLE); + } + + /** + * Get the actual line style for the IDiagramModelObject. + * If the value is IDiagramModelObject.LINE_STYLE_DEFAULT then the actual value will be + * either IDiagramModelObject.LINE_STYLE_SOLID or IDiagramModelObject.LINE_STYLE_DASHED + */ + private int getLineStyle(IDiagramModelObject dmo) { + return (int)ObjectUIFactory.INSTANCE.getProvider(dmo).getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE); + } + + void updateControl() { + IDiagramModelObject dmo = (IDiagramModelObject)section.getFirstSelectedObject(); + int lineStyle = getLineStyle(dmo); + + switch(lineStyle) { + case IDiagramModelObject.LINE_STYLE_SOLID: + default: + button.setImage(IArchiImages.ImageFactory.getImage(IArchiImages.LINE_SOLID)); + break; + case IDiagramModelObject.LINE_STYLE_DASHED: + button.setImage(IArchiImages.ImageFactory.getImage(IArchiImages.LINE_DASHED)); + break; + case IDiagramModelObject.LINE_STYLE_DOTTED: + button.setImage(IArchiImages.ImageFactory.getImage(IArchiImages.LINE_DOTTED)); + break; + } + + button.setEnabled(!section.isLocked(dmo)); + } + + void dispose() { + composite.dispose(); + composite = null; + section = null; + button = null; + } +} diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/Messages.java b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/Messages.java index 95db82883..5bffe4ff3 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/Messages.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/Messages.java @@ -247,6 +247,14 @@ public class Messages extends NLS { public static String LineOpacitySection_0; + public static String LineStyleComposite_0; + + public static String LineStyleComposite_1; + + public static String LineStyleComposite_2; + + public static String LineStyleComposite_3; + public static String LineWidthSection_0; public static String LineWidthSection_1; diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/messages.properties b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/messages.properties index be1c21a9d..a57e9620d 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/messages.properties +++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/messages.properties @@ -129,6 +129,10 @@ LineColorSection_2=Enable in Preferences LineColorSection_3=Derive from fill colour LineColorSection_4=Derive line colour LineOpacitySection_0=Line Opacity: +LineStyleComposite_0=Line Style: +LineStyleComposite_1=Solid +LineStyleComposite_2=Dashed +LineStyleComposite_3=Dotted LineWidthSection_0=Line Width: LineWidthSection_1=Normal LineWidthSection_2=Medium diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/AbstractGraphicalObjectUIProvider.java b/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/AbstractGraphicalObjectUIProvider.java index b7ebe3556..22e47f3ae 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/AbstractGraphicalObjectUIProvider.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/AbstractGraphicalObjectUIProvider.java @@ -8,6 +8,7 @@ import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.swt.graphics.Color; +import com.archimatetool.model.IDiagramModelObject; import com.archimatetool.model.ITextAlignment; import com.archimatetool.model.ITextPosition; @@ -54,4 +55,23 @@ public int getDefaultTextPosition() { public boolean hasIcon() { return false; } + + @Override + public Object getDefaultFeatureValue(String featureName) { + if(IDiagramModelObject.FEATURE_LINE_STYLE.equals(featureName)) { + return IDiagramModelObject.LINE_STYLE_SOLID; + } + + return super.getDefaultFeatureValue(featureName); + } + + @Override + public Object getFeatureValue(String featureName) { + if(IDiagramModelObject.FEATURE_LINE_STYLE.equals(featureName) && instance instanceof IDiagramModelObject dmo) { + int value = dmo.getLineStyle(); + return (value == IDiagramModelObject.LINE_STYLE_DEFAULT) ? getDefaultFeatureValue(featureName) : value; + } + + return super.getFeatureValue(featureName); + } } diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/diagram/DiagramImageUIProvider.java b/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/diagram/DiagramImageUIProvider.java index b1823924f..c7ac2cda4 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/diagram/DiagramImageUIProvider.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/diagram/DiagramImageUIProvider.java @@ -67,7 +67,8 @@ public boolean shouldExposeFeature(String featureName) { return featureName == IArchimatePackage.Literals.BORDER_OBJECT__BORDER_COLOR.getName() || featureName == IArchimatePackage.Literals.LINE_OBJECT__LINE_WIDTH.getName() || featureName == IArchimatePackage.Literals.DIAGRAM_MODEL_OBJECT__ALPHA.getName() - || featureName == IDiagramModelObject.FEATURE_LINE_ALPHA; + || featureName == IDiagramModelObject.FEATURE_LINE_ALPHA + || featureName == IDiagramModelObject.FEATURE_LINE_STYLE; } } diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/elements/GroupingUIProvider.java b/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/elements/GroupingUIProvider.java index bd9805568..4840779f0 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/elements/GroupingUIProvider.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/elements/GroupingUIProvider.java @@ -16,6 +16,7 @@ import com.archimatetool.editor.diagram.figures.elements.GroupingFigure; import com.archimatetool.editor.ui.IArchiImages; import com.archimatetool.model.IArchimatePackage; +import com.archimatetool.model.IDiagramModelObject; import com.archimatetool.model.ITextAlignment; import com.archimatetool.model.ITextPosition; @@ -74,4 +75,13 @@ public int getDefaultTextAlignment() { public int getDefaultTextPosition() { return ITextPosition.TEXT_POSITION_TOP; } + + @Override + public Object getDefaultFeatureValue(String featureName) { + if(IDiagramModelObject.FEATURE_LINE_STYLE.equals(featureName)) { + return IDiagramModelObject.LINE_STYLE_DASHED; + } + + return super.getDefaultFeatureValue(featureName); + } } diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/sketch/SketchActorUIProvider.java b/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/sketch/SketchActorUIProvider.java index 0ad30e4d5..b7bbe6cfa 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/sketch/SketchActorUIProvider.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/sketch/SketchActorUIProvider.java @@ -70,7 +70,8 @@ public boolean shouldExposeFeature(String featureName) { featureName == IDiagramModelObject.FEATURE_DERIVE_ELEMENT_LINE_COLOR || featureName == IDiagramModelObject.FEATURE_LINE_ALPHA || featureName == IArchimatePackage.Literals.DIAGRAM_MODEL_OBJECT__ALPHA.getName() || - featureName == IDiagramModelObject.FEATURE_GRADIENT) { + featureName == IDiagramModelObject.FEATURE_GRADIENT || + featureName == IDiagramModelObject.FEATURE_LINE_STYLE) { return false; } diff --git a/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelObject.java b/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelObject.java index f421d000e..7fe8b5dc4 100644 --- a/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelObject.java +++ b/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelObject.java @@ -45,6 +45,13 @@ public interface IDiagramModelObject extends IConnectable, IFontAttribute, ILine String FEATURE_DERIVE_ELEMENT_LINE_COLOR = "deriveElementLineColor"; boolean FEATURE_DERIVE_ELEMENT_LINE_COLOR_DEFAULT = true; + String FEATURE_LINE_STYLE = "lineStyle"; + int LINE_STYLE_DEFAULT = -1; + int LINE_STYLE_SOLID = 0; + int LINE_STYLE_DASHED = 1; + int LINE_STYLE_DOTTED = 2; + int FEATURE_LINE_STYLE_DEFAULT = LINE_STYLE_DEFAULT; + /** * @return the value of FEATURE_LINE_ALPHA */ @@ -100,6 +107,17 @@ public interface IDiagramModelObject extends IConnectable, IFontAttribute, ILine */ void setDeriveElementLineColor(boolean value); + /** + * @return the value of feature FEATURE_LINE_STYLE + */ + int getLineStyle(); + + /** + * Set the value of feature FEATURE_LINE_STYLE + * @param lineStyle + */ + void setLineStyle(int lineStyle); + /** * Returns the value of the 'Bounds' containment reference. * diff --git a/com.archimatetool.model/src/com/archimatetool/model/impl/DiagramModelObject.java b/com.archimatetool.model/src/com/archimatetool/model/impl/DiagramModelObject.java index cbf6d6183..c317a0d84 100644 --- a/com.archimatetool.model/src/com/archimatetool/model/impl/DiagramModelObject.java +++ b/com.archimatetool.model/src/com/archimatetool/model/impl/DiagramModelObject.java @@ -261,6 +261,16 @@ public void setDeriveElementLineColor(boolean value) { getFeatures().putBoolean(FEATURE_DERIVE_ELEMENT_LINE_COLOR, value, FEATURE_DERIVE_ELEMENT_LINE_COLOR_DEFAULT); } + @Override + public int getLineStyle() { + return getFeatures().getInt(FEATURE_LINE_STYLE, FEATURE_LINE_STYLE_DEFAULT); + } + + @Override + public void setLineStyle(int lineStyle) { + getFeatures().putInt(FEATURE_LINE_STYLE, lineStyle, FEATURE_LINE_STYLE_DEFAULT); + } + /** * * diff --git a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/AbstractGraphicalObjectUIProviderTests.java b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/AbstractGraphicalObjectUIProviderTests.java index 289202a17..7cdd0bfea 100644 --- a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/AbstractGraphicalObjectUIProviderTests.java +++ b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/AbstractGraphicalObjectUIProviderTests.java @@ -12,6 +12,7 @@ import org.eclipse.swt.graphics.Color; import com.archimatetool.editor.ParamsTest; +import com.archimatetool.model.IDiagramModelObject; import com.archimatetool.model.ITextAlignment; import com.archimatetool.model.ITextPosition; @@ -46,4 +47,11 @@ public void testGetDefaultTextPosition(IGraphicalObjectUIProvider provider) { assertEquals(ITextPosition.TEXT_POSITION_TOP, provider.getDefaultTextPosition()); } + @Override + @ParamsTest + public void testGetDefaultFeatureValue(IObjectUIProvider provider) { + super.testGetDefaultFeatureValue(provider); + assertEquals(IDiagramModelObject.LINE_STYLE_SOLID, provider.getDefaultFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE)); + } + } diff --git a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/AllArchiMateElementUIProviderTests.java b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/AllArchiMateElementUIProviderTests.java index d8777aace..df91ec957 100644 --- a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/AllArchiMateElementUIProviderTests.java +++ b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/AllArchiMateElementUIProviderTests.java @@ -78,7 +78,11 @@ import com.archimatetool.editor.ui.factory.elements.ValueStreamUIProvider; import com.archimatetool.editor.ui.factory.elements.ValueUIProvider; import com.archimatetool.editor.ui.factory.elements.WorkPackageUIProvider; +import com.archimatetool.model.IArchimateElement; +import com.archimatetool.model.IArchimateFactory; import com.archimatetool.model.IArchimatePackage; +import com.archimatetool.model.IDiagramModelArchimateObject; +import com.archimatetool.model.IDiagramModelObject; import com.archimatetool.model.ITextAlignment; public class AllArchiMateElementUIProviderTests extends AbstractGraphicalObjectUIProviderTests { @@ -213,4 +217,32 @@ public void testGetDefaultTextAlignment(IGraphicalObjectUIProvider provider) { super.testGetDefaultTextAlignment(provider); } } + + @Override + @ParamsTest + public void testGetDefaultFeatureValue(IObjectUIProvider provider) { + if(provider instanceof GroupingUIProvider) { + assertEquals(IDiagramModelObject.LINE_STYLE_DASHED, provider.getDefaultFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE)); + } + else { + super.testGetDefaultFeatureValue(provider); + } + } + + @Override + @ParamsTest + public void testGetFeatureValue(IObjectUIProvider provider) { + super.testGetFeatureValue(provider); + + IDiagramModelArchimateObject dmo = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject(); + dmo.setArchimateElement((IArchimateElement)IArchimateFactory.eINSTANCE.create(provider.providerFor())); + ((AbstractObjectUIProvider)provider).setInstance(dmo); + + if(provider instanceof GroupingUIProvider) { + assertEquals(IDiagramModelObject.LINE_STYLE_DASHED, provider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE)); + } + else { + assertEquals(IDiagramModelObject.LINE_STYLE_SOLID, provider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE)); + } + } } diff --git a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/DiagramModelImageUIProviderTests.java b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/DiagramModelImageUIProviderTests.java index 6ac94d85a..a8095c9ae 100644 --- a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/DiagramModelImageUIProviderTests.java +++ b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/DiagramModelImageUIProviderTests.java @@ -18,7 +18,10 @@ import com.archimatetool.editor.ParamsTest; import com.archimatetool.editor.diagram.editparts.diagram.DiagramImageEditPart; import com.archimatetool.editor.ui.factory.diagram.DiagramImageUIProvider; +import com.archimatetool.model.IArchimateFactory; import com.archimatetool.model.IArchimatePackage; +import com.archimatetool.model.IDiagramModelImage; +import com.archimatetool.model.IDiagramModelObject; public class DiagramModelImageUIProviderTests extends AbstractGraphicalObjectUIProviderTests { @@ -47,4 +50,15 @@ public void testShouldExposeFeature(IObjectUIProvider provider) { assertTrue(provider.shouldExposeFeature(IArchimatePackage.Literals.BORDER_OBJECT__BORDER_COLOR.getName())); assertFalse(provider.shouldExposeFeature((String)null)); } + + @Override + @ParamsTest + public void testGetFeatureValue(IObjectUIProvider provider) { + super.testGetFeatureValue(provider); + IDiagramModelImage dmi = IArchimateFactory.eINSTANCE.createDiagramModelImage(); + ((AbstractObjectUIProvider)provider).setInstance(dmi); + + assertEquals(IDiagramModelObject.LINE_STYLE_SOLID, provider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE)); + } + } diff --git a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/DiagramModelReferenceUIProviderTests.java b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/DiagramModelReferenceUIProviderTests.java index ae7d6b7aa..e459fb7b8 100644 --- a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/DiagramModelReferenceUIProviderTests.java +++ b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/DiagramModelReferenceUIProviderTests.java @@ -23,6 +23,7 @@ import com.archimatetool.editor.ui.factory.diagram.DiagramModelReferenceUIProvider; import com.archimatetool.model.IArchimateFactory; import com.archimatetool.model.IArchimatePackage; +import com.archimatetool.model.IDiagramModelObject; import com.archimatetool.model.IDiagramModelReference; public class DiagramModelReferenceUIProviderTests extends AbstractGraphicalObjectUIProviderTests { @@ -73,4 +74,13 @@ public void testHasIcon(IGraphicalObjectUIProvider provider) { assertTrue(provider.hasIcon()); } + @Override + @ParamsTest + public void testGetFeatureValue(IObjectUIProvider provider) { + super.testGetFeatureValue(provider); + IDiagramModelReference ref = IArchimateFactory.eINSTANCE.createDiagramModelReference(); + ((AbstractObjectUIProvider)provider).setInstance(ref); + + assertEquals(IDiagramModelObject.LINE_STYLE_SOLID, provider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE)); + } } diff --git a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/GroupUIProviderTests.java b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/GroupUIProviderTests.java index a9660462c..ada21869b 100644 --- a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/GroupUIProviderTests.java +++ b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/GroupUIProviderTests.java @@ -18,7 +18,10 @@ import com.archimatetool.editor.ParamsTest; import com.archimatetool.editor.diagram.editparts.diagram.GroupEditPart; import com.archimatetool.editor.ui.factory.diagram.GroupUIProvider; +import com.archimatetool.model.IArchimateFactory; import com.archimatetool.model.IArchimatePackage; +import com.archimatetool.model.IDiagramModelGroup; +import com.archimatetool.model.IDiagramModelObject; import com.archimatetool.model.ITextAlignment; public class GroupUIProviderTests extends AbstractGraphicalObjectUIProviderTests { @@ -61,4 +64,14 @@ public void testGetDefaultTextAlignment(IGraphicalObjectUIProvider provider) { assertEquals(ITextAlignment.TEXT_ALIGNMENT_LEFT, provider.getDefaultTextAlignment()); } + @Override + @ParamsTest + public void testGetFeatureValue(IObjectUIProvider provider) { + super.testGetFeatureValue(provider); + IDiagramModelGroup group = IArchimateFactory.eINSTANCE.createDiagramModelGroup(); + ((AbstractObjectUIProvider)provider).setInstance(group); + + assertEquals(IDiagramModelObject.LINE_STYLE_SOLID, provider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE)); + } + } diff --git a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/NoteUIProviderTests.java b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/NoteUIProviderTests.java index 63345ad13..9428407d8 100644 --- a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/NoteUIProviderTests.java +++ b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/NoteUIProviderTests.java @@ -17,7 +17,10 @@ import com.archimatetool.editor.ParamsTest; import com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart; import com.archimatetool.editor.ui.factory.diagram.NoteUIProvider; +import com.archimatetool.model.IArchimateFactory; import com.archimatetool.model.IArchimatePackage; +import com.archimatetool.model.IDiagramModelNote; +import com.archimatetool.model.IDiagramModelObject; import com.archimatetool.model.ITextAlignment; public class NoteUIProviderTests extends AbstractGraphicalObjectUIProviderTests { @@ -46,4 +49,14 @@ public void testGetDefaultSize(IGraphicalObjectUIProvider provider) { public void testGetDefaultTextAlignment(IGraphicalObjectUIProvider provider) { assertEquals(ITextAlignment.TEXT_ALIGNMENT_LEFT, provider.getDefaultTextAlignment()); } + + @Override + @ParamsTest + public void testGetFeatureValue(IObjectUIProvider provider) { + super.testGetFeatureValue(provider); + IDiagramModelNote note = IArchimateFactory.eINSTANCE.createDiagramModelNote(); + ((AbstractObjectUIProvider)provider).setInstance(note); + + assertEquals(IDiagramModelObject.LINE_STYLE_SOLID, provider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE)); + } } diff --git a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/SketchStickyUIProviderTests.java b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/SketchStickyUIProviderTests.java index 3509c4d9f..fe0b7a1a4 100644 --- a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/SketchStickyUIProviderTests.java +++ b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/SketchStickyUIProviderTests.java @@ -17,7 +17,10 @@ import com.archimatetool.editor.ParamsTest; import com.archimatetool.editor.diagram.sketch.editparts.StickyEditPart; import com.archimatetool.editor.ui.factory.sketch.SketchStickyUIProvider; +import com.archimatetool.model.IArchimateFactory; import com.archimatetool.model.IArchimatePackage; +import com.archimatetool.model.IDiagramModelObject; +import com.archimatetool.model.ISketchModelSticky; import com.archimatetool.model.ITextAlignment; public class SketchStickyUIProviderTests extends AbstractGraphicalObjectUIProviderTests { @@ -46,4 +49,14 @@ public void testGetDefaultSize(IGraphicalObjectUIProvider provider) { public void testGetDefaultTextAlignment(IGraphicalObjectUIProvider provider) { assertEquals(ITextAlignment.TEXT_ALIGNMENT_LEFT, provider.getDefaultTextAlignment()); } + + @Override + @ParamsTest + public void testGetFeatureValue(IObjectUIProvider provider) { + super.testGetFeatureValue(provider); + ISketchModelSticky sticky = IArchimateFactory.eINSTANCE.createSketchModelSticky(); + ((AbstractObjectUIProvider)provider).setInstance(sticky); + + assertEquals(IDiagramModelObject.LINE_STYLE_SOLID, provider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE)); + } } diff --git a/tests/com.archimatetool.model.tests/src/com/archimatetool/model/impl/DiagramModelObjectTests.java b/tests/com.archimatetool.model.tests/src/com/archimatetool/model/impl/DiagramModelObjectTests.java index 08867a184..8791c845b 100644 --- a/tests/com.archimatetool.model.tests/src/com/archimatetool/model/impl/DiagramModelObjectTests.java +++ b/tests/com.archimatetool.model.tests/src/com/archimatetool/model/impl/DiagramModelObjectTests.java @@ -159,6 +159,13 @@ public void testGetLineColor() { assertEquals("#ffffff", object.getLineColor()); } + @Test + public void testGetLineStyle() { + assertEquals(IDiagramModelObject.LINE_STYLE_DEFAULT, object.getLineStyle()); + object.setLineStyle(IDiagramModelObject.LINE_STYLE_SOLID); + assertEquals(IDiagramModelObject.LINE_STYLE_SOLID, object.getLineStyle()); + } + @Test public void testAddConnection_Null_ThrowsException() { assertThrows(IllegalArgumentException.class, () -> {