| Summary: | Support composite connections | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Modeling] Graphiti | Reporter: | Benjamin Schmeling <Benjamin.Schmeling> | ||||||||||||
| Component: | Core | Assignee: | Project Inbox <graphiti-inbox> | ||||||||||||
| Status: | CLOSED FIXED | QA Contact: | |||||||||||||
| Severity: | enhancement | ||||||||||||||
| Priority: | P4 | CC: | matthias.gorning, michael.wenz | ||||||||||||
| Version: | 0.8.0 | Flags: | michael.wenz:
juno+
|
||||||||||||
| Target Milestone: | 0.9.0 | ||||||||||||||
| Hardware: | All | ||||||||||||||
| OS: | All | ||||||||||||||
| Whiteboard: | Juno M6 Theme_round_offs | ||||||||||||||
| Attachments: |
|
||||||||||||||
|
Description
Benjamin Schmeling
Created attachment 208767 [details]
Example for composite connection.
This an example for a composite connection. A double line composite connection with two freeform child connections.
Created attachment 210777 [details]
1st patch for CompositeConnections
Created attachment 210778 [details]
2nd patch for CompositeConnections
Cool, thanks for the patches!
While having a look into them, I was wondering how to correctly create such a composite connection. I tried with the following coding using curved connections as children and somehow succeeded:
CompositeConnection compositeConnection = Graphiti.getPeCreateService().createCompositeConnection(getDiagram());
compositeConnection.getChildren().add(Graphiti.getPeCreateService().createCurvedConnection(new double[] { 0.2d, -100d, 0.5d, 100d, 0.6d, -100d }, getDiagram()));
compositeConnection.getChildren().add(Graphiti.getPeCreateService().createCurvedConnection(new double[] { 0.2d, 100d, 0.5d, -100d, 0.6d, 100d }, getDiagram()));
After that I set a polyline as GA and start and end anchors on each of the child connections. Pulling an end point of the composite connection within the diagram however allows to reconnect only one of the child connections, which appeared strange to me...
After that I tried to use FreeformConnections as children but that failed completely with a NPE...
Do you have an example how to use composite connections?
Michael
Hi,
yes I have an example that I used for my tests. Maybe you forgot to set the GA of the composite connection?
Please try my example and tell me if there are still problems:
IPeService pe = Graphiti.getPeService();
CompositeConnection composite = pe.createCompositeConnection(getDiagram());
Polyline compLine = ga.createPolyline(composite);
compLine.setLineVisible(false);
//CurvedConnection con1 = pe.createCurvedConnection(new double[]{0.25d, -50d, 0.75d, 50d}, getDiagram());
//FreeFormConnection con1 = pe.createFreeFormConnection(getDiagram());
ManhattanConnection con1 = pe.createManhattanConnection(getDiagram());
CurvedConnection con2 = pe.createCurvedConnection(new double[]{0.50d, 50d}, getDiagram());
composite.getChildren().add(con1);
composite.getChildren().add(con2);
ga.createPolyline(con1);
ga.createPolyline(con2);
composite.setStart(cContext.getSourceAnchor());
composite.setEnd(cContext.getTargetAnchor());
Thanks, that works much better. But that's at least something that needs documentation. Selection handling is another point I struggle with: the selection state is currently only shown with the small begin and end points I can use to re-connect. Yes you are right. There are still some problems --- as you said --- with the selection which isn't shown by the child connections with colered lines nor is there any symbol when reconnecting. I tried to fix that problem by overriding the setSelection method in the CompositeConnectionEditPart and delegating it to the child connections, but without any effect. However, I think when this problem is solved the composite connection will work as expected. Any ideas to solve the selection issue? Regards, Benjamin (In reply to comment #7) > Yes you are right. There are still some problems --- as you said --- with the > selection which isn't shown by the child connections with colered lines nor is > there any symbol when reconnecting. I tried to fix that problem by overriding > the setSelection method in the CompositeConnectionEditPart and delegating it to > the child connections, but without any effect. However, I think when this > problem is solved the composite connection will work as expected. Any ideas to > solve the selection issue? > Regards, > Benjamin After some digging I found that the edit policy for highlighting needs to be adapted. So far, it only had to highlight the direct figure of the edit part. in the case of a CompositeConnectionEditPart there are several other figures that need highlighting. I changed this in a local branch on my PC. I will do some more testing and probably check this in later. I noticed another gap: the context needs to be filled with additional information when the pictogram element is a composite connection: the user might need the info which sub connection has been clicked (e.g. in the case of a custom feature). Another gap in refresh handling: after changing an attribute (e.g. line style) for the children of a composite connection the representation in the diagram is not updated. Re-opening the editor shows the correct representation. Since there are still some open issues I checked in the changes to a seperate branch to our Eclipse Git repository. Please sync origin/compositeConnections to get the current state. Created attachment 210895 [details]
Custom Feature Context will be filled with additional information in case of composite connections
I've implemented the feature for filling Custom Feature context with additional information when the pictogram element is a composite connection: the user gets information which sub connection has been clicked by setting
innerPictogramElement and innerGA depending on which children was
nearest to the click.
(In reply to comment #12) > Created attachment 210895 [details] > Custom Feature Context will be filled with additional information in case of > composite connections > I've implemented the feature for filling Custom Feature context with additional > information when the pictogram element is a composite connection: the user gets > information which sub connection has been clicked by setting > innerPictogramElement and innerGA depending on which children was > nearest to the click. Sorry for the late reply, I was knocked-out by a cold... Thanks for this patch! However, I would rather go for the standard way Graphiti uses to check if a connection is clicked: the connection line itself plus a corridor arround it (by default 5 pixels to the left and right). If composite connection react differently the user might be confused. While looking at the last patch I noticed two more things: - Deleting a composite connection does not delete the child connections - Are other types of child connections besides CurvedConnections allowed? I tried with FreeFormConnections and was not able to add bendpoints. (In reply to comment #10) > Another gap in refresh handling: after changing an attribute (e.g. line style) > for the children of a composite connection the representation in the diagram is > not updated. Re-opening the editor shows the correct representation. This is at least partially caused by the child connections not having a source and target anchor. E.g. DiagramChangeListener.addRelevantChildEditPartsToRefreshJob adds a null EditPart to the list of EditParts to update in that case. Hi, 1. Regarding the custom feature: The only information that I had was the points of a connection and I checked the distance to the lines between those points. If there is a standard way to get the corridor, how can I get the rectangle which I can check against the point that was clicked? Could you please clarify this? 2. Regarding deletion of child connections: I tested it and you probably mean that they still stay in the diagram file after deletion of the composite. The composite connection will be deleted, but the children stay there. My proposal would be to make the child connections reference a containment, but this is not straight forward because the connections are already contained by the diagram. We probably need the same solution as for container shapes. What do you think? 3. It was not intended to allow editing of the child connections from my side. At least I have no use case for that. I tested with a ManhattanConnection and a CurvedConnection and it worked well so far. I also found another small problem: After reconnecting the CompositeConnection it is still selected but the selection is not shown anymore by the orange color. Best regards, Benjamin (In reply to comment #16) > 1. Regarding the custom feature: The only information that I had was the points > of a connection and I checked the distance to the lines between those points. > If there is a standard way to get the corridor, how can I get the rectangle > which I can check against the point that was clicked? Could you please clarify > this? I don't have a solution for that. It works as expected for the selection of a CurvedConnection (5 pixel area besides the connection). What behaves differently is just the way teh context information is filled. In most cases the user won't notice this but there could be situations in which he does. > 2. Regarding deletion of child connections: I tested it and you probably mean > that they still stay in the diagram file after deletion of the composite. The > composite connection will be deleted, but the children stay there. My proposal > would be to make the child connections reference a containment, but this is not > straight forward because the connections are already contained by the diagram. > We probably need the same solution as for container shapes. What do you think? Yes, that is what I meant. I came to the same thought and was not sure if it is a good idea. Currently all connections are directs children of the diagram and teher might be coding in various spots of the framework relying on that. On the other hand it would be more obvious to treat child connections of composite connections really as children of the composite connection. But that might turn out to get really complex... > 3. It was not intended to allow editing of the child connections from my side. > At least I have no use case for that. I tested with a ManhattanConnection and a > CurvedConnection and it worked well so far. Yes, but modifying a connection is natural and users will probably do it. I think there is not much lacking here, it might be as simple as the refresh fix for the curved connection. I just didn't find the time to look into this. > I also found another small problem: After reconnecting the CompositeConnection > it is still selected but the selection is not shown anymore by the orange > color. Right, I also see that Created attachment 211680 [details]
Recursive Logic for deleting and removing CompositeConnections
Hi,
I've implemented the deletion of child connections through an extension in the default remove and delete feature. This is much easier than changing the overall nesting of connections.
Regards,
Benjamin
(In reply to comment #18) > I've implemented the deletion of child connections through an extension in the > default remove and delete feature. This is much easier than changing the > overall nesting of connections. Finally got back to this, sorry for the long delay... This is indeed easier but it might turn out that other areas will also need some special treatment for composite connections. Nevertheless I also prefer this to a radical change in connection containment in general. I took over your patch, optimized the deletion of BOs and pushed the change to Eclipse into the composite connection branch: commit 0544e458d9412f49ed8f136495683660fc556a1b Author: mwenz <michael.wenz@sap.com> 2012-03-14 10:32:45 Committer: mwenz <michael.wenz@sap.com> 2012-03-14 10:32:45 Parent: 58344cbcb261b58b60aea8a441c319c2803d9a74 (Bug 367483 - Support composite connections - Sketch improvements) Branches: origin/compositeConnections, compositeConnections (In reply to comment #16) > 1. Regarding the custom feature: The only information that I had was the points > of a connection and I checked the distance to the lines between those points. > If there is a standard way to get the corridor, how can I get the rectangle > which I can check against the point that was clicked? Could you please clarify > this? It seems I found another easier solution for filling the custom context: I simply store the originally selected child connection on a selection request (getTargetEditPart) at the CompositeConnectionEditPart and use this info when the context menu is constructed. Checked-in and pushed to Eclipse in the feature branch: commit 37189c04d46be6c826e1a9680791c49674c2f8b5 Author: mwenz <michael.wenz@sap.com> 2012-03-14 13:54:41 Committer: mwenz <michael.wenz@sap.com> 2012-03-14 13:54:41 Parent: 0544e458d9412f49ed8f136495683660fc556a1b (Bug 367483 - Support composite connections - Delete of composite connection recursively deletes child connections) Branches: origin/compositeConnections, compositeConnections (In reply to comment #17) > > I also found another small problem: After reconnecting the CompositeConnection > > it is still selected but the selection is not shown anymore by the orange > > color. > I have spent some time trying to solve the refresh problem, but couldn't figure out. But during these investigations I found the reason for the selection feedback issue: the selected state was not promoted to the child connections. I fixed that by adding the corresponding delegation to CompositeConnectionEditPart: commit 6f035326190300b8d88bceacd44b4716ccc5775c Author: mwenz <michael.wenz@sap.com> 2012-03-15 10:53:31 Committer: mwenz <michael.wenz@sap.com> 2012-03-15 10:53:31 Parent: 0d115c7acb563ee897a7f0e0965bded706b826cc (Bug 367483 - Support composite connections - Fixed NPE during refresh) Branches: origin/compositeConnections, compositeConnections I have restricted the composite connection children to be only curved connections, since all other connection types to not really work and I doubt if they make sense: commit fae754b54b1d8f2fdb286926cd2be988d1af4925 Author: mwenz <michael.wenz@sap.com> 2012-03-15 13:05:33 Committer: mwenz <michael.wenz@sap.com> 2012-03-15 13:05:33 Parent: 6f035326190300b8d88bceacd44b4716ccc5775c (Bug 367483 - Support composite connections - Fixed selection visualization) Branches: origin/compositeConnections, compositeConnections Thanks to Matthias who found and fixed the issue with the refresh. Since now all major issues seem to be resolved, I would like to add this to our main brach to get part of M6 (API-freeze). One thing is still missing: visual feedback during reconnect, I have opened https://bugs.eclipse.org/bugs/show_bug.cgi?id=374376 for this. I have rebased the changes in our feature branch on top of the master and pushed everything to the master branch. It's in now for Graphiti M6. Thanks again Benjamin for contributions! Having a look into the patches, the change again appears rather big, but same argument as for the CurvedConnection patch applies here as well: the original changes are rather small (well below 200 lines) but the generated content makes it appear big. Central tests went through Bookkeeping: Set target release Part of Graphiti 0.9.0 (Eclipse Juno) |