]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Passing data between tooltip check and content creation. 92/2492/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 26 Nov 2018 11:18:34 +0000 (13:18 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 26 Nov 2018 11:18:34 +0000 (13:18 +0200)
gitlab #146

Change-Id: I415f79b182cacbeca9999aacc50ac920c31a344b

bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/contributor/labeler/ColumnLabelerContributorImpl.java

index 47dcf92c255a4b3a5015931e6d6aab7212e0d688..51963dce2d669bd8b9a3e1cb24c659db058829d2 100644 (file)
@@ -12,6 +12,7 @@
  *******************************************************************************/
 package org.simantics.browsing.ui.graph.impl.contributor.labeler;
 
+import java.util.HashMap;
 import java.util.Map;
 
 import org.simantics.browsing.ui.BuiltinKeys;
@@ -56,11 +57,11 @@ abstract public class ColumnLabelerContributorImpl<T> implements Contributor<Lab
         this.clazz = clazz;
     }
 
-    public boolean shouldCreateToolTip(Object event, T input) {
+    public boolean shouldCreateToolTip(Object event, T input, Map<Object, Object> auxiliary) {
         return false;
     }
 
-    public Object createToolTipContentArea(Object event, Object parent, T input) {
+    public Object createToolTipContentArea(Object event, Object parent, T input, Map<Object, Object> auxiliary) {
         return null;
     }
 
@@ -108,17 +109,23 @@ abstract public class ColumnLabelerContributorImpl<T> implements Contributor<Lab
                     public String toString() {
                         return ColumnLabelerContributorImpl.this.toString();
                     }
+                    
+                    private Map<Object, Object> auxiliary = new HashMap<>();
 
                     @Override
                     public boolean createToolTip(Object event, NodeContext nodeContext) {
                         T input = (T)context.getConstant(BuiltinKeys.INPUT);
-                        return ColumnLabelerContributorImpl.this.shouldCreateToolTip(event, input);
+                        return ColumnLabelerContributorImpl.this.shouldCreateToolTip(event, input, auxiliary);
                     }
 
                     @Override
                     public Object createToolTipContent(Object event, Object parent, NodeContext nodeContext) {
                         T input = (T)context.getConstant(BuiltinKeys.INPUT);
-                        return ColumnLabelerContributorImpl.this.createToolTipContentArea(event, parent, input);
+                        try {
+                            return ColumnLabelerContributorImpl.this.createToolTipContentArea(event, parent, input, auxiliary);
+                        } finally {
+                            auxiliary.clear();
+                        }
                     }
 
                 };