ANIMATOR : Modify Filter 13/20913/1
authorjinwooim.bae <jinwooim.bae@samsung.com>
Wed, 14 May 2014 01:13:28 +0000 (10:13 +0900)
committerjinwooim.bae <jinwooim.bae@samsung.com>
Wed, 14 May 2014 01:13:28 +0000 (10:13 +0900)
The timelineview is refreshed if click filter button or other action.

Change-Id: I2391d5848a145c85d4ce68366811d311f2fc1556
Signed-off-by: jinwooim.bae <jinwooim.bae@samsung.com>
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/TimelineContentContainer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/TimelinePage.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/header/TimelineOutlineHeader.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/tool/TimelineContentToolsContainer.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/tool/TimelineToolbar.java

index 6a7e288..f853e24 100644 (file)
@@ -287,16 +287,8 @@ public class TimelineContentContainer extends Composite {
             @Override
             public void widgetSelected(SelectionEvent e) {
                 boolean isFilter = contentToolsContainer.isFilter();
-
-                if (isFilter == true) {
-                    contentToolsContainer.setFilter(false);
-                } else {
-                    contentToolsContainer.setFilter(true);
-                }
-
-                viewer.setContents(viewer.getPage().getModel());
-                viewer.filter(isFilter);
-                viewer.refreshTimelineViewer();
+                contentToolsContainer.setFilter(!isFilter);
+                viewer.refreshClickedFilter();
             }
 
             @Override
index 5e06c1a..e4d6ad3 100644 (file)
@@ -40,7 +40,6 @@ import org.eclipse.ui.actions.ActionFactory;
 import org.eclipse.ui.part.IPageSite;
 import org.tizen.webuibuilder.animator.gef.viewer.AnimatorBrowserViewer;
 import org.tizen.webuibuilder.animator.model.AnimatorAnimation;
-import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
 import org.tizen.webuibuilder.animator.model.descriptor.AnimatorDescriptorManager;
 import org.tizen.webuibuilder.animator.model.descriptor.CssAnimationDescriptor;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
@@ -226,6 +225,7 @@ public class TimelinePage extends ContentOutlinePage {
         viewer.setEditPartFactory(new TimelineEditPartFactory(viewer, timelineActionRegistry));
         viewer.setMainContainer(getMainContainer());
         viewer.setPage(this);
+        viewer.addModelListener();
         selectionSync.addViewer(getViewer());
 
         viewer.refreshTimelineViewer();
@@ -344,7 +344,8 @@ public class TimelinePage extends ContentOutlinePage {
                         .getOutlineHeader().initialize();
                 // refresh h-scroll
                 getMainContainer().getContentContainer().refreshHScroll(0.0, 0, 0, 0);
-
+                // refresh filter
+                getMainContainer().getContentContainer().getContentToolsContainer().setFilter(false);
                 if (animatorBrowserViwer != null && viewer != null) {
                     viewer.refreshTimelineViewer();
                     viewer.setContents(model);
index b65881e..bfbee98 100644 (file)
@@ -41,24 +41,26 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.TreeEditor;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Tree;
 import org.eclipse.swt.widgets.TreeColumn;
 import org.eclipse.swt.widgets.TreeItem;
 import org.eclipse.swt.widgets.Widget;
+import org.tizen.webuibuilder.animator.model.AnimatorFrame;
+import org.tizen.webuibuilder.animator.model.AnimatorKeyframe;
 import org.tizen.webuibuilder.animator.model.AnimatorModel;
-import org.tizen.webuibuilder.animator.model.AnimatorModelManager;
+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.AnimatorPagePart;
+import org.tizen.webuibuilder.animator.model.part.AnimatorPart;
 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.KeyFrameComponent;
-import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
 import org.tizen.webuibuilder.model.Part;
-import org.tizen.webuibuilder.model.app.AppManager;
 import org.tizen.webuibuilder.utility.Platform;
 
 
@@ -81,6 +83,8 @@ public class TimelineViewer extends TreeViewer implements ISelectionChangedListe
     private TimelineMainContainer mainContainer = null;
     private TimelinePage timelinePage;
 
+    private AnimatorModelEventAdapter animatorModelEventAdapter;
+
     /**
      * Construct
      */
@@ -234,7 +238,7 @@ public class TimelineViewer extends TreeViewer implements ISelectionChangedListe
                 } else if (widget instanceof Tree) {
                     // select page
                     selectTreeItem(null, false);
-  
+
                 }
             }
         }
@@ -472,30 +476,121 @@ public class TimelineViewer extends TreeViewer implements ISelectionChangedListe
     /**
      * Filter
      * 
-     * @param isFilter
-     */
-    public void filter(boolean isFilter) {
-        if (isFilter == true) {
-            RootEditPart rootEditPart = getRootEditPart();
-            List children = rootEditPart.getChildren();
-            if (children != null) {
-                List<TimelineEditPart> editParts = ((EditPart) children.get(0)).getChildren();
-                for (int i = 0; i < editParts.size(); ++i) {
-                    AnimatorWidget model = (AnimatorWidget) editParts.get(i).getModel();
-                    List<AnimatorModel> selectorModel = model.getChildren();
-                    for(int j = 0; j < selectorModel.size(); ++j) {
-                        int size = selectorModel.get(j).getChildrenSize();
-                        if (size <= 0) {
-                            TimelineEditPart childEditpart =
-                                    (TimelineEditPart) editParts.get(i).getParent();
-                            childEditpart.removeChild(editParts.get(i));
-                            --i;
-                        }
+     */
+    public void filter() {
+
+        RootEditPart rootEditPart = getRootEditPart();
+        List children = rootEditPart.getChildren();
+        if (children != null) {
+            List<TimelineEditPart> editParts = ((EditPart) children.get(0)).getChildren();
+            for (int i = 0; i < editParts.size(); ++i) {
+                AnimatorWidget model = (AnimatorWidget) editParts.get(i).getModel();
+                List<AnimatorModel> selectorModel = model.getChildren();
+                for (int j = 0; j < selectorModel.size(); ++j) {
+                    int size = selectorModel.get(j).getChildrenSize();
+                    if (size <= 0) {
+                        TimelineEditPart parentEditpart =
+                                (TimelineEditPart) editParts.get(i).getParent();
+                        parentEditpart.removeChild(editParts.get(i));
+                        --i;
                     }
                 }
             }
+            Tree contentTree = (Tree) getControl();
+            contentTree.pack();
         }
+    }
+
+    /**
+     * Add RootPartlListener
+     */
+    public void addModelListener() {
+        Part rootPart = getPage().getRootPart();
+        animatorModelEventAdapter = new AnimatorModelEventAdapter();
+        ((AnimatorPart) rootPart).addAnimatorModelListener(animatorModelEventAdapter);
+
+    }
+
+    /**
+     * Refresh Clicked Filter
+     */
+    public void refreshClickedFilter() {
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                boolean isFilter =
+                        getMainContainer().getContentContainer().getContentToolsContainer()
+                                .isFilter();
+                if (isFilter == true) {
+                    filter();
+                } else {
+                    setContents(getPage().getModel());
+                    refreshTimelineViewer();
+                }
+            }
+        });
+    }
+
+    /**
+     * Refresh Event Filter
+     * 
+     * @param isAdd
+     *            Add event call
+     * @param model
+     *            Event Model
+     */
+    public void refreshEventFilter(final boolean isAdd, final AnimatorModel model) {
+        Display.getDefault().asyncExec(new Runnable() {
+            @Override
+            public void run() {
+                boolean isFilter =
+                        getMainContainer().getContentContainer().getContentToolsContainer()
+                                .isFilter();
+                if (isFilter == true) {
+                    if (isAdd == true) {
+                        boolean isExist = findModelInTree(model);
+                        if (isExist == false) {
+                            setContents(getPage().getModel());
+                            filter();
+                            refreshTimelineViewer();
+                        }
+                    } else {
+                        filter();
+                    }
+                } else {
+                    // do nothing
+                }
+            }
+
+            private boolean findModelInTree(AnimatorModel model) {
 
+                AnimatorModel parentModel = null;
+                if (model instanceof AnimatorKeyframe) {
+                    parentModel = model.getParent();
+                } else if (model instanceof AnimatorFrame) {
+                    parentModel = model.getParent().getParent();
+                } else {
+                    return false;
+                }
+
+                RootEditPart rootEditPart = getRootEditPart();
+
+                List children = rootEditPart.getChildren();
+                if (children != null) {
+                    List<TimelineEditPart> editParts = ((EditPart) children.get(0)).getChildren();
+                    for (int i = 0; i < editParts.size(); ++i) {
+                        AnimatorWidget widgetModel = (AnimatorWidget) editParts.get(i).getModel();
+                        List<AnimatorModel> selectorModel = widgetModel.getChildren();
+                        for (int j = 0; j < selectorModel.size(); ++j) {
+                            if (selectorModel.get(j).getId().equals(parentModel.getId())) {
+                                return true;
+                            }
+                        }
+                    }
+                }
+                return false;
+            }
+        });
     }
 
     /**********************************************************************************************
@@ -672,4 +767,42 @@ public class TimelineViewer extends TreeViewer implements ISelectionChangedListe
     public void setLastSelectedKeyframeComponent(KeyFrameComponent lastSelectedKeyframeComponent) {
         this.lastSelectedKeyframeComponent = lastSelectedKeyframeComponent;
     }
+
+    /*****************************************************************************************
+     * Listener , Event
+     *****************************************************************************************/
+
+    private class AnimatorModelEventAdapter extends AnimatorModelListenerAdapter {
+
+        @Override
+        public void animationAdd(AnimatorModelEvent e) {
+            getMainContainer().getContentContainer().getContentToolsContainer().setFilter(false);
+        }
+
+        @Override
+        public void animationRemove(AnimatorModelEvent e) {
+            getMainContainer().getContentContainer().getContentToolsContainer().setFilter(false);
+        }
+
+        @Override
+        public void keyframeAdd(AnimatorModelEvent e) {
+            refreshEventFilter(true, e.getModel());
+        }
+
+        @Override
+        public void keyframeRemove(AnimatorModelEvent e) {
+            refreshEventFilter(false, e.getModel());
+        }
+
+        @Override
+        public void frameAdd(AnimatorModelEvent e) {
+            refreshEventFilter(true, e.getModel());
+        }
+
+        @Override
+        public void frameRemove(AnimatorModelEvent e) {
+            refreshEventFilter(false, e.getModel());
+        }
+    }
+
 }
index 0271aee..0eca333 100644 (file)
@@ -228,10 +228,13 @@ public class TimelineOutlineHeader extends Composite {
                                 animationGroup = pagePart.getAnimation(animationGroupId);
                             }
 
+                            //refresh tree viewer
                             TimelineViewer viewer = getTimelineMainContainer().getViewer();
                             viewer.setContents(animationGroup);
                             viewer.refreshTimelineViewer();
-
+                            //refresh filter
+                            getTimelineMainContainer().getContentContainer().getContentToolsContainer().setFilter(false);
+                            
                             setTime2Zero();
                         }
                     });
