]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Column support in ConstantLabelDecorationRule
authorAntti Villberg <antti.villberg@semantum.fi>
Thu, 2 May 2019 06:13:16 +0000 (09:13 +0300)
committerAntti Villberg <antti.villberg@semantum.fi>
Thu, 2 May 2019 06:13:16 +0000 (09:13 +0300)
Change-Id: I5f6c6c1cdbd1a5e2d5e070ca377da62e0d2af6a4

bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/labeldecorators/ConstantLabelDecorationRule.java
bundles/org.simantics.viewpoint.ontology/graph/Viewpoint.pgraph

index 5ba9ced6ed3fa07ca9ae71f96e8661818cb00044..a82fd0d091663ac1260acdbbe183baf122ead76a 100644 (file)
@@ -39,13 +39,14 @@ public class ConstantLabelDecorationRule extends AbstractLabelDecorator implemen
 
     String prefix;
     String postfix;
+    String column;
     ColorDescriptor foregroundColor;
     ColorDescriptor backgroundColor;
     int style;
     
     public ConstantLabelDecorationRule(String format,
             ColorDescriptor foregroundColor, ColorDescriptor backgroundColor,
-            String style) {
+            String style, String column) {
         if(format != null) {
             String[] split = format.split("%s", 2);
             if(split.length == 1) {
@@ -59,6 +60,7 @@ public class ConstantLabelDecorationRule extends AbstractLabelDecorator implemen
         }
         this.foregroundColor = foregroundColor;
         this.backgroundColor = backgroundColor;
+        this.column = column;
         this.style = SWT.NORMAL;
         if(style != null)
             for(char c : style.toCharArray())
@@ -92,12 +94,13 @@ public class ConstantLabelDecorationRule extends AbstractLabelDecorator implemen
         ColorDescriptor backgroundColor = getPossibleRelatedColor(g, r, vr.ConstantLabelDecorationRule_HasBackgroundColor);
         
         String style = g.getPossibleRelatedValue(r, vr.ConstantLabelDecorationRule_HasStyle, Bindings.STRING);
+        String column = g.getPossibleRelatedValue(r, vr.ConstantLabelDecorationRule_HasColumn, Bindings.STRING);
         
         return new ConstantLabelDecorationRule(
                 format, 
                 foregroundColor, 
                 backgroundColor,
-                style
+                style, column
         );
     }
     
@@ -114,6 +117,9 @@ public class ConstantLabelDecorationRule extends AbstractLabelDecorator implemen
     
     @Override
     public String decorateLabel(String label, String column, int itemIndex) {
+        if(this.column != null)
+            if(!this.column.equals(column))
+                return label;
         if(postfix == null)
             return label;
         else
@@ -122,6 +128,9 @@ public class ConstantLabelDecorationRule extends AbstractLabelDecorator implemen
     
     @SuppressWarnings("unchecked")
     public <Color> Color decorateForeground(Color color, String column, int itemIndex) {
+        if(this.column != null)
+            if(!this.column.equals(column))
+                return color;
         if(foregroundColor == null)
             return color;
         else
@@ -130,6 +139,9 @@ public class ConstantLabelDecorationRule extends AbstractLabelDecorator implemen
 
     @SuppressWarnings("unchecked")
     public <Color> Color decorateBackground(Color color, String column, int itemIndex) {
+        if(this.column != null)
+            if(!this.column.equals(column))
+                return color;
         if(backgroundColor == null)
             return color;
         else
@@ -138,6 +150,9 @@ public class ConstantLabelDecorationRule extends AbstractLabelDecorator implemen
     
     @SuppressWarnings("unchecked")
     public <Font> Font decorateFont(Font font, String column, int itemIndex) {
+        if(this.column != null)
+            if(!this.column.equals(column))
+                return font;
         if(style == 0)
             return font;
         else {
index e345d6798b83c20da9dc0beb2e8961f8d48815b0..3fb6a6db0ec3c9691ff0559e1b2ab2ece942de4f 100644 (file)
@@ -157,6 +157,9 @@ VP.ConstantLabelDecorationRule.HasFont <R L0.HasProperty : L0.FunctionalRelation
 VP.ConstantLabelDecorationRule.HasStyle <R L0.HasProperty : L0.FunctionalRelation            
     L0.HasDomain VP.ConstantLabelDecorationRule
     L0.HasRange L0.String
+VP.ConstantLabelDecorationRule.HasColumn <R L0.HasProperty : L0.FunctionalRelation
+    L0.HasDomain VP.ConstantLabelDecorationRule
+    L0.HasRange L0.String
 
 VP.FlatNodeRule : VP.VisualsRule