ANIMATOR : Modify Z-order keyframe 88/21188/1
authorjinwooim.bae <jinwooim.bae@samsung.com>
Fri, 16 May 2014 04:52:02 +0000 (13:52 +0900)
committerjinwooim.bae <jinwooim.bae@samsung.com>
Fri, 16 May 2014 04:52:02 +0000 (13:52 +0900)
Show z-order MenuItem When you click timelineElement that has same time
keyframeUnits

Change-Id: Ib9a3218a191b66365e49a67313591bc7465ad04a
Signed-off-by: jinwooim.bae <jinwooim.bae@samsung.com>
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/TimelineContextMenu.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/TimelineViewer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/action/ZOrderKeyFrameAction.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/common/TimelineMessages.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/common/TimelineMessages.properties
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/tree/TimeTreeElement.java

index b996a66..255b105 100644 (file)
@@ -15,7 +15,9 @@ import org.eclipse.jface.action.Separator;
 import org.eclipse.ui.actions.ActionFactory;\r
 import org.tizen.webuibuilder.animator.model.descriptor.AnimatorDescriptorManager;\r
 import org.tizen.webuibuilder.animator.model.descriptor.CssAnimationDescriptor;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.action.ZOrderKeyFrameAction;\r
 import org.tizen.webuibuilder.animator.ui.views.timeline.common.TimelineMessages;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrameUnit;\r
 import org.tizen.webuibuilder.animator.utils.AnimatorUtils;\r
 import org.tizen.webuibuilder.model.app.AppManager;\r
 import org.tizen.webuibuilder.ui.contextmenu.ContextMenu;\r
@@ -58,6 +60,10 @@ public class TimelineContextMenu extends ContextMenu {
 \r
         action = getAction(TimelineMessages.PASTE_KEYFRAME);\r
         menu.appendToGroup(GEFActionConstants.GROUP_COPY, action);\r
+\r
+        MenuManager zorder = buildContextZorderMenu();\r
+        menu.appendToGroup(GEFActionConstants.GROUP_REST, zorder);\r
+\r
     }\r
 \r
     private MenuManager buildContextPredefineMenu() {\r
@@ -104,4 +110,21 @@ public class TimelineContextMenu extends ContextMenu {
 \r
         return addPKeyframes;\r
     }\r
+\r
+    private MenuManager buildContextZorderMenu() {\r
+        MenuManager zOderMenu = new MenuManager(TimelineMessages.Z_ORDER, TimelineMessages.Z_ORDER);\r
+\r
+        TimelineViewer treeViewer = (TimelineViewer) getViewer();\r
+        List<KeyFrameUnit> findStackKeyframeUnits = treeViewer.findStackKeyframeUnit();\r
+\r
+        if (findStackKeyframeUnits != null && findStackKeyframeUnits.size() > 1) {\r
+\r
+            for (final KeyFrameUnit keyFrameUnit : findStackKeyframeUnits) {\r
+                IAction action = new ZOrderKeyFrameAction(keyFrameUnit, getViewer());\r
+                zOderMenu.add(action);\r
+            }\r
+        }\r
+\r
+        return zOderMenu;\r
+    }\r
 }\r
index f9852c7..bc4a63b 100644 (file)
 package org.tizen.webuibuilder.animator.ui.views.timeline;
 
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.eclipse.gef.EditPart;
 import org.eclipse.gef.RootEditPart;
 import org.eclipse.gef.editparts.RootTreeEditPart;
 import org.eclipse.gef.ui.parts.TreeViewer;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.layout.TreeColumnLayout;
 import org.eclipse.jface.viewers.ColumnPixelData;
 import org.eclipse.jface.viewers.ColumnWeightData;
@@ -55,11 +58,14 @@ import org.tizen.webuibuilder.animator.model.AnimatorModelEvent;
 import org.tizen.webuibuilder.animator.model.AnimatorModelListenerAdapter;
 import org.tizen.webuibuilder.animator.model.AnimatorWidget;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPart;
