From d37bbafac2e0d0ae36544e58c9586c26ef3ba03b Mon Sep 17 00:00:00 2001 From: daxzel Date: Wed, 3 Jul 2013 16:05:47 +0400 Subject: [PATCH] Fixed animator error. ChangeTo AnimateProxy --- pom.xml | 37 ++++- src/org/vaadin/notifique/Notifique.java | 134 ++++++++++-------- .../sample/NotifiqueSampleApplicationUI.java | 2 + .../widgetset/NotifiqueWidgetset.gwt.xml | 6 +- 4 files changed, 110 insertions(+), 69 deletions(-) diff --git a/pom.xml b/pom.xml index 48f1296..9cbd161 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,8 @@ UTF-8 - 7.1.0 + 7.1.0.h.M0 + 7.1.0 ${vaadin.version} 1.7 @@ -56,14 +57,14 @@ com.vaadin - vaadin-client + vaadin-themes ${vaadin.version} - provided com.vaadin - vaadin-themes + vaadin-client ${vaadin.version} + provided org.vaadin.addons @@ -105,6 +106,20 @@ + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + verify + + jar-no-fork + + + + maven-clean-plugin 2.4.1 @@ -119,7 +134,7 @@ com.vaadin vaadin-maven-plugin - ${vaadin.plugin.version} + ${plugin.vaadin.version} -Xmx512M -Xss1024k ${basedir}/WebContent/VAADIN/widgetsets @@ -145,6 +160,18 @@ + + org.mortbay.jetty + maven-jetty-plugin + + ${basedir}/WebContent + + + ${basedir}/WebContent + + + + diff --git a/src/org/vaadin/notifique/Notifique.java b/src/org/vaadin/notifique/Notifique.java index d342c9a..dc1115a 100644 --- a/src/org/vaadin/notifique/Notifique.java +++ b/src/org/vaadin/notifique/Notifique.java @@ -5,8 +5,6 @@ import java.util.List; import java.util.Map; -import org.vaadin.jouni.animator.Animator; - import com.vaadin.event.LayoutEvents.LayoutClickEvent; import com.vaadin.event.LayoutEvents.LayoutClickListener; import com.vaadin.server.Resource; @@ -21,6 +19,8 @@ import com.vaadin.ui.Panel; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.themes.Reindeer; +import org.vaadin.jouni.animator.AnimatorProxy; +import org.vaadin.jouni.animator.shared.AnimType; public class Notifique extends CustomComponent { @@ -77,22 +77,25 @@ public interface HideListener extends Serializable { private Panel root; private CssLayout css; - private List items = new LinkedList(); + private List items = new LinkedList(); private boolean autoScroll; private int visibleCount = 5; private boolean fillFromTop = false; private HideListener hideListener; private ClickListener clickListener; + private AnimatorProxy ap; public class Message implements Serializable { private static final long serialVersionUID = 5892777954593320723L; private Component component; - private MessageAnimator animation; + private CssLayout animatedContent; private boolean visible; private Object data; private void show() { - animation.rollDown(); + ap.animate(animatedContent, AnimType.ROLL_DOWN_OPEN).setDuration(200) + .setDelay(0); + visible = true; } @@ -100,7 +103,8 @@ public void hide() { if (!isVisible()) { return; } - animation.rollUp(); + ap.animate(animatedContent, AnimType.ROLL_UP_CLOSE_REMOVE).setDuration(200) + .setDelay(0); visible = false; if (getHideListener() != null) { getHideListener().messageHide(this); @@ -130,41 +134,51 @@ public Notifique getNotifique() { } /** - * Custom animator extension allowing us to react on hide events coming from - * client-side. - * - * We use this to actually remove the components from layout after they have - * been animated away. - * - * @author Sami Ekblad - * - */ - public class MessageAnimator extends Animator { - private static final long serialVersionUID = 1L; - - @Override - public void changeVariables(Object source, Map variables) { - boolean wasHidden = isRolledUp(); - super.changeVariables(source, variables); - if (!wasHidden && isRolledUp()) { - removeAfterHide(this); - } else if (!isRolledUp() && !fillFromTop) { - root.setScrollTop(10000); - root.requestRepaint(); // TODO - } - } - - public MessageAnimator(Component toAnimate) { - super(toAnimate); - setWidth("100%"); - } - } +// * Custom animator extension allowing us to react on hide events coming from +// * client-side. +// * +// * We use this to actually remove the components from layout after they have +// * been animated away. +// * +// * @author Sami Ekblad +// * +// */ +// public class MessageAnimator extends Animator { +// private static final long serialVersionUID = 1L; +// +// @Override +// public void changeVariables(Object source, Map variables) { +// boolean wasHidden = isRolledUp(); +// super.changeVariables(source, variables); +// if (!wasHidden && isRolledUp()) { +// removeAfterHide(this); +// } else if (!isRolledUp() && !fillFromTop) { +// root.setScrollTop(10000); +// root.requestRepaint(); // TODO +// } +// } +// +// public MessageAnimator(Component toAnimate) { +// super(toAnimate); +// setWidth("100%"); +// } +// } public Notifique(boolean autoScroll) { + ap = new AnimatorProxy(); css = new CssLayout(); root = new Panel(css); root.setStyleName(Reindeer.PANEL_LIGHT); css.setWidth("100%"); + css.addComponent(ap); + ap.addListener(new AnimatorProxy.AnimationListener() { + @Override + public void onAnimation(AnimatorProxy.AnimationEvent animationEvent) { + if (animationEvent.getAnimation().getType().equals(AnimType.ROLL_LEFT_CLOSE_REMOVE)) { + items.remove(animationEvent.getComponent()); + } + } + }); root.addStyleName(STYLE_QUEUE); root.getContent().setStyleName(STYLE_QUEUE); setCompositionRoot(root); @@ -181,10 +195,10 @@ protected void publish(Message m) { if (fillFromTop) { items.add(0, m); ((CssLayout) root.getContent()) - .addComponentAsFirst(m.animation); + .addComponentAsFirst(m.animatedContent); } else { items.add(m); - css.addComponent(m.animation); + css.addComponent(m.animatedContent); } m.show(); if (autoScroll && items.size() > getVisibleCount()) { @@ -196,27 +210,27 @@ protected void publish(Message m) { } } - /** - * Remove the item after it has been hidden. - * - * @param toBeRemoved - */ - private void removeAfterHide(MessageAnimator toBeRemoved) { - synchronized (items) { - Message removed = null; - for (Message m : items) { - if (m.animation.equals(toBeRemoved)) { - removed = m; - break; - } - } - - if (removed != null) { - css.removeComponent(removed.animation); - items.remove(removed); - } - } - } +// /** +// * Remove the item after it has been hidden. +// * +// * @param toBeRemoved +// */ +// private void removeAfterHide(MessageAnimator toBeRemoved) { +// synchronized (items) { +// Message removed = null; +// for (Message m : items) { +// if (m.animatedContent.equals(toBeRemoved)) { +// removed = m; +// break; +// } +// } +// +// if (removed != null) { +// css.removeComponent(removed.animatedContent); +// items.remove(removed); +// } +// } +// } /** * Create a new item into the queue. It is not visible until added with @@ -239,10 +253,8 @@ protected Message createMessage(final Component component, String style) { css.addComponent(component); // Wrap component into an animator - final MessageAnimator anim = new MessageAnimator(css); m.component = component; - m.animation = anim; - anim.setImmediate(true); + m.animatedContent = css; return m; } diff --git a/src/org/vaadin/notifique/sample/NotifiqueSampleApplicationUI.java b/src/org/vaadin/notifique/sample/NotifiqueSampleApplicationUI.java index fa90d31..360257c 100644 --- a/src/org/vaadin/notifique/sample/NotifiqueSampleApplicationUI.java +++ b/src/org/vaadin/notifique/sample/NotifiqueSampleApplicationUI.java @@ -2,6 +2,7 @@ import java.util.Date; +import com.vaadin.annotations.Theme; import com.vaadin.server.VaadinRequest; import org.vaadin.notifique.Notifique; import org.vaadin.notifique.Notifique.ClickListener; @@ -15,6 +16,7 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Button.ClickEvent; +@Theme("reindeer") public class NotifiqueSampleApplicationUI extends UI implements ClickListener, HideListener { diff --git a/src/org/vaadin/notifique/widgetset/NotifiqueWidgetset.gwt.xml b/src/org/vaadin/notifique/widgetset/NotifiqueWidgetset.gwt.xml index 09a9e60..9a6ec67 100644 --- a/src/org/vaadin/notifique/widgetset/NotifiqueWidgetset.gwt.xml +++ b/src/org/vaadin/notifique/widgetset/NotifiqueWidgetset.gwt.xml @@ -17,10 +17,10 @@ Firefox 2 and safari is used for webkit based browsers including Google Chrome. --> - - + - + +