ANIMATOR : Replace getRootPart() and getPagePart() from AnimatorModelManager 94/19994/2
authorseongwon.shim <seongwon.shim@samsung.com>
Thu, 24 Apr 2014 07:55:48 +0000 (16:55 +0900)
committerseongwon.shim <seongwon.shim@samsung.com>
Thu, 24 Apr 2014 08:29:24 +0000 (17:29 +0900)
Replace to get rootPart or pagePart from AppManager in AnimatorBrowserViewer

Change-Id: Ibc8946f1b4407e752be8ce4c7b3cef5eb31c7959
Signed-off-by: seongwon.shim <seongwon.shim@samsung.com>
21 files changed:
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/command/AnimationCreateAndChangeFrameCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/command/AnimationCreateCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/command/AnimationPathMoveCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/editparts/AnimatorEditPart.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/viewer/AnimatorBrowserViewer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorAnimation.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorModelManager.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/io/AnimatorFileWriter.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/part/AnimatorPagePart.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/part/AnimatorWidgetPart.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/serializer/AnimatorPagePartSerializer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/command/TimelineAnimationGroupDeleteCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/command/TimelineFrameCreateCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/command/TimelineFrameDeleteCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/command/TimelineFrameEditCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/command/TimelineKeyframeDeleteCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/command/TimelineKeyframeEditCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/commands/DeletePartCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/editparts/HoverViewerEditPart.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/AppManagerForAppXML.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/AppManagerForHTML.java

index c1d6847..818ae7b 100644 (file)
@@ -99,7 +99,7 @@ public class AnimationCreateAndChangeFrameCommand extends Command {
                
                        frame.addOrEditProperties(properties);
                        frame.setPredefined(false);
-                       
+                       currentSelector.updateSelectorTime();
                        newSelector = currentSelector.cloneAnimatorSelector();
                }
        } else {
index ecda44c..59a7246 100644 (file)
@@ -103,6 +103,7 @@ public class AnimationCreateCommand extends Command {
                        currentSelector.updateSelectorTime();
                        
                     currentSelector.mergeOrSplitKeyframe();
+                    currentSelector.updateSelectorTime();
                        newSelector = currentSelector.cloneAnimatorSelector();
                 }
                } else {
index c44118b..f3383a1 100644 (file)
@@ -63,6 +63,7 @@ public class AnimationPathMoveCommand extends AnimationPathCommand {
                 }
             }
             super.execute();