+import org.tizen.webuibuilder.animator.ui.views.timeline.action.ZOrderKeyFrameAction;
 import org.tizen.webuibuilder.animator.ui.views.timeline.common.TimelineConstants;
 import org.tizen.webuibuilder.animator.ui.views.timeline.editpart.TimelineEditPart;
 import org.tizen.webuibuilder.animator.ui.views.timeline.tree.TimeTreeElement;
 import org.tizen.webuibuilder.animator.ui.views.timeline.tree.TimelineOutlineElement;
+import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrame;
 import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrameComponent;
+import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrameUnit;
 import org.tizen.webuibuilder.model.Part;
 import org.tizen.webuibuilder.utility.Platform;
 
@@ -495,7 +501,7 @@ public class TimelineViewer extends TreeViewer implements ISelectionChangedListe
                     }
                 }
             }
-            
+
             refreshTree();
             refreshContextMenu();
         }
@@ -513,37 +519,37 @@ public class TimelineViewer extends TreeViewer implements ISelectionChangedListe
      * Refresh ContextMenu
      */
     private void refreshContextMenu() {
-      //refresh contextMenu
+        // refresh contextMenu
 
         this.getControl().setMenu(getContextMenu().createContextMenu(this.getControl()));
 
-      RootEditPart rootEditPart = getRootEditPart();
-      List children = rootEditPart.getChildren();
-      if (children != null) {
-          List<TimelineEditPart> editParts = ((EditPart) children.get(0)).getChildren();
-          for (TimelineEditPart editPart : editParts) {
-              List<TimelineEditPart> childEditParts = editPart.getChildren();
-              for(TimelineEditPart treeEditPart : childEditParts) {
-                  TimeTreeElement treeElement = treeEditPart.getTimeElement();
-                  if(treeElement != null) {
-                      treeElement.createContextMenu();
-                  }
-              }
-          }
-      }
+        RootEditPart rootEditPart = getRootEditPart();
+        List children = rootEditPart.getChildren();
+        if (children != null) {
+            List<TimelineEditPart> editParts = ((EditPart) children.get(0)).getChildren();
+            for (TimelineEditPart editPart : editParts) {
+                List<TimelineEditPart> childEditParts = editPart.getChildren();
+                for (TimelineEditPart treeEditPart : childEditParts) {
+                    TimeTreeElement treeElement = treeEditPart.getTimeElement();
+                    if (treeElement != null) {
+                        treeElement.createContextMenu();
+                    }
+                }
+            }
+        }
     }
 
     /**
      * applyNonFilter
      */
     private void applyNonFilter() {
-        //setContents(getPage().getModel());
+        // setContents(getPage().getModel());
         TimelineEditPart pageEditPart = getPageEditPart();
         pageEditPart.refresh();
 
         Tree contentTree = (Tree) getControl();
         contentTree.pack();
-        //refreshTimelineViewer();
+        // refreshTimelineViewer();
     }
 
     /**
@@ -664,6 +670,33 @@ public class TimelineViewer extends TreeViewer implements ISelectionChangedListe
         });
     }
 
+    /**
+     * Find KeyFrameUnit in Stack for z-ordering
+     * 
+     * @return {@link KeyFrameUnit}
+     */
+    public List<KeyFrameUnit> findStackKeyframeUnit() {
+        List<KeyFrameUnit> keyFrameUnits = new ArrayList<KeyFrameUnit>();
+
+        KeyFrameComponent selectedkeyFrameComponent = getLastSelectedKeyframeComponent();
+
+        if (selectedkeyFrameComponent != null) {
+            KeyFrameUnit selectKeyFrameUnit = null;
+            if (selectedkeyFrameComponent instanceof KeyFrameUnit) {
+                selectKeyFrameUnit = (KeyFrameUnit) selectedkeyFrameComponent;
+            } else if (selectedkeyFrameComponent instanceof KeyFrame) {
+                selectKeyFrameUnit = ((KeyFrame) selectedkeyFrameComponent).getKeyFrameUnit();
+            }
+
+            if (selectKeyFrameUnit != null) {
+                TimeTreeElement timeTreeElement = selectKeyFrameUnit.getTimeTreeElement();
+                keyFrameUnits.add((KeyFrameUnit) selectKeyFrameUnit);
+                timeTreeElement.addKeyFrameUnit(selectKeyFrameUnit, keyFrameUnits);
+            }
+        }
+        return keyFrameUnits;
+    }
+
     /**********************************************************************************************
      * Getter, Setter
      **********************************************************************************************/
