]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tooltips/DescriptionTooltipRule.java
Prevent unnecessary exception logging in DescriptionTooltipRule
[simantics/platform.git] / bundles / org.simantics.browsing.ui.model / src / org / simantics / browsing / ui / model / tooltips / DescriptionTooltipRule.java
index 7bef8e22c127bf00946f7c35f92c8c3f48bcb403..a9ebb9dfcbe26e2aa4e9ba1ff16d46be1ddb9699 100644 (file)
@@ -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<Object, Object> auxiliary) throws DatabaseException {
+    public boolean shouldCreateToolTip(ReadGraph graph, NodeContext context, Map<Object, Object> auxiliary) throws DatabaseException {
         String content = getToolTipContent(graph, context);
         if (content == null || content.isEmpty())
             return false;