Skip to content

Commit

Permalink
Check all connection types
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillipus committed Dec 11, 2024
1 parent 312f882 commit 1b2c088
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import org.eclipse.gef.EditPart;

import com.archimatetool.editor.model.DiagramModelUtils;
import com.archimatetool.editor.preferences.ConnectionPreferences;
import com.archimatetool.model.IDiagramModelArchimateConnection;
import com.archimatetool.model.IDiagramModelConnection;


Expand All @@ -22,12 +20,6 @@ public class NestedConnectionEditPartFilter implements IConnectionEditPartFilter

@Override
public boolean isConnectionVisible(EditPart editPart, IDiagramModelConnection connection) {
// If the connection is an Archimate type and its target element is an Archimate type
// and this box contains that box and that box qualifies, don't show the connection
if(ConnectionPreferences.useNestedConnections() && connection instanceof IDiagramModelArchimateConnection) {
return !DiagramModelUtils.shouldBeHiddenConnection((IDiagramModelArchimateConnection)connection);
}

return true;
return !DiagramModelUtils.shouldBeHiddenConnection(connection);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -271,25 +271,28 @@ public static boolean isNestedConnectionTypeRelationship(IArchimateRelationship
* @param connection The connection to check
* @return true if a connection should be hidden when its source (parent) element contains its target (child) element
*/
public static boolean shouldBeHiddenConnection(IDiagramModelArchimateConnection connection) {
public static boolean shouldBeHiddenConnection(IDiagramModelConnection connection) {
if(!ConnectionPreferences.useNestedConnections()) {
return false;
}

// If the connection's source is an object and the connection's target is an object
// and the source contains the target or the target contains the source
if(connection.getSource() instanceof IDiagramModelArchimateObject dmoSource && connection.getTarget() instanceof IDiagramModelArchimateObject dmoTarget
&& (dmoSource.getChildren().contains(dmoTarget) || dmoTarget.getChildren().contains(dmoSource))) {
return isNestedConnectionTypeRelationship(connection.getArchimateRelationship());
// This is an Archimate connection
// and the connection's source is an Archimate object and the connection's target is an Archimate object
// and the connection's source contains the connection's target or the connection's target contains the connection's source
if(connection instanceof IDiagramModelArchimateConnection dmc
&& connection.getSource() instanceof IDiagramModelArchimateObject source
&& connection.getTarget() instanceof IDiagramModelArchimateObject target
&& (source.getChildren().contains(target) || target.getChildren().contains(source))) {
return isNestedConnectionTypeRelationship(dmc.getArchimateRelationship());
}

// If the connection's source is a connection and is a hidden type
if(connection.getSource() instanceof IDiagramModelArchimateConnection dmc) {
if(connection.getSource() instanceof IDiagramModelConnection dmc) {
return shouldBeHiddenConnection(dmc);
}

// If the connection's target is a connection and is a hidden type
if(connection.getTarget() instanceof IDiagramModelArchimateConnection dmc) {
if(connection.getTarget() instanceof IDiagramModelConnection dmc) {
return shouldBeHiddenConnection(dmc);
}

Expand Down

0 comments on commit 1b2c088

Please sign in to comment.