| Summary: | Hide Shapes - enable simple collapse/expand | ||
|---|---|---|---|
| Product: | [Modeling] Graphiti | Reporter: | Tim Kaiser <tim.kaiser> |
| Component: | Core | Assignee: | Michael Wenz <michael.wenz> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P4 | CC: | juergen.pasch, matteo.miraz, michael.wenz, selvam.jp |
| Version: | 0.7.0 | Flags: | michael.wenz:
juno+
|
| Target Milestone: | 0.9.0 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | Juno M5 Theme_bugs | ||
|
Description
Tim Kaiser
Added to the backlog for post 0.7.0 We would need this feature soon.. we need the feature collapse/expand and filtering the connections without making the editor dirty. Raised priority (in planning for 0.8.0). Needs further clarification and technical discussions. Out-of-scope for Juno unless there are contributions in this area Does there is any progress? Using the current milestone(0.9.0v20111028-1029) it almost works, as you can hide both inner shapes and inner connectors, and re-layout the pictogramElement. The only problem is that the selection stops working: the hidden shape causes the following exception: java.lang.IllegalArgumentException: An EditPart has to be selectable (isSelectable() == true) in order to get selected. at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63) at org.eclipse.gef.editparts.AbstractEditPart.setSelected(AbstractEditPart.java:1060) at org.eclipse.gef.SelectionManager.setSelection(SelectionManager.java:273) at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setSelection(AbstractEditPartViewer.java:751) at org.eclipse.graphiti.ui.internal.editor.GraphitiScrollingGraphicalViewer.setSelection(GraphitiScrollingGraphicalViewer.java:62) at org.eclipse.graphiti.ui.internal.editor.DiagramEditorInternal.selectPictogramElements(DiagramEditorInternal.java:1560) at org.eclipse.graphiti.ui.internal.editor.DiagramEditorInternal.selectionChanged(DiagramEditorInternal.java:1540) at org.eclipse.ui.internal.AbstractSelectionService.fireSelection(AbstractSelectionService.java:156) Could you post some more details on the solution you built for hiding and showing stuff? We only sketched a possible solution, but that idea turned out to be more complex, so this topic was postponed. (So, the answer to your question would be no, there has been no progress in this.) It is explained here: http://www.eclipse.org/forums/index.php/t/264388/ In short, I use a property to store if an element is expanded or collapsed. The collapse feature just toggle that property and forces a layout. The layout verifies the actual and the desired collapse status, and: * hides (shows) inner connectors & shapes, using method setVisible * updates the graphical representation of the element This approach seems to work, as the the element is shown correctly. The only problem I found is with selection. I have a view that shows all the element of the model. When I select an element, the linked graphical shapes & connectors are highlighted (selected). Note that a model element can be linked to several graphical elements: when such element is selected, several shapes are highlighted. The problem arises when one of the shapes is not visible (i.e., belongs to a collapsed shape). In this case, an exception is thrown (see later) and the diagram has a wrong set of elements highlighted. Instead, only the visible elements should be highlighted. The exception I experience is: java.lang.IllegalArgumentException: An EditPart has to be selectable (isSelectable() == true) in order to get selected. at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63) at org.eclipse.gef.editparts.AbstractEditPart.setSelected(AbstractEditPart.java:1060) at org.eclipse.gef.SelectionManager.setSelection(SelectionManager.java:273) at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setSelection(AbstractEditPartViewer.java:751) at org.eclipse.graphiti.ui.internal.editor.GraphitiScrollingGraphicalViewer.setSelection(GraphitiScrollingGraphicalViewer.java:62) at org.eclipse.graphiti.ui.internal.editor.DiagramEditorInternal.selectPictogramElements(DiagramEditorInternal.java:1560) at org.eclipse.graphiti.ui.internal.editor.DiagramEditorInternal.selectionChanged(DiagramEditorInternal.java:1540) at org.eclipse.ui.internal.AbstractSelectionService.fireSelection(AbstractSelectionService.java:156) Matteo, that sounds really good, but almost too easy... ;-) I had a look into this and it appears as if the only thing we need to do is to prevent that the diagram editor tries to force the selection for EditParts that are not selectable (e.g. invisible). Sounds very much reasonable as weel in general. I checked in a change doing exactly this in head and pushed it to Eclipse: commit a4dc363edfbadb61ea8897069fe9683ab3af0289 Author: mwenz <michael.wenz@sap.com> 2011-12-30 10:10:35 Committer: mwenz <michael.wenz@sap.com> 2011-12-30 10:10:35 Parent: 70c4695586a0f149d4f618bc797f60296c29c7d7 (Bug 367204: Correctly return the added PE inAbstractFeatureProvider's addIfPossible method by enhancing the IDiagramEditor.executeFeature method with a return value) Branches: origin/master, master Matteo,
Could you try that change if it works for you,please?
Unfortunatly this is all on top of our editor restructoring, so it will probably not be ease for you to test. So here's the change I did to the selectPictogramElements method in DiagramEditor (you will need to apply the changes to DiagramEditorInternal):
public void selectPictogramElements(PictogramElement[] pictogramElements) {
List<EditPart> editParts = new ArrayList<EditPart>();
Map<?, ?> editPartRegistry = getGraphicalViewer().getEditPartRegistry();
if (editPartRegistry != null) {
for (int i = 0; i < pictogramElements.length; i++) {
PictogramElement pe = pictogramElements[i];
Object obj = editPartRegistry.get(pe);
if (obj instanceof EditPart && ((EditPart) obj).isSelectable()) {
editParts.add((EditPart) obj);
}
}
getSite().getSelectionProvider().setSelection(new StructuredSelection(editParts));
if (editParts.size() > 0) {
final EditPart editpart = editParts.get(0);
if (!(editpart instanceof IConnectionEditPart)) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
getGraphicalViewer().reveal(editpart);
}
});
}
}
}
}
Michael, the patch you sent me solves the exception I was speaking about, and now everything seems to work smoothly (at least, in my application)! Thank you very much for your help! So it appears that collapse/expand works now. Aparently, the only missing piece needed was a bugfix as described here. Therefor I flag this as a bug and close the issue with the bugfix being part of Juno M5. I checked it and it is O.K. Bookkeeping: Set target release Part of Graphiti 0.9.0 (Eclipse Juno) |