X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.model%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fmodel%2Ftooltips%2FTooltipContribution.java;h=7d7b0232478864b9f6f6aa7c0bcb7ee23be05be2;hp=2a9d36d02a1a9ae24d4626f167983f4bbef2e989;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tooltips/TooltipContribution.java b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tooltips/TooltipContribution.java index 2a9d36d02..7d7b02324 100644 --- a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tooltips/TooltipContribution.java +++ b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tooltips/TooltipContribution.java @@ -1,44 +1,44 @@ -package org.simantics.browsing.ui.model.tooltips; - -import java.util.HashMap; -import java.util.Map; - -import org.simantics.browsing.ui.BuiltinKeys; -import org.simantics.browsing.ui.NodeContext; -import org.simantics.browsing.ui.model.InvalidContribution; -import org.simantics.browsing.ui.model.nodetypes.NodeType; -import org.simantics.browsing.ui.model.tests.Test; -import org.simantics.browsing.ui.model.visuals.VisualsContribution; -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; - -public class TooltipContribution extends VisualsContribution { - TooltipRule tooltipRule; - - private Map auxiliary = new HashMap<>(); - - public TooltipContribution(NodeType nodeType, Test test, TooltipRule tooltipRule, double priority) throws InvalidContribution { - super(nodeType, test, priority); - if(!tooltipRule.isCompatible(nodeType.getContentType())) - throw new InvalidContribution("Tooltip rule is not compatible with the content type."); - this.tooltipRule = tooltipRule; - } - - public Object getTooltip(Object event, Object parent, NodeContext context) { - try { - return tooltipRule.createTooltip(event, parent, context, auxiliary); - } finally { - auxiliary.clear(); - } - - } - - public boolean shouldCreateToolTip(ReadGraph graph, NodeContext context) throws DatabaseException { - Object content = context.getConstant(BuiltinKeys.INPUT); - if(test != null && !test.test(graph, content)) - return false; - - return tooltipRule.shouldCreateToolTip(graph, context, auxiliary); - } - -} +package org.simantics.browsing.ui.model.tooltips; + +import java.util.HashMap; +import java.util.Map; + +import org.simantics.browsing.ui.BuiltinKeys; +import org.simantics.browsing.ui.NodeContext; +import org.simantics.browsing.ui.model.InvalidContribution; +import org.simantics.browsing.ui.model.nodetypes.NodeType; +import org.simantics.browsing.ui.model.tests.Test; +import org.simantics.browsing.ui.model.visuals.VisualsContribution; +import org.simantics.db.ReadGraph; +import org.simantics.db.exception.DatabaseException; + +public class TooltipContribution extends VisualsContribution { + TooltipRule tooltipRule; + + private Map auxiliary = new HashMap<>(); + + public TooltipContribution(NodeType nodeType, Test test, TooltipRule tooltipRule, double priority) throws InvalidContribution { + super(nodeType, test, priority); + if(!tooltipRule.isCompatible(nodeType.getContentType())) + throw new InvalidContribution("Tooltip rule is not compatible with the content type."); + this.tooltipRule = tooltipRule; + } + + public Object getTooltip(Object event, Object parent, NodeContext context) { + try { + return tooltipRule.createTooltip(event, parent, context, auxiliary); + } finally { + auxiliary.clear(); + } + + } + + public boolean shouldCreateToolTip(ReadGraph graph, NodeContext context) throws DatabaseException { + Object content = context.getConstant(BuiltinKeys.INPUT); + if(test != null && !test.test(graph, content)) + return false; + + return tooltipRule.shouldCreateToolTip(graph, context, auxiliary); + } + +}