index 4b16129..96019c8 100644 (file)
@@ -80,7 +80,7 @@ public class TimelineContentToolsContainer extends Composite {
         this.setData("CompositeName", "contentToolsContainer");
 
         //button
-        filter = new Button(this, SWT.TOGGLE);
+        filter = new Button(this, SWT.NONE);
         filter.setData("name", "filter");
         filter.setText("filter");
         FormData filterFormData = new FormData();
@@ -242,20 +242,35 @@ public class TimelineContentToolsContainer extends Composite {
         this.hScroll = hScroll;
     }
 
+    /**
+     * Get Filter Button
+     * @return
+     */
     public Button getFilter() {
         return filter;
     }
 
+    /**
+     * Set Filter Button
+     * @param filter
+     */
     public void setFilter(Button filter) {
         this.filter = filter;
     }
 
+    /**
+     * Check Filter flag
+     * @return
+     */
     public boolean isFilter() {
         return isFilter;
     }
 
+    /**
+     * Set Filter flag
+     * @param isFilter
+     */
     public void setFilter(boolean isFilter) {
         this.isFilter = isFilter;
     }
-
 }
index ba42bd3..0401057 100644 (file)
@@ -66,7 +66,6 @@ import org.tizen.webuibuilder.animator.model.AnimatorFrame;
 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.AnimatorSelector;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
 import org.tizen.webuibuilder.animator.model.part.AnimatorPart;