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