+            currentSelector.updateSelectorTime();
             newSelector = currentSelector.cloneAnimatorSelector();
        } else {
                currentSelector.replaceAll(newSelector);
index d1d1640..9fb91f3 100644 (file)
@@ -42,7 +42,6 @@ import org.tizen.webuibuilder.animator.gef.viewer.AnimatorBrowserViewer;
 import org.tizen.webuibuilder.animator.model.AnimationPathModel;
 import org.tizen.webuibuilder.animator.model.AnimatorModelEvent;
 import org.tizen.webuibuilder.animator.model.AnimatorModelListenerAdapter;
-import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
 import org.tizen.webuibuilder.animator.model.AnimatorSelector;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPart;
@@ -82,8 +81,9 @@ public class AnimatorEditPart extends HoverViewerEditPart {
     @Override
     public void addNotify() {
         super.addNotify();
-        AnimatorModelManager animatorModelManager = AnimatorModelManager.getInstance(appManager);
-        AnimatorPart part = (AnimatorPart)animatorModelManager.getRootPart();
+//        AnimatorModelManager animatorModelManager = AnimatorModelManager.getInstance(appManager);
+//        AnimatorPart part = (AnimatorPart)animatorModelManager.getRootPart();
+        AnimatorPart part = (AnimatorPart)appManager.getPageDataSet().getBaseRootPart();
         part.addAnimatorModelListener(animatorModelEventAdapter);
     }
 
@@ -94,8 +94,9 @@ public class AnimatorEditPart extends HoverViewerEditPart {
      */
     @Override
     public void removeNotify() {
-        AnimatorModelManager animatorModelManager = AnimatorModelManager.getInstance(appManager);
-        AnimatorPart part = (AnimatorPart)animatorModelManager.getRootPart();
+//        AnimatorModelManager animatorModelManager = AnimatorModelManager.getInstance(appManager);
+//        AnimatorPart part = (AnimatorPart)animatorModelManager.getRootPart();
+        AnimatorPart part = (AnimatorPart)appManager.getPageDataSet().getBaseRootPart();
         part.removeAnimatorModelListener(animatorModelEventAdapter);
         super.removeNotify();
     }
index a369cc0..30f8144 100644 (file)
@@ -43,14 +43,12 @@ import org.tizen.webuibuilder.animator.model.AnimatorKeyframe;
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
 import org.tizen.webuibuilder.animator.model.AnimatorModelEvent;
 import org.tizen.webuibuilder.animator.model.AnimatorModelListenerAdapter;
-import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
 import org.tizen.webuibuilder.animator.model.AnimatorProperty;
 import org.tizen.webuibuilder.animator.model.AnimatorSelector;
 import org.tizen.webuibuilder.animator.model.AnimatorWidget;
 import org.tizen.webuibuilder.animator.model.io.AnimatorFileWriter;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPart;
-import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
 import org.tizen.webuibuilder.bridge.DesignerGoingBridge.WidgetPosition;
 import org.tizen.webuibuilder.gef.viewer.HoverBrowserViewer;
 import org.tizen.webuibuilder.model.Part;
@@ -83,15 +81,16 @@ public class AnimatorBrowserViewer extends HoverBrowserViewer {
     public AnimatorBrowserViewer(AppManager appManager, ScreenSize screen, IEditorInput editorInput) {
         super(appManager, screen, editorInput);
 
-        AnimatorModelManager manager = AnimatorModelManager.getInstance(appManager);
-        AnimatorPagePart pagePart = (AnimatorPagePart) manager.getPagePart();
-
+//        AnimatorModelManager manager = AnimatorModelManager.getInstance(appManager);
+//        AnimatorPagePart pagePart = (AnimatorPagePart) manager.getPagePart();
+        
+        AnimatorPagePart pagePart = (AnimatorPagePart)appManager.getPageData(appManager.getPageIndex(pageData)).getPagePart();
         List<AnimatorAnimation> animations = pagePart.getAnimations();
         if (!animations.isEmpty()) {
             this.currentAnimationGroupId = animations.get(0).getId();
         }
 
-        setAnimatorModelListener(manager.getRootPart());
+        setAnimatorModelListener(appManager.getPageDataSet().getBaseRootPart());
     }
 
     /**
@@ -120,8 +119,10 @@ public class AnimatorBrowserViewer extends HoverBrowserViewer {
     protected void handleDispose(DisposeEvent e) {
         super.handleDispose(e);
 
-        AnimatorModelManager manager = AnimatorModelManager.getInstance(appManager);
-        ((AnimatorPart)manager.getRootPart()).removeAnimatorModelListener(animatorModelEventAdapter);
+//        AnimatorModelManager manager = AnimatorModelManager.getInstance(appManager);
+//        ((AnimatorPart)manager.getRootPart()).removeAnimatorModelListener(animatorModelEventAdapter);
+        
+        ((AnimatorPart)appManager.getPageDataSet().getBaseRootPart()).removeAnimatorModelListener(animatorModelEventAdapter);
     }
 
     /**
@@ -146,9 +147,7 @@ public class AnimatorBrowserViewer extends HoverBrowserViewer {
      */
     @Override
     protected String generateCssCode() {
-        AnimatorModelManager manager =
-                AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
-        return CodeGenerator.generateCssCode(manager.getRootPart());
+        return CodeGenerator.generateCssCode(appManager.getPageDataSet().getBaseRootPart());
     }
 
     /**
@@ -216,11 +215,13 @@ public class AnimatorBrowserViewer extends HoverBrowserViewer {
      * play animation using javascript framework API.
      */
     public void playCurrentAnimation() {
-        AnimatorModelManager manager = AnimatorModelManager.getInstance(appManager);
-        AnimatorPagePart pagePart = (AnimatorPagePart) manager.getPagePart();
-
-        String pageId = pagePart.getPropertyValue("id");
-        getGoingBridge().aniBridge_play(pageId, currentAnimationGroupId);
+//        AnimatorModelManager manager = AnimatorModelManager.getInstance(appManager);
+//        AnimatorPagePart pagePart = (AnimatorPagePart) manager.getPagePart();
+//
+//        String pageId = pagePart.getPropertyValue("id");
+       
+        getGoingBridge().aniBridge_play(appManager.getPageData(appManager.getPageIndex(pageData)).getName(), 
+                       currentAnimationGroupId);
     }
 
     /**
@@ -241,27 +242,24 @@ public class AnimatorBrowserViewer extends HoverBrowserViewer {
      */
     public void pauseAnimation(double pointTime) {
         this.pointTime = pointTime;
-        AnimatorModelManager manager = AnimatorModelManager.getInstance(appManager);
-        AnimatorPagePart pagePart = (AnimatorPagePart) manager.getPagePart();
-
-        String pageId = pagePart.getPropertyValue("id");
-        getGoingBridge().aniBridge_pause(pageId);
+//        AnimatorModelManager manager = AnimatorModelManager.getInstance(appManager);
+//        AnimatorPagePart pagePart = (AnimatorPagePart) manager.getPagePart();
+//
+//        String pageId = pagePart.getPropertyValue("id");
+        getGoingBridge().aniBridge_pause(appManager.getPageData(appManager.getPageIndex(pageData)).getName());
     }
 
     /**
      * initialize javascript animation framework.
      */
     public void initAnimationFW() {
-        AnimatorModelManager manager = AnimatorModelManager.getInstance(appManager);
         getGoingBridge()
                 .aniBridge_initFW(AnimatorFileWriter
-                                          .getOneAnimationGroupModelString(manager.getPagePart()
-                                                                                   .getIdPropertyValue(),
+                                          .getOneAnimationGroupModelString(appManager.getPageData(appManager.getPageIndex(pageData)).getName(),
                                                                            currentAnimationGroupId,
-                                                                           appManager, manager
-                                                                                   .getRootPart()),
-                                   AnimatorFileWriter.getOnePageAnimatorKeyFrameString(manager
-                                          .getRootPart()));
+                                                                           appManager, appManager.getPageDataSet().getBaseRootPart()),
+                                   AnimatorFileWriter.getOnePageAnimatorKeyFrameString(appManager.getPageDataSet().getBaseRootPart(),
+                                                               appManager.getPageData(appManager.getPageIndex(pageData)).getPagePart()));
     }
 
     /**
@@ -321,26 +319,24 @@ public class AnimatorBrowserViewer extends HoverBrowserViewer {
      * framework API.
      */
     private void updateAnimationModel() {
-        AnimatorModelManager manager = AnimatorModelManager.getInstance(appManager);
+        
         getGoingBridge()
-                .aniBridge_setAnimationCss(AnimatorFileWriter.getOnePageAnimatorKeyFrameString(manager
-                                                   .getRootPart()));
+                .aniBridge_setAnimationCss(AnimatorFileWriter.getOnePageAnimatorKeyFrameString(appManager.getPageDataSet().getBaseRootPart(), 
+                               appManager.getPageData(appManager.getPageIndex(pageData)).getPagePart()));
         getGoingBridge()
                 .aniBridge_setAnimationJs(AnimatorFileWriter
-                                                  .getOneAnimationGroupModelString(manager.getPagePart()
-                                                                                           .getIdPropertyValue(),
+                                                  .getOneAnimationGroupModelString(appManager.getPageData(appManager.getPageIndex(pageData)).getName(),
                                                                                    currentAnimationGroupId,
                                                                                    appManager,
-                                                                                   manager.getRootPart()));
+                                                                                   appManager.getPageDataSet().getBaseRootPart()));
     }
 
     /**
      * Apply status(lock and invisible) to widget from animation model.
      */
     public void checkLockInvisibleWidget() {
-        AnimatorModelManager manager =
-                AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
-        AnimatorAnimation animation = manager.findAnimation(currentAnimationGroupId);
+       AnimatorPagePart pagePart = (AnimatorPagePart)appManager.getPageData(appManager.getPageIndex(pageData)).getPagePart();
+       AnimatorAnimation animation = pagePart.getAnimation(currentAnimationGroupId);
         if (animation == null) {
             return;
         }
index 3c16492..2b619be 100644 (file)
 package org.tizen.webuibuilder.animator.model;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
 
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.swt.widgets.Display;
@@ -402,156 +399,136 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
         eventSource.fireEvent(fireRootPart, fireModel, eventType, origin, model);
     }
 
-    /******************************************************************************************************************
-     * Interface for command(about Widget)
-     ******************************************************************************************************************/
-
-
+    
     /**
-     * Add AnimatorWidgtes to animation group
+     * Update AnimatorModel by current rootPart After two-way editing new rootPart is generated so,
+     * animatorModel need to change PartLink, and parent link
      * 
-     * @param animatorWidgetGroup
-     * @param origin
+     * @param newRootPart
      */
-    public void addAnimatorWidgets(Map<AnimatorModel, Integer> animatorWidgetGroup, Origin origin) {
-        AnimatorAnimation currentAnimation = getCurrentAnimation();
-        List<AnimatorModel> animatorWidgets = new ArrayList<AnimatorModel>();
-        Iterator<Entry<AnimatorModel, Integer>> iter = animatorWidgetGroup.entrySet().iterator();
-        while (iter.hasNext()) {
-            Entry<AnimatorModel, Integer> next = iter.next();
-            AnimatorWidget animatorWidget = (AnimatorWidget) next.getKey();
-            AnimatorAnimation animation = (AnimatorAnimation) animatorWidget.getParent();
-            animation.addChild(next.getValue(), animatorWidget);
-
-            if (currentAnimation != null) {
-                if (currentAnimation.equals(animation))
-                    animatorWidgets.add(animatorWidget);
+    public void updateAnimatorModel(Part newRootPart) {
+        Part oldRootPart = getRootPart();
+        if (!oldRootPart.equals(newRootPart)) {
+            for (Part oldPart : oldRootPart.getChildren()) {
+                for (Part newPart : newRootPart.getChildren()) {
+                       AnimatorPart part = (AnimatorPart)newPart;
+                    if (part.getPropertyValue("id").equals(oldPart.getPropertyValue("id"))) {
+                       part.updateAnimatorTrigger((AnimatorPart)oldPart);
+                        ((AnimatorPagePart) newPart).updateAnimatorAnimation((AnimatorPagePart) oldPart);
+                        break;
+                    }
+                }
             }
-        }
-
-        eventSource
-                .fireEvent(currentAnimation, EventType.WIDGET_ADD, origin, null, animatorWidgets);
-        eventSource.fireEvent(EventType.WIDGET_ADD, origin, null);
-    }
 
+            for (Part newPart : newRootPart.getChildren()) {
+                AnimatorPagePart newPagePart = (AnimatorPagePart) newPart;
 
-    /******************************************************************************************************************
-     * Interface for command(about Frame)
-     ******************************************************************************************************************/
-    /**
-     * Add AnimatorFrames to selectors return list of frames(at most a frame per selector if
-     * selector has no frame at that time)
-     * 
-     * @param selectors
-     * @param currentTime
-     * @return
-     */
-    public List<AnimatorFrame> createOrGetAnimatorFrames(AnimatorModelFactory modelFactory,
-                                                                                                        List<AnimatorModel> selectors,
-                                                         double currentTime) {
-        List<AnimatorFrame> frames = new ArrayList<AnimatorFrame>();
-        for (AnimatorModel model : selectors) {
-            AnimatorSelector selector = (AnimatorSelector) model;
-            AnimatorFrame frame = selector.createOrGetAnimatorFrame(currentTime);
-            if (frame != null)
-                frames.add(frame);
-        }
-        return frames;
-    }
-
-    /**
-     * find selector for the frame and add the frame to the found selector;
-     * 
-     * @param frames
-     * @param currentTime
-     * @param origin
-     */
-    public void addAnimatorFrames(List<AnimatorFrame> frames, double currentTime, Origin origin) {
-        for (AnimatorFrame model : frames) {
-            addAnimatorFrame(model, currentTime, origin);
+                if (newPagePart.getAnimations().size() == 0) {
+                       newPagePart.addAnimation(newPagePart.createAnimation(null, true, 1, false));
+                }
+            }
         }
     }
-
+    
     /**
-     * Add frame with no property specified there are 2 cases 1. A AnimatorKeyframe with one frame
-     * is created with no specific property 2. A frame is created inside existing AnimatorKyeframe
-     * and animated properties are specified
-     * 
-     * @precondition frame was already created
-     * @param model
-     * @param currentTime
-     * @param origin
+     * Add animator related resources to index.html
      */
-    public void addAnimatorFrame(AnimatorFrame frame, double currentTime, Origin origin) {
-        AnimatorKeyframe keyframe = (AnimatorKeyframe) frame.getParent();
-        AnimatorSelector selector = (AnimatorSelector) keyframe.getParent();
-
-        keyframe.addChild(frame, true);
-
-        if (!selector.isExistKeyframe(keyframe)) {// case 1
-            selector.addChild(keyframe);
-//            copyPropertiesInLeftOrRightFrame(frame, keyframe);
-        } else {// case 2
-               frame.findAnimatedPropertyAndSetInFrame((AnimatorFrame) keyframe.getPrevChild(frame),
-                               (AnimatorFrame) keyframe.getNextChild(frame));
-//            findAnimatedPropertyAndSetInFrame(frame, keyframe);
-        }
+    public void addAnimatorRelatedResources() {
+        if (appManager instanceof AppManagerForHTML) {
+            if (!((AnimatorPart)rootPart).hasAnimation()) {
+                Document editDoc = ((AppManagerForHTML) appManager).getDocument();
 
-        eventSource.fireEvent(AnimatorModelEvent.EventType.FRAME_ADD, origin, frame);
-    }
+                NodeList heads = editDoc.getElementsByTagName("head");
+                Element head = (Element) heads.item(0);
 
+                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_FRAMEWORK_JSPATH)) {
+                            return;
+                        }
+                    }
+                }
 
-    /**
-     * Remove AnimatorFrames
-     * 
-     * @param frames
-     * @param name
-     * @param origin
-     */
-    public void removeAnimatorFrames(List<AnimatorFrame> frames, String name, Origin origin) {
-        for (AnimatorModel model : frames) {
-            removeAnimatorFrame(model, name, origin);
-        }
-    }
+                Element animatorJs = editDoc.createElement("script");
+                animatorJs.setAttribute("src", "./" + AnimatorConstants.ANIMATOR_MODEL_JS_FILE);
 
-    /**
-     * Remove AnimatorFrame
-     * 
-     * @param model
-     * @param name
-     * @param origin
-     */
-    public void removeAnimatorFrame(AnimatorModel model, String name, Origin origin) {
-        AnimatorFrame frame = (AnimatorFrame) model;
-        AnimatorKeyframe keyframe = (AnimatorKeyframe) frame.getParent();
+                Element framework = editDoc.createElement("script");
+                framework.setAttribute("src", "./"
+                        + AnimatorConstants.ANIMATOR_TIZEN_UI_BUILDER_FRAMEWORK
+                        + AnimatorConstants.SLASH + AnimatorConstants.ANIMATOR_FRAMEWORK_JSPATH);
 
-        keyframe.removeChild(frame, true);
-        eventSource.fireEvent(AnimatorModelEvent.EventType.FRAME_REMOVE, origin, frame);
-    }
+                Element animatorCss = editDoc.createElement("link");
+                animatorCss.setAttribute("type", "text/css");
+                animatorCss.setAttribute("rel", "stylesheet");
+                animatorCss.setAttribute("href", "./" + AnimatorConstants.ANIMATOR_MODEL_CSS_FILE);
 
-    /******************************************************************************************************************
-     * Interface for utility
-     ******************************************************************************************************************/
-    private AnimatorAnimation getCurrentAnimation() {
-        if (AnimatorUtils.getActiveAnimatorBrowserViewer() != null)
-            return findAnimation(AnimatorUtils.getActiveAnimatorBrowserViewer()
-                    .getCurrentAnimationGroupId());
-        return null;
+                head.insertBefore(framework, head.getLastChild());
+                head.insertBefore(animatorJs, framework);
+                head.insertBefore(animatorCss, animatorJs);
+            }
+        }
     }
 
     /**
-     * Search animation by id and return animation
-     * 
-     * @param animationId
-     * @return
+     * Remove animator related resources from index.html
      */
-    public AnimatorAnimation findAnimation(String animationId) {
-        AnimatorAnimation animation = null;
-
-        AnimatorPagePart pagePart = (AnimatorPagePart) getPagePart();
-        animation = pagePart.getAnimation(animationId);
-
-        return animation;
+    public void removeAnimatorRelatedResources() {
+        if (appManager instanceof AppManagerForHTML) {
+            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());
+                    }
+                }
+                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("");
+                            }
+                        }
+                    }
+                }
+            }
+        }
     }
 
 
