ANIMATOR : Implements merge/split keyframe 69/20969/1
authorseongwon.shim <seongwon.shim@samsung.com>
Wed, 14 May 2014 08:56:07 +0000 (17:56 +0900)
committerseongwon.shim <seongwon.shim@samsung.com>
Wed, 14 May 2014 08:56:07 +0000 (17:56 +0900)
Implements merge/split keyframe when keyframe is edited by user from timeline view including undo/redo

Change-Id: Ie4825a47310665dc1704d575066d8aecdc60ce72
Signed-off-by: seongwon.shim <seongwon.shim@samsung.com>
28 files changed:
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/AnimatorConstants.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/command/ActoinAnimationGroupChangeCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/command/ActoinAnimationGroupCreateCommand.java
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/AnimationPropertyChangeCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/gef/editparts/AnimatorEditPart.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimationPathModel.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorAnimation.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorCurveFrame.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorFrame.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorKeyframe.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorModel.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorModelFactory.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorModelManager.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorSelector.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorTrigger.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/AnimatorWidget.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/IDGenerator.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/part/AnimatorPagePart.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/model/part/AnimatorPart.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/action/PasteKeyFrameAction.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/TimelineKeyframeEditCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/commands/CreatePartCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/commands/PastePartCommand.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/editor/PageDesignerForHTML.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/style/CssStyleAnimationEventDelegater.java

