list = new ArrayList<>();
+
+ for(Object object : getSelectedObjects()) {
+ if(isValidObject(object)) {
+ list.add((IDiagramModelObject)((EditPart)object).getModel());
+ }
+ }
+
+ return list;
+ }
+
+ private boolean isValidObject(Object object) {
+ return object instanceof EditPart editPart && // Is an EditPart
+ editPart.getModel() instanceof IDiagramModelObject dmo && // Diagram Model Object
+ dmo instanceof IDiagramModelContainer container && // And a container
+ dmo.eContainer() instanceof IDiagramModelContainer && // And parent is a container
+ !(dmo instanceof ILockable lockable && lockable.isLocked()) && // And not locked
+ !container.getChildren().isEmpty(); // And has child objects
+ }
+
+ private static class ChangePositionCommand extends Command {
+ private IDiagramModelObject dmo;
+ private IBounds oldBounds, newBounds;
+
+ public ChangePositionCommand(IDiagramModelObject dmo, IBounds parentBounds) {
+ this.dmo = dmo;
+ oldBounds = dmo.getBounds();
+ newBounds = IArchimateFactory.eINSTANCE.createBounds(oldBounds.getX() + parentBounds.getX(),
+ oldBounds.getY() + parentBounds.getY(), oldBounds.getWidth(), oldBounds.getHeight());
+ }
+
+ @Override
+ public void execute() {
+ dmo.setBounds(newBounds);
+ }
+
+ @Override
+ public void undo() {
+ dmo.setBounds(oldBounds);
+ }
+
+ @Override
+ public void dispose() {
+ dmo = null;
+ oldBounds = null;
+ newBounds = null;
+ }
+ }
+}
diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/DiagramCommandFactory.java b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/DiagramCommandFactory.java
index 20dc72a67..d8d3044e3 100644
--- a/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/DiagramCommandFactory.java
+++ b/com.archimatetool.editor/src/com/archimatetool/editor/diagram/commands/DiagramCommandFactory.java
@@ -22,23 +22,22 @@
public final class DiagramCommandFactory {
/**
- * @param object
* @return A new Delete Diagram Object Command
*/
public static Command createDeleteDiagramObjectCommand(IDiagramModelObject object) {
- CompoundCommand result = new CompoundCommand();
- __addDeleteDiagramObjectCommands(object, result);
- return result.unwrap();
+ return createDeleteDiagramObjectCommand(object, true);
}
/**
- * Recurse and add child delete commands.
- * We have to do this because if the object has children with connections going outside these need explicit Delete Commands too
- * otherwise we end up with trailing connections...
- * @param container
- * @param result
+ * @return A new Delete Diagram Object Command with option of deleting child objects
*/
- private static void __addDeleteDiagramObjectCommands(IDiagramModelObject object, CompoundCommand result) {
+ public static Command createDeleteDiagramObjectCommand(IDiagramModelObject object, boolean deleteChildren) {
+ CompoundCommand result = new CompoundCommand();
+ addDeleteDiagramObjectCommands(object, result, deleteChildren);
+ return result.unwrap();
+ }
+
+ private static void addDeleteDiagramObjectCommands(IDiagramModelObject object, CompoundCommand result, boolean deleteChildren) {
result.add(new DeleteDiagramObjectCommand(object));
for(IDiagramModelConnection connection : object.getSourceConnections()) {
@@ -49,9 +48,9 @@ private static void __addDeleteDiagramObjectCommands(IDiagramModelObject object,
result.add(createDeleteDiagramConnectionCommand(connection));
}
- if(object instanceof IDiagramModelContainer) {
- for(IDiagramModelObject child : ((IDiagramModelContainer)object).getChildren()) {
- __addDeleteDiagramObjectCommands(child, result);
+ if(deleteChildren && object instanceof IDiagramModelContainer container) {
+ for(IDiagramModelObject child : container.getChildren()) {
+ addDeleteDiagramObjectCommands(child, result, deleteChildren);
}
}
}
@@ -62,11 +61,11 @@ private static void __addDeleteDiagramObjectCommands(IDiagramModelObject object,
*/
public static Command createDeleteDiagramConnectionCommand(IDiagramModelConnection connection) {
CompoundCommand result = new CompoundCommand();
- __addDeleteDiagramConnectionCommands(connection, result);
+ addDeleteDiagramConnectionCommands(connection, result);
return result.unwrap();
}
- private static void __addDeleteDiagramConnectionCommands(IDiagramModelConnection connection, CompoundCommand result) {
+ private static void addDeleteDiagramConnectionCommands(IDiagramModelConnection connection, CompoundCommand result) {
for(IDiagramModelConnection conn : connection.getSourceConnections()) {
result.add(createDeleteDiagramConnectionCommand(conn));
}
diff --git a/com.archimatetool.help/help/Text/view_copy_paste_delete.html b/com.archimatetool.help/help/Text/view_copy_paste_delete.html
index 1832e72d5..c1be1daa6 100644
--- a/com.archimatetool.help/help/Text/view_copy_paste_delete.html
+++ b/com.archimatetool.help/help/Text/view_copy_paste_delete.html
@@ -39,7 +39,17 @@ Copy As Image to Clipboard
Deleting Elements and Relationships (Connections) in a View
- Selected elements and/or connections in a View can be deleted from the View by choosing the "Delete from View" menu item from the main "Edit" menu, from the main toolbar or from the right-click menu. Note - this action deletes those elements from the View not from the model. To delete the element completely you have to delete it in the Model Tree or select "Delete from Model".
+ Selected elements and/or connections in a View can be deleted from the View by choosing the "Delete from View" menu item from the main "Edit" menu, from the main toolbar or from the right-click menu. Note - this action deletes the selected objects from the View not from the model.
+
+
+
+ Delete from View (keep children)
+ This menu item is available from the main "Edit" menu or when right-clicking an object in a View. It allows you to delete the selected objects but retain the object's child objects. Child objects are re-parented to the selected object's immediate parent. Note - this action deletes the selected objects from the View not from the model.
+
+
+
+ Delete from Model
+ This menu item is available from the main "Edit" menu or when right-clicking an element or relationship in a View. The selected elements and/or relationships are deleted from the model itself and any Views that reference those elements. This is the equivalent of selecting the elements in the Model Tree and choosing "Delete".
@@ -52,11 +62,6 @@ Changing an Object's ArchiMate Concept Type in a View
Select in Model Tree
This menu item is available when right-clicking an element or relationship in a View. It will select the corresponding model element in the Model Tree.
-
-
- Delete from Model
- This menu item is available when right-clicking an element or relationship in a View. The selected elements and/or relationships are then deleted from the model itself and any Views that reference those elements. This is the equivalent of selecting the elements in the Model Tree and choosing "Delete".
-