Colo(u)r in the background of the background data values, depending on how they relat...
authorAndy Allan <andy@gravitystorm.co.uk>
Mon, 4 Jul 2011 13:54:53 +0000 (14:54 +0100)
committerAndy Allan <andy@gravitystorm.co.uk>
Mon, 4 Jul 2011 13:54:53 +0000 (14:54 +0100)
net/systemeD/potlatch2/panels/BackgroundMergeFieldComponent.as [new file with mode: 0644]
net/systemeD/potlatch2/panels/BackgroundMergePanel.mxml

diff --git a/net/systemeD/potlatch2/panels/BackgroundMergeFieldComponent.as b/net/systemeD/potlatch2/panels/BackgroundMergeFieldComponent.as
new file mode 100644 (file)
index 0000000..08a0ada
--- /dev/null
@@ -0,0 +1,20 @@
+package net.systemeD.potlatch2.panels {
+
+    import mx.controls.Label;
+    import mx.controls.dataGridClasses.*;
+    import net.systemeD.potlatch2.panels.BackgroundMergePanel;
+
+    public class BackgroundMergeFieldComponent extends Label {
+
+     override public function set data(value:Object):void
+     {
+        if(value != null)
+        {
+            super.data = value;
+            textField.background = true;
+            textField.backgroundColor = BackgroundMergePanel(listData.owner.parent).getColorFor(listData.rowIndex);
+        }
+     }
+  }
+
+}
\ No newline at end of file
index 7af12ee..64450c0 100644 (file)
@@ -17,7 +17,7 @@
           </mx:Component>
         </mx:itemRenderer>
       </mx:DataGridColumn>
-      <mx:DataGridColumn editable="false" dataField="b" headerText="Background value" />
+      <mx:DataGridColumn editable="false" itemRenderer="net.systemeD.potlatch2.panels.BackgroundMergeFieldComponent" dataField="b" headerText="Background value" />
     </mx:columns>
   </mx:DataGrid>
   <mx:Script><![CDATA[
       public function mergeForKey(key:String):void {
           trace("merge for " + key);
       }
+
+      public function getColorFor(i:int):int {
+          if (tagDataProvider[i].e == tagDataProvider[i].b) {
+              return 0xDDFFDD; // matching, green
+           } else if (tagDataProvider[i].e == null) {
+              return 0xDDDDFF; // new value, blue
+           } else {
+              return 0xFFDDDD; // conflicting, red
+           }
+      }
   ]]>
   </mx:Script>
 </mx:VBox>
\ No newline at end of file