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..99b6a7add 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/ArchimateDiagramModelFactory.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/ArchimateDiagramModelFactory.java @@ -29,7 +29,6 @@ import com.archimatetool.model.IProfile; import com.archimatetool.model.ITextAlignment; import com.archimatetool.model.ITextPosition; -import com.archimatetool.model.impl.Grouping; @@ -68,11 +67,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 +80,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 +115,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.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 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