@@ -579,55 +556,7 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
         }
     }
 
-    /**
-     * Update AnimatorModel by current rootPart After two-way editing new rootPart is generated so,
-     * animatorModel need to change PartLink, and parent link
-     * 
-     * @param newRootPart
-     */
-    public void updateAnimatorModel(Part newRootPart) {
-        Part oldRootPart = getRootPart();
-        if (!oldRootPart.equals(newRootPart)) {
-            for (Part oldPart : oldRootPart.getChildren()) {
-                for (Part newPart : newRootPart.getChildren()) {
-                       AnimatorPart part = (AnimatorPart)newPart;
-                    if (part.getPropertyValue("id").equals(oldPart.getPropertyValue("id"))) {
-                       part.updateAnimatorTrigger((AnimatorPart)oldPart);
-                        ((AnimatorPagePart) newPart).updateAnimatorAnimation((AnimatorPagePart) oldPart);
-                        break;
-                    }
-                }
-            }
 
-            for (Part newPart : newRootPart.getChildren()) {
-                AnimatorPagePart newPagePart = (AnimatorPagePart) newPart;
-
-                if (newPagePart.getAnimations().size() == 0) {
-                       newPagePart.addAnimation(newPagePart.createAnimation(null, true, 1, false));
-                }
-            }
-        }
-    }
-
-    /**
-     * Edit widget Property
-     * 
-     * @param part
-     */
-    public void widgetPropertyEdit(Part part) {
-       AnimatorPagePart pagePart = (AnimatorPagePart)part.getOwnerPage();
-        AnimatorAnimation animation = pagePart.getCurrentAnimation();
-        if (animation != null) {
-            AnimatorWidget widget = (AnimatorWidget) animation.findAnimatorModelByPartLink(part);
-
-            if (widget != null) {
-                // temporary is not always need...
-                widget.setId(part.getPropertyValue("id"));
-                /*******************************/
-                eventSource.fireEvent(widget, EventType.WIDGET_EDIT, Origin.PROPERTY, null);
-            }
-        }
-    }
 
     /*
      * (non-Javadoc)
@@ -723,105 +652,4 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
         // TODO Auto-generated method stub
 
     }
-
-    /**
-     * Add animator related resources to index.html
-     */
-    public void addAnimatorRelatedResources() {
-        if (appManager instanceof AppManagerForHTML) {
-            if (!((AnimatorPart)rootPart).hasAnimation()) {
-                Document editDoc = ((AppManagerForHTML) appManager).getDocument();
-
-                NodeList heads = editDoc.getElementsByTagName("head");
-                Element head = (Element) heads.item(0);
-
-                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_FRAMEWORK_JSPATH)) {
-                            return;
-                        }
-                    }
-                }
-
-                Element animatorJs = editDoc.createElement("script");
-                animatorJs.setAttribute("src", "./" + AnimatorConstants.ANIMATOR_MODEL_JS_FILE);
-
-                Element framework = editDoc.createElement("script");
-                framework.setAttribute("src", "./"
-                        + AnimatorConstants.ANIMATOR_TIZEN_UI_BUILDER_FRAMEWORK
-                        + AnimatorConstants.SLASH + AnimatorConstants.ANIMATOR_FRAMEWORK_JSPATH);
-
-                Element animatorCss = editDoc.createElement("link");
-                animatorCss.setAttribute("type", "text/css");
-                animatorCss.setAttribute("rel", "stylesheet");
-                animatorCss.setAttribute("href", "./" + AnimatorConstants.ANIMATOR_MODEL_CSS_FILE);
-
-                head.insertBefore(framework, head.getLastChild());
-                head.insertBefore(animatorJs, framework);
-                head.insertBefore(animatorCss, animatorJs);
-            }
-        }
-    }
-
-    /**
-     * Remove animator related resources from index.html
-     */
-    public void removeAnimatorRelatedResources() {
-        if (appManager instanceof AppManagerForHTML) {
-            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());
-                    }
-                }
-                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("");
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
 }
