diff --git a/com.archimatetool.editor/plugin.xml b/com.archimatetool.editor/plugin.xml index fa115ab68..e12938c0c 100644 --- a/com.archimatetool.editor/plugin.xml +++ b/com.archimatetool.editor/plugin.xml @@ -1339,10 +1339,6 @@ class="com.archimatetool.editor.model.compatibility.handlers.Archimate32Handler" id="com.archimatetool.editor.compatibility.archimate32converter"> - - diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/ArchimateDiagramModelFactory.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/ArchimateDiagramModelFactory.java index 556e0be52..7e5b53ea9 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/ArchimateDiagramModelFactory.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/ArchimateDiagramModelFactory.java @@ -68,11 +68,6 @@ public static IDiagramModelArchimateObject createDiagramModelArchimateObject(IAr // Gradient dmo.setGradient(ArchiPlugin.PREFERENCES.getInt(IPreferenceConstants.DEFAULT_GRADIENT)); - // Line Style for Grouping - if(element instanceof Grouping) { - dmo.setLineStyle(IDiagramModelObject.LINE_STYLE_DASHED); - } - return dmo; } @@ -86,8 +81,6 @@ public static IDiagramModelArchimateConnection createDiagramModelArchimateConnec connection.setArchimateRelationship(relation); IGraphicalObjectUIProvider provider = (IGraphicalObjectUIProvider)ObjectUIFactory.INSTANCE.getProvider(connection); - - // Text alignment connection.setTextAlignment(provider.getDefaultTextAlignment()); // Set user default colors as set in prefs @@ -123,58 +116,63 @@ public Object getNewObject() { return null; } - boolean isSpecialization = fProfile != null && fProfile.getArchimateModel() != null; + boolean isSpecialization = fProfile != null && fProfile.getArchimateModel() != null; EObject object = IArchimateFactory.eINSTANCE.create(fTemplate); // Add Profile to Concept if set - if(object instanceof IArchimateConcept concept && isSpecialization) { - concept.getProfiles().add(fProfile); + if(object instanceof IArchimateConcept && isSpecialization) { + ((IArchimateConcept)object).getProfiles().add(fProfile); } - // Archimate Connection created from Relationship Template - if(object instanceof IArchimateRelationship relationship) { - return createDiagramModelArchimateConnection(relationship); + // Connection created from Relationship Template + if(object instanceof IArchimateRelationship) { + return createDiagramModelArchimateConnection((IArchimateRelationship)object); } // Archimate Diagram Object created from Archimate Element Template - else if(object instanceof IArchimateElement element) { + else if(object instanceof IArchimateElement) { + IArchimateElement element = (IArchimateElement)object; element.setName(isSpecialization ? fProfile.getName() : ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate)); return createDiagramModelArchimateObject(element); } // Group - else if(object instanceof IDiagramModelGroup group) { + else if(object instanceof IDiagramModelGroup) { + IDiagramModelGroup group = (IDiagramModelGroup)object; group.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate)); ColorFactory.setDefaultColors(group); + // Gradient group.setGradient(ArchiPlugin.PREFERENCES.getInt(IPreferenceConstants.DEFAULT_GRADIENT)); } // Note - else if(object instanceof IDiagramModelNote note) { + else if(object instanceof IDiagramModelNote) { + IDiagramModelNote note = (IDiagramModelNote)object; ColorFactory.setDefaultColors(note); + // Gradient note.setGradient(ArchiPlugin.PREFERENCES.getInt(IPreferenceConstants.DEFAULT_GRADIENT)); } // Connection - else if(object instanceof IDiagramModelConnection connection) { - ColorFactory.setDefaultColors(connection); + else if(object instanceof IDiagramModelConnection) { + ColorFactory.setDefaultColors((IDiagramModelConnection)object); } IGraphicalObjectUIProvider provider = (IGraphicalObjectUIProvider)ObjectUIFactory.INSTANCE.getProvider(object); - if(object instanceof ITextAlignment textAlignment) { - textAlignment.setTextAlignment(provider.getDefaultTextAlignment()); + if(object instanceof ITextAlignment) { + ((ITextAlignment)object).setTextAlignment(provider.getDefaultTextAlignment()); } - if(object instanceof ITextPosition textPosition) { - textPosition.setTextPosition(provider.getDefaultTextPosition()); + if(object instanceof ITextPosition) { + ((ITextPosition)object).setTextPosition(provider.getDefaultTextPosition()); } // Add new bounds with a default user size - if(object instanceof IDiagramModelObject dmo) { + if(object instanceof IDiagramModelObject) { Dimension size = provider.getDefaultSize(); - dmo.setBounds(0, 0, size.width, size.height); + ((IDiagramModelObject)object).setBounds(0, 0, size.width, size.height); } return object; diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/DiagramModelObjectLineStyleCommand.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/DiagramModelObjectLineStyleCommand.java index 44c879036..c57eb5b25 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/DiagramModelObjectLineStyleCommand.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/DiagramModelObjectLineStyleCommand.java @@ -17,8 +17,7 @@ */ public class DiagramModelObjectLineStyleCommand extends FeatureCommand { - public DiagramModelObjectLineStyleCommand(IDiagramModelObject object, int style) { - super("Change Line Style", object, - IDiagramModelObject.FEATURE_LINE_STYLE, style, IDiagramModelObject.FEATURE_LINE_STYLE_DEFAULT); + public DiagramModelObjectLineStyleCommand(IDiagramModelObject object, int style, int defaultValue) { + super("Change Line Style", object, IDiagramModelObject.FEATURE_LINE_STYLE, style, defaultValue); } } \ No newline at end of file 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 a1a94d4a9..f2910c4cd 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; @@ -269,7 +270,8 @@ protected int getLineWidth() { } protected int getLineStyle() { - return fDiagramModelObject.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 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 a2d7e2b74..6ef3ddcf2 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 @@ -213,8 +216,9 @@ CompoundCommand createCommand(IDiagramModelComponent targetComponent) { } // Line Style - if(targetUIProvider != null && targetUIProvider.shouldExposeFeature(IDiagramModelObject.FEATURE_LINE_STYLE)) { - cmd = new FeatureCommand("", target, IDiagramModelObject.FEATURE_LINE_STYLE, source.getLineStyle(), IDiagramModelObject.FEATURE_LINE_STYLE_DEFAULT); //$NON-NLS-1$ + if(targetUIProvider != null && sourceUIProvider != null && targetUIProvider.shouldExposeFeature(IDiagramModelObject.FEATURE_LINE_STYLE)) { + cmd = new DiagramModelObjectLineStyleCommand(target, (int)sourceUIProvider.getFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE), + (int)targetUIProvider.getDefaultFeatureValue(IDiagramModelObject.FEATURE_LINE_STYLE)); if(cmd.canExecute()) { result.add(cmd); } diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/model/compatibility/handlers/LineStyleHandler.java b/com.archimatetool.editor/src/com/archimatetool/editor/model/compatibility/handlers/LineStyleHandler.java deleted file mode 100644 index 6d794cfd5..000000000 --- a/com.archimatetool.editor/src/com/archimatetool/editor/model/compatibility/handlers/LineStyleHandler.java +++ /dev/null @@ -1,52 +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.model.compatibility.handlers; - -import java.util.Iterator; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; - -import com.archimatetool.editor.model.compatibility.CompatibilityHandlerException; -import com.archimatetool.editor.model.compatibility.ICompatibilityHandler; -import com.archimatetool.editor.utils.StringUtils; -import com.archimatetool.model.IArchimateModel; -import com.archimatetool.model.IDiagramModelArchimateObject; -import com.archimatetool.model.IDiagramModelObject; -import com.archimatetool.model.IGrouping; - - - -/** - * Convert Grouping line styles to dashed < 5.0.1 - * - * @author Phillip Beauvoir - */ -public class LineStyleHandler implements ICompatibilityHandler { - - @Override - public void fixCompatibility(Resource resource) throws CompatibilityHandlerException { - IArchimateModel model = (IArchimateModel)resource.getContents().get(0); - - if(isVersion(model)) { - setLineStyle(model); - } - } - - private boolean isVersion(IArchimateModel model) { - String version = model.getVersion(); - return version != null && StringUtils.compareVersionNumbers(version, "5.0.1") < 0; //$NON-NLS-1$ - } - - private void setLineStyle(IArchimateModel model) { - for(Iterator iter = model.eAllContents(); iter.hasNext();) { - EObject eObject = iter.next(); - if(eObject instanceof IDiagramModelArchimateObject dmo && dmo.getArchimateConcept() instanceof IGrouping) { - dmo.setLineStyle(IDiagramModelObject.LINE_STYLE_DASHED); - } - } - } -} diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineStyleComposite.java b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineStyleComposite.java index 24b38c09b..08fb47e58 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineStyleComposite.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/LineStyleComposite.java @@ -24,6 +24,8 @@ 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; @@ -78,7 +80,8 @@ public void run() { for(EObject object : section.getEObjects()) { if(isValidObject(object)) { - Command cmd = new DiagramModelObjectLineStyleCommand((IDiagramModelObject)object, value); + IDiagramModelObject dmo = (IDiagramModelObject)object; + Command cmd = new DiagramModelObjectLineStyleCommand(dmo, value, getDefaultLineStyle(dmo)); if(cmd.canExecute()) { result.add(cmd); } @@ -94,7 +97,8 @@ public ImageDescriptor getImageDescriptor() { } }; - action.setChecked(((IDiagramModelObject)section.getFirstSelectedObject()).getLineStyle() == value); + int lineStyle = getActualLineStyle((IDiagramModelObject)section.getFirstSelectedObject()); + action.setChecked(lineStyle == value); return action; } @@ -107,9 +111,19 @@ private boolean isValidObject(EObject 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 = dmo.getLineStyle(); + int lineStyle = getActualLineStyle(dmo); switch(lineStyle) { case IDiagramModelObject.LINE_STYLE_SOLID: 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/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.model/src/com/archimatetool/model/IDiagramModelObject.java b/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelObject.java index 4cbdaebdc..7fe8b5dc4 100644 --- a/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelObject.java +++ b/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelObject.java @@ -46,10 +46,11 @@ public interface IDiagramModelObject extends IConnectable, IFontAttribute, ILine boolean FEATURE_DERIVE_ELEMENT_LINE_COLOR_DEFAULT = true; String FEATURE_LINE_STYLE = "lineStyle"; - int FEATURE_LINE_STYLE_DEFAULT = 0; + 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 diff --git a/com.archimatetool.model/src/com/archimatetool/model/ModelVersion.java b/com.archimatetool.model/src/com/archimatetool/model/ModelVersion.java index 1995762c1..47333fb07 100644 --- a/com.archimatetool.model/src/com/archimatetool/model/ModelVersion.java +++ b/com.archimatetool.model/src/com/archimatetool/model/ModelVersion.java @@ -11,12 +11,13 @@ * Use this to determine when loading a different version model if it will bring the whole * show down. Example, folders were introduced in version 1.3 of Archi but won't open in Archi 1.2.

* - * PLEASE NOTE - THIS IS THE VERSION OF THE INTERNAL MODEL, NOT ARCHI. + * PLEASE NOTE - THIS IS THE VERSION OF THE MODEL, NOT ARCHI. + * As from Archi version 2.6.0 I will try to keep the model version number the same as Archi's version number when the model version is incremented. * Only need to change the model version number if there are changes that affect backwards compatibility.

- *

- * History:
  * 
- * 1.0.0 - Archi versions 0.7 - 1.2.0 the version number was not saved to the XMI file
+ * History:
+ * + * 1.0.0 - Archi versions 0.7 - 1.2.0 the version number was not saved to the XMI file
* 1.1.0 - Archi version 1.3.0 introduced sub-folders which are not backwards-compatible * 1.1.1 - Archi version 1.4.0 added sub-folders in the Views folder which are not backwards-compatible * 1.2.0 - Archi version 1.5.0 added the Sketch View which is not backwards-compatible, and text alignment attribute @@ -50,11 +51,9 @@ * - Add images to IDiagramModelArchimateObject * - Refactor IDiagramModelImageProvider, IIconic and more... * 5.0.0 - ArchiMate 3.2 - * 5.0.1 - Line styles on diagram objects. Grouping figure has to be set to dashed lines. * - *
* @author Phillip Beauvoir */ public interface ModelVersion { - String VERSION = "5.0.1"; //$NON-NLS-1$ + String VERSION = "5.0.0"; //$NON-NLS-1$ } 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 3aed579c7..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 @@ -161,9 +161,9 @@ public void testGetLineColor() { @Test public void testGetLineStyle() { - assertEquals(0, object.getLineStyle()); - object.setLineStyle(1); - assertEquals(1, object.getLineStyle()); + assertEquals(IDiagramModelObject.LINE_STYLE_DEFAULT, object.getLineStyle()); + object.setLineStyle(IDiagramModelObject.LINE_STYLE_SOLID); + assertEquals(IDiagramModelObject.LINE_STYLE_SOLID, object.getLineStyle()); } @Test