-
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete nested connections instead of hiding them
* This solves the issue of trying to hide connections to connections that are also hidden
- Loading branch information
Showing
10 changed files
with
120 additions
and
437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
....editor/src/com/archimatetool/editor/diagram/commands/DeleteNestedConnectionsCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* 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.diagram.commands; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.eclipse.gef.commands.Command; | ||
import org.eclipse.gef.commands.CompoundCommand; | ||
|
||
import com.archimatetool.model.IDiagramModelArchimateObject; | ||
import com.archimatetool.model.IDiagramModelConnection; | ||
|
||
/** | ||
* Compound Command to delete nested connections between parent and childObjects in nested objects. | ||
* This is used when the user drags objects into a parent Archimate object and nested connections to child are removed. | ||
* | ||
* @author Phillip Beauvoir | ||
*/ | ||
public class DeleteNestedConnectionsCommand extends CompoundCommand { | ||
|
||
IDiagramModelArchimateObject fParentObject; | ||
List<IDiagramModelArchimateObject> fChildObjects; | ||
|
||
public DeleteNestedConnectionsCommand(IDiagramModelArchimateObject parentObject, IDiagramModelArchimateObject childObject) { | ||
fParentObject = parentObject; | ||
fChildObjects = new ArrayList<IDiagramModelArchimateObject>(); | ||
fChildObjects.add(childObject); | ||
} | ||
|
||
public DeleteNestedConnectionsCommand(IDiagramModelArchimateObject parentObject, List<IDiagramModelArchimateObject> childObjects) { | ||
fParentObject = parentObject; | ||
fChildObjects = childObjects; | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
createDeleteCommands(); | ||
|
||
super.execute(); | ||
} | ||
|
||
// These should return true always because sub-commands are only created on execute() | ||
|
||
@Override | ||
public boolean canExecute() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean canUndo() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean canRedo() { | ||
return true; | ||
} | ||
|
||
/** | ||
* Child Objects that have connections | ||
*/ | ||
void createDeleteCommands() { | ||
for(IDiagramModelArchimateObject child : fChildObjects) { | ||
for(IDiagramModelConnection connection : child.getTargetConnections()) { | ||
if(connection.getSource() == fParentObject) { | ||
Command cmd = DiagramCommandFactory.createDeleteDiagramConnectionCommand(connection); | ||
add(cmd); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a issue with this commit. This breaks the behavior putted in place to solve Issue 26: Relation not copied if nested objects copied and pasted. We have to look at this.
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I don't know what to do then.
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking at it. Maybe I could revert and manage the hidding of connections to connections... (or add all model relations between nested elements to the CopySnapshot?)
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to review CopySnapshot, I think. Hiding connections is a bad idea, for various reasons. If a connection is not there, then it should be deleted.
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, the more I think about it, the more I think hiding connections is a good idea. I played a bit with the latest version and it is rather frequent (at least for me) to try different layouts for my views. This leads me to nest and un-nest things quite often. The issue with latest behavior is that I no more have the same connections when un-nesting because I loose connections to connections, and other connections appear (because they are in the model, but were not in my view). So I think I'll try to revert this commit and solve original issue.
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is when the model connections update occurs - getModelConnections methods. When moving one box, it only updates for that box, not the connecting boxes and connections.
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is when the model connections update occurs - getModelConnections methods. When moving one box, it only updates for that box, not the connecting boxes and connections.
I don't get you ?
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AbstractConnectedEditPart#getModelSourceConnections() AbstractConnectedEditPart#getModelTargetConnections()
ArchimateRelationshipEditPart#getModelSourceConnections()
ArchimateRelationshipEditPart#getModelTargetConnections()
These are only called for the box when it is moved and nested. So only that box's connections are re-created and re-drawn. These methods are not called for any associated connections or boxes, so there are hanging connections.
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I understand now (I tested some code change yesterday and was blocked by this).
I'm now thinking about doing the filtering in a way similar to Viewpoints: create a NestedConnectionEditPartFilter that would implement IConnectionEditPartFilter and hide a connection based on the hiden/shown "state" of its source/target (through some calls to DiagramModelUtils.shouldBeHiddenConnection())...
What do you think about it ?
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that some actions - move a child into/out of parent, delete box or connection, add new connection, box, etc would then require to trigger an update of more than one EditPart. Most of these actions only trigger one update for the one EditPart concerned. Propagating all of the necessary updates to several EdiParts manually could be complicated, and expensive. The reason it works in the VP filter is that changing the VP then reloads the whole GEF model.
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so I might be trying to solve two different things which requires two different approaches:
So my conclusion is that: when nesting we should delete all potential connections to connections, but hide the connection which is used as a base (meaning) for nesting.
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
I've implemented my proposed behavior in the new branch 'hide-nested-connections'.
While working on it I've noticed some strange behavior (that existed before, even in Archi 3.x): when nesting A into B while a connection C already exists between them, all existing relationship (and not only the one related to C) are converted to hidden connections, which doesn't make sens... I'm working on a fix.
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just discovered another good reason to create hidden connections when nesting: if we don't do so, then the Validator will list (most of) the relationships as not used in views, leading user (like me 2min ago) to think he can delete them... to discover just after doing so that now there's nesting without proper relationship...
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that can be solved by changing logic of calculating an "implicit" relationship. I still think that hiding connections may lead to unforeseen problems. I think of a connection as a visual thing, not a semantic thing.
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think of a connection as a visual thing, not a semantic thing.
IMHO when nesting, I really think it's good to know which relationship was nested. Hidding connection is (at least for the moment) the best way to do it. That's why my proposal is to keep hidden connections in this case (but only this one: connections to connections have to be removed when nesting because there's no semantic link to the nesting itself).
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used to have a method that determined a semantic "implicit" connection by (1) Is A a graphical child of B? (2) If yes, does A have a relationship to B in the model of correct type? (3) Yes - then it's an implicit connection. This could be put back.
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't work from a semantic point of view because as a user I might want to use (e.g.) aggregation is some viewpoints but assignment is other viewpoints. If I use your rule, I might make wrong conclusions.
In addition, I would even go further: when nesting an element inside another one while there exist some relationships in the model but no connection in the view, I would ask the user to choose which relationship to associate to this visual nesting (and then create appropriate hidden connection) or even create another one (from another kind).
c22f4cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my "hide-nested-connections" branch can be merged on master for the upcomming beta (I've just rebased it to your latest commit). I guess some more tests are needed to be sure nothing is broken, but at least it passes my personnal tests.