This is copy, cut and paste fuction in timeline.
Change-Id: I456c525afdb615b432f5d65f8a9a2d58feae5ec3
Signed-off-by: jinwooim.bae <jinwooim.bae@samsung.com>
--- /dev/null
+\r
+\r
+package org.tizen.webuibuilder.animator.ui.views.timeline;\r
+\r
+import org.eclipse.gef.dnd.SimpleObjectTransfer;\r
+import org.eclipse.swt.dnd.Clipboard;\r
+import org.eclipse.swt.dnd.Transfer;\r
+import org.eclipse.swt.widgets.Display;\r
+\r
+\r
+/**\r
+ * This class is Clipboard in Timeline.\r
+ */\r
+public class TimelineClipboard {\r
+\r
+ private Clipboard clipboard = null;\r
+ private static final SimpleObjectTransfer timelineTransper = new SimpleObjectTransfer() {\r
+ private final String TYPE_NAME =\r
+ "org.tizen.webuibuilder.animator.ui.views.timeline.clipboard.transfer"; //$NON-NLS-1$\r
+ private final int TYPE_ID = registerType(TYPE_NAME);\r
+\r
+ protected int[] getTypeIds() {\r
+ return new int[] { TYPE_ID };\r
+ }\r
+\r
+ protected String[] getTypeNames() {\r
+ return new String[] { TYPE_NAME };\r
+ }\r
+ };\r
+\r
+ /**\r
+ * Construct\r
+ * \r
+ * @param display\r
+ * {@link Display}\r
+ */\r
+ public TimelineClipboard(Display display) {\r
+ clipboard = new Clipboard(display);\r
+ }\r
+\r
+ /**\r
+ * Get Clipboard\r
+ */\r
+ public Clipboard getClipboard() {\r
+ return clipboard;\r
+ }\r
+\r
+ /**\r
+ * Get Object\r
+ */\r
+ public Object getContents() {\r
+ org.eclipse.swt.dnd.Clipboard cb = new org.eclipse.swt.dnd.Clipboard(null);\r
+ Object contents = cb.getContents(timelineTransper);\r
+ cb.dispose();\r
+ return contents;\r
+ }\r
+\r
+ /**\r
+ * Set Contents\r
+ * \r
+ * @param contents\r
+ * {@link Object}\r
+ */\r
+ public void setContents(Object contents) {\r
+ org.eclipse.swt.dnd.Clipboard cb = new org.eclipse.swt.dnd.Clipboard(null);\r
+ cb.setContents(new Object[] { contents }, new Transfer[] { timelineTransper });\r
+ cb.dispose();\r
+ }\r
+\r
+}\r
import org.eclipse.gef.ui.parts.SelectionSynchronizer;
import org.eclipse.jface.action.IAction;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
private ActionRegistry actionRegistry = null;
private ActionRegistry timelineActionRegistry = null;
+ private TimelineClipboard clipboard = null;
+
/**
* Construct
*
public void init(IPageSite pageSite) {
super.init(pageSite);
+ clipboard = new TimelineClipboard(pageSite.getShell().getDisplay());
+
String id = ActionFactory.UNDO.getId();
timelineActionRegistry.registerAction(getActionRegistry().getAction(id));
*/
public void initPage() {
AppManager appManager = (AppManager) AnimatorUtils.getAppManager();
- if(appManager != null) {
+ if (appManager != null) {
AnimatorModelManager modelManager = appManager.getAnimatorModelManager();
- if(modelManager != null) {
- pagePart = (AnimatorPagePart) modelManager.getPagePart();
+ if (modelManager != null) {
+ pagePart = (AnimatorPagePart) modelManager.getPagePart();
}
}
refreshPage(pagePart);
this.actionRegistry = actionRegistry;
}
+ /**
+ * Get TimelineActionRegistry
+ *
+ * @return
+ */
public ActionRegistry getTimelineActionRegistry() {
return timelineActionRegistry;
}
+ /**
+ * Get Clipboard
+ *
+ * @return
+ */
+ public TimelineClipboard getClipboard() {
+ return clipboard;
+ }
}
import org.tizen.webuibuilder.animator.utils.AnimatorUtils;\r
\r
\r
+/**\r
+ * This class is Action for adding KeyFrame.\r
+ */\r
public class AddKeyFrameAction extends SelectionAction {\r
\r
EditPartViewer editPartViewer = null;\r
\r
+ /**\r
+ * Construct\r
+ * \r
+ * @param text\r
+ * {@link String}\r
+ * @param editPartViewer\r
+ * {@link EditPartViewer}\r
+ */\r
public AddKeyFrameAction(String text, EditPartViewer editPartViewer) {\r
super(null);\r
\r
this.editPartViewer = editPartViewer;\r
}\r
\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()\r
+ */\r
@Override\r
protected boolean calculateEnabled() {\r
if (editPartViewer == null) {\r
return true;\r
}\r
\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.eclipse.jface.action.Action#run()\r
+ */\r
@Override\r
public void run() {\r
TimelineViewer viewer = (TimelineViewer) editPartViewer;\r
import org.tizen.webuibuilder.utility.ResourceManager;\r
\r
\r
+/**\r
+ * This class is Action for adding predefined keyframe.\r
+ * \r
+ * @author jinwoo\r
+ * \r
+ */\r
public class AddPredefinedKeyFrameAction extends SelectionAction {\r
\r
private EditPartViewer editPartViewer = null;\r
private CssAnimationDescriptor cssAnimation = null;\r
\r
+ /**\r
+ * Construct\r
+ * \r
+ * @param cssAnimation\r
+ * {@link CssAnimationDescriptor}\r
+ * @param editPartViewer\r
+ * {@link EditPartViewer}\r
+ */\r
public AddPredefinedKeyFrameAction(final CssAnimationDescriptor cssAnimation,\r
EditPartViewer editPartViewer) {\r
super(null);\r
\r
}\r
\r
+ /**\r
+ * Set DisplayName\r
+ */\r
private void setDisplayName(String text) {\r
setText(text);\r
}\r
\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()\r
+ */\r
@Override\r
protected boolean calculateEnabled() {\r
if (editPartViewer == null) {\r
return true;\r
}\r
\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.eclipse.jface.action.Action#run()\r
+ */\r
@Override\r
public void run() {\r
TimelineViewer viewer = (TimelineViewer) editPartViewer;\r
Part partModel = model.getPartLink();\r
\r
String animationGroupId =\r
- viewer.getMainContainer().getContentContainer().getContentHeaderContainer()\r
- .getOutlineHeader().getSelectedAnimationGroupId();\r
- double pointTime =\r
- viewer.getMainContainer().getContentContainer().getContentHeaderContainer()\r
- .getKeyframeHeader().getTimeBar().getPlayHeader().getCurrentPointTime();\r
+ AnimatorUtils.getActiveAnimatorBrowserViewer().getCurrentAnimationGroupId();\r
+ double pointTime = AnimatorUtils.getActiveAnimatorBrowserViewer().getPointTime();\r
+\r
AppManager appManager = AnimatorUtils.getAppManager();\r
Command command =\r
new AnimationCreateCommand(animationGroupId, cssAnimation, appManager,\r
- AnimatorModelEvent.Origin.EDITOR, partModel,\r
+ AnimatorModelEvent.Origin.TIMELINE, partModel,\r
partModel.getUiSelector(), pointTime);\r
\r
viewer.getEditDomain().getCommandStack().execute(command);\r
\r
package org.tizen.webuibuilder.animator.ui.views.timeline.action;\r
\r
+import java.util.ArrayList;\r
import java.util.List;\r
\r
import org.eclipse.gef.EditPartViewer;\r
import org.eclipse.gef.ui.actions.SelectionAction;\r
import org.eclipse.ui.ISharedImages;\r
import org.eclipse.ui.PlatformUI;\r
+import org.tizen.webuibuilder.animator.model.AnimatorModel;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineClipboard;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.TimelinePage;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineViewer;\r
\r
\r
+/**\r
+ * This class is Action for coping KeyFrame.\r
+ */\r
public class CopyKeyFrameAction extends SelectionAction {\r
\r
private EditPartViewer editPartViewer = null;\r
\r
+ /**\r
+ * Construct\r
+ * \r
+ * @param text\r
+ * {@link String}\r
+ * @param editPartViewer\r
+ * {@link EditPartViewer}\r
+ */\r
public CopyKeyFrameAction(String text, EditPartViewer editPartViewer) {\r
super(null);\r
setId(text);\r
this.editPartViewer = editPartViewer;\r
}\r
\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()\r
+ */\r
@Override\r
protected boolean calculateEnabled() {\r
if (editPartViewer == null) {\r
return false;\r
}\r
-\r
List<Object> selectedList = getSelectedObjects();\r
int size = selectedList.size();\r
- if (size > 0) {\r
- return true;\r
+ if (size <= 0) {\r
+ return false;\r
+ }\r
+ TimelinePage page = ((TimelineViewer) editPartViewer).getPage();\r
+ TimelineClipboard clipboard = page.getClipboard();\r
+ if (clipboard == null) {\r
+ return false;\r
}\r
\r
- return false;\r
+ return true;\r
}\r
\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.eclipse.jface.action.Action#run()\r
+ */\r
@Override\r
public void run() {\r
\r
+ List<Object> selectedList = getSelectedObjects();\r
+\r
+ // Animator model clone\r
+ List<AnimatorModel> cloneModels = new ArrayList<AnimatorModel>();\r
+\r
+ //\r
+ TimelinePage page = ((TimelineViewer) editPartViewer).getPage();\r
+ TimelineClipboard clipboard = page.getClipboard();\r
+ clipboard.setContents(cloneModels);\r
+\r
}\r
\r
}\r
\r
package org.tizen.webuibuilder.animator.ui.views.timeline.action;\r
\r
+import java.util.ArrayList;\r
import java.util.List;\r
\r
import org.eclipse.gef.EditPartViewer;\r
import org.eclipse.gef.ui.actions.SelectionAction;\r
import org.eclipse.ui.ISharedImages;\r
import org.eclipse.ui.PlatformUI;\r
+import org.tizen.webuibuilder.animator.model.AnimatorModel;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineClipboard;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.TimelinePage;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineViewer;\r
\r
\r
+/**\r
+ * This class is Action for cutting KeyFrame.\r
+ */\r
public class CutKeyFrameAction extends SelectionAction {\r
\r
EditPartViewer editPartViewer = null;\r
\r
+ /**\r
+ * Construct\r
+ * \r
+ * @param text\r
+ * {@link String}\r
+ * @param editPartViewer\r
+ * {@link EditPartViewer}\r
+ */\r
public CutKeyFrameAction(String text, EditPartViewer editPartViewer) {\r
super(null);\r
setId(text);\r
this.editPartViewer = editPartViewer;\r
}\r
\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()\r
+ */\r
@Override\r
protected boolean calculateEnabled() {\r
if (editPartViewer == null) {\r
return false;\r
}\r
-\r
List<Object> selectedList = getSelectedObjects();\r
int size = selectedList.size();\r
- if (size > 0) {\r
- return true;\r
+ if (size <= 0) {\r
+ return false;\r
+ }\r
+ TimelinePage page = ((TimelineViewer) editPartViewer).getPage();\r
+ TimelineClipboard clipboard = page.getClipboard();\r
+ if (clipboard == null) {\r
+ return false;\r
}\r
\r
- return false;\r
+ return true;\r
}\r
\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.eclipse.jface.action.Action#run()\r
+ */\r
@Override\r
public void run() {\r
\r
+ List<Object> selectedList = getSelectedObjects();\r
+\r
+ // Animator model clone\r
+ List<AnimatorModel> cloneModels = new ArrayList<AnimatorModel>();\r
+\r
+ // delete realModels\r
+\r
+ TimelinePage page = ((TimelineViewer) editPartViewer).getPage();\r
+ TimelineClipboard clipboard = page.getClipboard();\r
+\r
+ clipboard.setContents(cloneModels);\r
+\r
}\r
\r
}\r
import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrameUnit;\r
\r
\r
+/**\r
+ * This class is Action for deleting KeyFrame.\r
+ */\r
public class DeleteKeyFrameAction extends SelectionAction {\r
\r
private EditPartViewer editPartViewer = null;\r
\r
+ /**\r
+ * Construct\r
+ * \r
+ * @param text\r
+ * {@link String}\r
+ * @param editPartViewer\r
+ * {@link EditPartViewer}\r
+ */\r
public DeleteKeyFrameAction(String text, EditPartViewer editPartViewer) {\r
super(null);\r
setId(text);\r
this.editPartViewer = editPartViewer;\r
}\r
\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()\r
+ */\r
@Override\r
protected boolean calculateEnabled() {\r
if (editPartViewer == null) {\r
return false;\r
}\r
\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.eclipse.jface.action.Action#run()\r
+ */\r
@Override\r
public void run() {\r
List<Object> selectedList = getSelectedObjects();\r
\r
package org.tizen.webuibuilder.animator.ui.views.timeline.action;\r
\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
import org.eclipse.gef.EditPartViewer;\r
import org.eclipse.gef.ui.actions.SelectionAction;\r
+import org.eclipse.swt.custom.TreeEditor;\r
+import org.eclipse.swt.widgets.TreeItem;\r
import org.eclipse.ui.ISharedImages;\r
import org.eclipse.ui.PlatformUI;\r
+import org.tizen.webuibuilder.animator.model.AnimatorModel;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineClipboard;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.TimelinePage;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineViewer;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.tree.TimelineOutlineElement;\r
\r
\r
+/**\r
+ * This class is Action for pasting KeyFrame.\r
+ */\r
public class PasteKeyFrameAction extends SelectionAction {\r
\r
private EditPartViewer editPartViewer = null;\r
\r
+ /**\r
+ * Construct\r
+ * \r
+ * @param text\r
+ * {@link String}\r
+ * @param editPartViewer\r
+ * {@link EditPartViewer}\r
+ */\r
public PasteKeyFrameAction(String text, EditPartViewer editPartViewer) {\r
super(null);\r
setId(text);\r
this.editPartViewer = editPartViewer;\r
}\r
\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()\r
+ */\r
@Override\r
protected boolean calculateEnabled() {\r
if (editPartViewer == null) {\r
return false;\r
}\r
\r
- /*\r
- * List<Object> selectedList = getSelectedObjects(); int size = selectedList.size(); if\r
- * (size > 0) { return true; }\r
- */\r
+ if (((TimelineViewer) editPartViewer).getLastSelectedTreeItem() == null) {\r
+ return false;\r
+ }\r
+\r
+ TimelinePage page = ((TimelineViewer) editPartViewer).getPage();\r
+ TimelineClipboard clipboard = page.getClipboard();\r
+ if (clipboard == null) {\r
+ return false;\r
+ }\r
+ Object contents = clipboard.getContents();\r
+ if (contents == null) {\r
+ return false;\r
+ }\r
+\r
+ List<AnimatorModel> parts = null;\r
+ if (!(contents instanceof List<?>)) {\r
+ return false;\r
+ } else {\r
+ parts = (List<AnimatorModel>) contents;\r
+ }\r
+\r
+ if (parts == null || parts.size() == 0) {\r
+ return false;\r
+ }\r
+\r
+ return true;\r
\r
- return false;\r
}\r
\r
+ /*\r
+ * (non-Javadoc)\r
+ * \r
+ * @see org.eclipse.jface.action.Action#run()\r
+ */\r
@Override\r
public void run() {\r
+ TimelineViewer viewer = (TimelineViewer) editPartViewer;\r
+ TimelinePage page = viewer.getPage();\r
+ TimelineClipboard clipboard = page.getClipboard();\r
+ Object contents = clipboard.getContents();\r
\r
- }\r
+ // clone models for paste\r
+ List<AnimatorModel> cloneModels = (List<AnimatorModel>) contents;\r
+\r
+ TreeItem treeItem = viewer.getLastSelectedTreeItem();\r
+ TreeEditor outlineEditor = (TreeEditor) treeItem.getData("OutlineTreeEditor");\r
+ TimelineOutlineElement outlineElement = (TimelineOutlineElement) outlineEditor.getEditor();\r
+\r
+ TreeItem parentItem = treeItem.getParentItem();\r
+\r
+ List<AnimatorModel> children = null; // selectors\r
+ if (parentItem == null) {\r
+ children = ((AnimatorModel) outlineElement.getModel()).getChildren();\r
+ } else {\r
+ children = new ArrayList<AnimatorModel>();\r
+ children.add((AnimatorModel) outlineElement.getModel());\r
+ }\r
\r
+ // Add KeyFrame or KeyFrame\r
+ // Predefined animation\r
+ // keyframe\r
+ // frame\r
+ /*\r
+ * Command command = new TimelineFrameCreateCommand(children, AnimatorUtils\r
+ * .getActiveAnimatorBrowserViewer().getPointTime());\r
+ * editPartViewer.getEditDomain().getCommandStack().execute(command);\r
+ */\r
+\r
+ /*\r
+ * viewer.getControl().getDisplay().syncExec(new Runnable() {\r
+ * \r
+ * @Override public void run() {\r
+ * viewer.setLastSelectedKeyframeComponent(lastSelectedKeyframeComponent);\r
+ * viewer.setLastSelectedTreeItem(lastSelectedTreeItem); } }); }\r
+ */\r
+\r
+ }\r
}\r