ANIMATOR : Bug fix for delete widgets 99/22399/1
authorseongwon.shim <seongwon.shim@samsung.com>
Tue, 3 Jun 2014 05:15:07 +0000 (14:15 +0900)
committerseongwon.shim <seongwon.shim@samsung.com>
Tue, 3 Jun 2014 05:21:37 +0000 (14:21 +0900)
Bug fix for delete widgets and undo logic

Change-Id: I326405a357132cfb15454341a543093a17fa5c06
Signed-off-by: seongwon.shim <seongwon.shim@samsung.com>
org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/commands/DeletePartCommand.java

index 63ca28a..fa40e1d 100644 (file)
@@ -38,6 +38,7 @@ import org.tizen.webuibuilder.animator.model.AnimatorModelEvent.Origin;
 import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
 import org.tizen.webuibuilder.animator.model.AnimatorWidget;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
+import org.tizen.webuibuilder.animator.model.part.AnimatorPart;
 import org.tizen.webuibuilder.animator.model.part.AnimatorWidgetPart;
 import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
 import org.tizen.webuibuilder.model.Part;
@@ -209,32 +210,30 @@ public class DeletePartCommand extends Command {
                 } else {
                     group.getParent().insertChildBefore(child, nextSibling, true);
                 }
-                
-                List<AnimatorModel> animatorWidgets = new ArrayList<AnimatorModel>();
-                AnimatorPagePart pagePart = (AnimatorPagePart)child.getOwnerPage();
-                AnimatorAnimation currentAnimation = pagePart.getCurrentAnimation();
-                Iterator<Entry<AnimatorModel, Integer>> iterator = animatorWidgetGroup.entrySet().iterator();
-                while(iterator.hasNext()) {
-                       Entry<AnimatorModel, Integer> next = iterator.next();
-                       AnimatorModel animatorWidget = (AnimatorWidget)next.getKey();
-                       if (animatorWidget != null) {
-                               if(animatorWidget.getPartLink().equals(child)) {
-                                       AnimatorAnimation animation = (AnimatorAnimation) animatorWidget.getParent();
-                            animation.addChild(next.getValue(), animatorWidget);
-                            
-                            if (currentAnimation != null) {
-                                if (currentAnimation.equals(animation))
-                                    animatorWidgets.add(animatorWidget);
-                            }
-                               }
-                       }
-                }
-                
-                
-                animatorModelManager
-                       .fireEvent(currentAnimation, EventType.WIDGET_ADD, Origin.EDITOR, null, animatorWidgets);
-                animatorModelManager.fireEvent(EventType.WIDGET_ADD, Origin.EDITOR, null);
             }
         }
+        
+        AnimatorAnimation currentAnimation = null;
+        List<AnimatorModel> animatorWidgets = new ArrayList<AnimatorModel>();
+        Iterator<Entry<AnimatorModel, Integer>> iterator = animatorWidgetGroup.entrySet().iterator();
+        while(iterator.hasNext()) {
+               Entry<AnimatorModel, Integer> next = iterator.next();
+               AnimatorModel animatorWidget = (AnimatorWidget)next.getKey();
+               if (animatorWidget != null) {
+                       AnimatorPart animatorPart = (AnimatorPart)animatorWidget.getPartLink();
+                       AnimatorPagePart pagePart = (AnimatorPagePart)animatorPart.getOwnerPage();
+                       currentAnimation = pagePart.getCurrentAnimation();
+                       AnimatorAnimation animation = (AnimatorAnimation) animatorWidget.getParent();
+                animation.addChild(next.getValue(), animatorWidget);
+                if (currentAnimation != null) {
+                    if (currentAnimation.equals(animation))
+                        animatorWidgets.add(animatorWidget);
+                }
+               }
+        }
+        
+        animatorModelManager
+               .fireEvent(currentAnimation, EventType.WIDGET_ADD, Origin.EDITOR, null, animatorWidgets);
+        animatorModelManager.fireEvent(EventType.WIDGET_ADD, Origin.EDITOR, null);
     }
 }
\ No newline at end of file