PROP : Add validate routine in Metrics. 72/20472/1
authornakyoung2.choi <nakyoung2.choi@samsung.com>
Thu, 8 May 2014 04:54:21 +0000 (13:54 +0900)
committernakyoung2.choi <nakyoung2.choi@samsung.com>
Thu, 8 May 2014 04:54:21 +0000 (13:54 +0900)
Check integer value.

Change-Id: I52d840ed58225eb811635b3f83805b75bb8e452b
Signed-off-by: nakyoung2.choi <nakyoung2.choi@samsung.com>
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/method/MetricsMethod.java

index ea2adcc..2373280 100644 (file)
@@ -1120,8 +1120,9 @@ public class MetricsMethod extends Method {
                                 Label label = textEditor.getLabel();
                                 String editorData = textEditor.getEditor().getText();
                                 if (editorData != null) {
-                                    /** TODO : need validation */
-                                    if (isDefaultValue(editorData)) {
+                                    if (!validateTextEditor(textEditor)) {
+                                        return;
+                                    } else if (isDefaultValue(editorData)) {
                                         label.setText(DEFAULT_VALUE);
                                     } else {
                                         label.setText(editorData);
@@ -1145,8 +1146,10 @@ public class MetricsMethod extends Method {
                         Label label = textEditor.getLabel();
                         String editorData = textEditor.getEditor().getText();
                         if (editorData != null) {
-                            /** TODO : need validation */
-                            if (isDefaultValue(editorData)) {
+                            if (!validateTextEditor(textEditor)) {
+                                textEditor.showLabel();
+                                return;
+                            } else if (isDefaultValue(editorData)) {
                                 label.setText(DEFAULT_VALUE);
                             } else {
                                 label.setText(editorData);
@@ -1194,4 +1197,17 @@ public class MetricsMethod extends Method {
         data.right = new FormAttachment(100, 0);
         return data;
     }
+    
+    private boolean validateTextEditor(TextEditor textEditor) {
+        String labelText = textEditor.getLabel().getText();
+        String editorData = textEditor.getEditor().getText();
+        if (editorData == null) {
+            return false;
+        } else if (!editorData.matches(BuilderConstants.INTEGERVALUE)) {
+            return false;
+        } else if (editorData.equals(labelText)) {
+            return false;
+        }
+        return true;
+    }
 }