ANIMATOR : Fixed Forward null 41/18641/1
authorjinwooim.bae <jinwooim.bae@samsung.com>
Thu, 27 Mar 2014 09:21:46 +0000 (18:21 +0900)
committerjinwooim.bae <jinwooim.bae@samsung.com>
Thu, 27 Mar 2014 09:23:39 +0000 (18:23 +0900)
This code do not check forward null.

Change-Id: If9abc6f2bb05fc76dad1c26eccbb8808d4a1a473
Signed-off-by: jinwooim.bae <jinwooim.bae@samsung.com>
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorModelManager.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/deserializer/AnimatorAnimationDeserializer.java

index 19e9e8f..74e6556 100644 (file)
@@ -1388,49 +1388,50 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
      */
     public void removeAnimatorRelatedResources() {
         if (appManager instanceof AppManagerForHTML) {
-            if (!((AnimatorPart)rootPart).hasAnimation()) {
+            if (!((AnimatorPart) rootPart).hasAnimation()) {
                 Document editDoc = ((AppManagerForHTML) appManager).getDocument();
                 NodeList heads = editDoc.getElementsByTagName("head");
                 Element head = null;
                 if (heads != null) {
                     head = (Element) heads.item(0);
                 } else {
-                       head = editDoc.createElement("head");
-                    if(head != null) {
-                       editDoc.insertBefore(head, editDoc.getFirstChild());
+                    head = editDoc.createElement("head");
+                    if (head != null) {
+                        editDoc.insertBefore(head, editDoc.getFirstChild());
                     }
                 }
-
-                NodeList scripts = head.getElementsByTagName("script");
-                if (scripts != null) {
-                    int len = scripts.getLength();
-                    for (int i = 0; i < len; i++) {
-                        Element script = (Element) scripts.item(i);
-                        String src = script.getAttribute("src");
-                        int fileidx = src.lastIndexOf("/");
-                        String filename = src.substring(fileidx + 1);
-                        if (filename.equals(AnimatorConstants.ANIMATOR_MODEL_JS_FILE)
-                                || filename.equals(AnimatorConstants.ANIMATOR_FRAMEWORK_JSPATH)) {
-                            // elm.removeChild(script);
-                            script.removeAttribute("src");
-                            script.setTextContent("");
+                if (head != null) {
+                    NodeList scripts = head.getElementsByTagName("script");
+                    if (scripts != null) {
+                        int len = scripts.getLength();
+                        for (int i = 0; i < len; i++) {
+                            Element script = (Element) scripts.item(i);
+                            String src = script.getAttribute("src");
+                            int fileidx = src.lastIndexOf("/");
+                            String filename = src.substring(fileidx + 1);
+                            if (filename.equals(AnimatorConstants.ANIMATOR_MODEL_JS_FILE)
+                                    || filename.equals(AnimatorConstants.ANIMATOR_FRAMEWORK_JSPATH)) {
+                                // elm.removeChild(script);
+                                script.removeAttribute("src");
+                                script.setTextContent("");
+                            }
                         }
                     }
-                }
-                NodeList links = head.getElementsByTagName("link");
-                if (links != null) {
-                    int len = links.getLength();
-                    for (int i = 0; i < len; i++) {
-                        Element link = (Element) links.item(i);
-                        String src = link.getAttribute("href");
-                        int fileidx = src.lastIndexOf("/");
-                        String filename = src.substring(fileidx + 1);
-                        if (filename.equals(AnimatorConstants.ANIMATOR_MODEL_CSS_FILE)) {
-                            // elm.removeChild(script);
-                            link.removeAttribute("href");
-                            link.removeAttribute("rel");
-                            link.removeAttribute("type");
-                            link.setTextContent("");
+                    NodeList links = head.getElementsByTagName("link");
+                    if (links != null) {
+                        int len = links.getLength();
+                        for (int i = 0; i < len; i++) {
+                            Element link = (Element) links.item(i);
+                            String src = link.getAttribute("href");
+                            int fileidx = src.lastIndexOf("/");
+                            String filename = src.substring(fileidx + 1);
+                            if (filename.equals(AnimatorConstants.ANIMATOR_MODEL_CSS_FILE)) {
+                                // elm.removeChild(script);
+                                link.removeAttribute("href");
+                                link.removeAttribute("rel");
+                                link.removeAttribute("type");
+                                link.setTextContent("");
+                            }
                         }
                     }
                 }
index bf6751f..d25b7ab 100644 (file)
@@ -48,7 +48,7 @@ public class AnimatorAnimationDeserializer extends AnimatorModelDeserializer<Ani
                super(modelFactory);
        }
 
-       /*
+    /*
      * (non-Javadoc)
      * 
      * @see
@@ -57,15 +57,16 @@ public class AnimatorAnimationDeserializer extends AnimatorModelDeserializer<Ani
      * com.google.gson.JsonDeserializationContext)
      */
     @Override
-    public AnimatorModel deserialize(JsonElement json, Type arg1,
-                                         JsonDeserializationContext context)
+    public AnimatorModel deserialize(JsonElement json, Type arg1, JsonDeserializationContext context)
             throws JsonParseException {
 
         AnimatorAnimation animation = null;
         if (getPagePart() != null) {
             JsonObject jobject = (JsonObject) json;
 
-            animation = (AnimatorAnimation)getModelFactory().createAnimatorModel(AnimatorModelType.ANIMATION);
+            animation =
+                    (AnimatorAnimation) getModelFactory()
+                            .createAnimatorModel(AnimatorModelType.ANIMATION);
             animation.setId(jobject.get("id").getAsString());
 
             JsonElement jsonElement = jobject.get("name");
@@ -92,37 +93,42 @@ public class AnimatorAnimationDeserializer extends AnimatorModelDeserializer<Ani
                     AnimatorWidget widget = (AnimatorWidget) animation.getChild(id);
                     Part widgetPart = null;
                     if (widget == null) {
-                       widgetPart = (Part) getPagePart().getChildOfIdPropertyValue(id, true);
-                       if(widgetPart != null) {
-                               widget = (AnimatorWidget)getModelFactory().createAnimatorModel(AnimatorModelType.WIDGET);
-                               if(widget != null) {
-                                       widget.setPartLink(widgetPart);
+                        widgetPart = (Part) getPagePart().getChildOfIdPropertyValue(id, true);
+                        if (widgetPart != null) {
+                            widget =
+                                    (AnimatorWidget) getModelFactory()
+                                            .createAnimatorModel(AnimatorModelType.WIDGET);
+                            if (widget != null) {
+                                widget.setPartLink(widgetPart);
                                 widget.setId(widgetPart.getPropertyValue("id"));
                                 widget.setParent(animation);
                                 animation.addChild(widget);
-                               }
-                       }
-//                        widgetPart = (Part) getPagePart().getChildOfIdPropertyValue(id, true);
-//                        widget = (AnimatorWidget)getModelFactory().createAnimatorModel(AnimatorModelType.WIDGET);
-//                        widget.setPartLink(widgetPart);
-//                        widget.setId(widgetPart.getPropertyValue("id"));
-//                        widget.setParent(animation);
-//                        animation.addChild(widget);
+                            }
+                        }
+                        // widgetPart = (Part) getPagePart().getChildOfIdPropertyValue(id, true);
+                        // widget =
+                        // (AnimatorWidget)getModelFactory().createAnimatorModel(AnimatorModelType.WIDGET);
+                        // widget.setPartLink(widgetPart);
+                        // widget.setId(widgetPart.getPropertyValue("id"));
+                        // widget.setParent(animation);
+                        // animation.addChild(widget);
                     }
 
-                    widget.setLock(membersObject.get("lock").getAsBoolean());
-                    widget.setVisibility(membersObject.get("visibility").getAsBoolean());
-
-                    if (membersObject.has("animation")) {
-                        AnimatorSelector selector =
-                                context.deserialize(membersObject.get("animation")
-                                        .getAsJsonObject(), AnimatorSelector.class);
-                        selector.setSelector(membersObject.get("selector").getAsString());
-                        selector.setParent(widget);
-                        if (widgetPart != null) {
-                            selector.setPartLink(widgetPart);
+                    if (widget != null) {
+                        widget.setLock(membersObject.get("lock").getAsBoolean());
+                        widget.setVisibility(membersObject.get("visibility").getAsBoolean());
+
+                        if (membersObject.has("animation")) {
+                            AnimatorSelector selector =
+                                    context.deserialize(membersObject.get("animation")
+                                            .getAsJsonObject(), AnimatorSelector.class);
+                            selector.setSelector(membersObject.get("selector").getAsString());
+                            selector.setParent(widget);
+                            if (widgetPart != null) {
+                                selector.setPartLink(widgetPart);
+                            }
+                            widget.addChild(selector);
                         }
-                        widget.addChild(selector);
                     }
                 }
             }