index 2d3da6a..e69b7fe 100644 (file)
@@ -76,6 +76,7 @@ public class AnimatorConstants {
     public static final String MODEL_ID_PREFIX_ANIMATION = "TizenAnimation";
     public static final String MODEL_ID_PREFIX_SELECTOR = "TizenSelector";
     public static final String MODEL_ID_PREFIX_KEYFRAME = "TizenKeyframe";
+    public static final String MODEL_ID_PREFIX_FRAME = "TizenFrame";
     public static final String MODEL_ID_PREFIX_TRIGGER = "TizenTrigger";
     public static final String MODEL_ID_PREFIX_ACTION = "TizenAction";
 
index bda757d..b13b62f 100644 (file)
@@ -28,6 +28,7 @@ import org.tizen.webuibuilder.animator.model.AnimatorActionAnimation;
 import org.tizen.webuibuilder.animator.model.AnimatorTrigger;
 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.ui.views.properties.action.ActionAnimationGroupComposite.ActionAnimationGroupTypes;
 
 
@@ -98,7 +99,8 @@ public class ActoinAnimationGroupChangeCommand extends Command {
         if (afterActionAnimation == null) {
             afterActionAnimation =
                        pagePart
-                            .createAnimatorActionAnimation(groupId,
+                            .createAnimatorActionAnimation(AnimatorUtils.getAppManager().getAnimatorModelManager().getModelFactory(),
+                                                                                  groupId,
                                                            convertActionAnimationGroupTypes(type),
                                                            time, trigger);
         }
index 4644bcd..5273704 100644 (file)
@@ -28,6 +28,7 @@ import org.tizen.webuibuilder.animator.model.AnimatorActionAnimation;
 import org.tizen.webuibuilder.animator.model.AnimatorTrigger;
 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.ui.views.properties.action.ActionAnimationGroupComposite.ActionAnimationGroupTypes;
 
 
@@ -89,7 +90,8 @@ public class ActoinAnimationGroupCreateCommand extends Command {
         if (actionAnimation == null) {
             actionAnimation =
                        pagePart
-                            .createAnimatorActionAnimation(groupId,
+                            .createAnimatorActionAnimation(AnimatorUtils.getAppManager().getAnimatorModelManager().getModelFactory(),
+                                                                                  groupId,
                                                            convertActionAnimationGroupTypes(type),
                                                            time, trigger);
         }
index a82484e..ae201f3 100644 (file)
@@ -27,6 +27,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.eclipse.gef.commands.Command;
+import org.eclipse.wst.sse.core.internal.model.ModelManagerImpl;
 import org.tizen.webuibuilder.animator.model.AnimatorFrame;
 import org.tizen.webuibuilder.animator.model.AnimatorKeyframe;
 import org.tizen.webuibuilder.animator.model.AnimatorModelEvent;
@@ -87,12 +88,12 @@ public class AnimationCreateAndChangeFrameCommand extends Command {
                if(frame == null) {
                        keyframe = currentSelector.getCurrentKeyframe(currentTime);
                 if (keyframe == null) {
-                       keyframe = currentSelector.createKeyframe("custom", currentTime);
+                       keyframe = currentSelector.createKeyframe(animatorModelManager.getModelFactory(), "custom", currentTime);
                     currentSelector.addChild(keyframe);
                     isKeyframeCreate = true;
                 }
                 
-                frame = keyframe.createAnimatorFrame(currentTime);
+                frame = keyframe.createAnimatorFrame(animatorModelManager.getModelFactory(), currentTime);
                keyframe.addChild(frame, false);
                isFrameCreate = true;
                } else {
@@ -199,7 +200,7 @@ public class AnimationCreateAndChangeFrameCommand extends Command {
        if (frame != null) {
                AnimatorKeyframe keyframe = (AnimatorKeyframe)frame.getParent();
                if (keyframe != null) {
-                       frame.removeOrReplaceProperties(oldProperties, properties);
+                       frame.removeOrReplaceProperties(animatorModelManager.getModelFactory(), oldProperties, properties);
                        
                        //It is possible that keyframe has been changed in removeOrReplaceProperties
                        keyframe = (AnimatorKeyframe)frame.getParent();
index 36bfc4b..4c4b609 100644 (file)
@@ -117,7 +117,7 @@ public class AnimationCreateCommand extends Command {
        if(frames == null) {
                frames = animatorModelManager.getPredefinedAnimationFactory()
                        .createPredefinedFrames(preDefinedAnimationDescriptor, delay);
-               keyframe = currentSelector.createKeyframe(preDefinedAnimationDescriptor.getDisplayName(), delay);
+               keyframe = currentSelector.createKeyframe(animatorModelManager.getModelFactory(), preDefinedAnimationDescriptor.getDisplayName(), delay);
                
        } else {
                for(AnimatorFrame frame : frames) {
@@ -178,7 +178,7 @@ public class AnimationCreateCommand extends Command {
                currentSelector.removeChild(keyframe);
        }
        
-       currentSelector.mergeOrSplitKeyframe();
+//     currentSelector.mergeOrSplitKeyframe(animatorModelManager.getModelFactory());
        currentSelector.updateSelectorTime();
        currentSelector.setKeyframeNames(names);
        
index 9ca119e..b7d7c6c 100644 (file)
@@ -132,7 +132,7 @@ public class AnimationPropertyChangeCommand extends Command {
                        AnimatorModelEvent.EventType.SELECTOR_REFRESH, Origin.PROPERTY, currentSelector);*/
        
        AnimatorModelManager animatorModelManager = AnimatorUtils.getAppManager().getAnimatorModelManager();
-        frame.removeOrReplaceProperty(Key, oldValue);
+        frame.removeOrReplaceProperty(animatorModelManager.getModelFactory(), Key, oldValue);
         animatorModelManager.fireEvent(AnimatorModelEvent.EventType.FRAME_EDIT, Origin.PROPERTY,
                                        frame);
     }
index 467ce73..a49fc3f 100644 (file)
@@ -204,7 +204,8 @@ public class AnimatorEditPart extends HoverViewerEditPart {
                        pagePart.findAnimatorSelector(AnimatorUtils.getActiveAnimatorBrowserViewer()
                             .getCurrentAnimationGroupId(), part.getPropertyValue("id"), part.getUiSelector());
 
-            AnimationPathModel test = new AnimationPathModel(selector);
+            AnimationPathModel test = new AnimationPathModel(
+                       AnimatorUtils.getAppManager().getAnimatorModelManager().getModelFactory(), selector);
             editpart.setModel(test);
             editpart.setParent(this);
             editpart.setSelected(SELECTED);
@@ -235,7 +236,8 @@ public class AnimatorEditPart extends HoverViewerEditPart {
                        pagePart.findAnimatorSelector(AnimatorUtils.getActiveAnimatorBrowserViewer()
                                        .getCurrentAnimationGroupId(), part.getPropertyValue("id"), part.getUiSelector());
             
-            AnimationPathModel test = new AnimationPathModel(selector);
+            AnimationPathModel test = new AnimationPathModel(
+                       AnimatorUtils.getAppManager().getAnimatorModelManager().getModelFactory(), selector);
             editpart.setModel(test);
             editpart.refresh();
         }
index e2e553b..ea3afc4 100644 (file)
@@ -47,6 +47,7 @@ import org.tizen.webuibuilder.model.Part;
  * The Class AnimationPathModel.
  */
 public class AnimationPathModel implements IPropertySource {
+       private AnimatorModelFactory modelFactory = null;
     private AnimatorSelector selector;
     private List<AnimationPathKeyframe> keyframes = null;
 
@@ -56,7 +57,8 @@ public class AnimationPathModel implements IPropertySource {
      * @param selector
      *            the selector
      */
-    public AnimationPathModel(AnimatorSelector selector) {
+    public AnimationPathModel(AnimatorModelFactory modelFactory, AnimatorSelector selector) {
+       this.modelFactory = modelFactory;
         this.selector = selector;
         this.keyframes = getPathPointsFromAnimatorKeyFrame(selector);
     }
@@ -70,7 +72,7 @@ public class AnimationPathModel implements IPropertySource {
      * 
      * @return the css keyframes
      */
-    public List<AnimatorFrame> getCssKeyframes(AnimatorModelFactory modelFactory) {
+    public List<AnimatorFrame> getCssKeyframes() {
         List<AnimatorFrame> frames = new ArrayList<AnimatorFrame>();
 
         WidgetPosition widgetPosition = selector.getPartLink().getWidgetPosition();
@@ -82,7 +84,7 @@ public class AnimationPathModel implements IPropertySource {
                 int top = translateInDesigner.height;
 
                 int i = 0;
-                List<AnimatorFrame> mergedFrames = selector.getMergedFramesWithWidgetProperty();
+                List<AnimatorFrame> mergedFrames = selector.getMergedFramesWithWidgetProperty(modelFactory);
                 Set<String> propertiesUsed = selector.getAllPropertiesUsed(mergedFrames);
 
                 for (AnimatorFrame frame : mergedFrames) {
@@ -297,8 +299,8 @@ public class AnimationPathModel implements IPropertySource {
                 int left = translateInDesigner.width;
                 int top = translateInDesigner.height;
 
-                int width = selector.getPartLink().getPositionProperty().width;
-                int height = selector.getPartLink().getPositionProperty().height;
+                int width = widgetPosition.width;
+                int height = widgetPosition.height;
 
                 /*
                  * Hard coding origin origin is displayed in css : ex) -webkit-transform-origin:-35% 50%;
@@ -306,7 +308,7 @@ public class AnimationPathModel implements IPropertySource {
                 int originX = 50;
                 int originY = 50;
 
-                List<AnimatorFrame> frameList = selector.getMergedFramesWithWidgetProperty();
+                List<AnimatorFrame> frameList = selector.getMergedFramesWithWidgetProperty(modelFactory);
                 for (AnimatorModel frameElement : frameList) {
                     AnimatorFrame frame = ((AnimatorFrame) frameElement).getFrameLink();
 
@@ -373,7 +375,7 @@ public class AnimationPathModel implements IPropertySource {
         properties.put(Constants.translateX, AnimatorUtils.convertPixToString(p.x));
         properties.put(Constants.translateY, AnimatorUtils.convertPixToString(p.y));
 
-        editingFrame.editProperties(properties);
+        editingFrame.editProperties(AnimatorUtils.getAppManager().getAnimatorModelManager().getModelFactory(), properties);
 
         // editingFrame.addProperty(Constants.translateX,
         // AnimatorUtils.convertPixToString(p.x));
index 56491bf..468737e 100644 (file)
@@ -194,8 +194,7 @@ public class AnimatorAnimation extends AnimatorModel {
      * 
      * @param part
      */
-    public void updateAnimatorWidget(Part part) {      
-        AnimatorModelManager manager = AnimatorUtils.getAppManager().getAnimatorModelManager();
+    public void updateAnimatorWidget(AnimatorModelManager manager, Part part) {        
         // Update current exist animatorWidget's PartLink
         Iterator<AnimatorModel> iter = getChildren().iterator();
         while (iter.hasNext()) {
@@ -213,7 +212,7 @@ public class AnimatorAnimation extends AnimatorModel {
         }
 
         // Create added animatorWidget by PagePart's children
-        List<AnimatorModel> animaotrWidgets = updateAnimatorWidget(getId(), part.getChildren());
+        List<AnimatorModel> animaotrWidgets = updateAnimatorWidget(manager.getModelFactory(), getId(), part.getChildren());
         if (animaotrWidgets.size() > 0) {
             addChildren(animaotrWidgets);
             manager.fireEvent(this, EventType.WIDGET_ADD, Origin.EDITOR, null, animaotrWidgets);
@@ -226,16 +225,16 @@ public class AnimatorAnimation extends AnimatorModel {
      * @param partChildren
      * @return List of AnimatorWidget
      */
-    public List<AnimatorModel> composeAnimatorWidget(List<Part> partChildren) {
+    public List<AnimatorModel> composeAnimatorWidget(AnimatorModelFactory modelFactory, List<Part> partChildren) {
 
         List<AnimatorModel> animatorWidgets = new ArrayList<AnimatorModel>();
         for (Part partChild : partChildren) {
-            AnimatorWidget animatorWidget = createAnimatorWidget(partChild);
+            AnimatorWidget animatorWidget = createAnimatorWidget(modelFactory, partChild);
             animatorWidgets.add(animatorWidget);
 
             if (partChild.getChildren().size() >= 1) {
                 List<AnimatorModel> childAnimatorWidgets =
-                        composeAnimatorWidget(partChild.getChildren());
+                        composeAnimatorWidget(modelFactory, partChild.getChildren());
                 animatorWidgets.addAll(childAnimatorWidgets);
             }
         }
@@ -249,9 +248,9 @@ public class AnimatorAnimation extends AnimatorModel {
      * @param part
      * @return Created AnimatorWidget
      */
-    public AnimatorWidget createAnimatorWidget(Part part) {
+    public AnimatorWidget createAnimatorWidget(AnimatorModelFactory modelFactory, Part part) {
 
-        AnimatorWidget animatorWidget = (AnimatorWidget)getModelFactory()
+        AnimatorWidget animatorWidget = (AnimatorWidget)modelFactory
                        .createAnimatorModel(AnimatorModelType.WIDGET);
         animatorWidget.setPartLink(part);
         animatorWidget.setId(part.getPropertyValue("id"));
@@ -265,14 +264,14 @@ public class AnimatorAnimation extends AnimatorModel {
             // FIXME - by returned value
 
             AnimatorSelector animatorSelector =
-                    animatorWidget.createAnimatorSelector(part.getUiSelector());
+                    animatorWidget.createAnimatorSelector(modelFactory, part.getUiSelector());
             animatorWidget.addChild(animatorSelector);
         }
 
         return animatorWidget;
     }
 
-    private List<AnimatorModel> updateAnimatorWidget(String animationGroup, List<Part> partChildren) {
+    private List<AnimatorModel> updateAnimatorWidget(AnimatorModelFactory modelFactory, String animationGroup, List<Part> partChildren) {
 
         List<AnimatorModel> animatorWidgets = new ArrayList<AnimatorModel>();
         for (Part partChild : partChildren) {
@@ -289,13 +288,13 @@ public class AnimatorAnimation extends AnimatorModel {
             }
 
             if (!isExist) {
-                AnimatorWidget animatorWidget = createAnimatorWidget(partChild);
+                AnimatorWidget animatorWidget = createAnimatorWidget(modelFactory, partChild);
                 animatorWidgets.add(animatorWidget);
             }
 
             if (partChild.getChildren().size() >= 1) {
                 List<AnimatorModel> childAnimatorWidgets =
-                        updateAnimatorWidget(animationGroup, partChild.getChildren());
+                        updateAnimatorWidget(modelFactory, animationGroup, partChild.getChildren());
                 animatorWidgets.addAll(childAnimatorWidgets);
             }
         }
@@ -303,14 +302,14 @@ public class AnimatorAnimation extends AnimatorModel {
         return animatorWidgets;
     }
 
-        public List<AnimatorModel> createAnimatorWidgetsForWidget(Part child) {
+        public List<AnimatorModel> createAnimatorWidgetsForWidget(AnimatorModelFactory modelFactory, Part child) {
        
        List<AnimatorModel> widgetList = new ArrayList<AnimatorModel>();
-               AnimatorWidget animatorWidget = createAnimatorWidget(child);
+               AnimatorWidget animatorWidget = createAnimatorWidget(modelFactory, child);
                widgetList.add(animatorWidget);
                
                for (Part part : child.getChildren()) {
-                       widgetList.addAll(createAnimatorWidgetsForWidget(part));
+                       widgetList.addAll(createAnimatorWidgetsForWidget(modelFactory, part));
                }
                
                return widgetList;
index 90ee660..ef00ade 100644 (file)
@@ -41,8 +41,8 @@ public class AnimatorCurveFrame extends AnimatorModel {
     public AnimatorCurveFrame() {
     }
     
-       public AnimatorCurveFrame cloneAnimatorCurveFrame() {
-               AnimatorCurveFrame curveFrame = (AnimatorCurveFrame)getModelFactory().createAnimatorModel(AnimatorModelType.CURVEFRAME);
+       public AnimatorCurveFrame cloneAnimatorCurveFrame(AnimatorModelFactory modelFactory) {
+               AnimatorCurveFrame curveFrame = (AnimatorCurveFrame)modelFactory.cloneAnimatorModel(this);
                cloneAnimatorModel(curveFrame);
                
                curveFrame.setLocation(this.location.getCopy());
index 6fafb6b..a874352 100644 (file)
@@ -55,9 +55,9 @@ public class AnimatorFrame extends AnimatorModel {
 
     }
     
-       public AnimatorFrame cloneAnimatorFrame() {
+       public AnimatorFrame cloneAnimatorFrame(AnimatorModelFactory modelFactory) {
                
-               AnimatorFrame frame = (AnimatorFrame)getModelFactory().createAnimatorModel(AnimatorModelType.FRAME);
+               AnimatorFrame frame = (AnimatorFrame)modelFactory.cloneAnimatorModel(this);
                
                cloneAnimatorModel(frame);
                frame.setPredefined(isPredefined());
@@ -71,7 +71,7 @@ public class AnimatorFrame extends AnimatorModel {
                }
                
                for (AnimatorCurveFrame curveFrame : getCurveFrames())
-                       frame.addCurveFrame(curveFrame.cloneAnimatorCurveFrame());
+                       frame.addCurveFrame(curveFrame.cloneAnimatorCurveFrame(modelFactory));
                
                return frame;
        }
@@ -81,9 +81,9 @@ public class AnimatorFrame extends AnimatorModel {
      * 
      * @return frame
      */
-       public AnimatorFrame cloneAnimatorFrameWithFrameLink() {
+       public AnimatorFrame cloneAnimatorFrameWithFrameLink(AnimatorModelFactory modelFactory) {
                
-               AnimatorFrame frame = (AnimatorFrame)getModelFactory().createAnimatorModel(AnimatorModelType.FRAME);
+               AnimatorFrame frame = (AnimatorFrame)modelFactory.cloneAnimatorModel(this);
                
                frame.setFrameTime(frameTime);
                frame.setFrameLink(this);
@@ -97,7 +97,7 @@ public class AnimatorFrame extends AnimatorModel {
         }
 
         for (AnimatorCurveFrame curveFrame : getCurveFrames())
-            frame.addCurveFrame(curveFrame.cloneAnimatorCurveFrame());
+            frame.addCurveFrame(curveFrame.cloneAnimatorCurveFrame(modelFactory));
         
                return frame;
        }
@@ -373,7 +373,8 @@ public class AnimatorFrame extends AnimatorModel {
      * 
      * @param properties
      */
-    public void editProperties(Map<String, String> properties) {
+    public void editProperties(AnimatorModelFactory modelFactory,
+               Map<String, String> properties) {
         Iterator<Entry<String, String>> editingPropertiesIterator =
                 properties.entrySet().iterator();
         while (editingPropertiesIterator.hasNext()) {
@@ -390,7 +391,7 @@ public class AnimatorFrame extends AnimatorModel {
         if (nextFrame != null) {
             if (nextFrame.hasSamePropertyValue(this)) {
                 AnimatorKeyframe nextKeyframe =
-                        selector.createKeyframe("custom", nextFrame.getFrameTime());
+                        selector.createKeyframe(modelFactory, "custom", nextFrame.getFrameTime());
                 keyframe.splitFrame(nextKeyframe, nextFrame, true);
                 selector.addChild(nextKeyframe);
             }
@@ -408,7 +409,7 @@ public class AnimatorFrame extends AnimatorModel {
         if (previousFrame != null) {
             if (previousFrame.hasSamePropertyValue(this)) {
                 AnimatorKeyframe previousKeyframe =
-                        selector.createKeyframe("custom", previousFrame.getFrameTime());
+                        selector.createKeyframe(modelFactory, "custom", previousFrame.getFrameTime());
                 keyframe.splitFrame(previousKeyframe, this, true);
                 selector.addChild(previousKeyframe);
             }
@@ -440,7 +441,7 @@ public class AnimatorFrame extends AnimatorModel {
      * @param key
      * @param oldValue
      */
-    public void removeOrReplaceProperty(String key, String oldValue) {
+    public void removeOrReplaceProperty(AnimatorModelFactory modelFactory, String key, String oldValue) {
         AnimatorKeyframe keyframe = (AnimatorKeyframe) getParent();
         String currentValue = getProperty(key);
 
@@ -450,7 +451,7 @@ public class AnimatorFrame extends AnimatorModel {
             addProperty(key, oldValue);
 
         if (currentValue != null)
-            keyframe.splitKeyframe(this);
+            keyframe.splitKeyframe(modelFactory, this);
     }
 
     /**
@@ -459,7 +460,8 @@ public class AnimatorFrame extends AnimatorModel {
      * @param oldProperties
      * @param properties
      */
-    public void removeOrReplaceProperties(Map<String, String> oldProperties,
+    public void removeOrReplaceProperties(AnimatorModelFactory modelFactory,
+                                                                         Map<String, String> oldProperties,
                                           Map<String, String> properties) {
         AnimatorKeyframe keyframe = (AnimatorKeyframe) getParent();
         Iterator<Entry<String, String>> editingPropertiesIterator =
@@ -477,7 +479,7 @@ public class AnimatorFrame extends AnimatorModel {
             } else
                 removeProperty(editingPropertyKey);
         }
-        keyframe.splitKeyframe(this);
+        keyframe.splitKeyframe(modelFactory, this);
     }
 
     /**
@@ -799,7 +801,7 @@ public class AnimatorFrame extends AnimatorModel {
      * @param frame
      * @param keyframe
      */
-    public void findAnimatedPropertyAndSetInFrame(AnimatorFrame previousFrame, AnimatorFrame nextFrame) {
+    public void findAnimatedPropertyAndSetInFrame(AnimatorModelFactory modelFactory, AnimatorFrame previousFrame, AnimatorFrame nextFrame) {
         if(previousFrame == null || nextFrame == null) {
                return;
         }
@@ -829,7 +831,7 @@ public class AnimatorFrame extends AnimatorModel {
             Point p;
             p =
                     AnimationPathModel
-                            .findTranslateValueAtTime(getModelFactory(), getFrameTime(), previousFrame,
+                            .findTranslateValueAtTime(modelFactory, getFrameTime(), previousFrame,
                                                       nextFrame,
                                                       AnimatorUtils.getEasingMethod(easingProperty));
 
index a3f0067..9f21038 100644 (file)
@@ -43,8 +43,8 @@ public class AnimatorKeyframe extends AnimatorModel {
        }
     
 
-       public AnimatorKeyframe cloneAnimatorKeyframe() {
-               AnimatorKeyframe keyframe = (AnimatorKeyframe)getModelFactory().createAnimatorModel(AnimatorModelType.KEYFRAME);
+       public AnimatorKeyframe cloneAnimatorKeyframe(AnimatorModelFactory modelFactory) {
+               AnimatorKeyframe keyframe = (AnimatorKeyframe)modelFactory.cloneAnimatorModel(this);
                
                cloneAnimatorModel(keyframe);
                keyframe.setName(getName());
@@ -52,7 +52,7 @@ public class AnimatorKeyframe extends AnimatorModel {
                keyframe.setDelay(getDelay());
                
                for(AnimatorModel model : getChildren()) {
-                       AnimatorFrame frame = ((AnimatorFrame)model).cloneAnimatorFrame();
+                       AnimatorFrame frame = ((AnimatorFrame)model).cloneAnimatorFrame(modelFactory);
                        keyframe.addChild(frame);
                }
                
@@ -516,13 +516,13 @@ public class AnimatorKeyframe extends AnimatorModel {
      * 
      * @param frame
      */
-    public void splitKeyframe(AnimatorFrame frame) {
+    public void splitKeyframe(AnimatorModelFactory modelFactory, AnimatorFrame frame) {
         AnimatorSelector selector = (AnimatorSelector) getParent();
         AnimatorFrame nextFrame = (AnimatorFrame) getNextChild(frame);
         if (nextFrame != null) {
             if (nextFrame.hasSamePropertyValue(frame)) {
                 AnimatorKeyframe nextKeyframe =
-                        selector.createKeyframe("custom", frame.getFrameTime());
+                        selector.createKeyframe(modelFactory, "custom", frame.getFrameTime());
                 splitFrame(nextKeyframe, nextFrame, true);
                 selector.addChild(nextKeyframe);
             }
@@ -532,7 +532,7 @@ public class AnimatorKeyframe extends AnimatorModel {
         if (previousFrame != null) {
             if (previousFrame.hasSamePropertyValue(frame)) {
                 AnimatorKeyframe currentKeyframe =
-                        selector.createKeyframe("custom", frame.getFrameTime());
+                        selector.createKeyframe(modelFactory, "custom", frame.getFrameTime());
                 splitFrame(currentKeyframe, frame, true);
                 selector.addChild(currentKeyframe);
             }
@@ -573,8 +573,8 @@ public class AnimatorKeyframe extends AnimatorModel {
             splitFrame(keyframe, nextFrame);
     }
     
-    public AnimatorFrame createAnimatorFrame(double currentTime) {
-       AnimatorFrame frame = (AnimatorFrame)getModelFactory().createAnimatorModel(AnimatorModelType.FRAME);
+    public AnimatorFrame createAnimatorFrame(AnimatorModelFactory modelFactory, double currentTime) {
+       AnimatorFrame frame = (AnimatorFrame)modelFactory.createAnimatorModel(AnimatorModelType.FRAME);
        frame.setFrameTime(currentTime);
        frame.setParent(this);
                
@@ -620,18 +620,23 @@ public class AnimatorKeyframe extends AnimatorModel {
        }
 
 
-       public List<AnimatorFrame> getClonedFrames() {
+       public List<AnimatorFrame> getClonedFrames(AnimatorModelFactory modelFactory) {
                List<AnimatorFrame> frames = new ArrayList<AnimatorFrame>();
                
                for(AnimatorModel model : getChildren()) {
                        AnimatorFrame frame = (AnimatorFrame)model;
-                       frames.add(frame.cloneAnimatorFrame());
+                       frames.add(frame.cloneAnimatorFrame(modelFactory));
                }
                return frames;
        }
 
-
-       public void setChildrenByClonedAnimatorFrames(List<AnimatorModel> children) {
-               
+       public AnimatorFrame getFrameById(String id) {
+               for(AnimatorModel model : getChildren()) {
+                       AnimatorFrame frame = (AnimatorFrame)model;
+                       if(frame.getId().equals(id)) {
+                               return frame;
+                       }
+               }
+               return null;
        }
 }
index f953995..e6c5991 100644 (file)
@@ -38,7 +38,6 @@ public abstract class AnimatorModel {
     private AnimatorModel parent = null;
     private List<AnimatorModel> children = new ArrayList<AnimatorModel>();
     private Part partLink = null;
-    private AnimatorModelFactory modelFactory = null;
 
     private List<IAnimatorModelListener> animatorListeners =
             new ArrayList<IAnimatorModelListener>();
@@ -140,14 +139,6 @@ public abstract class AnimatorModel {
         return null;
     }
 
-    public AnimatorModelFactory getModelFactory() {
-               return modelFactory;
-       }
-
-       public void setModelFactory(AnimatorModelFactory modelFactory) {
-               this.modelFactory = modelFactory;
-       }
-
        /**
      * Get child index
      * 
index a1ba5d4..8488951 100644 (file)
@@ -37,28 +37,37 @@ public class AnimatorModelFactory {
        public AnimatorModelFactory(IDGenerator idGenerator) {
                this.idGenerator = idGenerator; 
        }
-
-       public AnimatorModel createAnimatorModel(AnimatorModelType modelType) {
+       
+       public AnimatorModel createAnimatorModel(AnimatorModelType modelType, boolean isIdGenerate) {
                
                AnimatorModel model = null;
                switch(modelType) {
                case ANIMATION:
                        model = new AnimatorAnimation();
-                       model.setId(idGenerator.generateAnimationId());
+                       if(isIdGenerate) {
+                               model.setId(idGenerator.generateAnimationId());
+                       }
                        break;
                case WIDGET:
                        model = new AnimatorWidget();
                        break;
                case SELECTOR:
                        model = new AnimatorSelector();
-                       model.setId(idGenerator.generateSelectorId());
+                       if(isIdGenerate) {
+                               model.setId(idGenerator.generateSelectorId());
+                       }
                        break;  
                case KEYFRAME:
                        model = new AnimatorKeyframe();
-                       model.setId(idGenerator.generateKeyframeId());
+                       if(isIdGenerate) {
+                               model.setId(idGenerator.generateKeyframeId());
+                       }
                        break;
                case FRAME:
                        model = new AnimatorFrame();
+                       if(isIdGenerate) {
+                               model.setId(idGenerator.generateframeId());
+                       }
                        break;
                case CURVEFRAME:
                        model = new AnimatorCurveFrame();
@@ -68,20 +77,53 @@ public class AnimatorModelFactory {
                        break;
                case ACTION:
                        model = new AnimatorAction();
-                       model.setId(idGenerator.generateActionId());
+                       if(isIdGenerate) {
+                               model.setId(idGenerator.generateActionId());
+                       }
                        break;
                case ACTION_ANIMATION:
                        model = new AnimatorActionAnimation();
-                       model.setId(idGenerator.generateActionId());
+                       if(isIdGenerate) {
+                               model.setId(idGenerator.generateActionId());
+                       }
                        break;
                case ACTION_TIMER:
                case ACTION_AUDIO:
                case ACTION_VIDEO:
                }
                
-               if(model != null)
-                       model.setModelFactory(this);
-               
                return model;
        }
+
+       public AnimatorModel createAnimatorModel(AnimatorModelType modelType) {
+               return createAnimatorModel(modelType, true);
+       }
+       
+       public AnimatorModel cloneAnimatorModel(AnimatorModel model) {
+               AnimatorModelType modelType = null;
+               if(model instanceof AnimatorAnimation) {
+                       modelType = AnimatorModelType.ANIMATION;
+               } else if(model instanceof AnimatorWidget) {
+                       modelType = AnimatorModelType.WIDGET;
+               } else if(model instanceof AnimatorSelector) {
+                       modelType = AnimatorModelType.SELECTOR;
+               } else if(model instanceof AnimatorKeyframe) {
+                       modelType = AnimatorModelType.KEYFRAME;
+               } else if(model instanceof AnimatorFrame) {
+                       modelType = AnimatorModelType.FRAME;
+               } else if(model instanceof AnimatorCurveFrame) {
+                       modelType = AnimatorModelType.CURVEFRAME;
+               } else if(model instanceof AnimatorTrigger) {
+                       modelType = AnimatorModelType.TRIGGER;
+               } else if(model instanceof AnimatorAction) {
+                       modelType = AnimatorModelType.ACTION;
+               } else if(model instanceof AnimatorActionAnimation) {
+                       modelType = AnimatorModelType.ACTION_ANIMATION;
+               }
+               
+               AnimatorModel clonedModel = createAnimatorModel(modelType, false);
+               clonedModel.setId(model.getId());
+               
+               return clonedModel;
+       }
 }
index 2c76816..9530148 100644 (file)
@@ -292,15 +292,14 @@ public class AnimatorModelManager implements ISelectionListener, IPageDataSetLis
      * 
      * @param newRootPart
      */
-    public void updateAnimatorModel(Part newRootPart) {
-        Part oldRootPart = getAppManager().getPageDataSet().getBaseRootPart();
+    public void updateAnimatorModel(Part newRootPart, Part oldRootPart) {
         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);
+                        ((AnimatorPagePart) newPart).updateAnimatorAnimation(this, (AnimatorPagePart) oldPart);
                         break;
                     }
                 }
index f6cb953..ca03a46 100644 (file)
@@ -53,8 +53,8 @@ public class AnimatorSelector extends AnimatorModel {
        }
     
     
-       public AnimatorSelector cloneAnimatorSelector() {
-               AnimatorSelector selector = (AnimatorSelector)getModelFactory().createAnimatorModel(AnimatorModelType.SELECTOR);
+       public AnimatorSelector cloneAnimatorSelector(AnimatorModelFactory modelFactory) {
+               AnimatorSelector selector = (AnimatorSelector)modelFactory.cloneAnimatorModel(this);
                
                cloneAnimatorModel(selector);
                selector.setSelector(getSelector());
@@ -65,7 +65,7 @@ public class AnimatorSelector extends AnimatorModel {
                selector.setHoldEnd(isHoldEnd());
                
                for(AnimatorModel model : getChildren()) {      
-                       AnimatorKeyframe clonedKeyframe = ((AnimatorKeyframe)model).cloneAnimatorKeyframe();
+                       AnimatorKeyframe clonedKeyframe = ((AnimatorKeyframe)model).cloneAnimatorKeyframe(modelFactory);
                        selector.addChild(clonedKeyframe);
                }
                
@@ -358,7 +358,7 @@ public class AnimatorSelector extends AnimatorModel {
      * 
      * @return all the frames used in this Selector
      */
-    public List<AnimatorFrame> getMergedFrames() {
+    public List<AnimatorFrame> getMergedFrames(AnimatorModelFactory modelFactory) {
 
         updateSelectorTime();
 
@@ -371,7 +371,7 @@ public class AnimatorSelector extends AnimatorModel {
             for (AnimatorModel frameModel : keyframe.getChildren()) {
                 AnimatorFrame frame = (AnimatorFrame) frameModel;
 
-                AnimatorFrame newFrame = frame.cloneAnimatorFrameWithFrameLink();
+                AnimatorFrame newFrame = frame.cloneAnimatorFrameWithFrameLink(modelFactory);
                 newFrame.setFrameTime(calculateMergeFrameTime(keyframe.getCurrentTime(frame
                         .getFrameTime())));
 
@@ -407,8 +407,8 @@ public class AnimatorSelector extends AnimatorModel {
         return frames;
     }
     
-    public List<AnimatorFrame> getMergedFramesWithComputedProperty() {
-       List<AnimatorFrame> mergedFrames = getMergedFrames();
+    public List<AnimatorFrame> getMergedFramesWithComputedProperty(AnimatorModelFactory modelFactory) {
+       List<AnimatorFrame> mergedFrames = getMergedFrames(modelFactory);
        Set<String> propertiesUsed = getAllPropertiesUsed(mergedFrames);
        Map<String, String> widgetProperties = getWidgetProperties(propertiesUsed);
                
@@ -431,9 +431,9 @@ public class AnimatorSelector extends AnimatorModel {
        return mergedFrames;
     }
     
-    public List<AnimatorFrame> getMergedFramesWithWidgetProperty() {
+    public List<AnimatorFrame> getMergedFramesWithWidgetProperty(AnimatorModelFactory modelFactory) {
        
-       List<AnimatorFrame> mergedFrames = getMergedFramesWithComputedProperty();
+       List<AnimatorFrame> mergedFrames = getMergedFramesWithComputedProperty(modelFactory);
        Set<String> propertiesUsed = getAllPropertiesUsed(mergedFrames);
        Map<String, String> widgetProperties = getWidgetProperties(propertiesUsed);
        
@@ -475,8 +475,8 @@ public class AnimatorSelector extends AnimatorModel {
      * @param frameTime
      * @return
      */
-    public AnimatorKeyframe createKeyframe(String name, double frameTime) {        
-        AnimatorKeyframe keyframe = (AnimatorKeyframe)getModelFactory().createAnimatorModel(AnimatorModelType.KEYFRAME);
+    public AnimatorKeyframe createKeyframe(AnimatorModelFactory modelFactory, String name, double frameTime) {        
+        AnimatorKeyframe keyframe = (AnimatorKeyframe)modelFactory.createAnimatorModel(AnimatorModelType.KEYFRAME);
         keyframe.setName(name);
         keyframe.setDuration(0.0);
         keyframe.setDelay(frameTime);
@@ -537,6 +537,18 @@ public class AnimatorSelector extends AnimatorModel {
 
         return null;
     }
+    
+    public AnimatorFrame getAnimatorFrameById(String id) {
+       for(AnimatorModel model : getChildren()) {
+               AnimatorKeyframe keyframe = (AnimatorKeyframe)model;
+               AnimatorFrame frame = keyframe.getFrameById(id);
+               if(frame != null) {
+                       return frame;
+               }
+       }
+       
+       return null;
+    }
 
     /**
      * Merge Frame if two frame at same time If next frame has property that has previous frame,
@@ -574,8 +586,8 @@ public class AnimatorSelector extends AnimatorModel {
     }
     
     
-    public boolean mergeOrSplitKeyframe() {
-       boolean result = false;         
+    public boolean mergeOrSplitKeyframe(AnimatorModelFactory modelFactory, List<AnimatorKeyframe> removedKeyframes) {
+       boolean result = false;
        AnimatorFrame currentFrame = getNextAnimatorFrameByTime(null);
        while(currentFrame != null) {
                AnimatorKeyframe currentKeyframe = (AnimatorKeyframe)currentFrame.getParent();
@@ -585,17 +597,23 @@ public class AnimatorSelector extends AnimatorModel {
                                AnimatorKeyframe expectedPreviousKeyframe = (AnimatorKeyframe)previousFrame.getParent();
                                if(previousFrame.hasSamePropertyValue(currentFrame)) {
                                        if(expectedPreviousKeyframe.equals(currentKeyframe)) {
-                                               AnimatorKeyframe newKeyframe =
-                                       createKeyframe("custom", currentKeyframe.getDelay() + currentFrame.getFrameTime());
+                                               AnimatorKeyframe nextKeyframe = (AnimatorKeyframe)getNextChild(currentKeyframe);
+                                               if(nextKeyframe == null) {
+                                                       nextKeyframe =
+                                               createKeyframe(modelFactory, "custom", currentKeyframe.getDelay() + currentFrame.getFrameTime());
+                                                       addChild(nextKeyframe);
+                                               }
                                                currentKeyframe.removeChild(currentFrame, true);
-                                               newKeyframe.addChild(currentFrame, true);
-                               addChild(newKeyframe);
+                                               nextKeyframe.addChild(currentFrame, true);
                                result = true;
                                        }
                                } else {
                                        if(!previousFrame.getParent().equals(currentFrame.getParent())) {
                                                currentKeyframe.removeChild(currentFrame, true);
                                                expectedPreviousKeyframe.addChild(currentFrame, true);
+                                               if(currentKeyframe.getChildrenSize() == 0) {
+                                                       removedKeyframes.add(currentKeyframe);
+                                               }
                                                result = true;
                                        }
                                }
@@ -731,7 +749,7 @@ public class AnimatorSelector extends AnimatorModel {
             builder.append("@-webkit-keyframes " + id + " {");
             builder.append("\n");
             builder.append("\t");
-            List<AnimatorFrame> frames = new AnimationPathModel(this).getCssKeyframes(modelFactory);
+            List<AnimatorFrame> frames = new AnimationPathModel(modelFactory, this).getCssKeyframes();
             Set<String> propertiesUsed = getAllPropertiesUsed(frames);
 
             for (AnimatorModel frame : frames) {
@@ -779,14 +797,14 @@ public class AnimatorSelector extends AnimatorModel {
         return result;
     }
     
-    public AnimatorFrame createAnimatorFrame(double currentTime) {
+    public AnimatorFrame createAnimatorFrame(AnimatorModelFactory modelFactory, double currentTime) {
        AnimatorKeyframe keyframe = getCurrentKeyframe(currentTime);
         if (keyframe == null) {
-               keyframe = createKeyframe("custom", currentTime);
+               keyframe = createKeyframe(modelFactory, "custom", currentTime);
             addChild(keyframe);
         }
         
-        AnimatorFrame frame = keyframe.createAnimatorFrame(currentTime);
+        AnimatorFrame frame = keyframe.createAnimatorFrame(modelFactory, currentTime);
        keyframe.addChild(frame, true);
         
        return frame;
@@ -799,15 +817,15 @@ public class AnimatorSelector extends AnimatorModel {
      * @param currentTime
      * @return
      */
-    public AnimatorFrame createOrGetAnimatorFrame(double currentTime) {
+    public AnimatorFrame createOrGetAnimatorFrame(AnimatorModelFactory modelFactory, double currentTime) {
         AnimatorFrame frame = null;
         AnimatorKeyframe keyframe = getCurrentKeyframe(currentTime);
         if (keyframe == null)
-            keyframe = createKeyframe("custom", currentTime);
+            keyframe = createKeyframe(modelFactory, "custom", currentTime);
 
         AnimatorFrame currentframe = keyframe.getFrameByCurrentTime(currentTime);
         if (currentframe == null) {
-               frame = keyframe.createAnimatorFrame(currentTime);
+               frame = keyframe.createAnimatorFrame(modelFactory, currentTime);
         }
 
         return frame;
@@ -885,4 +903,71 @@ public class AnimatorSelector extends AnimatorModel {
                }
                return null;
        }
+
+       public void rearrangementByAnimatorSelector(AnimatorModelManager modelManager, AnimatorSelector oldSelector, List<AnimatorKeyframe> removedKeyframes) {
+
+               for(AnimatorModel keyframeModel : oldSelector.getChildren()) {
+                       AnimatorKeyframe oldKeyframe = (AnimatorKeyframe)keyframeModel;
+                       for(AnimatorModel frameModel : oldKeyframe.getChildren()) {
+                               AnimatorFrame oldFrame = (AnimatorFrame)frameModel;
+                               Double currentTime = oldKeyframe.getDelay() + oldFrame.getFrameTime();
+                               AnimatorFrame currentFrame = getAnimatorFrameById(oldFrame.getId());
+                               if(currentFrame != null) {
+                                       AnimatorKeyframe currentKeyframe = (AnimatorKeyframe)currentFrame.getParent();                                  
+                                       //oldKeyframe's id and currentKeyframe's id is not equal
+                                       //I means currentFrame has been moved to other keyframe
+                                       if(!oldKeyframe.getId().equals(currentKeyframe.getId())) {
+                                               //find keyframe that has same id with oldKeyframe from currentSelector
+                                               AnimatorKeyframe currentKeyframeById = null;
+                                               for(AnimatorModel currentKeyframeModel : getChildren()) {
+                                                       AnimatorKeyframe candidateKeyframe = (AnimatorKeyframe)currentKeyframeModel; 
+                                                       if(candidateKeyframe.getId().equals(oldKeyframe.getId())) {
+                                                               currentKeyframeById = candidateKeyframe;
+                                                               break;
+                                                       }
+                                               }
+                                               if(currentKeyframeById != null) {
+                                                       //If there is keyframe that has same id
+                                                       currentKeyframe.removeChild(currentFrame, true);
+                                                       currentFrame.setFrameTime(currentTime);
+                                                       currentKeyframeById.addChild(currentFrame, true);
+                                               } else {
+                                                       //Keyframe has been removed
+                                                       //find removedKeyframe list
+                                                       for(AnimatorKeyframe removedKeyframe : removedKeyframes) {
+                                                               if(removedKeyframe.getId().equals(oldKeyframe.getId())) {
+                                                                       currentKeyframeById = removedKeyframe;
+                                                                       break;
+                                                               }
+                                                       }
+                                                       
+                                                       //if currentKeyframeById is still null
+                                                       //it is.. not possible
+                                                       if(currentKeyframeById == null) {
+                                                               currentKeyframeById = (AnimatorKeyframe)modelManager.getModelFactory().cloneAnimatorModel(oldKeyframe);
+                                                       }
+                                                       
+                                                       currentKeyframe.removeChild(currentFrame, true);
+                                                       currentFrame.setFrameTime(currentTime);
+                                                       currentKeyframeById.addChild(currentFrame, false);
+                                                       addChild(currentKeyframeById);
+//                                                     modelManager.fireEvent(true, this, AnimatorModelEvent.EventType.KEYFRAME_ADD, 
+//                                                                     AnimatorModelEvent.Origin.TIMELINE, currentKeyframeById);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+
+       public AnimatorKeyframe getAnimatorKeyframeById(String id) {
+               for(AnimatorModel model : getChildren()) {
+                       AnimatorKeyframe currentKeyframeById = (AnimatorKeyframe)model;
+                       if(currentKeyframeById.getId().equals(id)) {
+                               return currentKeyframeById;
+                       }
+               }
+               return null;
+       }
 }
index bfc9931..545f955 100644 (file)
@@ -72,11 +72,11 @@ public class AnimatorTrigger extends AnimatorModel {
             getParent().removeChild(this);
     }
 
-       public AnimatorActionAnimation createAnimatorActionAnimation(
+       public AnimatorActionAnimation createAnimatorActionAnimation(AnimatorModelFactory modelFactory,
                        AnimatorAnimation animation, String actionType, double time) {
                
                AnimatorActionAnimation actionAnimation = 
-                               (AnimatorActionAnimation)getModelFactory().createAnimatorModel(AnimatorModelType.ACTION_ANIMATION);
+                               (AnimatorActionAnimation)modelFactory.createAnimatorModel(AnimatorModelType.ACTION_ANIMATION);
 
            actionAnimation.setAnimation(animation);
            actionAnimation.setActionType(actionType);
index b490ac0..d5e731b 100644 (file)
@@ -121,9 +121,9 @@ public class AnimatorWidget extends AnimatorModel {
      * @param widget
      * @return
      */
-    public AnimatorSelector createAnimatorSelector(String selector) {
+    public AnimatorSelector createAnimatorSelector(AnimatorModelFactory modelFactory, String selector) {
        AnimatorSelector animatorSelector =
-                       (AnimatorSelector)getModelFactory().createAnimatorModel(AnimatorModelType.SELECTOR);
+                       (AnimatorSelector)modelFactory.createAnimatorModel(AnimatorModelType.SELECTOR);
        animatorSelector.setSelector(selector);
        animatorSelector.setDelay(0.0);
        animatorSelector.setDuration(0.0);
index 1ea7c2c..b9b3693 100644 (file)
@@ -66,6 +66,15 @@ public class IDGenerator {
     public String generateKeyframeId() {
         return getIdOfMap(AnimatorConstants.MODEL_ID_PREFIX_KEYFRAME);
     }
+    
+    /**
+     * Generate frame id
+     * 
+     * @return frame id
+     */
+    public String generateframeId() {
+        return getIdOfMap(AnimatorConstants.MODEL_ID_PREFIX_FRAME);
+    }
 
     /**
      * Generate action id
@@ -189,36 +198,4 @@ public class IDGenerator {
     private void clearMap() {
         idMap.clear();
     }
-
-    /**
-     * Decrease animation id
-     */
-    public void decreaseAnimationId() {
-        idMap.put(AnimatorConstants.MODEL_ID_PREFIX_ANIMATION,
-                  (int) idMap.get(AnimatorConstants.MODEL_ID_PREFIX_ANIMATION) - 1);
-    }
-
-    /**
-     * Decrease selector id
-     */
-    public void decreaseSelectorId() {
-        idMap.put(AnimatorConstants.MODEL_ID_PREFIX_SELECTOR,
-                  (int) idMap.get(AnimatorConstants.MODEL_ID_PREFIX_SELECTOR) - 1);
-    }
-
-    /**
-     * Decrease keyframe id
-     */
-    public void decreaseKeyframeId() {
-        idMap.put(AnimatorConstants.MODEL_ID_PREFIX_KEYFRAME,
-                  (int) idMap.get(AnimatorConstants.MODEL_ID_PREFIX_KEYFRAME) - 1);
-    }
-
-    /**
-     * Decrease action id
-     */
-    public void decreaseActionId() {
-        idMap.put(AnimatorConstants.MODEL_ID_PREFIX_ACTION,
-                  (int) idMap.get(AnimatorConstants.MODEL_ID_PREFIX_ACTION) - 1);
-    }
 }
index bdaad52..e6e7519 100644 (file)
@@ -103,11 +103,11 @@ public class AnimatorPagePart extends AnimatorPart {
                return animationGroup;
        }
 
-       public void updateAnimatorAnimation(Part oldPagePart) {
+       public void updateAnimatorAnimation(AnimatorModelManager modelManager, Part oldPagePart) {
                for (AnimatorModel model : ((AnimatorPagePart)oldPagePart).getAnimations()) {
                        AnimatorAnimation animation = (AnimatorAnimation) model;
                        animation.setPartLink(this);
-                       animation.updateAnimatorWidget(this);
+                       animation.updateAnimatorWidget(modelManager, this);
                        addAnimation(animation);
                }
        }
@@ -147,7 +147,7 @@ public class AnimatorPagePart extends AnimatorPart {
                 createAnimatorAnimation(modelManager.getModelFactory());
 
         List<AnimatorModel> makeAnimatorWidget =
-                animationGroup.composeAnimatorWidget(getChildren());
+                animationGroup.composeAnimatorWidget(modelManager.getModelFactory(), getChildren());
         animationGroup.setChildren(makeAnimatorWidget);
 
         return animationGroup;
@@ -210,10 +210,10 @@ public class AnimatorPagePart extends AnimatorPart {
      * @param child
      * @return
      */
-    public List<AnimatorModel> createAnimatorWidgetsForAllAnimations(Part child) {
+    public List<AnimatorModel> createAnimatorWidgetsForAllAnimations(AnimatorModelFactory modelFactory, Part child) {
         List<AnimatorModel> widgetList = new ArrayList<AnimatorModel>();
         for (AnimatorAnimation animation : getAnimations())
-            widgetList.addAll(animation.createAnimatorWidgetsForWidget(child));
+            widgetList.addAll(animation.createAnimatorWidgetsForWidget(modelFactory, child));
 
         return widgetList;
     }
@@ -224,11 +224,11 @@ public class AnimatorPagePart extends AnimatorPart {
      * @param clonedParts
      * @return
      */
-    public List<AnimatorModel> createAnimatorWidgetsForAllAnimations(List<Part> clonedParts) {
+    public List<AnimatorModel> createAnimatorWidgetsForAllAnimations(AnimatorModelFactory modelFactory, List<Part> clonedParts) {
         List<AnimatorModel> widgetList = new ArrayList<AnimatorModel>();
         for (AnimatorAnimation animation : getAnimations()) {
             for (Part part : clonedParts) {
-                widgetList.addAll(animation.createAnimatorWidgetsForWidget(part));
+                widgetList.addAll(animation.createAnimatorWidgetsForWidget(modelFactory, part));
             }
         }
 
@@ -367,14 +367,15 @@ public class AnimatorPagePart extends AnimatorPart {
      * @param trigger
      * @return
      */
-    public AnimatorActionAnimation createAnimatorActionAnimation(String animationGroup,
+    public AnimatorActionAnimation createAnimatorActionAnimation(AnimatorModelFactory modelFactory,
+                                                                                                                        String animationGroup,
                                                                  String actionType, double time,
                                                                  AnimatorTrigger trigger) {
         AnimatorActionAnimation actionAnimation = null;
         AnimatorAnimation animation = getAnimation(animationGroup);
 
         if (animation != null) {
-            actionAnimation = trigger.createAnimatorActionAnimation(animation, actionType, time);
+            actionAnimation = trigger.createAnimatorActionAnimation(modelFactory, animation, actionType, time);
         }
 
         return actionAnimation;
index 2e09783..3d67f44 100644 (file)
@@ -42,7 +42,6 @@ import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
 import org.tizen.webuibuilder.bridge.DesignerGoingBridge.WidgetPosition;
 import org.tizen.webuibuilder.model.Part;
 import org.tizen.webuibuilder.model.PartEvent;
-import org.tizen.webuibuilder.model.app.AppManager;
 import org.tizen.webuibuilder.model.descriptors.PartDescriptor;
 
 import com.google.gson.annotations.Expose;
index 6ef2446..576dddb 100644 (file)
@@ -132,7 +132,7 @@ public class PasteKeyFrameAction extends SelectionAction {
         double pointTime =\r
                 viewer.getMainContainer().getContentContainer().getContentHeaderContainer()\r
                         .getKeyframeHeader().getTimeBar().getPlayHeader().getCurrentPointTime();\r
-        CompoundCommand command = new CompoundCommand();\r
+        CompoundCommand command = new CompoundCommand();
         for (AnimatorModel selectorModel : children) {\r
             AnimatorSelector selector = (AnimatorSelector) selectorModel;\r
             for (AnimatorModel model : cloneModels) {\r
@@ -164,11 +164,13 @@ public class PasteKeyFrameAction extends SelectionAction {
                                                                pointTime, null));\r
                     } else {\r
                         AnimatorKeyframe newKeyframe =\r
-                                selector.createKeyframe(keyframe.getName(), pointTime);\r
+                                selector.createKeyframe(appManager.getAnimatorModelManager().getModelFactory(), \r
+                                               keyframe.getName(), pointTime);\r
                         List<AnimatorFrame> frames = new ArrayList<AnimatorFrame>();\r
                         for (AnimatorModel modelFrame : keyframe.getChildren()) {\r
                             AnimatorFrame frame = (AnimatorFrame) modelFrame;\r
-                            AnimatorFrame clonedFrame = frame.cloneAnimatorFrame();\r
+                            AnimatorFrame clonedFrame = frame.cloneAnimatorFrame(\r
+                                       appManager.getAnimatorModelManager().getModelFactory());\r
                             clonedFrame.setParent(newKeyframe);\r
                             frames.add(clonedFrame);\r
                         }\r
@@ -188,7 +190,7 @@ public class PasteKeyFrameAction extends SelectionAction {
                                                                                  .getProperties(),\r
                                                                          AnimatorModelEvent.Origin.TIMELINE));\r
                 }\r
-            }\r
+            }
         }\r
 \r
         if (!command.isEmpty()) {\r
index 8f7dcab..d9d05fd 100644 (file)
@@ -120,7 +120,7 @@ public class TimelineFrameCreateCommand extends Command {
                        }
                        
                        if(currentFrame == null) {
-                               currentFrame = currentSelector.createOrGetAnimatorFrame(currentTime); 
+                               currentFrame = currentSelector.createOrGetAnimatorFrame(animatorModelManager.getModelFactory(), currentTime); 
                        }
                        
                        //if there is a exist frame at the same current time currentFrame is null
@@ -130,7 +130,7 @@ public class TimelineFrameCreateCommand extends Command {
                                if (!currentSelector.isExistKeyframe(keyframe)) {// case 1
                                        currentSelector.addChild(keyframe);
                                } else {// case 2
-                                       currentFrame.findAnimatedPropertyAndSetInFrame((AnimatorFrame) keyframe.getPrevChild(currentFrame),
+                                       currentFrame.findAnimatedPropertyAndSetInFrame(animatorModelManager.getModelFactory(), (AnimatorFrame) keyframe.getPrevChild(currentFrame),
                                                        (AnimatorFrame) keyframe.getNextChild(currentFrame));
                                } 
                                if(!isExist) {
index 0c34423..5c3742c 100644 (file)
@@ -23,6 +23,7 @@
 
 package org.tizen.webuibuilder.animator.ui.views.timeline.command;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.gef.commands.Command;
@@ -46,8 +47,11 @@ public class TimelineKeyframeEditCommand extends Command {
     private double afterDuration = 0.0;
     
     private AnimatorSelector currentSelector = null;
+    private AnimatorSelector oldSelector = null;
     private List<String> names = null;
     private AnimatorKeyframe keyframe = null;
+    private boolean isMerged = false;
+    private List<AnimatorKeyframe> removedKeyframes = null;
 
     /**
      * Construct
@@ -57,7 +61,7 @@ public class TimelineKeyframeEditCommand extends Command {
      * @param start
      *            start Time
      * @param duration
-     *            duratio Time
+     *            duration Time
      */
     public TimelineKeyframeEditCommand(AnimatorKeyframe keyframe, double start, double duration) {
         this.beforeStart = keyframe.getDelay();
@@ -67,6 +71,7 @@ public class TimelineKeyframeEditCommand extends Command {
         this.keyframe = keyframe;
         this.currentSelector = (AnimatorSelector)keyframe.getParent();
         this.names = currentSelector.getAnimatorKeyframeNames();
+        this.removedKeyframes = new ArrayList<AnimatorKeyframe>();
     }
 
     /*
@@ -109,6 +114,8 @@ public class TimelineKeyframeEditCommand extends Command {
        
        AnimatorModelManager animatorModelManager = AnimatorUtils.getAppManager().getAnimatorModelManager();
        
+       keyframe = currentSelector.getAnimatorKeyframeById(keyframe.getId());
+               
        keyframe.setDelay(afterStart);
        
        if (beforeDuration != afterDuration) {
@@ -121,13 +128,17 @@ public class TimelineKeyframeEditCommand extends Command {
 
        currentSelector.removeChild(keyframe);
        currentSelector.addChild(keyframe);
-
        currentSelector.updateSelectorTime();
-//     if(!currentSelector.mergeOrSplitKeyframe()) {
-//             
-               animatorModelManager.fireEvent(true, currentSelector,
-                               AnimatorModelEvent.EventType.KEYFRAME_EDIT, AnimatorModelEvent.Origin.TIMELINE, keyframe);
-//     }
+       
+       if(oldSelector == null) {
+               oldSelector = currentSelector.cloneAnimatorSelector(animatorModelManager.getModelFactory());
+       }
+       
+       isMerged = currentSelector.mergeOrSplitKeyframe(animatorModelManager.getModelFactory(), removedKeyframes);
+       
+       animatorModelManager.fireEvent(true, currentSelector,
+                       AnimatorModelEvent.EventType.KEYFRAME_EDIT, AnimatorModelEvent.Origin.TIMELINE, keyframe);
+       
     }
 
     /*
@@ -154,9 +165,14 @@ public class TimelineKeyframeEditCommand extends Command {
 //     animatorModelManager.fireEvent(true, currentSelector,
 //                     AnimatorModelEvent.EventType.SELECTOR_REFRESH, AnimatorModelEvent.Origin.TIMELINE, currentSelector);
        
-       
        AnimatorModelManager animatorModelManager = AnimatorUtils.getAppManager().getAnimatorModelManager();
-               
+       
+       if(isMerged) {
+               currentSelector.rearrangementByAnimatorSelector(animatorModelManager, oldSelector, removedKeyframes);
+       }
+       
+       keyframe = currentSelector.getAnimatorKeyframeById(keyframe.getId());
+       
        keyframe.setDelay(beforeStart);
        
        if (beforeDuration != afterDuration) {
@@ -170,12 +186,10 @@ public class TimelineKeyframeEditCommand extends Command {
        currentSelector.removeChild(keyframe);
        currentSelector.addChild(keyframe);
        
-
        currentSelector.updateSelectorTime();
-//     if(!currentSelector.mergeOrSplitKeyframe()) {
-               animatorModelManager.fireEvent(true, currentSelector,
-                               AnimatorModelEvent.EventType.KEYFRAME_EDIT, AnimatorModelEvent.Origin.TIMELINE, keyframe);
-//     }
                currentSelector.setKeyframeNames(names);
+               
+               animatorModelManager.fireEvent(true, currentSelector,
+                               AnimatorModelEvent.EventType.KEYFRAME_EDIT, AnimatorModelEvent.Origin.TIMELINE, keyframe);
     }
 }
\ No newline at end of file
index 1af974d..92be261 100644 (file)
@@ -154,7 +154,8 @@ public class CreatePartCommand extends Command {
             
             if (animatorWidgetList.size() == 0) {
                 animatorWidgetList =
-                        ((AnimatorPagePart)child.getOwnerPage()).createAnimatorWidgetsForAllAnimations(child);
+                        ((AnimatorPagePart)child.getOwnerPage()).createAnimatorWidgetsForAllAnimations(
+                                       AnimatorUtils.getAppManager().getAnimatorModelManager().getModelFactory(), child);
             }
 
             ((AnimatorPagePart)child.getOwnerPage()).addAnimatorWidgets(animatorWidgetList, Origin.EDITOR);
index b33ed5f..ee7f331 100644 (file)
@@ -166,7 +166,8 @@ public class PastePartCommand extends Command {
 
         if (animatorWidgetGroup.size() == 0)
             animatorWidgetGroup =
-                       ((AnimatorPagePart)parentPart.getOwnerPage()).createAnimatorWidgetsForAllAnimations(clonedParts);
+                       ((AnimatorPagePart)parentPart.getOwnerPage()).createAnimatorWidgetsForAllAnimations(
+                                       AnimatorUtils.getAppManager().getAnimatorModelManager().getModelFactory(),clonedParts);
 
         ((AnimatorPagePart)parentPart.getOwnerPage()).addAnimatorWidgets(animatorWidgetGroup, Origin.EDITOR);
     }
index 9104f55..34ef1ff 100644 (file)
@@ -312,7 +312,7 @@ public class PageDesignerForHTML extends PageDesigner implements ITextEditorList
             }
         }
 
-        setRootPart(appManager.getPageDataSet().getBaseRootPart());
+       
 
         GraphicalViewer viewer = getGraphicalViewer();
         // viewer.setContents(appManager.getRootPart(currentPageIndex));
@@ -322,8 +322,10 @@ public class PageDesignerForHTML extends PageDesigner implements ITextEditorList
         ((HoverBrowserViewer) viewer).getRootEditPart().refresh();
 
         AnimatorModelManager manager = appManager.getAnimatorModelManager();
-        manager.updateAnimatorModel(getRootPart());
-        manager.setPagePart((AnimatorPagePart) getRootPart().getChildren().get(0));
+        manager.updateAnimatorModel(appManager.getPageDataSet().getBaseRootPart(), getRootPart());
+        manager.setPagePart((AnimatorPagePart) appManager.getPageDataSet().getBaseRootPart().getChildren().get(0));
+        
+        setRootPart(appManager.getPageDataSet().getBaseRootPart());
 
         AnimatorBrowserViewer animatorViewer = getAnimatorViewer();
         if (animatorViewer != null) {
index 15067ce..b87dce1 100644 (file)
@@ -259,7 +259,8 @@ public class CssStyleAnimationEventDelegater implements IValueChangeListener, IC
         if (animatorSelector == null) {
             return null;
         }
-        List<AnimatorFrame> frameList = animatorSelector.getMergedFrames();
+        List<AnimatorFrame> frameList = animatorSelector.getMergedFrames(
+                       AnimatorUtils.getAppManager().getAnimatorModelManager().getModelFactory());
         double delayTime = animatorSelector.getDelay();
         /* search current time */
         double currentTime = AnimatorUtils.getActiveAnimatorBrowserViewer().getPointTime();