Merge branch 'master' into history
[potlatch2.git] / net / systemeD / controls / DataGridWarningField.as
1 package net.systemeD.controls {
2         import mx.controls.Label;
3         import mx.controls.listClasses.*;
4         import flash.display.DisplayObject;
5         import mx.controls.Image;
6  
7         public class DataGridWarningField extends Label {
8
9                 private var _image:Image;
10                 [Embed(source="../../../embedded/warning.png")] private var warningIcon:Class;
11                 private var _whiteList:Array = ["source","collection_times","service_times","smoking_hours","opening_hours"];
12
13                 function DataGridWarningField():void {
14                         super();
15                         setStyle('paddingLeft',2);
16                 }
17
18                 override protected function createChildren():void {
19                         super.createChildren();
20                         _image = new Image();
21                         _image.source = warningIcon;
22                         _image.width = 16;
23                         _image.height = 16;
24                         addChild(DisplayObject(_image));
25                 }
26
27                 override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
28                         super.updateDisplayList(unscaledWidth, unscaledHeight);
29
30                         if (data.value && (_whiteList.indexOf(data.key)==-1) && (data.value.indexOf(';')>-1)) { 
31                                 setStyle('color',0xFF0000);
32                                 _image.visible=true;
33                                 _image.x = width -_image.width -5;
34                                 _image.y = height-_image.height-3;
35                                 _image.toolTip = "The tag contains more than one value - please check";
36                                 textField.width = width-_image.width-5;
37                         } else {
38                                 setStyle('color',0);
39                                 _image.visible=false;
40                         }
41                 }
42         }
43 }