DATABIND : Remove NPE. 34/18734/1
authorparary <kyunghan80.park@samsung.com>
Mon, 31 Mar 2014 05:05:03 +0000 (14:05 +0900)
committerparary <kyunghan80.park@samsung.com>
Mon, 31 Mar 2014 05:05:03 +0000 (14:05 +0900)
Change-Id: I5caa59419bcf5f805cef282698bf551a10a5c712
Signed-off-by: parary <kyunghan80.park@samsung.com>
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/databinding/dialog/Helper.java

index 9bccb50..2f17202 100644 (file)
@@ -232,20 +232,24 @@ public class Helper {
 
         String imageName = null;
         
-        if( type.equals("Boolean") ){
-            imageName = null;
-        }else if( type.equals( "Number" ) ){
-            imageName = null;
-        }else if( type.equals( "String" ) ){
-            imageName = null;
-        }else if( type.equals( "Array" ) ){
-            imageName = "temp.png";
-        }else if( type.equals( "Index" ) ){
-            imageName = null;
-        }else{
-            imageName = null;
+//        if( type.equals("Boolean") ){
+//            imageName = null;
+//        }else if( type.equals( "Number" ) ){
+//            imageName = null;
+//        }else if( type.equals( "String" ) ){
+//            imageName = null;
+//        }else if( type.equals( "Array" ) ){
+//            imageName = "temp.png";
+//        }else if( type.equals( "Index" ) ){
+//            imageName = null;
+//        }else{
+//            imageName = null;
+//        }
+        
+        if( type.equals( "Array" ) ){
+          imageName = "temp.png";
         }
-
+        
         if (imageName != null) {
             treeItem.setImage ( ResourceManager.getImage( BuilderConstants.ICON_DIR, imageName ) );
         }
@@ -260,20 +264,11 @@ public class Helper {
         
         TreeItem[] items = parentItem.getItems();
         
-        JsonObject parentJson = null;
-        JsonArray parentArray = null;
-        
-        if( parentJsonElement instanceof JsonObject ){
-            parentJson = (JsonObject) parentJsonElement;
-        } else if( parentJsonElement instanceof JsonArray ){
-            parentArray = (JsonArray) parentJsonElement;
-        }
-        
         JsonObject jsonOb = null;
         
         if( type.equals("Array") ){
             JsonArray array = new JsonArray();
-            parentJson.add(key, array);
+            ((JsonObject)parentJsonElement).add(key, array);
             jsonOb = null;
             for (TreeItem item : items) {
                 if( item.getText(2).equals("Index") ){
@@ -288,7 +283,7 @@ public class Helper {
             }
         }else if( type.equals("Object") ){
             jsonOb = new JsonObject();
-            parentJson.add(key, jsonOb);
+            ((JsonObject)parentJsonElement).add(key, jsonOb);
             for (TreeItem item : items) {
                 makeJsonFromTree( item, jsonOb );
             }
@@ -298,19 +293,19 @@ public class Helper {
                 if(item.getText().length() > 0){
                     makeJsonFromTree( item, jsonOb );
                 }else{
-                    parentArray.add( new JsonPrimitive(item.getText(1)) );
+                    ((JsonArray)parentJsonElement).add( new JsonPrimitive(item.getText(1)) );
                 }
             }
             if( !jsonOb.entrySet().isEmpty() )
-                parentArray.add(jsonOb);
+                ((JsonArray)parentJsonElement).add(jsonOb);
         }else if( type.equals("String") ){
-            parentJson.addProperty( key, value );
+            ((JsonObject)parentJsonElement).addProperty( key, value );
         }else if( type.equals("Boolean") ){
-            parentJson.addProperty( key, Boolean.valueOf( value ) );
+            ((JsonObject)parentJsonElement).addProperty( key, Boolean.valueOf( value ) );
         }else if( type.equals("Number") ){
-            parentJson.addProperty( key, Long.parseLong( value ) );
+            ((JsonObject)parentJsonElement).addProperty( key, Long.parseLong( value ) );
         }else{
-            parentJson.add( key, null );
+            ((JsonObject)parentJsonElement).add( key, null );
         }
     }
     
@@ -444,4 +439,4 @@ public class Helper {
 //        }
 //        return false;
 //    } 
-}
+}
\ No newline at end of file