Highlighting Connection of ConnectionDecorator [message #1404182] |
Wed, 30 July 2014 09:43 |
Simon Sperl Messages: 21 Registered: May 2014 |
Junior Member |
|
|
I would really like to have when I mouseover/select a ConnectionDecorator get an indication to which Connection the Decorator belongs.
Currently I tried via by adding ColorDecorator on the connection whenever a decorator becomes selected.
But it seems selection does not trigger a DiagramBehavior.refreshRenderingDecorators() so I am stuck and I don't know how to correctly react/(register a listener) to selection changes.
Can I do this like I tried or some other way?
[Updated on: Wed, 30 July 2014 16:06] Report message to a moderator
|
|
|
|
Re: Highlighting Connection of ConnectionDecorator [message #1404259 is a reply to message #1404227] |
Wed, 30 July 2014 17:32 |
Simon Sperl Messages: 21 Registered: May 2014 |
Junior Member |
|
|
thank you, I did.
But did not like that to trigger the decorator I had to click-pause-click (also https://bugs.eclipse.org/bugs/show_bug.cgi?id=440760 )
(since single click feature does not get called on the first click (which selects the shape))
currently I use this in DiagramEditor.init
final GDiagramEditor me = this;
final DiagramBehavior behav = (DiagramBehavior) this.getDiagramTypeProvider().getDiagramBehavior();
//Highlight Connection of selected ConnectionDecorator
selectionListener = new ISelectionListener() {
HashSet<Connection > lastHighlighted = new HashSet<Connection >();
@Override
public void selectionChanged(IWorkbenchPart part, ISelection s) {
if (part != me)
return;
HashSet<Connection > highlighted = new HashSet<Connection >();
if (s instanceof IStructuredSelection)
for (Object sel : ((IStructuredSelection) s).toArray())
if (sel instanceof AbstractEditPart)
if (((AbstractEditPart) sel).getModel() instanceof ConnectionDecorator)
// ..jo I heard you like typecasts
highlighted.add((Connection) ((ConnectionDecorator) ((AbstractEditPart) sel).getModel()).eContainer());
for (Connection high : highlighted)
if (!lastHighlighted.contains(high)) {
// me.getDiagramBehavior().refreshRenderingDecorators(high);
GraphicalEditPart p = behav.getEditPartForPictogramElement(high);
if (p != null)
p.refresh();
p.refresh();
}
for (Connection high : lastHighlighted)
if (!highlighted.contains(high)) {
// me.getDiagramBehavior().refreshRenderingDecorators(high);
GraphicalEditPart p = behav.getEditPartForPictogramElement(high);
if (p != null)
p.refresh();
}
lastHighlighted = highlighted;
}
};
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(selectionListener);
But both ways seemingly run into a bug:
//printed the calls of refresh & ToolBehaviorProvider.getDecorators
//where I click between two ConnectionDecorators belonging to different connections
refresh Connection@1f0f970 (visible: true, active: true)
getDecorators Connection@1f0f970 (visible: true, active: true)
refresh Connection@9dc8ad (visible: true, active: true)
getDecorators Connection@9dc8ad (visible: true, active: true)
refresh Connection@1f0f970 (visible: true, active: true)
refresh Connection@9dc8ad (visible: true, active: true)
refresh Connection@1f0f970 (visible: true, active: true)
refresh Connection@9dc8ad (visible: true, active: true)
I have no idea why getDecorators doesn't get called anymore O.o
edit: after a bit more experimenting getDecorators gets called somewhat randomly on refresh (aka not always on the first refresh)
[Updated on: Wed, 30 July 2014 17:45] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03566 seconds