X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.swt%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fswt%2FGraphExplorerToolTip.java;h=f23d4ee1943ae1afb6ce4b1cb167ff197b473c7f;hp=1debee624e803ae51d95622c6c983c041fc16872;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerToolTip.java b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerToolTip.java index 1debee624..f23d4ee19 100644 --- a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerToolTip.java +++ b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/GraphExplorerToolTip.java @@ -1,60 +1,60 @@ -package org.simantics.browsing.ui.swt; - -import org.eclipse.jface.window.ToolTip; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.simantics.browsing.ui.BuiltinKeys; -import org.simantics.browsing.ui.NodeContext; -import org.simantics.browsing.ui.common.internal.GENodeQueryManager; -import org.simantics.browsing.ui.common.labelers.LabelerStub; -import org.simantics.browsing.ui.content.Labeler; -import org.simantics.browsing.ui.swt.GraphExplorerImpl.GraphExplorerContext; - -public class GraphExplorerToolTip extends ToolTip { - - private boolean DEBUG = false; - - private Tree parent; - private NodeContext nodeContext; - private Labeler labeler; - - private GraphExplorerContext explorerContext; - - public GraphExplorerToolTip(GraphExplorerContext explorerContext, Tree parent) { - super(parent, NO_RECREATE, false); - setHideOnMouseDown(false); - setPopupDelay(400); - this.explorerContext = explorerContext; - this.parent = parent; - this.nodeContext = null; - if (DEBUG) - System.out.println("GraphExplorerToolTip constructor called for parent : " + parent + ", class : " + parent.getClass().toString()); - } - - @Override - protected Composite createToolTipContentArea(Event event, Composite parent) { - return ((LabelerStub) labeler).createToolTipContentArea(event, parent, nodeContext); - } - - @Override - protected boolean shouldCreateToolTip(Event event) { - TreeItem treeItem = parent.getItem(new Point(event.x, event.y)); - if (treeItem == null) - return false; - GENodeQueryManager manager = new GENodeQueryManager(explorerContext, null, null, TreeItemReference.create(treeItem.getParentItem())); - nodeContext = (NodeContext) treeItem.getData(); - if (nodeContext != null) - labeler = manager.query(nodeContext, BuiltinKeys.SELECTED_LABELER); - if (nodeContext == null || !(labeler instanceof LabelerStub)) - return false; - return ((LabelerStub) labeler).shouldCreateToolTip(event, nodeContext); - } - - public void setGraphExplorerContext(GraphExplorerContext explorerContext) { - this.explorerContext = explorerContext; - } - -} +package org.simantics.browsing.ui.swt; + +import org.eclipse.jface.window.ToolTip; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; +import org.simantics.browsing.ui.BuiltinKeys; +import org.simantics.browsing.ui.NodeContext; +import org.simantics.browsing.ui.common.internal.GENodeQueryManager; +import org.simantics.browsing.ui.common.labelers.LabelerStub; +import org.simantics.browsing.ui.content.Labeler; +import org.simantics.browsing.ui.swt.GraphExplorerImpl.GraphExplorerContext; + +public class GraphExplorerToolTip extends ToolTip { + + private boolean DEBUG = false; + + private Tree parent; + private NodeContext nodeContext; + private Labeler labeler; + + private GraphExplorerContext explorerContext; + + public GraphExplorerToolTip(GraphExplorerContext explorerContext, Tree parent) { + super(parent, NO_RECREATE, false); + setHideOnMouseDown(false); + setPopupDelay(400); + this.explorerContext = explorerContext; + this.parent = parent; + this.nodeContext = null; + if (DEBUG) + System.out.println("GraphExplorerToolTip constructor called for parent : " + parent + ", class : " + parent.getClass().toString()); + } + + @Override + protected Composite createToolTipContentArea(Event event, Composite parent) { + return ((LabelerStub) labeler).createToolTipContentArea(event, parent, nodeContext); + } + + @Override + protected boolean shouldCreateToolTip(Event event) { + TreeItem treeItem = parent.getItem(new Point(event.x, event.y)); + if (treeItem == null) + return false; + GENodeQueryManager manager = new GENodeQueryManager(explorerContext, null, null, TreeItemReference.create(treeItem.getParentItem())); + nodeContext = (NodeContext) treeItem.getData(); + if (nodeContext != null) + labeler = manager.query(nodeContext, BuiltinKeys.SELECTED_LABELER); + if (nodeContext == null || !(labeler instanceof LabelerStub)) + return false; + return ((LabelerStub) labeler).shouldCreateToolTip(event, nodeContext); + } + + public void setGraphExplorerContext(GraphExplorerContext explorerContext) { + this.explorerContext = explorerContext; + } + +}