From 2c9d9195fa493d0eda7e3eaeee61a3d6842a6adc Mon Sep 17 00:00:00 2001
From: Phillipus
Date: Wed, 18 Dec 2024 15:03:58 +0000
Subject: [PATCH] Remove the "None" border style for Notes
- But this breaks backward compatibility
---
com.archimatetool.editor/plugin.xml | 4 ++
.../diagram/figures/diagram/NoteFigure.java | 2 +-
.../handlers/NoteBorderStyleHandler.java | 44 +++++++++++++++++++
.../editor/propertysections/Messages.java | 2 -
.../NoteBorderTypeSection.java | 3 +-
.../propertysections/messages.properties | 1 -
.../help/Text/properties_note.html | 2 +-
.../model/IDiagramModelNote.java | 2 +
8 files changed, 53 insertions(+), 7 deletions(-)
create mode 100644 com.archimatetool.editor/src/com/archimatetool/editor/model/compatibility/handlers/NoteBorderStyleHandler.java
diff --git a/com.archimatetool.editor/plugin.xml b/com.archimatetool.editor/plugin.xml
index 2bc2d661b..3235949a6 100644
--- a/com.archimatetool.editor/plugin.xml
+++ b/com.archimatetool.editor/plugin.xml
@@ -1345,6 +1345,10 @@
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/figures/diagram/NoteFigure.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/NoteFigure.java
index 1ee54b7e2..b4c7c978c 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/NoteFigure.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/figures/diagram/NoteFigure.java
@@ -152,7 +152,7 @@ protected void paintFigure(Graphics graphics) {
// Icon
drawIconImage(graphics, bounds);
- if(getDiagramModelObject().getBorderType() != IDiagramModelNote.BORDER_NONE && getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
+ if(getLineStyle() != IDiagramModelObject.LINE_STYLE_NONE) {
graphics.setAlpha(getLineAlpha());
graphics.setForegroundColor(getLineColor());
graphics.drawPolygon(points);
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/model/compatibility/handlers/NoteBorderStyleHandler.java b/com.archimatetool.editor/src/com/archimatetool/editor/model/compatibility/handlers/NoteBorderStyleHandler.java
new file mode 100644
index 000000000..793dc959d
--- /dev/null
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/model/compatibility/handlers/NoteBorderStyleHandler.java
@@ -0,0 +1,44 @@
+/**
+ * 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.model.IArchimateModel;
+import com.archimatetool.model.IDiagramModelNote;
+import com.archimatetool.model.IDiagramModelObject;
+
+
+
+/**
+ * Change a Note's border type from "None" to "Rectangle" and set its line style to "None" instead
+ *
+ * @author Phillip Beauvoir
+ */
+public class NoteBorderStyleHandler implements ICompatibilityHandler {
+
+ @Override
+ public void fixCompatibility(Resource resource) throws CompatibilityHandlerException {
+ IArchimateModel model = (IArchimateModel)resource.getContents().get(0);
+ convertNoteBorders(model);
+ }
+
+ private void convertNoteBorders(IArchimateModel model) {
+ for(Iterator iter = model.eAllContents(); iter.hasNext();) {
+ EObject eObject = iter.next();
+
+ if((eObject instanceof IDiagramModelNote note && note.getBorderType() == IDiagramModelNote.BORDER_NONE)) {
+ note.setBorderType(IDiagramModelNote.BORDER_RECTANGLE);
+ note.setLineStyle(IDiagramModelObject.LINE_STYLE_NONE);
+ }
+ }
+ }
+}
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/Messages.java b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/Messages.java
index b45e3ad65..929489c1d 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/Messages.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/Messages.java
@@ -273,8 +273,6 @@ public class Messages extends NLS {
public static String NoteBorderTypeSection_1;
- public static String NoteBorderTypeSection_2;
-
public static String PropertiesLabelProvider_0;
public static String SketchElementSection_0;
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/NoteBorderTypeSection.java b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/NoteBorderTypeSection.java
index 755425079..243582058 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/NoteBorderTypeSection.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/NoteBorderTypeSection.java
@@ -17,8 +17,7 @@ public class NoteBorderTypeSection extends BorderTypeSection {
private static final String[] noteComboItems = {
Messages.NoteBorderTypeSection_0,
- Messages.NoteBorderTypeSection_1,
- Messages.NoteBorderTypeSection_2
+ Messages.NoteBorderTypeSection_1
};
/**
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/messages.properties b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/messages.properties
index e933a254b..7010f09ec 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/messages.properties
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/propertysections/messages.properties
@@ -144,7 +144,6 @@ LockedSection_0=Locked:
NameSection_0=Add a name here
NoteBorderTypeSection_0=Dog Ear
NoteBorderTypeSection_1=Rectangle
-NoteBorderTypeSection_2=None
PropertiesLabelProvider_0=(Multiple Selection)
diff --git a/com.archimatetool.help/help/Text/properties_note.html b/com.archimatetool.help/help/Text/properties_note.html
index fc4ba8ff8..3baf78534 100644
--- a/com.archimatetool.help/help/Text/properties_note.html
+++ b/com.archimatetool.help/help/Text/properties_note.html
@@ -70,7 +70,7 @@ Note Properties
Border: |
- Sets the border type. Can be either "Dog Ear", "Rectangle" or "None". |
+ Sets the border type. Can be either "Dog Ear" or "Rectangle". |
Text Alignment: |
diff --git a/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelNote.java b/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelNote.java
index e5d5bb78c..e445decf5 100644
--- a/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelNote.java
+++ b/com.archimatetool.model/src/com/archimatetool/model/IDiagramModelNote.java
@@ -20,6 +20,8 @@ public interface IDiagramModelNote extends IDiagramModelObject, ITextContent, IT
int BORDER_DOGEAR = 0; // Default
int BORDER_RECTANGLE = 1;
+
+ // TODO: Remove this
int BORDER_NONE = 2;
} // IDiagramModelNote