From 7754cc9adc240214e9ea864dc5dfe0aaed43b818 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Tue, 1 Aug 2017 14:52:19 +0300 Subject: [PATCH] Prevent unnecessary exception logging in DescriptionTooltipRule refs #7393 Change-Id: Ifd473d11d0987f112c2bf616f2619d05cdf7c055 --- .../tooltips/DescriptionTooltipRule.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tooltips/DescriptionTooltipRule.java b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tooltips/DescriptionTooltipRule.java index 7bef8e22c..a9ebb9dfc 100644 --- a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tooltips/DescriptionTooltipRule.java +++ b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tooltips/DescriptionTooltipRule.java @@ -18,9 +18,9 @@ import org.simantics.db.layer0.variable.Variable; import org.simantics.layer0.Layer0; public class DescriptionTooltipRule implements TooltipRule { - + public static final DescriptionTooltipRule INSTANCE = new DescriptionTooltipRule(); - + public DescriptionTooltipRule() { } @@ -58,28 +58,26 @@ public class DescriptionTooltipRule implements TooltipRule { public boolean isCompatible(Class contentType) { return (contentType == Resource.class || contentType == Variable.class); } - + private static String getToolTipContent(ReadGraph graph, NodeContext nodeContext) throws DatabaseException { Object input = nodeContext.getConstant(BuiltinKeys.INPUT); - String content = null; if (input instanceof Variable) { Variable var = (Variable) input; - Resource res = var.getPredicateResource(graph); - Layer0 L0 = Layer0.getInstance(graph); - String description = graph.getPossibleRelatedValue2(res, L0.HasDescription); - return description; + Resource res = var.getPossiblePredicateResource(graph); + if (res != null) { + Layer0 L0 = Layer0.getInstance(graph); + return graph.getPossibleRelatedValue2(res, L0.HasDescription); + } } else if (input instanceof Resource) { Resource res = (Resource) input; - Layer0 L0 = Layer0.getInstance(graph); - String description = graph.getPossibleRelatedValue2(res, L0.HasDescription); - return description; + return graph.getPossibleRelatedValue2(res, L0.HasDescription); } - return content; + return null; } @Override - public boolean shouldCreateToolTip(ReadGraph graph , NodeContext context, Map auxiliary) throws DatabaseException { + public boolean shouldCreateToolTip(ReadGraph graph, NodeContext context, Map auxiliary) throws DatabaseException { String content = getToolTipContent(graph, context); if (content == null || content.isEmpty()) return false; -- 2.47.1