This will check for duplicate animationgroup names.
Change-Id: I93ebacae639d4d8872b421fd23e79155a0516e09
Signed-off-by: jinwooim.bae <jinwooim.bae@samsung.com>
return animation;
}
+
+ public AnimatorAnimation getAnimationByName(String animationName) {
+ AnimatorAnimation animation = null;
+ for (AnimatorAnimation currentAnimation : getAnimations()) {
+ String currentAnimationName = currentAnimation.getName();
+ if (currentAnimationName.equals(animationName)) {
+ animation = currentAnimation;
+ break;
+ }
+ }
+
+ return animation;
+ }
public AnimatorAnimation createAnimatorAnimation(AnimatorModelFactory modelFactory) {
AnimatorAnimation animationGroup = (AnimatorAnimation)modelFactory.createAnimatorModel(AnimatorModelType.ANIMATION);
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;
+import org.tizen.webuibuilder.animator.model.AnimatorAnimation;
+import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
/**
private boolean isRepeated = false;
private boolean isAutoPlay = false;
+ private TimelineOutlineHeader outlineHeader = null;
/**
* Construct
*
* @param style
* SWT Composite style
*/
- public AnimationGroupCreateDialog(Shell parent, int style) {
+ public AnimationGroupCreateDialog(Shell parent, TimelineOutlineHeader outlineHeader, int style) {
super(parent, style);
setText("Create animation group");
+ this.outlineHeader = outlineHeader;
}
/**
animationGroupName.setTextLimit(31);
animationGroupName.setMessage("Under 32 characters.");
animationGroupName
- .setToolTipText("Under 32 Characters, and check pattern, [^A-Za-z0-9\\.\\@_\\-~#\\s]+");
+ .setToolTipText("Under 32 Characters, and check pattern, [^A-Za-z0-9//_//-]+");
animationGroupName.addListener(SWT.Verify, new Listener() {
public void handleEvent(Event e) {
String animationGroupName = e.text;
- Pattern pattern = Pattern.compile("[^A-Za-z0-9\\.\\@_\\-~#\\s]+");
+ Pattern pattern = Pattern.compile("[^A-Za-z0-9//_//-]+");
Matcher matcher = pattern.matcher(animationGroupName);
boolean find = matcher.find();
if (find) {
public void mouseUp(MouseEvent e) {
String newAnimationGroupName = animationGroupName.getText();
- result =
- new AnimationGroupDialogResult(animationIterationSpinner.getSelection(),
- isRepeated, isAutoPlay,
- newAnimationGroupName);
-
- shell.dispose();
+ if (newAnimationGroupName == null || newAnimationGroupName.length() == 0) {
+ AnimatorGroupToolTip toolTip =
+ new AnimatorGroupToolTip(shell, animationGroupName);
+ toolTip.showErrorToolTip("Insert Name");
+ } else {
+ AnimatorPagePart pagePart =
+ outlineHeader.getTimelineMainContainer().getPage().getPagePart();
+ AnimatorAnimation animation =
+ pagePart.getAnimationByName(newAnimationGroupName);
+ if (animation != null) {
+ AnimatorGroupToolTip toolTip =
+ new AnimatorGroupToolTip(shell, animationGroupName);
+ toolTip.showErrorToolTip("Duplicate Name");
+ } else {
+ result =
+ new AnimationGroupDialogResult(animationIterationSpinner
+ .getSelection(), isRepeated, isAutoPlay,
+ newAnimationGroupName);
+ shell.dispose();
+ }
+ }
}
@Override
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolTip;
import org.tizen.webuibuilder.animator.model.AnimatorAnimation;
+import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
/**
private AnimatorAnimation animation = null;
private boolean isDirty = false;
+ private TimelineOutlineHeader outlineHeader = null;
/**
* Construct
*
* @param animation
* {@link AnimatorAnimation}
*/
- public AnimationGroupEditDialog(Shell parent, int style, AnimatorAnimation animation) {
+ public AnimationGroupEditDialog(Shell parent, TimelineOutlineHeader outlineHeader, int style,
+ AnimatorAnimation animation) {
super(parent, style);
this.animation = animation;
+ this.outlineHeader = outlineHeader;
setText("Show and edit animation group");
}
animationGroupName.setTextLimit(32);
animationGroupName.setMessage("Under 32 characters.");
animationGroupName
- .setToolTipText("Under 32 Characters, and check pattern, [^A-Za-z0-9\\.\\@_\\-~#\\s]+");
+ .setToolTipText("Under 32 Characters, and check pattern, [^A-Za-z0-9\\_\\-]+");
animationGroupName.setText(animation.getName());
animationGroupName.addListener(SWT.Verify, new Listener() {
public void handleEvent(Event e) {
String animationGroupName = e.text;
- Pattern pattern = Pattern.compile("[^A-Za-z0-9\\.\\@_\\-~#\\s]+");
+ Pattern pattern = Pattern.compile("[^A-Za-z0-9\\_\\-]+");
Matcher matcher = pattern.matcher(animationGroupName);
boolean find = matcher.find();
if (find) {
createAnimationButton.addMouseListener(new MouseListener() {
@Override
public void mouseUp(MouseEvent e) {
- if (!animation.getName().equals(animationGroupName.getText())) {
- isDirty = true;
- }
-
- if (animation.getIteration() != animationIterationSpinner.getSelection()) {
- isDirty = true;
- }
- if (animation.isRepeated() != isRepeated) {
- isDirty = true;
- }
+ String newAnimationGroupName = animationGroupName.getText();
- if (animation.isJustPlay() != isAutoPlay) {
- isDirty = true;
- }
-
- if (isDirty) {
- result =
- new AnimationGroupDialogResult(
- animationIterationSpinner.getSelection(),
- isRepeated, isAutoPlay,
- animationGroupName.getText());
+ if (newAnimationGroupName == null || newAnimationGroupName.length() == 0) {
+ AnimatorGroupToolTip toolTip =
+ new AnimatorGroupToolTip(shell, animationGroupName);
+ toolTip.showErrorToolTip("Insert Name");
} else {
- result = null;
+ AnimatorPagePart pagePart =
+ outlineHeader.getTimelineMainContainer().getPage().getPagePart();
+ AnimatorAnimation findAnimation =
+ pagePart.getAnimationByName(newAnimationGroupName);
+ if (findAnimation != null) {
+ AnimatorGroupToolTip toolTip =
+ new AnimatorGroupToolTip(shell, animationGroupName);
+ toolTip.showErrorToolTip("Duplicate Name");
+ } else {
+
+ if (!animation.getName().equals(animationGroupName.getText())) {
+ isDirty = true;
+ }
+
+ if (animation.getIteration() != animationIterationSpinner.getSelection()) {
+ isDirty = true;
+ }
+
+ if (animation.isRepeated() != isRepeated) {
+ isDirty = true;
+ }
+
+ if (animation.isJustPlay() != isAutoPlay) {
+ isDirty = true;
+ }
+
+ if (isDirty) {
+ result =
+ new AnimationGroupDialogResult(animationIterationSpinner
+ .getSelection(), isRepeated, isAutoPlay,
+ animationGroupName.getText());
+ } else {
+ result = null;
+ }
+ shell.dispose();
+ }
}
- shell.dispose();
}
@Override
--- /dev/null
+\r
+\r
+package org.tizen.webuibuilder.animator.ui.views.timeline.header;\r
+\r
+import java.util.Timer;\r
+import java.util.TimerTask;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.FocusEvent;\r
+import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.swt.widgets.ToolTip;\r
+\r
+\r
+public class AnimatorGroupToolTip {\r
+\r
+ private ToolTip tooltip = null;\r
+ private Shell shell = null;\r
+ private Control control = null;\r
+\r
+ public AnimatorGroupToolTip(Shell shell, Control control) {\r
+ this.shell = shell;\r
+ this.control = control;\r
+ }\r
+\r
+ /**\r
+ * Show Error ToolTip\r
+ * \r
+ * @param text\r
+ */\r
+ public void showErrorToolTip(String text) {\r
+ hideErrorTooltip();\r
+ tooltip = new ToolTip(shell, SWT.ICON_WARNING | SWT.BALLOON);\r
+ tooltip.setText(text);\r
+\r
+ Point location = control.toDisplay(control.getSize().x, control.getSize().y);\r
+\r
+ tooltip.setLocation(location.x - control.getSize().x + control.getBorderWidth(), location.y\r
+ - control.getBorderWidth());\r
+ tooltip.setVisible(true);\r
+\r
+ control.addFocusListener(new FocusListener() {\r
+\r
+ @Override\r
+ public void focusLost(FocusEvent e) {\r
+ if (tooltip != null) {\r
+ Timer timer = new Timer();\r
+ TimerTask timerTask = new TimerTask() {\r
+ @Override\r
+ public void run() {\r
+ Display.getDefault().asyncExec(new Runnable() {\r
+\r
+ @Override\r
+ public void run() {\r
+ hideErrorTooltip();\r
+ }\r
+ });\r
+ }\r
+ };\r
+\r
+ timer.schedule(timerTask, 300);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void focusGained(FocusEvent e) {\r
+ // Do nothing\r
+ }\r
+ });\r
+ }\r
+\r
+ /**\r
+ * Hides error message on the control \r
+ */\r
+ public void hideErrorTooltip() {\r
+ if (tooltip != null && !tooltip.isDisposed()) {\r
+ tooltip.setVisible(false);\r
+ tooltip.dispose();\r
+ tooltip = null;\r
+ }\r
+ }\r
+}\r
for (int i = 0; i < animations.size(); i++) {
final MenuItem aniGroupItem = new MenuItem(animationGroupMenu, SWT.CHECK);
final AnimatorAnimation animatorAnimation = animations.get(i);
- aniGroupItem.setText(animatorAnimation.getName() + getId(animatorAnimation));
+ aniGroupItem.setText(animatorAnimation.getName());
aniGroupItem.setData("id", animatorAnimation.getId());
if (selectedAnimationGroupId != null
if (size != 0) {
selectedAnimationGroupId = animations.get(0).getId();
- animationGroupLabel.setText(animations.get(0).getName() + getId(animations.get(0)));
+ animationGroupLabel.setText(animations.get(0).getName());
animationGroupLabel.setData("id", animations.get(0).getId());
} else {
animationGroupLabel.setText("NONE");
}
/**
- * Get AnimationGroupId
- *
- * @param animationGroup {@link AnimatorAnimation}
- * @return
- */
- private String getId(AnimatorAnimation animationGroup) {
- String id = " ( ID : " + animationGroup.getId() + " )";
- return id;
- }
-
- /**
* Clear Tree in Timeline
*/
public void clearTree() {
* Add Animation Group
*/
public void addAnimationGroup() {
+
AnimationGroupCreateDialog createDialog =
- new AnimationGroupCreateDialog(getShell(), SWT.NONE);
+ new AnimationGroupCreateDialog(getShell(), this, SWT.NONE);
AnimationGroupDialogResult result = (AnimationGroupDialogResult) createDialog.open();
if (result != null) {
return;
}
+
AnimationGroupEditDialog editDialog =
- new AnimationGroupEditDialog(getShell(), SWT.NONE, editAnimation);
+ new AnimationGroupEditDialog(getShell(), this, SWT.NONE, editAnimation);
AnimationGroupDialogResult result = (AnimationGroupDialogResult) editDialog.open();
if (result != null) {
AnimatorPagePart pagePart = getTimelineMainContainer().getPage().getPagePart();
}
}
- private TimelineMainContainer getTimelineMainContainer() {
+ public TimelineMainContainer getTimelineMainContainer() {
return (TimelineMainContainer) getParent().getParent().getParent().getParent();
}
String animationId = animation.getId();
setSelectedAnimationGroupId(animationId);
- animationGroupLabel.setText(animationName + getId(animation));
+ animationGroupLabel.setText(animationName);
getAnimationGroupLabel().setData("id", animationId);
animationGroupLabel.setToolTipText(animationName);
animationGroupLabel.pack();
String animationName = animation.getName();
String animationId = animation.getId();
- animationGroupLabel.setText(animationName + getId(animation));
+ animationGroupLabel.setText(animationName);
getAnimationGroupLabel().setData("id", animationId);
animationGroupLabel.setToolTipText(animationName);
animationGroupLabel.pack();