@@ -842,6 +875,7 @@ public class TimelineViewer extends TreeViewer implements ISelectionChangedListe
     private TimelineEditPart getPageEditPart() {
         return (TimelineEditPart) getRootEditPart().getChildren().get(0);
     }
+
     /*****************************************************************************************
      * Listener , Event
      *****************************************************************************************/
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/action/ZOrderKeyFrameAction.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/action/ZOrderKeyFrameAction.java
new file mode 100644 (file)
index 0000000..ff3a685
--- /dev/null
@@ -0,0 +1,45 @@
+\r
+\r
+package org.tizen.webuibuilder.animator.ui.views.timeline.action;\r
+\r
+import org.eclipse.gef.EditPartViewer;\r
+import org.eclipse.jface.action.Action;\r
+import org.tizen.webuibuilder.animator.model.AnimatorModelEvent;\r
+import org.tizen.webuibuilder.animator.model.AnimatorModelManager;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineViewer;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.tree.TimeTreeElement;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrameUnit;\r
+import org.tizen.webuibuilder.animator.utils.AnimatorUtils;\r
+\r
+\r
+public class ZOrderKeyFrameAction extends Action {\r
+\r
+    private EditPartViewer editPartViewer = null;\r
+    private KeyFrameUnit keyFrameUnit = null;\r
+\r
+    public ZOrderKeyFrameAction(KeyFrameUnit keyFrameUnit, EditPartViewer editPartViewer) {\r
+        super(null);\r
+\r
+        this.keyFrameUnit = keyFrameUnit;\r
+        this.editPartViewer = editPartViewer;\r
+\r
+        setText(keyFrameUnit.getModel().getName());\r
+        setId(keyFrameUnit.getModel().getName());\r
+    }\r
+\r
+    public void run() {\r
+\r
+        if (keyFrameUnit != null) {\r
+            TimelineViewer viewer = (TimelineViewer) editPartViewer;\r
+            keyFrameUnit.selected();\r
+            viewer.setLastSelectedKeyframeComponent(keyFrameUnit);\r
+\r
+            TimeTreeElement timeTreeElement = keyFrameUnit.getTimeTreeElement();\r
+            timeTreeElement.redraw();\r
+\r
+            AnimatorModelManager manager = AnimatorUtils.getAppManager().getAnimatorModelManager();\r
+            manager.fireEvent(AnimatorModelEvent.EventType.SELECTION_CHANGE,\r
+                              AnimatorModelEvent.Origin.TIMELINE, keyFrameUnit.getModel());\r
+        }\r
+    }\r
+}\r
index 53a835e..0382b3e 100644 (file)
@@ -37,6 +37,8 @@ public class TimelineMessages {
     public static String CUT_KEYFRAME;
     public static String PASTE_KEYFRAME;
 
+    public static String Z_ORDER;
+    
     public static String NEW_ANIMATION_GROUP;
     public static String DELETE_ANIMATION_GROUP;
     public static String EDIT_ANIMATION_GROUP;
index daa2341..9c5de08 100644 (file)
@@ -7,6 +7,8 @@ COPY_KEYFRAME = &Copy\tCtrl+C
 CUT_KEYFRAME = &Cut\tCtrl+X
 PASTE_KEYFRAME = &Paste\tCtrl+V
 
+Z_ORDER = Bring to front
+
 NEW_ANIMATION_GROUP = New animation group
 DELETE_ANIMATION_GROUP = Delete animation group
 EDIT_ANIMATION_GROUP = Show and Edit animation group
index eb904de..d8f131a 100644 (file)
@@ -151,7 +151,6 @@ public class TimeTreeElement extends Canvas implements ISelectionProvider {
                          TimelineConstants.DEFAULT_TIMEELEMENT_ZOOMIN_HEIGHT);
     }
 
