| Summary: | Marquee Selection Behavior Options | ||
|---|---|---|---|
| Product: | [Modeling] Graphiti | Reporter: | Rhett Hudson <rhett.hudson> |
| Component: | Core | Assignee: | Project Inbox <graphiti-inbox> |
| Status: | REOPENED --- | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | erwindl0, ignaciospain1, michael.wenz |
| Version: | 0.7.0 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Rhett Hudson
Out-of-scope for Juno, unless there are contributions in this area I've had to revisit this after the 0.9 refactor. The default drag tracker for marquee selection is created by an anonymous class created in DiagramEditor's configureGraphicalViewer() method. This object is an instance of ScalableRootEditPartAnimated. It would be nice if I could optionally provide a DragTracker factory that ScalableRootEditPartAnimated could use instead of its simple default implementation. That would allow me to set up the DragTracker in the manner that I desired. Any news on this issue? I´m looking into DiagramBehavior´s configureGraphicalViewer, is there a workaround to modify the marquee selection behavior as of today? (In reply to Ignacio Ibanez from comment #3) > Any news on this issue? Sorry, no news. I simply did not have this on my radar. But as I wrote, I'm open for ideas and contributions here. On the other hand I'm afraid that for the current dev cycle for Eclipse Neon and Graphiti 0.13.0 this is too late, since M6 has passed which means API freeze. but I can put tis on the topics list for the next Graphiti release as part of Eclipse O... Michael Hi Michael,
I can tell you what I tried, though it might be perfectly useless.
Based on what I read around regarding GEF I tried something along these lines:
In my Diagram Behavior class, calling either in initializeGraphicalViewer() or elsewhere:
...
updateToolEntryProperty(getPaletteBehavior().getPaletteRoot().getChildren(), GFMarqueeToolEntry.class,
MarqueeSelectionTool.PROPERTY_MARQUEE_BEHAVIOR, MarqueeSelectionTool.BEHAVIOR_NODES_CONTAINED_AND_RELATED_CONNECTIONS);
...
private static void updateToolEntryProperty(List<?> paletteContainerList, Class<? extends ToolEntry> toolEntryClass,
Object property, Object value) {
for (Object paletteEntry : paletteContainerList) {
if (paletteEntry instanceof PaletteContainer) {
updateToolEntryProperty(((PaletteContainer) paletteEntry).getChildren(), toolEntryClass, property,
value);
}
if (toolEntryClass.isInstance(paletteEntry)) {
((ToolEntry) paletteEntry).setToolProperty(property, value);
return;
}
}
}
Which did not work. The other option I thought of required extending/overriding classes/methods 3-4 layers deep into graphiti code iirc.
This issue, in my scenario, seems to be related to https://bugs.eclipse.org/bugs/show_bug.cgi?id=376714
as the selection behavior is not consistent between marquee and ctrl-A, and both are hard/impossible to customize without deep hack & slash.
Thanks for your time, any ideas/updates on these issues will be greatly appreciated.
From Ignacio's hint, to override something in your own Diagram Behavior, I seem to have something that could work.
This is for cases where the user selects several diagram elements with the mouse drag to do a marquee selection.
I'm not using a palette marquee tool.
When trying it out, I indeed get the contained connections in the selection as well.
I'm overriding with :
protected void configureGraphicalViewer() {
ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getDiagramContainer().getGraphicalViewer();
ScalableRootEditPartAnimated rootEditPart = new ScalableRootEditPartAnimated(viewer, getConfigurationProvider()) {
protected GridLayer createGridLayer() {
return new org.eclipse.graphiti.ui.internal.util.draw2d.GridLayer(
(IConfigurationProviderInternal) getConfigurationProvider());
}
@Override
public DragTracker getDragTracker(Request req) {
GFMarqueeDragTracker trckr= new GFMarqueeDragTracker(this);
trckr.setMarqueeBehavior(GFMarqueeSelectionTool.BEHAVIOR_NODES_AND_CONNECTIONS);
return trckr;
}
};
// configure ZoomManager
viewer.setRootEditPart(rootEditPart); // support
// animation of the zoom
ZoomManager zoomManager = rootEditPart.getZoomManager();
List<String> zoomLevels = new ArrayList<String>(3);
zoomLevels.add(ZoomManager.FIT_ALL);
zoomLevels.add(ZoomManager.FIT_WIDTH);
zoomLevels.add(ZoomManager.FIT_HEIGHT);
zoomManager.setZoomLevelContributions(zoomLevels);
IToolBehaviorProvider toolBehaviorProvider = getConfigurationProvider().getDiagramTypeProvider()
.getCurrentToolBehaviorProvider();
zoomManager.setZoomLevels(toolBehaviorProvider.getZoomLevels());
this.initActionRegistry(zoomManager);
// set the keyhandler.
viewer.setKeyHandler((new GraphicalViewerKeyHandler(viewer)).setParent(getCommonKeyHandler()));
// settings for grid and guides
Diagram diagram = getConfigurationProvider().getDiagram();
boolean snapToGrid = diagram.isSnapToGrid();
int horizontalGridUnit = diagram.getGridUnit();
int verticalGridUnit = diagram.getVerticalGridUnit();
if (verticalGridUnit == -1) {
// No vertical grid unit set (or old diagram before 0.8): use
// vertical grid unit
verticalGridUnit = horizontalGridUnit;
}
boolean gridVisisble = (horizontalGridUnit > 0) && (verticalGridUnit > 0);
viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, new Boolean(gridVisisble));
viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, new Boolean(snapToGrid));
viewer.setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(horizontalGridUnit, verticalGridUnit));
viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, toolBehaviorProvider.isShowGuides());
// context button manager
IConfigurationProviderInternal configurationProvider = (IConfigurationProviderInternal) this
.getConfigurationProvider();
configurationProvider.setContextButtonManager(new ContextButtonManagerForPad(this, configurationProvider
.getResourceRegistry()));
}
The important part in here is the getDragTracker() change, that sets the selection mode for each created marquee selection tool.
The rest of the method implementation is just copied over from the base class, except that I had to remove :
/* sw: make scroll bars always visible */
if (getDiagramScrollingBehavior() == DiagramScrollingBehavior.SCROLLBARS_ALWAYS_VISIBLE) {
GFFigureCanvas figureCanvas = getGFFigureCanvas();
if (figureCanvas != null) {
figureCanvas.setScrollBarVisibility(FigureCanvas.ALWAYS);
}
}
as this uses private methods. As it was marked as deprecated I hope this is not a problem!?
Erwin, thanks for this proposal. Without checking if there are further changes in your code snippet for that method, it would be a rather easy change to extract the getDragDracker method and make it overridable. Would that already help? Regardsing the decprecated stuff: removing should not be an issue as long as your tool does not use that mode. Thanks, Michael Hi Michael, An overridable method getDragtracker() on DiagramBehavior would indeed make this easier and would also provide better separation from the other things done in the configureGraphicalViewer() method. Which would reduce maintainability risks when upgrading to future Graphiti versions. So yes, that would be great! On the other hand, the approach above is not yet complete I guess. I.e. any other places where marquee selections can be triggered (where instances of the DragTracker or even of GFMarqueeSelectionTool are created/used) still stick to the default BEHAVIOR_NODES_CONTAINED. I guess this would be the case for e.g. editors using the palette marquee tool? I also haven't figured out yet what to do for the select-all behaviour. If there would be a way to set a general "selection behavior" for marquee tool, drag and select-all that would be ideal... (Can you point me to where to look for the select-all behavior?) And while I'm dreaming ;-) as it seems some users/developers prefer to select model elements without connections while others want to include connections : why not make both possible via a modifier key or so? E.g. Alt drag or so doesn't pick connections and plain drag does; Ctrl-A selects everything and Ctrl-Alt-A no connections etc? (but such choice is not needed in Triquetrum, we always want to copy connections along) cheers erwin Hi agree, word by word, with erwin´s last comment. Merged for Oxygen M1 and Graphiti 0.14.0 (In reply to Michael Wenz from comment #10) > Merged for Oxygen M1 and Graphiti 0.14.0 Sorry, wrong bug |