\ No newline at end of file
index c73363d..1b10815 100644 (file)
@@ -310,16 +310,15 @@ public class AnimatorFileWriter {
      * @param rootPart
      * @return
      */
-    public static String getOnePageAnimatorKeyFrameString(Part rootPart) {
+    public static String getOnePageAnimatorKeyFrameString(Part rootPart, Part pagePart) {
         try {
             AnimatorModelManager manager =
                     AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
-            AnimatorPagePart pagePart = (AnimatorPagePart) manager.getPagePart();
             StringBuffer animationCssString = new StringBuffer(new String("".getBytes(), "utf-8"));// ask
                                                                                                    // why?
             for (Part part : rootPart.getChildren()) {
                 if (pagePart.equals(part)) {
-                    for (AnimatorAnimation animation : pagePart.getAnimations()) {
+                    for (AnimatorAnimation animation : ((AnimatorPagePart)pagePart).getAnimations()) {
                         for (AnimatorModel widget : animation.getChildren()) {
                             for (AnimatorModel model : widget.getChildren()) {
                                 AnimatorSelector selector = (AnimatorSelector) model;
index 05c665e..770e57a 100644 (file)
@@ -1,22 +1,19 @@
 package org.tizen.webuibuilder.animator.model.part;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
 
 import org.tizen.webuibuilder.animator.model.AnimatorActionAnimation;
 import org.tizen.webuibuilder.animator.model.AnimatorAnimation;
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
+import org.tizen.webuibuilder.animator.model.AnimatorModelEvent.EventType;
+import org.tizen.webuibuilder.animator.model.AnimatorModelEvent.Origin;
 import org.tizen.webuibuilder.animator.model.AnimatorModelFactory;
 import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
 import org.tizen.webuibuilder.animator.model.AnimatorModelType;
 import org.tizen.webuibuilder.animator.model.AnimatorSelector;
 import org.tizen.webuibuilder.animator.model.AnimatorTrigger;
 import org.tizen.webuibuilder.animator.model.AnimatorWidget;
-import org.tizen.webuibuilder.animator.model.AnimatorModelEvent.EventType;
-import org.tizen.webuibuilder.animator.model.AnimatorModelEvent.Origin;
 import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
 import org.tizen.webuibuilder.model.Part;
 import org.tizen.webuibuilder.model.descriptors.PartDescriptor;
index 0dd0952..c72ed35 100644 (file)
@@ -32,11 +32,10 @@ import java.util.Map.Entry;
 
 import org.tizen.webuibuilder.animator.model.AnimatorAnimation;
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
-import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
-import org.tizen.webuibuilder.animator.model.AnimatorSelector;
-import org.tizen.webuibuilder.animator.model.AnimatorWidget;
 import org.tizen.webuibuilder.animator.model.AnimatorModelEvent.EventType;
 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.utils.AnimatorUtils;
 import org.tizen.webuibuilder.model.Part;
 import org.tizen.webuibuilder.model.descriptors.WidgetPartDescriptor;
@@ -79,6 +78,27 @@ public class AnimatorWidgetPart extends AnimatorPart {
         return animatorWidgets;
     }
     
+    /**
+     * Edit widget Property
+     * 
+     * @param part
+     */
+    public void widgetPropertyEdit() {
+       AnimatorPagePart pagePart = (AnimatorPagePart)getOwnerPage();
+        AnimatorAnimation animation = pagePart.getCurrentAnimation();
+        if (animation != null) {
+            AnimatorWidget widget = (AnimatorWidget) animation.findAnimatorModelByPartLink(this);
+
+            if (widget != null) {
+                // temporary is not always need...
+                widget.setId(getPropertyValue("id"));
+                /*******************************/
+                AnimatorModelManager modelManager = AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
+                modelManager.fireEvent(widget, EventType.WIDGET_EDIT, Origin.PROPERTY, null);
+            }
+        }
+    }
+    
     private Map<AnimatorModel, Integer> collectWillRemoveAnimatorWidget(Part child) {
         Map<AnimatorModel, Integer> animatorWidgets = new LinkedHashMap<AnimatorModel, Integer>();
         AnimatorPagePart pagePart = (AnimatorPagePart) getOwnerPage();
index 6410ee8..4bf7da5 100644 (file)
@@ -27,7 +27,6 @@ import java.lang.reflect.Type;
 import java.util.List;
 
 import org.tizen.webuibuilder.animator.model.AnimatorAnimation;
-import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
 import org.tizen.webuibuilder.animator.model.AnimatorTrigger;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
 import org.tizen.webuibuilder.animator.model.part.AnimatorWidgetPart;
@@ -65,27 +64,10 @@ public class AnimatorPagePartSerializer implements JsonSerializer<AnimatorPagePa
         json.addProperty("id", arg0.getPropertyValue("id"));
 
         boolean isHome = false;
-        // ProjectManager projectManager = ProjectManager.getProjectManager(project);
-        // AppManager appManager = projectManager.getDefaultAppManager();
-        // List<PageData> pageDatas = appManager.getPages();
-        // for (PageData pageData : pageDatas) {
-        // Part rootPart = pageData.getRootPart();
-        //
-        // if (rootPart == arg0.getParent()) {
-        // // TODO - pageData.getPage is not List. why?
-        // // String pageId = arg0.getPropertyValue("id");
-        // //Page page = pageData.getPage();
-        // //isHome = page.isStartup();
-        // // isHome = pageData == appManager.getStartupPage();
-        // //FIXME
-        // //show sets true for first page temporarily
-        // if(rootPart.getChildren().indexOf(arg0) == 0)
-        // isHome = true;
-        // }
-        // }
-
-        AnimatorModelManager modelManager = AnimatorModelManager.getInstance(appManager);
-        Part rootPart = modelManager.getRootPart();
+//        AnimatorModelManager modelManager = AnimatorModelManager.getInstance(appManager);
+//        Part rootPart = modelManager.getRootPart();
+        
+        Part rootPart = appManager.getPageDataSet().getBaseRootPart();
         if (rootPart.getChildren().indexOf(arg0) == 0)
             isHome = true;
 
index d4f4a5b..d933e3e 100644 (file)
@@ -29,10 +29,10 @@ import org.eclipse.swt.widgets.MenuItem;
 import org.tizen.webuibuilder.animator.model.AnimatorAnimation;
 import org.tizen.webuibuilder.animator.model.AnimatorModelEvent;
 import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
+import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
 import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineViewer;
 import org.tizen.webuibuilder.animator.ui.views.timeline.header.TimelineOutlineHeader;
 import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
-import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
 
 
 /**
index 5c14b43..7bb56c3 100644 (file)
@@ -92,6 +92,7 @@ public class TimelineFrameCreateCommand extends Command {
                                         }
                         }
                         
+                        currentSelector.updateSelectorTime();
                         newSelectors.add(currentSelector.cloneAnimatorSelector());
                         manager.fireEvent(true, currentSelector,
                                AnimatorModelEvent.EventType.SELECTOR_REFRESH, AnimatorModelEvent.Origin.TIMELINE, currentSelector);
index 0cd8036..1b9d46a 100644 (file)
@@ -102,6 +102,7 @@ public class TimelineFrameDeleteCommand extends Command {
                
                keyframe.removeChild(frame, true);
                
+               currentSelector.updateSelectorTime();
                newSelector = currentSelector.cloneAnimatorSelector();
        } else {
                currentSelector.replaceAll(newSelector);
index cf5794f..6754e3f 100644 (file)
@@ -77,8 +77,8 @@ public class TimelineFrameEditCommand extends Command {
             keyframe.removeChild(frame, false);
             keyframe.addChild(frame, false);
             
+            currentSelector.updateSelectorTime();
             newSelector = currentSelector.cloneAnimatorSelector();
-
        } else {
                currentSelector.replaceAll(newSelector);
        }
index 4e440e2..64e16d3 100644 (file)
@@ -68,6 +68,7 @@ public class TimelineKeyframeDeleteCommand extends Command {
                keyframe = currentSelector.findAnimatorKeyframe(keyframe);
                currentSelector.removeChild(keyframe);
                
+               currentSelector.updateSelectorTime();
                newSelector = currentSelector.cloneAnimatorSelector();
        } else {
                currentSelector.replaceAll(newSelector);
index 3d4de9d..7273c8a 100644 (file)
@@ -95,7 +95,6 @@ public class TimelineKeyframeEditCommand extends Command {
                ((AnimatorSelector)keyframe.getParent()).addChild(keyframe);
                
                currentSelector.updateSelectorTime();
-     
                newSelector = currentSelector.cloneAnimatorSelector();
                
         } else {
index 7e97698..0a4cffa 100644 (file)
@@ -31,10 +31,12 @@ import java.util.Map;
 import java.util.Map.Entry;
 
 import org.eclipse.gef.commands.Command;
+import org.tizen.webuibuilder.animator.model.AnimatorAnimation;
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
-import org.tizen.webuibuilder.animator.model.AnimatorWidget;
+import org.tizen.webuibuilder.animator.model.AnimatorModelEvent.EventType;
 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.AnimatorWidgetPart;
 import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
@@ -208,10 +210,32 @@ 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);
             }
         }
-        
-        animatorModelManager.addAnimatorWidgets(animatorWidgetGroup, Origin.EDITOR);
     }
-
 }
\ No newline at end of file
index ca0621c..72bd134 100644 (file)
@@ -42,8 +42,7 @@ import org.eclipse.gef.SnapToGuides;
 import org.eclipse.gef.SnapToHelper;
 import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
 import org.eclipse.gef.rulers.RulerProvider;
-import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
-import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
+import org.tizen.webuibuilder.animator.model.part.AnimatorWidgetPart;
 import org.tizen.webuibuilder.gef.figure.PageFigure;
 import org.tizen.webuibuilder.gef.figure.PartFigure;
 import org.tizen.webuibuilder.gef.figure.WidgetFigure;
@@ -199,10 +198,9 @@ public class HoverViewerEditPart extends AbstractGraphicalEditPart implements IP
     public void propertyChanged(PartEvent e) {
         ((HoverBrowserViewer) getViewer()).updateModel();
         ((HoverBrowserViewer) getViewer()).updateAllPositionsForce();
+        
+        ((AnimatorWidgetPart)e.getPart()).widgetPropertyEdit();
 
-        AnimatorModelManager modelManager =
-                AnimatorModelManager.getInstance(AnimatorUtils.getAppManager());
-        modelManager.widgetPropertyEdit((Part) e.getPart());
     }
 
     @Override
index bde8ef3..9f5a9e4 100644 (file)
@@ -36,7 +36,6 @@ import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.tizen.webuibuilder.BuilderConstants;
 import org.tizen.webuibuilder.BuilderPlugin;
-import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
 import org.tizen.webuibuilder.animator.model.io.AnimatorFileWriter;
 import org.tizen.webuibuilder.builder.WebUIBuilderBuilder;
 import org.tizen.webuibuilder.model.Part;
@@ -276,11 +275,12 @@ public class AppManagerForAppXML extends AppManager {
                         + "/tizen-ui-builder-fw/tizen-animator-fw.js\"></script>";
         html = html.replace("%animator%", animator_script);
 
-        AnimatorModelManager modelManager = this.getAnimatorModelManager();
-        Part aniRootPart = modelManager.getRootPart();
+//        AnimatorModelManager modelManager = this.getAnimatorModelManager();
+//        Part aniRootPart = modelManager.getRootPart();
+        Part aniRootPart = getPageDataSet().getBaseRootPart();
         String animatorCss = AnimatorFileWriter.getAnimatorKeyFrameString(aniRootPart);
         String animatorJs =
-                       AnimatorFileWriter.getOneAnimationGroupModelString(modelManager.getPageId(),
+                       AnimatorFileWriter.getOneAnimationGroupModelString(getPageData(index).getName(),
                                                               animationGroupId, this, aniRootPart);
         html = html.replace("%animatorCss%", animatorCss);
         html = html.replace("%animatorJs%", animatorJs);
index 2ac23e2..ca20363 100644 (file)
@@ -40,7 +40,6 @@ import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.tizen.webuibuilder.BuilderConstants;
-import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
 import org.tizen.webuibuilder.animator.model.io.AnimatorFileWriter;
 import org.tizen.webuibuilder.builder.WebUIBuilderBuilder;
 import org.tizen.webuibuilder.model.GotoPageProperty;
@@ -533,11 +532,12 @@ public class AppManagerForHTML extends AppManager {
         /*
          * animation css, animation js
          */
-        AnimatorModelManager modelManager = this.getAnimatorModelManager();
-        Part aniRootPart = modelManager.getRootPart();
-        String animatorCss = AnimatorFileWriter.getOnePageAnimatorKeyFrameString(aniRootPart);
+//        AnimatorModelManager modelManager = this.getAnimatorModelManager();
+//        Part aniRootPart = modelManager.getRootPart();
+        Part aniRootPart = getPageDataSet().getBaseRootPart();
+        String animatorCss = AnimatorFileWriter.getOnePageAnimatorKeyFrameString(aniRootPart, getPageData(index).getPagePart());
         String animatorJs =
-                       AnimatorFileWriter.getOneAnimationGroupModelString(modelManager.getPageId(),
+                       AnimatorFileWriter.getOneAnimationGroupModelString(getPageData(index).getName(),
                                                               animationGroupId, this, aniRootPart);
 
         Element newAniElm1 = editDoc.createElement("style");