-
     @Override
     public void addSelectionChangedListener(ISelectionChangedListener listener) {
         // TODO Auto-generated method stub
@@ -180,7 +179,6 @@ public class TimeTreeElement extends Canvas implements ISelectionProvider {
 
     }
 
-    
     /*******************************************************************************
      * Class Method
      *******************************************************************************/
@@ -371,7 +369,7 @@ public class TimeTreeElement extends Canvas implements ISelectionProvider {
             if (keyframeUnit.getModel().getId().equals(keyframe.getId())) {
                 keyframeUnit.deleteChild(model);
                 int size = keyframeUnit.getKeyframelist().size();
-                if(size == 0) {
+                if (size == 0) {
                     keyframeUnits.remove(keyframeUnit);
                 }
                 break;
@@ -433,8 +431,7 @@ public class TimeTreeElement extends Canvas implements ISelectionProvider {
 
         // System.out.println("startTime " + startTime + " durationTime " + durationTime);
         Command animationPropertyChange =
-                new TimelineKeyframeEditCommand(keyframeUnit.getModel(), startTime,
-                                                durationTime);
+                new TimelineKeyframeEditCommand(keyframeUnit.getModel(), startTime, durationTime);
 
         viewer.getEditDomain().getCommandStack().execute(animationPropertyChange);
 
@@ -459,7 +456,37 @@ public class TimeTreeElement extends Canvas implements ISelectionProvider {
 
         TimelineViewer viewer = getEditpart().getViewer();
         viewer.getEditDomain().getCommandStack().execute(animationPropertyChange);
+    }
 
+    /**
+     * Add KeyFrameUnit in sameTime
+     * 
+     * @param selectKeyFrameUnit
+     *            {@link KeyFrameUnit}
+     * 
+     * @param keyFrameUnits
+     *            {@link KeyFrameUnit}
+     */
+    public void addKeyFrameUnit(KeyFrameUnit selectKeyFrameUnit, List<KeyFrameUnit> keyFrameUnits) {
+        double selectKeyFrameStart = selectKeyFrameUnit.getKeyframeUnitStartTime();
+        double selectKeyFrameDuration = selectKeyFrameUnit.getKeyframeUnitDurationTime();
+        List<KeyFrameUnit> childrenKeyframeWidget = getKeyframeUnits();
+        for (KeyFrameUnit childKeyframeWidget : childrenKeyframeWidget) {
+            if (!childKeyframeWidget.equals(selectKeyFrameUnit)) {
+
+                KeyFrameUnit currentKeyframeWidget = (KeyFrameUnit) childKeyframeWidget;
+                double currentKeyFrameStart = currentKeyframeWidget.getKeyframeUnitStartTime();
+                double currentKeyFrameDuration =
+                        currentKeyframeWidget.getKeyframeUnitDurationTime();
+
+                if (selectKeyFrameStart <= currentKeyFrameStart) {
+                    if (selectKeyFrameStart + selectKeyFrameDuration >= currentKeyFrameStart
+                            + currentKeyFrameDuration) {
+                        keyFrameUnits.add((KeyFrameUnit) childKeyframeWidget);
+                    }
+                }
+            }
+        }
     }
 
     /*******************************************************************************
@@ -1010,5 +1037,4 @@ public class TimeTreeElement extends Canvas implements ISelectionProvider {
             }
         }
     };
-
 }