1 package org.simantics.browsing.ui.swt;
\r
3 import org.eclipse.jface.window.ToolTip;
\r
4 import org.eclipse.swt.graphics.Point;
\r
5 import org.eclipse.swt.widgets.Composite;
\r
6 import org.eclipse.swt.widgets.Event;
\r
7 import org.eclipse.swt.widgets.Tree;
\r
8 import org.eclipse.swt.widgets.TreeItem;
\r
9 import org.simantics.browsing.ui.BuiltinKeys;
\r
10 import org.simantics.browsing.ui.NodeContext;
\r
11 import org.simantics.browsing.ui.common.internal.GENodeQueryManager;
\r
12 import org.simantics.browsing.ui.common.labelers.LabelerStub;
\r
13 import org.simantics.browsing.ui.content.Labeler;
\r
14 import org.simantics.browsing.ui.swt.GraphExplorerImpl.GraphExplorerContext;
\r
16 public class GraphExplorerToolTip extends ToolTip {
\r
18 private boolean DEBUG = false;
\r
20 private Tree parent;
\r
21 private NodeContext nodeContext;
\r
22 private Labeler labeler;
\r
24 private GraphExplorerContext explorerContext;
\r
26 public GraphExplorerToolTip(GraphExplorerContext explorerContext, Tree parent) {
\r
27 super(parent, NO_RECREATE, false);
\r
28 setHideOnMouseDown(false);
\r
30 this.explorerContext = explorerContext;
\r
31 this.parent = parent;
\r
32 this.nodeContext = null;
\r
34 System.out.println("GraphExplorerToolTip constructor called for parent : " + parent + ", class : " + parent.getClass().toString());
\r
38 protected Composite createToolTipContentArea(Event event, Composite parent) {
\r
39 return ((LabelerStub) labeler).createToolTipContentArea(event, parent, nodeContext);
\r
43 protected boolean shouldCreateToolTip(Event event) {
\r
44 TreeItem treeItem = parent.getItem(new Point(event.x, event.y));
\r
45 if (treeItem == null)
\r
47 GENodeQueryManager manager = new GENodeQueryManager(explorerContext, null, null, TreeItemReference.create(treeItem.getParentItem()));
\r
48 nodeContext = (NodeContext) treeItem.getData();
\r
49 if (nodeContext != null)
\r
50 labeler = manager.query(nodeContext, BuiltinKeys.SELECTED_LABELER);
\r
51 if (nodeContext == null || !(labeler instanceof LabelerStub))
\r
53 return ((LabelerStub) labeler).shouldCreateToolTip(event, nodeContext);
\r
56 public void setGraphExplorerContext(GraphExplorerContext explorerContext) {
\r
57 this.explorerContext = explorerContext;
\r