From 9aa6f6c9ca99c0f3d101c23e507e90fe0e6907db Mon Sep 17 00:00:00 2001
From: Phillipus
Date: Sat, 2 Nov 2024 14:18:20 +0000
Subject: [PATCH] Support Line Style on diagram objects
---
.../factory/CanvasStickyUIProvider.java | 1 +
.../canvas/figures/CanvasBlockFigure.java | 2 +
com.archimatetool.editor/plugin.xml | 12 +-
.../diagram/ArchimateDiagramModelFactory.java | 5 +-
.../DiagramModelObjectLineStyleCommand.java | 23 +++
.../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 | 12 ++
.../propertysections/LineOpacitySection.java | 103 ------------
.../editor/propertysections/LineSection2.java | 155 ++++++++++++++++++
.../propertysections/LineStyleComposite.java | 150 +++++++++++++++++
.../AbstractGraphicalObjectUIProvider.java | 20 +++
.../editor/ui/factory/IObjectUIProvider.java | 18 +-
.../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 +
.../AbstractObjectUIProviderTests.java | 10 ++
.../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 +
36 files changed, 603 insertions(+), 117 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 @@
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..08fb47e58
--- /dev/null
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineStyleComposite.java
@@ -0,0 +1,150 @@
+/**
+ * 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.IObjectUIProvider;
+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, "Line Style:", 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("Solid", IDiagramModelObject.LINE_STYLE_SOLID, IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.LINE_SOLID)));
+ menuManager.add(createAction("Dashed", IDiagramModelObject.LINE_STYLE_DASHED, IArchiImages.ImageFactory.getImageDescriptor(IArchiImages.LINE_DASHED)));
+ menuManager.add(createAction("Dotted", 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)) {
+ IDiagramModelObject dmo = (IDiagramModelObject)object;
+ Command cmd = new DiagramModelObjectLineStyleCommand(dmo, value, getDefaultLineStyle(dmo));
+ if(cmd.canExecute()) {
+ result.add(cmd);
+ }
+ }
+ }
+
+ section.executeCommand(result.unwrap());
+ }
+
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return imageDesc;
+ }
+ };
+
+ int lineStyle = getActualLineStyle((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);
+ }
+
+ private int getActualLineStyle(IDiagramModelObject dmo) {
+ IObjectUIProvider provider = ObjectUIFactory.INSTANCE.getProvider(dmo);
+ return provider != null && provider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE) instanceof Integer val ? val : IDiagramModelObject.LINE_STYLE_SOLID;
+ }
+
+ private int getDefaultLineStyle(IDiagramModelObject dmo) {
+ IObjectUIProvider provider = ObjectUIFactory.INSTANCE.getProvider(dmo);
+ return provider != null && provider.getDefaultFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE) instanceof Integer val ? val : IDiagramModelObject.LINE_STYLE_SOLID;
+ }
+
+ void updateControl() {
+ IDiagramModelObject dmo = (IDiagramModelObject)section.getFirstSelectedObject();
+ int lineStyle = getActualLineStyle(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/ui/factory/AbstractGraphicalObjectUIProvider.java b/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/AbstractGraphicalObjectUIProvider.java
index 046222988..857b44210 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;
@@ -62,4 +63,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/IObjectUIProvider.java b/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/IObjectUIProvider.java
index db665d178..f9da03f88 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/IObjectUIProvider.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/ui/factory/IObjectUIProvider.java
@@ -54,8 +54,24 @@ public interface IObjectUIProvider {
boolean shouldExposeFeature(EAttribute feature);
/**
- * @param feature The feature in question
+ * @param featureName The feature in question
* @return True if this object should expose a feature in the UI
*/
boolean shouldExposeFeature(String featureName);
+
+ /**
+ * @param featureName The feature in question
+ * @return a default value for a given feature. Default is null
+ */
+ default Object getDefaultFeatureValue(String featureName) {
+ return null;
+ }
+
+ /**
+ * @param featureName The feature in question
+ * @return a value for a given feature. Default is null
+ */
+ default Object getFeatureValue(String featureName) {
+ return null;
+ }
}
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/AbstractObjectUIProviderTests.java b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/AbstractObjectUIProviderTests.java
index c07914baf..b686c8854 100644
--- a/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/AbstractObjectUIProviderTests.java
+++ b/tests/com.archimatetool.editor.tests/src/com/archimatetool/editor/ui/factory/AbstractObjectUIProviderTests.java
@@ -7,6 +7,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.eclipse.emf.ecore.EClass;
@@ -82,7 +83,16 @@ public void testShouldExposeFeature(IObjectUIProvider provider) {
assertTrue(provider.shouldExposeFeature((String)null));
}
+ @ParamsTest
+ public void testGetDefaultFeatureValue(IObjectUIProvider provider) {
+ assertNull(provider.getDefaultFeatureValue((String)null));
+ }
+ @ParamsTest
+ public void testGetFeatureValue(IObjectUIProvider provider) {
+ assertNull(provider.getFeatureValue((String)null));
+ }
+
protected EObject createInstanceForExpectedClass(EClass expectedClass) {
return expectedClass.getEPackage().getEFactoryInstance().create(expectedClass);
}
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, () -> {