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;
private TimelineMainContainer mainContainer = null;
private TimelinePage timelinePage;
+ private AnimatorModelEventAdapter animatorModelEventAdapter;
+
/**
* Construct
*/
} else if (widget instanceof Tree) {
// select page
selectTreeItem(null, false);
-
+
}
}
}
/**
* 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;
+ }
+ });
}
/**********************************************************************************************
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());
+ }
+ }
+
}