X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.graph.impl%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fgraph%2Fimpl%2FEvaluatorLabeler.java;h=9e0b7b5380d60436e7f7e5abd564da1c4dc2b5e3;hp=222c0e261a4d04af05c4a21726339b857d49f40e;hb=96bb7ef9cbe42d82eb58306d8f9b62392cc29ba8;hpb=ae5bb63c5c88f6569518fed2a24df86fbd0570ff diff --git a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EvaluatorLabeler.java b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EvaluatorLabeler.java index 222c0e261..9e0b7b538 100644 --- a/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EvaluatorLabeler.java +++ b/bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/EvaluatorLabeler.java @@ -3,19 +3,28 @@ package org.simantics.browsing.ui.graph.impl; import java.util.Map; import org.simantics.browsing.ui.BuiltinKeys.LabelerKey; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.simantics.Simantics; import org.simantics.browsing.ui.NodeContext; import org.simantics.browsing.ui.PrimitiveQueryUpdater; import org.simantics.browsing.ui.graph.impl.contribution.LabelerContributionImpl; import org.simantics.browsing.ui.model.browsecontexts.BrowseContext; +import org.simantics.browsing.ui.model.tooltips.TooltipContribution; import org.simantics.db.ReadGraph; import org.simantics.db.UndoContext; +import org.simantics.db.common.request.UniqueRead; +import org.simantics.db.common.utils.RequestUtil; import org.simantics.db.exception.DatabaseException; +import org.simantics.ui.SimanticsUI; public class EvaluatorLabeler extends LabelerContributionImpl { final BrowseContext browseContext; final boolean useNodeBrowseContexts; + private TooltipContribution currentTooltipContribution; + public EvaluatorLabeler(PrimitiveQueryUpdater updater, NodeContext context, LabelerKey key, BrowseContext browseContext, boolean useNodeBrowseContexts) { @@ -54,5 +63,32 @@ public class EvaluatorLabeler extends LabelerContributionImpl { return "EvaluatorLabeler[" + browseContext + "] " + context; } + + @Override + public boolean shouldCreateToolTip(Event event, NodeContext context) { + try { + currentTooltipContribution = RequestUtil.trySyncRequest( + Simantics.getSession(), + SimanticsUI.UI_THREAD_REQUEST_START_TIMEOUT, + SimanticsUI.UI_THREAD_REQUEST_EXECUTION_TIMEOUT, + null, + new UniqueRead() { + @Override + public TooltipContribution perform(ReadGraph graph) throws DatabaseException { + return BrowseContext.get(graph,context,browseContext,useNodeBrowseContexts).shouldCreateToolTip(graph, event, context); + } + }); + if (currentTooltipContribution != null) + return true; + } catch (DatabaseException | InterruptedException e) { + e.printStackTrace(); + } + return false; + } + + @Override + public Composite createToolTipContentArea(Event event, Composite parent, NodeContext nodeContext) { + return (Composite) currentTooltipContribution.getTooltip(event, parent, nodeContext); + } }