@Override
public void selectionChanged(SelectionChangedEvent event) {
final ISelection selection = event.getSelection();
nodeListener.selectionChanged(part, selection);
AbstractNode node = AbstractNodes.getSelectedNode(selection);
RouteSupport route = AbstractNodes.getRoute(node);
if (route != null && route != previousSelection) {
// lets potentially update the selected route
previousSelection = route;
// only set the route if it differs from the currently selected one in the editor
if (editor.getSelectedRoute() != route) {
editor.setSelectedRoute(route);
}
// lets make sure we get the focus afterwards
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
//viewer.setSelection(selection);
setFocus();
}
});
}
// TODO should we update the diagram's selection too?
}
});
final Tree tree = (Tree)viewer.getControl();
ToolTip tooltip = new DefaultToolTip(tree) {
@Override
protected String getText(Event event) {
TreeItem item = tree.getItem(new Point(event.x, event.y));
if (item != null) {
Object data = item.getData();
AbstractNode node = AbstractNodes.toAbstractNode(item.getData());
if (node != null) {
return node.getDisplayToolTip();
}
if (data instanceof AbstractNodeTreeEditPart) {
AbstractNodeTreeEditPart nodeTree = (AbstractNodeTreeEditPart) data;
return nodeTree.getToolTip();
}