From 12bd65065f7e759e2e584e9d3bcae215365eb496 Mon Sep 17 00:00:00 2001 From: Aleksandr Pchelintcev Date: Fri, 11 Apr 2014 10:52:42 +0300 Subject: [PATCH] Removed MGWT dependency --- .../ui/contentapp/browser/BrowserSubApp.java | 5 +- magnolia-ui-vaadin-common-widgets/pom.xml | 18 +- .../gwt/user/client/impl/DOMImplMobileSafari.java | 135 +++++++ .../impl/DOMImplMozillaWithTransistions.java | 122 ++++++ .../client/impl/DOMImplSafariWithTransistion.java | 137 +++++++ .../mgwt/collection/GwtCollections.gwt.xml | 5 + .../mgwt/collection/client/JsLightArray.java | 86 ++++ .../collection/client/JsLightArrayBoolean.java | 88 ++++ .../collection/client/JsLightArrayInteger.java | 89 ++++ .../mgwt/collection/client/JsLightMap.java | 116 ++++++ .../mgwt/collection/shared/CollectionFactory.java | 76 ++++ .../mgwt/collection/shared/LightArray.java | 71 ++++ .../mgwt/collection/shared/LightArrayBoolean.java | 68 ++++ .../mgwt/collection/shared/LightArrayInt.java | 68 ++++ .../mgwt/collection/shared/LightMap.java | 70 ++++ .../collection/shared/java/JavaLightArray.java | 102 +++++ .../shared/java/JavaLightArrayBoolean.java | 77 ++++ .../collection/shared/java/JavaLightArrayInt.java | 76 ++++ .../mgwt/collection/shared/java/JavaLightMap.java | 74 ++++ .../main/java/com/googlecode/mgwt/dom/DOM.gwt.xml | 109 +++++ .../mgwt/dom/client/event/EventTypes.java | 7 + .../mgwt/dom/client/event/EventTypesDefault.java | 17 + .../mgwt/dom/client/event/MozEventTypes.java | 15 + .../mgwt/dom/client/event/SafariEventTypes.java | 14 + .../client/event/animation/AnimationEndEvent.java | 71 ++++ .../event/animation/AnimationEndHandler.java | 33 ++ .../event/animation/HasAnimationEndEvent.java | 35 ++ .../event/animation/HasTransitionEndEvent.java | 35 ++ .../client/event/animation/TransitionEndEvent.java | 68 ++++ .../event/animation/TransitionEndHandler.java | 33 ++ .../event/mouse/HandlerRegistrationCollection.java | 67 +++ .../event/mouse/MultiTouchMouseEmulator.java | 38 ++ .../client/event/mouse/SimulatedTouchEndEvent.java | 103 +++++ .../event/mouse/SimulatedTouchMoveEvent.java | 117 ++++++ .../event/mouse/SimulatedTouchStartEvent.java | 117 ++++++ .../event/mouse/TouchEndToMouseUpHandler.java | 54 +++ .../event/mouse/TouchMoveToMouseMoveHandler.java | 77 ++++ .../event/mouse/TouchStartToMouseDownHandler.java | 58 +++ .../orientation/HasOrientationChangeHandler.java | 34 ++ .../event/orientation/OrientationChangeEvent.java | 83 ++++ .../orientation/OrientationChangeHandler.java | 33 ++ .../mgwt/dom/client/event/tap/HasTapHandlers.java | 35 ++ .../googlecode/mgwt/dom/client/event/tap/Tap.java | 31 ++ .../mgwt/dom/client/event/tap/TapEvent.java | 99 +++++ .../mgwt/dom/client/event/tap/TapHandler.java | 28 ++ .../dom/client/event/touch/HasTouchHandlers.java | 88 ++++ .../mgwt/dom/client/event/touch/JavaTouch.java | 43 ++ .../mgwt/dom/client/event/touch/JsTouch.java | 51 +++ .../mgwt/dom/client/event/touch/Touch.java | 41 ++ .../dom/client/event/touch/TouchCancelEvent.java | 61 +++ .../dom/client/event/touch/TouchCancelHandler.java | 33 ++ .../mgwt/dom/client/event/touch/TouchEndEvent.java | 61 +++ .../dom/client/event/touch/TouchEndHandler.java | 33 ++ .../mgwt/dom/client/event/touch/TouchEvent.java | 92 +++++ .../mgwt/dom/client/event/touch/TouchHandler.java | 26 ++ .../dom/client/event/touch/TouchMoveEvent.java | 61 +++ .../dom/client/event/touch/TouchMoveHandler.java | 33 ++ .../dom/client/event/touch/TouchStartEvent.java | 61 +++ .../dom/client/event/touch/TouchStartHandler.java | 33 ++ .../mgwt/dom/client/event/touch/TouchUtil.java | 20 + .../dom/client/recognizer/EventPropagator.java | 35 ++ .../recognizer/EventPropagatorMobileImpl.java | 66 +++ .../recognizer/EventPropagatorStandardImpl.java | 39 ++ .../dom/client/recognizer/SystemTimeProvider.java | 31 ++ .../mgwt/dom/client/recognizer/TapRecognizer.java | 129 ++++++ .../mgwt/dom/client/recognizer/TimeProvider.java | 27 ++ .../recognizer/TimerExecturGwtTimerImpl.java | 50 +++ .../mgwt/dom/client/recognizer/TimerExecutor.java | 32 ++ .../recognizer/longtap/HasLongTapHandlers.java | 35 ++ .../client/recognizer/longtap/LongTapEvent.java | 108 +++++ .../client/recognizer/longtap/LongTapHandler.java | 33 ++ .../recognizer/longtap/LongTapRecognizer.java | 314 +++++++++++++++ .../client/recognizer/pinch/HasPinchHandlers.java | 34 ++ .../client/recognizer/pinch/OffsetProvider.java | 40 ++ .../dom/client/recognizer/pinch/PinchEvent.java | 107 +++++ .../dom/client/recognizer/pinch/PinchHandler.java | 35 ++ .../client/recognizer/pinch/PinchRecognizer.java | 211 ++++++++++ .../recognizer/pinch/UIObjectToOffsetProvider.java | 45 +++ .../client/recognizer/swipe/HasSwipeHandlers.java | 51 +++ .../dom/client/recognizer/swipe/SwipeEndEvent.java | 86 ++++ .../client/recognizer/swipe/SwipeEndHandler.java | 33 ++ .../dom/client/recognizer/swipe/SwipeEvent.java | 55 +++ .../client/recognizer/swipe/SwipeMoveEvent.java | 96 +++++ .../client/recognizer/swipe/SwipeMoveHandler.java | 33 ++ .../client/recognizer/swipe/SwipeRecognizer.java | 287 +++++++++++++ .../client/recognizer/swipe/SwipeStartEvent.java | 85 ++++ .../client/recognizer/swipe/SwipeStartHandler.java | 35 ++ .../dom/client/recognizer/tap/MultiTapEvent.java | 99 +++++ .../dom/client/recognizer/tap/MultiTapHandler.java | 33 ++ .../client/recognizer/tap/MultiTapRecognizer.java | 305 ++++++++++++++ .../main/java/com/googlecode/mgwt/ui/UI.gwt.xml | 34 ++ .../ui/client/util/NoopHandlerRegistration.java | 34 ++ .../widget/event/scroll/BeforeScrollEndEvent.java | 54 +++ .../widget/event/scroll/BeforeScrollMoveEvent.java | 55 +++ .../event/scroll/BeforeScrollStartEvent.java | 54 +++ .../event/scroll/ScrollAnimationEndEvent.java | 48 +++ .../event/scroll/ScrollAnimationMoveEvent.java | 48 +++ .../event/scroll/ScrollAnimationStartEvent.java | 48 +++ .../client/widget/event/scroll/ScrollEndEvent.java | 44 ++ .../widget/event/scroll/ScrollMoveEvent.java | 54 +++ .../widget/event/scroll/ScrollRefreshEvent.java | 44 ++ .../widget/event/scroll/ScrollStartEvent.java | 55 +++ .../widget/event/scroll/ScrollTouchEndEvent.java | 55 +++ .../ui/client/widget/touch/GestureUtility.java | 114 ++++++ .../mgwt/ui/client/widget/touch/TouchDelegate.java | 163 ++++++++ .../mgwt/ui/client/widget/touch/TouchPanel.java | 163 ++++++++ .../mgwt/ui/client/widget/touch/TouchWidget.java | 173 ++++++++ .../widget/touch/TouchWidgetDesktopImpl.java | 86 ++++ .../ui/client/widget/touch/TouchWidgetImpl.java | 69 ++++ .../client/widget/touch/TouchWidgetMobileImpl.java | 77 ++++ .../magnolia/ui/vaadin/gwt/CommonWidgetSet.gwt.xml | 42 +- .../actionbar/connector/ActionbarConnector.java | 4 +- .../layout/thumbnaillayout/widget/Slider.java | 14 +- .../vaadin/gwt/client/mgwt/SliderClientBundle.java | 3 +- .../gwt/client/touchwidget/VMgwtStylesUI.java | 448 --------------------- .../gwt/client/touchwidget/VMobileSafariUI.java | 2 +- .../info/magnolia/ui/vaadin/switcher/Switcher.java | 1 + .../ui/vaadin/gwt/MagnoliaWidgetSet.gwt.xml | 6 +- 118 files changed, 7706 insertions(+), 486 deletions(-) create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/google/gwt/user/client/impl/DOMImplMobileSafari.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/google/gwt/user/client/impl/DOMImplMozillaWithTransistions.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/google/gwt/user/client/impl/DOMImplSafariWithTransistion.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/GwtCollections.gwt.xml create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightArray.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightArrayBoolean.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightArrayInteger.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightMap.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/CollectionFactory.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightArray.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightArrayBoolean.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightArrayInt.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightMap.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightArray.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightArrayBoolean.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightArrayInt.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightMap.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/EventTypes.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/EventTypesDefault.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/MozEventTypes.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/SafariEventTypes.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/AnimationEndEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/AnimationEndHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/HasAnimationEndEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/HasTransitionEndEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/TransitionEndEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/TransitionEndHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/HandlerRegistrationCollection.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/MultiTouchMouseEmulator.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchEndEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchMoveEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchStartEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/TouchEndToMouseUpHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/TouchMoveToMouseMoveHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/TouchStartToMouseDownHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/orientation/HasOrientationChangeHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/orientation/OrientationChangeEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/orientation/OrientationChangeHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/HasTapHandlers.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/Tap.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/HasTouchHandlers.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/JavaTouch.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/JsTouch.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/Touch.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchCancelEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchCancelHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchEndEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchEndHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchMoveEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchMoveHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchStartEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchStartHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchUtil.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/EventPropagator.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/EventPropagatorMobileImpl.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/EventPropagatorStandardImpl.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/SystemTimeProvider.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TimeProvider.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TimerExecturGwtTimerImpl.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TimerExecutor.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/HasLongTapHandlers.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapRecognizer.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/HasPinchHandlers.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/OffsetProvider.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/PinchEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/PinchHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/PinchRecognizer.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/UIObjectToOffsetProvider.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/HasSwipeHandlers.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeEndEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeEndHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeMoveEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeMoveHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeRecognizer.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeStartEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeStartHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/tap/MultiTapEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/tap/MultiTapHandler.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/tap/MultiTapRecognizer.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/UI.gwt.xml create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/util/NoopHandlerRegistration.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/BeforeScrollEndEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/BeforeScrollMoveEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/BeforeScrollStartEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollAnimationEndEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollAnimationMoveEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollAnimationStartEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollEndEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollMoveEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollRefreshEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollStartEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollTouchEndEvent.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/GestureUtility.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchDelegate.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchPanel.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidget.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetDesktopImpl.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetImpl.java create mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetMobileImpl.java delete mode 100644 magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/touchwidget/VMgwtStylesUI.java diff --git a/magnolia-ui-contentapp/src/main/java/info/magnolia/ui/contentapp/browser/BrowserSubApp.java b/magnolia-ui-contentapp/src/main/java/info/magnolia/ui/contentapp/browser/BrowserSubApp.java index 5dec231..2213457 100644 --- a/magnolia-ui-contentapp/src/main/java/info/magnolia/ui/contentapp/browser/BrowserSubApp.java +++ b/magnolia-ui-contentapp/src/main/java/info/magnolia/ui/contentapp/browser/BrowserSubApp.java @@ -307,8 +307,9 @@ public class BrowserSubApp extends BaseSubApp { for (ActionbarItemDefinition itemDefinition : groupDefinition.getItems()) { String actionName = itemDefinition.getName(); - AvailabilityDefinition availability = actionExecutor.getActionDefinition(actionName).getAvailability(); - if (checker.isAvailable(availability, browser.getSelectedItemIds())) { + + ActionDefinition actionDefinition = actionExecutor.getActionDefinition(actionName); + if (actionDefinition != null && checker.isAvailable(actionDefinition.getAvailability(), browser.getSelectedItemIds())) { actionbar.enable(actionName); } else { actionbar.disable(actionName); diff --git a/magnolia-ui-vaadin-common-widgets/pom.xml b/magnolia-ui-vaadin-common-widgets/pom.xml index 7742669..24e34a8 100644 --- a/magnolia-ui-vaadin-common-widgets/pom.xml +++ b/magnolia-ui-vaadin-common-widgets/pom.xml @@ -35,6 +35,12 @@ vaadin-client provided + + + com.vaadin + vaadin-client-compiler + provided + com.vaadin vaadin-themes @@ -47,10 +53,10 @@ org.vaadin.addons aceeditor - - com.googlecode.mgwt - mgwt - + + + + org.vaadin.addons gwt-graphics @@ -103,7 +109,7 @@ src/main/java - com/ + com/vaadin com/vaadin/README.txt @@ -269,6 +275,8 @@ maven-checkstyle-plugin + com/googlecode/**, + com/google/**, com/vaadin/ui/**, com/vaadin/client/ui/**, org/vaadin/peter/contextmenu/** diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/google/gwt/user/client/impl/DOMImplMobileSafari.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/google/gwt/user/client/impl/DOMImplMobileSafari.java new file mode 100644 index 0000000..5a768e2 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/google/gwt/user/client/impl/DOMImplMobileSafari.java @@ -0,0 +1,135 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.user.client.impl; + +import com.google.gwt.user.client.Element; + +/** + *

DOMImplMobileSafari class.

+ * + * @author Daniel Kurka + * @version $Id: $ + */ +public class DOMImplMobileSafari extends DOMImplWebkit { + + /** + *

Constructor for DOMImplMobileSafari.

+ */ + public DOMImplMobileSafari() { + + } + protected native int eventGetTypeInt0(String eventType)/*-{ + switch (eventType) { + //added dom transistionend event + case "webkitTransitionEnd": return 0x8000000; + //added dom transistionend event + case "webkitAnimationEnd": return 0x10000000; + default: return -1; + } + }-*/; + + /** {@inheritDoc} */ + @Override + public int eventGetTypeInt(String eventType) { + int type = super.eventGetTypeInt(eventType); + if (type != -1) + return type; + return eventGetTypeInt0(eventType); + + } + + /** {@inheritDoc} */ + protected void sinkEventsImpl(Element elem, int bits) { + sinkEventsImpl0(elem, bits); + } + + protected native void sinkEventsImpl0(Element elem, int bits) /*-{ + var chMask = (elem.__eventBits || 0) ^ bits; + elem.__eventBits = bits; + if (!chMask) return; + + if (chMask & 0x00001) elem.onclick = (bits & 0x00001) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00002) elem.ondblclick = (bits & 0x00002) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00004) elem.onmousedown = (bits & 0x00004) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00008) elem.onmouseup = (bits & 0x00008) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00010) elem.onmouseover = (bits & 0x00010) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00020) elem.onmouseout = (bits & 0x00020) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00040) elem.onmousemove = (bits & 0x00040) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00080) elem.onkeydown = (bits & 0x00080) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00100) elem.onkeypress = (bits & 0x00100) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00200) elem.onkeyup = (bits & 0x00200) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00400) elem.onchange = (bits & 0x00400) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00800) elem.onfocus = (bits & 0x00800) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x01000) elem.onblur = (bits & 0x01000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x02000) elem.onlosecapture = (bits & 0x02000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x04000) elem.onscroll = (bits & 0x04000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x08000) elem.onload = (bits & 0x08000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchUnhandledEvent : null; + if (chMask & 0x10000) elem.onerror = (bits & 0x10000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x20000) elem.onmousewheel = (bits & 0x20000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x40000) elem.oncontextmenu = (bits & 0x40000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x80000) elem.onpaste = (bits & 0x80000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x100000) elem.ontouchstart = (bits & 0x100000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x200000) elem.ontouchmove = (bits & 0x200000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x400000) elem.ontouchend = (bits & 0x400000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x800000) elem.ontouchcancel= (bits & 0x800000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x1000000) elem.ongesturestart =(bits & 0x1000000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x2000000) elem.ongesturechange =(bits & 0x2000000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x4000000) elem.ongestureend = (bits & 0x4000000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + + //transistion end + if (chMask & 0x8000000) { + if(bits & 0x8000000){ + elem.addEventListener('webkitTransitionEnd', @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent, false); + } + } + + + //animation end + if (chMask & 0x10000000) { + if(bits & 0x10000000){ + elem.addEventListener('webkitAnimationEnd', @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent, false); + } + } + }-*/; + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/google/gwt/user/client/impl/DOMImplMozillaWithTransistions.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/google/gwt/user/client/impl/DOMImplMozillaWithTransistions.java new file mode 100644 index 0000000..d7f87b6 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/google/gwt/user/client/impl/DOMImplMozillaWithTransistions.java @@ -0,0 +1,122 @@ +package com.google.gwt.user.client.impl; + +import com.google.gwt.user.client.Element; + +public class DOMImplMozillaWithTransistions extends DOMImplMozilla{ + + /** + *

Constructor for DOMImplSafariWithTransistion.

+ */ + public DOMImplMozillaWithTransistions() { + + } + + + + + + + protected native int eventGetTypeInt0(String eventType)/*-{ + switch (eventType) { + //added dom transistionend event + case "transitionend": return 0x8000000; + //added dom transistionend event + case "animationend": return 0x10000000; + default: return -1; + } + }-*/; + + /** {@inheritDoc} */ + @Override + public int eventGetTypeInt(String eventType) { + int type = super.eventGetTypeInt(eventType); + if (type != -1) + return type; + return eventGetTypeInt0(eventType); + + } + + /** {@inheritDoc} */ + protected void sinkEventsImpl(Element elem, int bits) { + sinkEventsImpl0(elem, bits); + } + + protected native void sinkEventsImpl0(Element elem, int bits) /*-{ + var chMask = (elem.__eventBits || 0) ^ bits; + elem.__eventBits = bits; + if (!chMask) return; + + if (chMask & 0x00001) elem.onclick = (bits & 0x00001) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00002) elem.ondblclick = (bits & 0x00002) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00004) elem.onmousedown = (bits & 0x00004) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00008) elem.onmouseup = (bits & 0x00008) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00010) elem.onmouseover = (bits & 0x00010) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00020) elem.onmouseout = (bits & 0x00020) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00040) elem.onmousemove = (bits & 0x00040) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00080) elem.onkeydown = (bits & 0x00080) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00100) elem.onkeypress = (bits & 0x00100) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00200) elem.onkeyup = (bits & 0x00200) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00400) elem.onchange = (bits & 0x00400) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00800) elem.onfocus = (bits & 0x00800) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x01000) elem.onblur = (bits & 0x01000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x02000) elem.onlosecapture = (bits & 0x02000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x04000) elem.onscroll = (bits & 0x04000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x08000) elem.onload = (bits & 0x08000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchUnhandledEvent : null; + if (chMask & 0x10000) elem.onerror = (bits & 0x10000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x20000) elem.onmousewheel = (bits & 0x20000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x40000) elem.oncontextmenu = (bits & 0x40000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x80000) elem.onpaste = (bits & 0x80000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x100000) elem.ontouchstart = (bits & 0x100000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x200000) elem.ontouchmove = (bits & 0x200000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x400000) elem.ontouchend = (bits & 0x400000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x800000) elem.ontouchcancel= (bits & 0x800000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x1000000) elem.ongesturestart =(bits & 0x1000000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x2000000) elem.ongesturechange =(bits & 0x2000000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x4000000) elem.ongestureend = (bits & 0x4000000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + + //transistion end + if (chMask & 0x8000000) { + if(bits & 0x8000000){ + elem.addEventListener('transitionend', @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent, false); + } + } + + + //animation end + if (chMask & 0x10000000) { + if(bits & 0x10000000){ + elem.addEventListener('animationend', @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent, false); + } + } + }-*/; + + + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/google/gwt/user/client/impl/DOMImplSafariWithTransistion.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/google/gwt/user/client/impl/DOMImplSafariWithTransistion.java new file mode 100644 index 0000000..6d00110 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/google/gwt/user/client/impl/DOMImplSafariWithTransistion.java @@ -0,0 +1,137 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.user.client.impl; + +import com.google.gwt.user.client.Element; + +/** + *

DOMImplSafariWithTransistion class.

+ * + * @author Daniel Kurka + * @version $Id: $ + */ +public class DOMImplSafariWithTransistion extends DOMImplWebkit { + + /** + *

Constructor for DOMImplSafariWithTransistion.

+ */ + public DOMImplSafariWithTransistion() { + + } + + + protected native int eventGetTypeInt0(String eventType)/*-{ + switch (eventType) { + //added dom transistionend event + case "webkitTransitionEnd": return 0x8000000; + //added dom transistionend event + case "webkitAnimationEnd": return 0x10000000; + default: return -1; + } + }-*/; + + /** {@inheritDoc} */ + @Override + public int eventGetTypeInt(String eventType){ + int type = super.eventGetTypeInt(eventType); + if(type != -1) + return type; + return eventGetTypeInt0(eventType); + + } + + /** {@inheritDoc} */ + protected void sinkEventsImpl(Element elem, int bits){ + sinkEventsImpl0(elem, bits); + } + + protected native void sinkEventsImpl0(Element elem, int bits) /*-{ + var chMask = (elem.__eventBits || 0) ^ bits; + elem.__eventBits = bits; + if (!chMask) return; + + if (chMask & 0x00001) elem.onclick = (bits & 0x00001) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00002) elem.ondblclick = (bits & 0x00002) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00004) elem.onmousedown = (bits & 0x00004) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00008) elem.onmouseup = (bits & 0x00008) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00010) elem.onmouseover = (bits & 0x00010) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00020) elem.onmouseout = (bits & 0x00020) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00040) elem.onmousemove = (bits & 0x00040) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00080) elem.onkeydown = (bits & 0x00080) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00100) elem.onkeypress = (bits & 0x00100) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00200) elem.onkeyup = (bits & 0x00200) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00400) elem.onchange = (bits & 0x00400) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x00800) elem.onfocus = (bits & 0x00800) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x01000) elem.onblur = (bits & 0x01000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x02000) elem.onlosecapture = (bits & 0x02000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x04000) elem.onscroll = (bits & 0x04000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x08000) elem.onload = (bits & 0x08000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchUnhandledEvent : null; + if (chMask & 0x10000) elem.onerror = (bits & 0x10000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x20000) elem.onmousewheel = (bits & 0x20000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x40000) elem.oncontextmenu = (bits & 0x40000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x80000) elem.onpaste = (bits & 0x80000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x100000) elem.ontouchstart = (bits & 0x100000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x200000) elem.ontouchmove = (bits & 0x200000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x400000) elem.ontouchend = (bits & 0x400000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x800000) elem.ontouchcancel= (bits & 0x800000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x1000000) elem.ongesturestart =(bits & 0x1000000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x2000000) elem.ongesturechange =(bits & 0x2000000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + if (chMask & 0x4000000) elem.ongestureend = (bits & 0x4000000) ? + @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent : null; + + //transistion end + if (chMask & 0x8000000) { + if(bits & 0x8000000){ + elem.addEventListener('webkitTransitionEnd', @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent, false); + } + } + + + //animation end + if (chMask & 0x10000000) { + if(bits & 0x10000000){ + elem.addEventListener('webkitAnimationEnd', @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent, false); + } + } +}-*/; + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/GwtCollections.gwt.xml b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/GwtCollections.gwt.xml new file mode 100644 index 0000000..6f41de8 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/GwtCollections.gwt.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightArray.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightArray.java new file mode 100644 index 0000000..0ffb30a --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightArray.java @@ -0,0 +1,86 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.collection.client; + +import com.google.gwt.core.client.JavaScriptObject; +import com.googlecode.mgwt.collection.shared.LightArray; + +/** + * This is a the javascript implementation of {@link LightArray}, which makes direct use of native + * javascript arrays + * + * @author Daniel Kurka + * + * @param the Type of the object to put into the array + */ +public class JsLightArray implements LightArray { + + private JavaScriptObject array; + + /** + * Construct a {@link JsLightArray} + */ + public JsLightArray() { + this(JavaScriptObject.createArray()); + } + + /** + * Construct a {@link JsLightArray} with a given javascript array + * + * @param array the array to use + */ + public JsLightArray(JavaScriptObject array) { + this.array = array; + } + + @Override + public native T get(int index) /*-{ + return this.@com.googlecode.mgwt.collection.client.JsLightArray::array[index]; + }-*/; + + /** + * returns the underlying javascript array + * + * @return the javascript array + */ + public JavaScriptObject getArray() { + return array; + } + + @Override + public native int length()/*-{ + return this.@com.googlecode.mgwt.collection.client.JsLightArray::array.length; + }-*/; + + @Override + public native void push(T value)/*-{ + this.@com.googlecode.mgwt.collection.client.JsLightArray::array[this.@com.googlecode.mgwt.collection.client.JsLightArray::array.length] = value; + }-*/; + + @Override + public native void set(int index, T value) /*-{ + this.@com.googlecode.mgwt.collection.client.JsLightArray::array[index] = value; + }-*/; + + @Override + public native T shift() /*-{ + return this.@com.googlecode.mgwt.collection.client.JsLightArray::array.shift(); + }-*/; + + @Override + public native void unshift(T value)/*-{ + this.@com.googlecode.mgwt.collection.client.JsLightArray::array.unshift(value); + }-*/; + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightArrayBoolean.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightArrayBoolean.java new file mode 100644 index 0000000..f18b7a4 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightArrayBoolean.java @@ -0,0 +1,88 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.collection.client; + +import com.google.gwt.core.client.JavaScriptObject; +import com.googlecode.mgwt.collection.shared.LightArrayBoolean; + +/** + * An implementation of {@link LightArrayBoolean} that uses native javascript arrays + * + * @author Daniel Kurka + * + */ +public class JsLightArrayBoolean implements LightArrayBoolean { + + private JavaScriptObject array; + + /** + * Construct a {@link JsLightArrayBoolean} + */ + public JsLightArrayBoolean() { + this(JavaScriptObject.createArray()); + } + + /** + * Construct a {@link JsLightArrayBoolean} with a given javascript array + * + * @param array the javascript array to use + */ + public JsLightArrayBoolean(JavaScriptObject array) { + this.array = array; + } + + @Override + public native void push(boolean value)/*-{ + this.@com.googlecode.mgwt.collection.client.JsLightArrayBoolean::array[this.@com.googlecode.mgwt.collection.client.JsLightArrayBoolean::array.length] = value; + }-*/; + + @Override + public native boolean shift() /*-{ + return this.@com.googlecode.mgwt.collection.client.JsLightArrayBoolean::array + .shift(); + }-*/; + + @Override + public native boolean get(int index) /*-{ + return this.@com.googlecode.mgwt.collection.client.JsLightArrayBoolean::array[index]; + }-*/; + + @Override + public native void set(int index, boolean value) /*-{ + this.@com.googlecode.mgwt.collection.client.JsLightArrayBoolean::array[index] = value; + }-*/; + + @Override + public native int length()/*-{ + return this.@com.googlecode.mgwt.collection.client.JsLightArrayBoolean::array.length; + }-*/; + + @Override + public native void unshift(boolean value)/*-{ + this.@com.googlecode.mgwt.collection.client.JsLightArrayBoolean::array + .unshift(value); + }-*/; + + /** + * get the underlying javascript array + * + * @return the javascript array + */ + public JavaScriptObject getArray() { + return array; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightArrayInteger.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightArrayInteger.java new file mode 100644 index 0000000..6e793c9 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightArrayInteger.java @@ -0,0 +1,89 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.collection.client; + +import com.google.gwt.core.client.JavaScriptObject; +import com.googlecode.mgwt.collection.shared.LightArrayInt; + +/** + * An implementation of {@link LightArrayInt} that uses native javascript arrays + * + * @author Daniel Kurka + * + */ +public class JsLightArrayInteger implements LightArrayInt { + + private JavaScriptObject array; + + /** + * Construct a {@link JsLightArrayInteger} + */ + public JsLightArrayInteger() { + this(JavaScriptObject.createArray()); + } + + /** + * Construct a {@link JsLightArrayInteger} with a given javascript array + * + * @param array the array to use + * + */ + public JsLightArrayInteger(JavaScriptObject array) { + this.array = array; + } + + @Override + public native void push(int value)/*-{ + this.@com.googlecode.mgwt.collection.client.JsLightArrayInteger::array[this.@com.googlecode.mgwt.collection.client.JsLightArrayInteger::array.length] = value; + }-*/; + + @Override + public native int shift() /*-{ + return this.@com.googlecode.mgwt.collection.client.JsLightArrayInteger::array + .shift(); + }-*/; + + @Override + public native int get(int index) /*-{ + return this.@com.googlecode.mgwt.collection.client.JsLightArrayInteger::array[index]; + }-*/; + + @Override + public native void set(int index, int value) /*-{ + this.@com.googlecode.mgwt.collection.client.JsLightArrayInteger::array[index] = value; + }-*/; + + @Override + public native int length()/*-{ + return this.@com.googlecode.mgwt.collection.client.JsLightArrayInteger::array.length; + }-*/; + + @Override + public native void unshift(int value)/*-{ + this.@com.googlecode.mgwt.collection.client.JsLightArrayInteger::array + .unshift(value); + }-*/; + + /** + * get the underlying javascript array + * + * @return the underlying javascript array + */ + public JavaScriptObject getArray() { + return array; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightMap.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightMap.java new file mode 100644 index 0000000..cd38377 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/client/JsLightMap.java @@ -0,0 +1,116 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.collection.client; + +import com.google.gwt.core.client.JavaScriptObject; +import com.googlecode.mgwt.collection.shared.LightArray; +import com.googlecode.mgwt.collection.shared.LightMap; + +/** + * An implementation of {@link LightMap} that uses native javascript objects as dictionaries + * + * @author Daniel Kurka + * + * @param the tyope of object to store + */ +public class JsLightMap implements LightMap { + private JavaScriptObject map; + + /** + * Construct a {@link JsLightMap} + */ + public JsLightMap() { + this(JavaScriptObject.createObject()); + } + + /** + * Construct a {@link JsLightMap} using a given javascript object + * + * @param data the javascript object to use + */ + public JsLightMap(JavaScriptObject data) { + if (data == null) { + throw new IllegalArgumentException("data must not be null"); + } + this.map = data; + } + + @Override + public final void clear() { + clearData(); + } + + private final native void clearData() /*-{ + this.@com.googlecode.mgwt.collection.client.JsLightMap::map = {}; + }-*/; + + @Override + public final native boolean containsKey(String key) /*-{ + return (this.@com.googlecode.mgwt.collection.client.JsLightMap::map)[key] != null; + }-*/; + + @Override + public void remove(String key) { + nativeDelete(key); + } + + private native V nativeDelete(String key) /*-{ + delete (this.@com.googlecode.mgwt.collection.client.JsLightMap::map)[key]; + }-*/; + + @Override + public V get(String key) { + return nativeGet(key); + } + + private native V nativeGet(String key) /*-{ + return (this.@com.googlecode.mgwt.collection.client.JsLightMap::map)[key]; + }-*/; + + @Override + public void put(String key, V value) { + nativePut(key, value); + + } + + private native V nativePut(String key, V value) /*-{ + (this.@com.googlecode.mgwt.collection.client.JsLightMap::map)[key] = value; + }-*/; + + @Override + public LightArray getKeys() { + JavaScriptObject array = getNativeKeyArray(); + return new JsLightArray(array); + } + + private native JavaScriptObject getNativeKeyArray()/*-{ + var array = []; + for ( var key in this.@com.googlecode.mgwt.collection.client.JsLightMap::map) { + array.push(key); + } + return array; + }-*/; + + /** + * get the underlying javascript object + * + * @return the underlying javascript object + */ + public JavaScriptObject getMap() { + return map; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/CollectionFactory.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/CollectionFactory.java new file mode 100644 index 0000000..ce222ae --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/CollectionFactory.java @@ -0,0 +1,76 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.collection.shared; + +import com.google.gwt.core.client.GWT; +import com.googlecode.mgwt.collection.client.JsLightArray; +import com.googlecode.mgwt.collection.client.JsLightArrayInteger; +import com.googlecode.mgwt.collection.client.JsLightMap; +import com.googlecode.mgwt.collection.shared.java.JavaLightArray; +import com.googlecode.mgwt.collection.shared.java.JavaLightArrayInt; +import com.googlecode.mgwt.collection.shared.java.JavaLightMap; + +/** + * A factory to create instances of the light collections api. + * + * If this is run in production code javascript objects are used to speed up collections. If run + * inside a JVM / dev mode the java implementation is used + * + * @author Daniel Kurka + * + */ +public class CollectionFactory { + /** + * Construct a LightMap + * + * @param the type of the map + * @return the map + */ + public static LightMap constructMap() { + if (GWT.isProdMode()) { + return new JsLightMap(); + } else { + return new JavaLightMap(); + } + } + + /** + * Construct a {@link LightArray} + * + * @param the type of objects that go into the array + * @return the array + */ + public static LightArray constructArray() { + if (GWT.isProdMode()) { + return new JsLightArray(); + } else { + return new JavaLightArray(); + } + } + + /** + * Construct an array of integers + * + * @return the array + */ + public static LightArrayInt constructIntegerArray() { + if (GWT.isProdMode()) { + return new JsLightArrayInteger(); + } else { + return new JavaLightArrayInt(); + } + } +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightArray.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightArray.java new file mode 100644 index 0000000..a94edc5 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightArray.java @@ -0,0 +1,71 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.collection.shared; + +/** + * A light array implements the same interface as a javascript array. + * + * @author Daniel Kurka + * + * @param the type of object to store + */ +public interface LightArray { + + /** + * get the object at a specific index + * + * @param index the index + * @return the object or null + */ + public T get(int index); + + /** + * put an object to a given index. the array autoexpands and fills up missing values with null + * + * @param index the index + * @param value the value to store + */ + public void set(int index, T value); + + /** + * the length of the array + * + * @return the length of the array + */ + public int length(); + + /** + * push a value on to the array + * + * @param value + */ + void push(T value); + + /** + * pop a value from the array + * + * @return the value + */ + public T shift(); + + /** + * push a value onto the array + * + * @param value to push + */ + public void unshift(T value); + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightArrayBoolean.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightArrayBoolean.java new file mode 100644 index 0000000..f7acf52 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightArrayBoolean.java @@ -0,0 +1,68 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.collection.shared; + +/** + * A light array implements the same interface as a javascript array. + * + * @author Daniel Kurka + * + */ +public interface LightArrayBoolean { + /** + * pop a value from the array + * + * @return the value + */ + public boolean shift(); + + /** + * get the object at a specific index + * + * @param index the index + * @return the object or null + */ + public boolean get(int index); + + /** + * put an object to a given index. the array autoexpands and fills up missing values with null + * + * @param index the index + * @param value the value to store + */ + public void set(int index, boolean value); + + /** + * the length of the array + * + * @return the length of the array + */ + public int length(); + + /** + * push a value onto the array + * + * @param value to push + */ + public void unshift(boolean value); + + /** + * push a value on to the array + * + * @param value + */ + public void push(boolean value); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightArrayInt.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightArrayInt.java new file mode 100644 index 0000000..769898c --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightArrayInt.java @@ -0,0 +1,68 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.collection.shared; + +/** + * An array that can store primitive ints + * + * @author Daniel Kurka + * + */ +public interface LightArrayInt { + /** + * pop a value from the array + * + * @return the value + */ + public int shift(); + + /** + * get the object at a specific index + * + * @param index the index + * @return the object or null + */ + public int get(int index); + + /** + * put an object to a given index. the array autoexpands and fills up missing values with null + * + * @param index the index + * @param value the value to store + */ + public void set(int index, int value); + + /** + * the length of the array + * + * @return the length of the array + */ + public int length(); + + /** + * push a value onto the array + * + * @param value to push + */ + public void unshift(int value); + + /** + * push a value on to the array + * + * @param value + */ + public void push(int value); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightMap.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightMap.java new file mode 100644 index 0000000..da6be9c --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/LightMap.java @@ -0,0 +1,70 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.collection.shared; + +/** + * + * A lightmap is a key value store that uses a native implementation if available. + * + * @author Daniel Kurka + * + * @param the type of object to store + */ +public interface LightMap { + + /** + * remove all objects from this map + */ + public void clear(); + + /** + * does the map contain a key + * + * @param key the key to test for + * @return true if the key is part of the map + */ + public boolean containsKey(String key); + + /** + * get all keys for this map + * + * @return the keys of this map + */ + public LightArray getKeys(); + + /** + * remove a value from the map + * + * @param key + */ + public void remove(String key); + + /** + * get a value from the map + * + * @param key the key to use + * @return the value + */ + public V get(String key); + + /** + * put a value into the map + * + * @param key the key + * @param value the value + */ + public void put(String key, V value); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightArray.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightArray.java new file mode 100644 index 0000000..b0cf4d6 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightArray.java @@ -0,0 +1,102 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.collection.shared.java; + +import java.util.ArrayList; +import java.util.Set; + +import com.googlecode.mgwt.collection.shared.LightArray; + +/** + * An implementation of {@link LightArray} used on the jvm + * + * @author Daniel Kurka + * + * @param + */ +public class JavaLightArray implements LightArray { + + private ArrayList list; + + /** + * Construct a {@link JavaLightArray} + */ + public JavaLightArray() { + list = new ArrayList(); + } + + @Override + public T shift() { + return list.remove(0); + } + + @Override + public T get(int index) { + // behave like js! + if (index < 0 || index >= list.size()) + return null; + return list.get(index); + } + + @Override + public void set(int index, T value) { + // behave like js! + if (index < 0) + return; + if (index >= list.size()) { + for (int i = list.size(); i < index; i++) { + list.add(null); + } + list.add(value); + } else { + list.set(index, value); + } + + } + + @Override + public int length() { + return list.size(); + } + + @Override + public void unshift(T value) { + list.add(0, value); + + } + + @Override + public void push(T value) { + list.add(value); + + } + + /** + * Construct a {@link JavaLightArray} from a set + * + * @param the types to store in the array + * @param set the set with the initial values + * @return the new array + */ + public static JavaLightArray fromSet(Set set) { + JavaLightArray array = new JavaLightArray(); + for (T t : set) { + array.push(t); + } + return array; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightArrayBoolean.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightArrayBoolean.java new file mode 100644 index 0000000..ccc98aa --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightArrayBoolean.java @@ -0,0 +1,77 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.collection.shared.java; + +import com.googlecode.mgwt.collection.shared.LightArrayBoolean; + +/** + * + * Implementation of {@link LightArrayBoolean} for java environments + * + * @author Daniel Kurka + * + */ +public class JavaLightArrayBoolean implements LightArrayBoolean { + + private JavaLightArray array; + + /** + * Construct a {@link JavaLightArrayBoolean} + */ + public JavaLightArrayBoolean() { + array = new JavaLightArray(); + } + + @Override + public boolean get(int index) { + Boolean boolean1 = array.get(index); + if (boolean1 != null) + return boolean1; + return false; + } + + @Override + public int length() { + return array.length(); + } + + @Override + public void push(boolean value) { + array.push(value); + + } + + @Override + public void set(int index, boolean value) { + array.set(index, value); + + } + + @Override + public boolean shift() { + Boolean shift = array.shift(); + if (shift != null) + return shift; + return false; + } + + @Override + public void unshift(boolean value) { + array.unshift(value); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightArrayInt.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightArrayInt.java new file mode 100644 index 0000000..ac613e5 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightArrayInt.java @@ -0,0 +1,76 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.collection.shared.java; + +import com.googlecode.mgwt.collection.shared.LightArrayInt; + +/** + * Java implemntation of {@link LightArrayInt} + * + * @author Daniel Kurka + * + */ +public class JavaLightArrayInt implements LightArrayInt { + + private JavaLightArray array; + + /** + * Construct a {@link JavaLightArray} + */ + public JavaLightArrayInt() { + array = new JavaLightArray(); + } + + @Override + public int get(int index) { + Integer integer = array.get(index); + if (integer != null) + return integer; + return 0; + } + + @Override + public int length() { + return array.length(); + } + + @Override + public void push(int value) { + array.push(Integer.valueOf(value)); + + } + + @Override + public void set(int index, int value) { + array.set(index, Integer.valueOf(value)); + + } + + @Override + public int shift() { + Integer shift = array.shift(); + if (shift != null) + return shift; + return 0; + } + + @Override + public void unshift(int value) { + array.unshift(Integer.valueOf(value)); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightMap.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightMap.java new file mode 100644 index 0000000..20f7243 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/collection/shared/java/JavaLightMap.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.collection.shared.java; + +import java.util.HashMap; +import java.util.Set; + +import com.googlecode.mgwt.collection.shared.LightArray; +import com.googlecode.mgwt.collection.shared.LightMap; + +/** + * Java implementation of {@link LightMap} + * + * @author Daniel Kurka + * + * @param type of objects to store + */ +public class JavaLightMap implements LightMap { + + private HashMap map; + + /** + * Construct a {@link JavaLightMap} + */ + public JavaLightMap() { + map = new HashMap(); + } + + @Override + public void clear() { + map.clear(); + + } + + @Override + public boolean containsKey(String key) { + return map.containsKey(key); + } + + @Override + public LightArray getKeys() { + Set keySet = map.keySet(); + return JavaLightArray.fromSet(keySet); + } + + @Override + public void remove(String key) { + map.remove(key); + } + + @Override + public V get(String key) { + return map.get(key); + } + + @Override + public void put(String key, V value) { + map.put(key, value); + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml new file mode 100644 index 0000000..e46c8b2 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/DOM.gwt.xml @@ -0,0 +1,109 @@ + + + + + + + = 2) { + return "ipad_retina"; + } + return "ipad"; + } + + if(ua.indexOf('iphone') != -1 || ua.indexOf('ipod') != -1) { + if(window.devicePixelRatio >= 2) { + return "retina"; + } + return "iphone"; + } + + return "desktop"; + + })(); + + return mgwt_os; + } + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/EventTypes.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/EventTypes.java new file mode 100644 index 0000000..be8a004 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/EventTypes.java @@ -0,0 +1,7 @@ +package com.googlecode.mgwt.dom.client.event; + +public interface EventTypes { + public String getAnimationEnd(); + + public String getTransistionEnd(); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/EventTypesDefault.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/EventTypesDefault.java new file mode 100644 index 0000000..ec3f897 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/EventTypesDefault.java @@ -0,0 +1,17 @@ +package com.googlecode.mgwt.dom.client.event; + +public class EventTypesDefault implements EventTypes{ + + @Override + public String getAnimationEnd() { + + return "animationend"; + } + + @Override + public String getTransistionEnd() { + + return "transitionend"; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/MozEventTypes.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/MozEventTypes.java new file mode 100644 index 0000000..8b90eff --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/MozEventTypes.java @@ -0,0 +1,15 @@ +package com.googlecode.mgwt.dom.client.event; + +public class MozEventTypes implements EventTypes{ + + @Override + public String getAnimationEnd() { + return "animationend"; + } + + @Override + public String getTransistionEnd() { + return "transitionend"; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/SafariEventTypes.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/SafariEventTypes.java new file mode 100644 index 0000000..808efd9 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/SafariEventTypes.java @@ -0,0 +1,14 @@ +package com.googlecode.mgwt.dom.client.event; + +public class SafariEventTypes implements EventTypes{ + + @Override + public String getAnimationEnd() { + return "webkitAnimationEnd"; + } + + @Override + public String getTransistionEnd() { + return "webkitTransitionEnd"; + } +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/AnimationEndEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/AnimationEndEvent.java new file mode 100644 index 0000000..df6bf49 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/AnimationEndEvent.java @@ -0,0 +1,71 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.animation; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.DomEvent; +import com.googlecode.mgwt.dom.client.event.EventTypes; + +/** + * + * Represent a native animation end event + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class AnimationEndEvent extends DomEvent { + + private static final EventTypes EVENT_TYPES = GWT.create(EventTypes.class); + /** + * Event type for animation end events. + */ + private static final Type TYPE = new Type(EVENT_TYPES.getAnimationEnd(), new AnimationEndEvent()); + + /** + *

getType

+ * + * @return a Type object. + */ + public static Type getType() { + return TYPE; + } + + /** + * {@inheritDoc} + * + * Gets the event type associated with animation end events. + */ + @Override + public com.google.gwt.event.dom.client.DomEvent.Type getAssociatedType() { + return TYPE; + } + + /** + * Protected constructor, use + * {@link DomEvent#fireNativeEvent(com.google.gwt.dom.client.NativeEvent, com.google.gwt.event.shared.HasHandlers)} + * to fire animation end events. + */ + protected AnimationEndEvent() { + + } + + /** {@inheritDoc} */ + @Override + protected void dispatch(AnimationEndHandler handler) { + handler.onAnimationEnd(this); + + } +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/AnimationEndHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/AnimationEndHandler.java new file mode 100644 index 0000000..4f8ab44 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/AnimationEndHandler.java @@ -0,0 +1,33 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.animation; + +import com.google.gwt.event.shared.EventHandler; + +/** + * Handler for {@link AnimationEndEvent} events: + * + * @author Daniel Kurka + * @version $Id: $ + */ +public interface AnimationEndHandler extends EventHandler { + /** + * Called when a animation end event is fired. + * + * @param event the {@link AnimationEndEvent} that was fired + */ + public void onAnimationEnd(AnimationEndEvent event); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/HasAnimationEndEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/HasAnimationEndEvent.java new file mode 100644 index 0000000..de11dd2 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/HasAnimationEndEvent.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.animation; + +import com.google.gwt.event.shared.HandlerRegistration; + +/** + * A widget that implements this interface provides registration for + * {@link AnimationEndHandler} instances. + * + * @author Daniel Kurka + * @version $Id: $ + */ +public interface HasAnimationEndEvent { + /** + * Adds a {@link AnimationEndEvent} handler. + * + * @param handler the animation end handler + * @return {@link HandlerRegistration} used to remove this handler + */ + public HandlerRegistration addAnimationEndHandler(AnimationEndHandler handler); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/HasTransitionEndEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/HasTransitionEndEvent.java new file mode 100644 index 0000000..0c2e164 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/HasTransitionEndEvent.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.animation; + +import com.google.gwt.event.shared.HandlerRegistration; + +/** + * A widget that implements this interface provides registration for + * {@link TransitionEndHandler} instances. + * + * @author Daniel Kurka + * @version $Id: $ + */ +public interface HasTransitionEndEvent { + /** + * Adds a {@link TransitionEndHandler} handler. + * + * @param handler the transistion end handler + * @return {@link HandlerRegistration} used to remove this handler + */ + public HandlerRegistration addTransitionEndHandler(TransitionEndHandler handler); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/TransitionEndEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/TransitionEndEvent.java new file mode 100644 index 0000000..7824331 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/TransitionEndEvent.java @@ -0,0 +1,68 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.animation; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.DomEvent; +import com.googlecode.mgwt.dom.client.event.EventTypes; + +/** + * + * Represent a native transition end event + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class TransitionEndEvent extends DomEvent { + + private static final EventTypes EVENT_TYPES = GWT.create(EventTypes.class); + + private static final Type TYPE = new Type(EVENT_TYPES.getTransistionEnd(), new TransitionEndEvent()); + + /** + *

getType

+ * + * @return a Type object. + */ + public static Type getType() { + return TYPE; + } + + /** + * {@inheritDoc} + * + * Gets the event type associated with transition end events. + */ + @Override + public com.google.gwt.event.dom.client.DomEvent.Type getAssociatedType() { + return TYPE; + } + + /** + *

Constructor for TransitionEndEvent.

+ */ + protected TransitionEndEvent() { + + } + + /** {@inheritDoc} */ + @Override + protected void dispatch(TransitionEndHandler handler) { + handler.onTransitionEnd(this); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/TransitionEndHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/TransitionEndHandler.java new file mode 100644 index 0000000..fd53d1d --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/animation/TransitionEndHandler.java @@ -0,0 +1,33 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.animation; + +import com.google.gwt.event.shared.EventHandler; + +/** + * Handler for {@link TransitionEndEvent} events: + * + * @author Daniel Kurka + * @version $Id: $ + */ +public interface TransitionEndHandler extends EventHandler { + /** + * Called when a transition end event is fired. + * + * @param event the {@link TransitionEndEvent} that was fired + */ + public void onTransitionEnd(TransitionEndEvent event); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/HandlerRegistrationCollection.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/HandlerRegistrationCollection.java new file mode 100644 index 0000000..144b750 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/HandlerRegistrationCollection.java @@ -0,0 +1,67 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.mouse; + +import java.util.LinkedList; + +import com.google.gwt.event.shared.HandlerRegistration; + +/** + * A collection of HandlerRegistrations which behaves like a single + * registration: On remove all collected Handlers are removed. + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class HandlerRegistrationCollection implements HandlerRegistration, com.google.web.bindery.event.shared.HandlerRegistration { + + private LinkedList collectedHandlers = new LinkedList(); + + /** + * Construct an empty HandlerRegistrationCollection + */ + public HandlerRegistrationCollection() { + + } + + /** + * Add a {@link HandlerRegistration} to the collection + * + * @param handlerRegistration the handlerregistration to add + */ + public void addHandlerRegistration(HandlerRegistration handlerRegistration) { + collectedHandlers.add(handlerRegistration); + } + + public void addHandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration handlerRegistration) { + collectedHandlers.add(handlerRegistration); + } + + /** + * {@inheritDoc} + * + * Remove all handlers: Call remove on each Handler + */ + @Override + public void removeHandler() { + for (com.google.web.bindery.event.shared.HandlerRegistration handlerRegistration : collectedHandlers) { + handlerRegistration.removeHandler(); + } + collectedHandlers.clear(); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/MultiTouchMouseEmulator.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/MultiTouchMouseEmulator.java new file mode 100644 index 0000000..462d2d8 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/MultiTouchMouseEmulator.java @@ -0,0 +1,38 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.mouse; + +public class MultiTouchMouseEmulator { + + private static int[] coordinates; + private static boolean hasValues; + + public static void onTouchStart(int x, int y) { + coordinates = new int[] {x, y}; + hasValues = true; + } + + public static int[] getTouchStart() { + return coordinates; + } + + public static boolean isHasValues() { + return hasValues; + } + + public static void reset() { + hasValues = false; + + } +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchEndEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchEndEvent.java new file mode 100644 index 0000000..ccdcbe3 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchEndEvent.java @@ -0,0 +1,103 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.mouse; + +import com.google.gwt.core.client.JsArray; +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.event.dom.client.MouseUpEvent; +import com.googlecode.mgwt.collection.client.JsLightArray; +import com.googlecode.mgwt.collection.shared.LightArray; +import com.googlecode.mgwt.dom.client.event.touch.JsTouch; +import com.googlecode.mgwt.dom.client.event.touch.Touch; +import com.googlecode.mgwt.dom.client.event.touch.TouchEndEvent; + +/** + * A simulated TouchEndEvent is really a mouseup event. This is used mostly in dev mode and for + * blackberry devices to handle them equally to real touch devices + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class SimulatedTouchEndEvent extends TouchEndEvent { + + private final int x; + private final int y; + private int x_start; + private int y_start; + private boolean multiTouch; + + /** + * Construct a simluated TouchEndEvent from a {@link MouseUpEvent} + * + * @param mouseUpEvent the data for the simulated event; + * @param multiTouch + */ + public SimulatedTouchEndEvent(MouseUpEvent mouseUpEvent, boolean multiTouch) { + x = mouseUpEvent.getClientX(); + y = mouseUpEvent.getClientY(); + this.multiTouch = multiTouch; + if (multiTouch) { + int[] start = MultiTouchMouseEmulator.getTouchStart(); + x_start = start[0]; + y_start = start[1]; + } + setNativeEvent(mouseUpEvent.getNativeEvent()); + setSource(mouseUpEvent.getSource()); + } + + @Override + public LightArray getTouches() { + return new JsLightArray(touches(getNativeEvent())); + } + + @Override + public LightArray getChangedTouches() { + return new JsLightArray(changedTouches(getNativeEvent())); + } + + /** {@inheritDoc} */ + @Override + protected native JsArray touches(NativeEvent nativeEvent) /*-{ + var toucharray = []; + if (this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchEndEvent::multiTouch) { + var touch_start = {}; + touch_start.pageX = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchEndEvent::x_start; + touch_start.pageY = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchEndEvent::y_start; + toucharray.push(touch_start); + } + + return toucharray; + }-*/; + + /** {@inheritDoc} */ + @Override + protected native JsArray changedTouches(NativeEvent nativeEvent) /*-{ + + var toucharray = []; + + if (this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchEndEvent::multiTouch) { + var touch_start = {}; + touch_start.pageX = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchEndEvent::x_start; + touch_start.pageY = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchEndEvent::y_start; + toucharray.push(touch_start); + } else { + var touch = {}; + touch.pageX = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchEndEvent::x; + touch.pageY = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchEndEvent::y; + toucharray.push(touch); + } + + return toucharray; + }-*/; +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchMoveEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchMoveEvent.java new file mode 100644 index 0000000..627c24f --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchMoveEvent.java @@ -0,0 +1,117 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.mouse; + +import com.google.gwt.core.client.JsArray; +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.event.dom.client.MouseMoveEvent; +import com.googlecode.mgwt.collection.client.JsLightArray; +import com.googlecode.mgwt.collection.shared.LightArray; +import com.googlecode.mgwt.dom.client.event.touch.JsTouch; +import com.googlecode.mgwt.dom.client.event.touch.Touch; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveEvent; + +/** + * A simulated TouchMoveEvent is really a mouse move event. This is used mostly in dev mode and for + * blackberry devices to handle them equally to real touch devices + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class SimulatedTouchMoveEvent extends TouchMoveEvent { + + private int x; + private int y; + + private int x_start; + private int y_start; + private boolean multiTouch; + + /** + *

+ * Constructor for SimulatedTouchMoveEvent. + *

+ * + * @param event a {@link com.google.gwt.event.dom.client.MouseMoveEvent} object. + */ + public SimulatedTouchMoveEvent(MouseMoveEvent event) { + x = event.getClientX(); + y = event.getClientY(); + multiTouch = false; + + if (event.isAltKeyDown() && MultiTouchMouseEmulator.isHasValues()) { + multiTouch = true; + int[] start = MultiTouchMouseEmulator.getTouchStart(); + x_start = start[0]; + y_start = start[1]; + } + + setNativeEvent(event.getNativeEvent()); + setSource(event.getSource()); + } + + @Override + public LightArray getTouches() { + return new JsLightArray(touches(getNativeEvent())); + } + + @Override + public LightArray getChangedTouches() { + return new JsLightArray(changedTouches(getNativeEvent())); + } + + /** {@inheritDoc} */ + @Override + protected native JsArray touches(NativeEvent nativeEvent) /*-{ + var touch = {}; + + touch.pageX = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchMoveEvent::x; + touch.pageY = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchMoveEvent::y; + + var toucharray = []; + + if (this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchMoveEvent::multiTouch) { + var touch_start = {}; + touch_start.pageX = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchMoveEvent::x_start; + touch_start.pageY = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchMoveEvent::y_start; + toucharray.push(touch_start); + } + + toucharray.push(touch); + + return toucharray; + }-*/; + + /** {@inheritDoc} */ + @Override + protected native JsArray changedTouches(NativeEvent nativeEvent) /*-{ + var touch = {}; + + touch.pageX = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchMoveEvent::x; + touch.pageY = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchMoveEvent::y; + + var toucharray = []; + + if (this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchMoveEvent::multiTouch) { + var touch_start = {}; + touch_start.pageX = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchMoveEvent::x_start; + touch_start.pageY = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchMoveEvent::y_start; + toucharray.push(touch_start); + } + + toucharray.push(touch); + + return toucharray; + }-*/; +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchStartEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchStartEvent.java new file mode 100644 index 0000000..4ac1a0c --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/SimulatedTouchStartEvent.java @@ -0,0 +1,117 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.mouse; + +import com.google.gwt.core.client.JsArray; +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.event.dom.client.MouseDownEvent; +import com.googlecode.mgwt.collection.client.JsLightArray; +import com.googlecode.mgwt.collection.shared.LightArray; +import com.googlecode.mgwt.dom.client.event.touch.JsTouch; +import com.googlecode.mgwt.dom.client.event.touch.Touch; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartEvent; + +/** + * A simulated TouchMoveEvent is really a mouse down event. This is used mostly in dev mode and for + * blackberry devices to handle them equally to real touch devices + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class SimulatedTouchStartEvent extends TouchStartEvent { + private int x; + private int y; + private final MouseDownEvent event; + private boolean multiTouch; + + /** + *

+ * Constructor for SimulatedTouchStartEvent. + *

+ * + * @param event a {@link com.google.gwt.event.dom.client.MouseDownEvent} object. + * @param multiTouch + */ + public SimulatedTouchStartEvent(MouseDownEvent event, boolean multiTouch) { + this.event = event; + x = event.getClientX(); + y = event.getClientY(); + this.multiTouch = multiTouch; + if (this.multiTouch) { + MultiTouchMouseEmulator.onTouchStart(x, y); + } + setNativeEvent(event.getNativeEvent()); + setSource(event.getSource()); + } + + @Override + public LightArray getTouches() { + return new JsLightArray(touches(getNativeEvent())); + } + + @Override + public LightArray getChangedTouches() { + return new JsLightArray(changedTouches(getNativeEvent())); + } + + /** {@inheritDoc} */ + @Override + protected native JsArray touches(NativeEvent nativeEvent) /*-{ + var touch = {}; + + touch.pageX = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent::x; + touch.pageY = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent::y; + + var toucharray = []; + + if (this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent::multiTouch) { + var touch_start = {}; + touch_start.pageX = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent::x; + touch_start.pageY = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent::y; + toucharray.push(touch_start); + } + + toucharray.push(touch); + + return toucharray; + }-*/; + + /** {@inheritDoc} */ + @Override + protected native JsArray changedTouches(NativeEvent nativeEvent) /*-{ + var touch = {}; + + touch.pageX = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent::x; + touch.pageY = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent::y; + + var toucharray = []; + + if (this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent::multiTouch) { + var touch_start = {}; + touch_start.pageX = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent::x; + touch_start.pageY = this.@com.googlecode.mgwt.dom.client.event.mouse.SimulatedTouchStartEvent::y; + toucharray.push(touch_start); + } + + toucharray.push(touch); + + return toucharray; + }-*/; + + @Override + public void stopPropagation() { + event.stopPropagation(); + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/TouchEndToMouseUpHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/TouchEndToMouseUpHandler.java new file mode 100644 index 0000000..a3effc7 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/TouchEndToMouseUpHandler.java @@ -0,0 +1,54 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.mouse; + +import com.google.gwt.event.dom.client.MouseUpEvent; +import com.google.gwt.event.dom.client.MouseUpHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler; + +/** + * Convert TouchEndHandlers to MouseUpHandlers for non touch devices or dev mode + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class TouchEndToMouseUpHandler implements MouseUpHandler { + private final TouchEndHandler handler; + + /** + *

+ * Constructor for TouchEndToMouseUpHandler. + *

+ * + * @param handler a {@link com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler} object. + */ + public TouchEndToMouseUpHandler(TouchEndHandler handler) { + this.handler = handler; + } + + /** {@inheritDoc} */ + @Override + public void onMouseUp(MouseUpEvent event) { + if (event.isAltKeyDown() || MultiTouchMouseEmulator.isHasValues()) { + MultiTouchMouseEmulator.reset(); + // fire to events + SimulatedTouchEndEvent simulatedTouchEndEvent = new SimulatedTouchEndEvent(event, true); + handler.onTouchEnd(simulatedTouchEndEvent); + } + + SimulatedTouchEndEvent simulatedTouchEndEvent = new SimulatedTouchEndEvent(event, false); + handler.onTouchEnd(simulatedTouchEndEvent); + + } +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/TouchMoveToMouseMoveHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/TouchMoveToMouseMoveHandler.java new file mode 100644 index 0000000..f6f5247 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/TouchMoveToMouseMoveHandler.java @@ -0,0 +1,77 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.mouse; + +import com.google.gwt.event.dom.client.MouseDownEvent; +import com.google.gwt.event.dom.client.MouseDownHandler; +import com.google.gwt.event.dom.client.MouseMoveEvent; +import com.google.gwt.event.dom.client.MouseMoveHandler; +import com.google.gwt.event.dom.client.MouseUpEvent; +import com.google.gwt.event.dom.client.MouseUpHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler; + +/** + * Convert TouchMoveHandlers to MouseMoveHandlers for non touch devices or dev + * mode + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class TouchMoveToMouseMoveHandler implements MouseMoveHandler, MouseDownHandler, MouseUpHandler { + + private boolean ignoreEvent; + private final TouchMoveHandler touchMoveHandler; + + /** + *

Constructor for TouchMoveToMouseMoveHandler.

+ * + * @param touchMoveHandler a {@link com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler} object. + */ + public TouchMoveToMouseMoveHandler(TouchMoveHandler touchMoveHandler) { + this.touchMoveHandler = touchMoveHandler; + ignoreEvent = true; + } + + /** {@inheritDoc} */ + @Override + public void onMouseMove(MouseMoveEvent event) { + if (ignoreEvent) + return; + touchMoveHandler.onTouchMove(new SimulatedTouchMoveEvent(event)); + + } + + /* (non-Javadoc) + * @see com.google.gwt.event.dom.client.MouseUpHandler#onMouseUp(com.google.gwt.event.dom.client.MouseUpEvent) + */ + /** {@inheritDoc} */ + @Override + public void onMouseUp(MouseUpEvent event) { + ignoreEvent = true; + + } + + /* (non-Javadoc) + * @see com.google.gwt.event.dom.client.MouseDownHandler#onMouseDown(com.google.gwt.event.dom.client.MouseDownEvent) + */ + /** {@inheritDoc} */ + @Override + public void onMouseDown(MouseDownEvent event) { + ignoreEvent = false; + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/TouchStartToMouseDownHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/TouchStartToMouseDownHandler.java new file mode 100644 index 0000000..8ff4d5e --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/mouse/TouchStartToMouseDownHandler.java @@ -0,0 +1,58 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.mouse; + +import com.google.gwt.event.dom.client.MouseDownEvent; +import com.google.gwt.event.dom.client.MouseDownHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler; + +/** + * Convert TouchStartHandlers to mouse down handlers for non touch devices or dev mode + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class TouchStartToMouseDownHandler implements MouseDownHandler { + + private final TouchStartHandler handler; + + /** + *

+ * Constructor for TouchStartToMouseDownHandler. + *

+ * + * @param handler a {@link com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler} object. + */ + public TouchStartToMouseDownHandler(TouchStartHandler handler) { + + this.handler = handler; + + } + + /** {@inheritDoc} */ + @Override + public void onMouseDown(MouseDownEvent event) { + if (event.isAltKeyDown()) { + SimulatedTouchStartEvent simulatedTouchStartEvent = new SimulatedTouchStartEvent(event, false); + handler.onTouchStart(simulatedTouchStartEvent); + simulatedTouchStartEvent = new SimulatedTouchStartEvent(event, true); + handler.onTouchStart(simulatedTouchStartEvent); + } else { + SimulatedTouchStartEvent simulatedTouchStartEvent = new SimulatedTouchStartEvent(event, false); + handler.onTouchStart(simulatedTouchStartEvent); + } + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/orientation/HasOrientationChangeHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/orientation/HasOrientationChangeHandler.java new file mode 100644 index 0000000..20d0020 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/orientation/HasOrientationChangeHandler.java @@ -0,0 +1,34 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.orientation; + +import com.google.gwt.event.shared.HandlerRegistration; + +/** + *

HasOrientationChangeHandler interface.

+ * + * @author Daniel Kurka + * @version $Id: $ + */ +public interface HasOrientationChangeHandler { + /** + *

addOrientationChangeHandler

+ * + * @param handler a {@link com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeHandler} object. + * @return a {@link com.google.gwt.event.shared.HandlerRegistration} object. + */ + public HandlerRegistration addOrientationChangeHandler(OrientationChangeHandler handler); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/orientation/OrientationChangeEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/orientation/OrientationChangeEvent.java new file mode 100644 index 0000000..904c17b --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/orientation/OrientationChangeEvent.java @@ -0,0 +1,83 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.orientation; + +import com.google.gwt.event.shared.GwtEvent; + +/** + *

OrientationChangeEvent class.

+ * + * @author Daniel Kurka + * @version $Id: $ + */ +public class OrientationChangeEvent extends GwtEvent { + + private static final GwtEvent.Type TYPE = new Type(); + private final ORIENTATION orientation; + + public enum ORIENTATION { + PORTRAIT, LANDSCAPE + } + + /** + *

Constructor for OrientationChangeEvent.

+ * + * @param orientation a {@link com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeEvent.ORIENTATION} object. + */ + public OrientationChangeEvent(ORIENTATION orientation) { + this.orientation = orientation; + + } + + /** {@inheritDoc} */ + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + /* (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) + */ + /** {@inheritDoc} */ + @Override + protected void dispatch(OrientationChangeHandler handler) { + handler.onOrientationChanged(this); + + } + + /** + *

Getter for the field orientation.

+ * + * @return a {@link com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeEvent.ORIENTATION} object. + */ + public ORIENTATION getOrientation() { + return orientation; + } + + /** + *

getType

+ * + * @return a Type object. + */ + public static Type getType() { + return TYPE; + } + + /** + * @return + */ + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/orientation/OrientationChangeHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/orientation/OrientationChangeHandler.java new file mode 100644 index 0000000..7d129ac --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/orientation/OrientationChangeHandler.java @@ -0,0 +1,33 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.orientation; + +import com.google.gwt.event.shared.EventHandler; + +/** + *

OrientationChangeHandler interface.

+ * + * @author Daniel Kurka + * @version $Id: $ + */ +public interface OrientationChangeHandler extends EventHandler { + /** + *

onOrientationChanged

+ * + * @param event a {@link com.googlecode.mgwt.dom.client.event.orientation.OrientationChangeEvent} object. + */ + public void onOrientationChanged(OrientationChangeEvent event); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/HasTapHandlers.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/HasTapHandlers.java new file mode 100644 index 0000000..7ba5f0a --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/HasTapHandlers.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.tap; + +import com.google.gwt.event.shared.HandlerRegistration; + +/** + * A widget that implements this interface provides registration for + * {@link TapHandler} instances. + * + * @author Daniel Kurka + * @version $Id: $ + */ +public interface HasTapHandlers { + /** + * Adds a {@link TapHandler} handler. + * + * @param handler the simple touch handler + * @return {@link HandlerRegistration} used to remove this handler + */ + public HandlerRegistration addTapHandler(TapHandler handler); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/Tap.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/Tap.java new file mode 100644 index 0000000..31f00df --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/Tap.java @@ -0,0 +1,31 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.tap; + +/** + * Tap is considered for elements that offer something like a normal + * "click event". Like a button. + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class Tap { + /** + * The radius that a finger can move before the touch is not considered a + * simple touch anymore + */ + public static final int RADIUS = 10; +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapEvent.java new file mode 100644 index 0000000..70fc851 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapEvent.java @@ -0,0 +1,99 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.tap; + +import com.google.gwt.dom.client.Element; +import com.google.gwt.event.shared.GwtEvent; + +/** + * TapEvent is considered an activation event something like a normal + * "click event". Like a button, but with touch events. + * + * + * @author Daniel Kurka + */ + +public class TapEvent extends GwtEvent { + + private static final Type TYPE = new Type(); + private final int startX; + private final int startY; + private final Element targetElement; + + /** + * @deprecated use {@link #TapEvent(Object, Element, int, int)} instead + */ + @Deprecated + public TapEvent(Object source, int startX, int startY) { + this(source, null, startX, startY); + } + + public TapEvent(Object source, Element targetElement, int startX, int startY) { + this.targetElement = targetElement; + this.startX = startX; + this.startY = startY; + setSource(source); + } + + /* + * (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + /* + * (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) + */ + @Override + protected void dispatch(TapHandler handler) { + handler.onTap(this); + + } + + public static Type getType() { + return TYPE; + } + + /** + * get the x start position of the tap + * + * @return the x start position of the tap + */ + public int getStartX() { + return startX; + } + + /** + * get the y start position of the tap + * + * @return the y start position of the tap + */ + public int getStartY() { + return startY; + } + + /** + * Returns the element that was the actual target of the Tap event. + */ + public Element getTargetElement() { + return targetElement; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapHandler.java new file mode 100644 index 0000000..34f177a --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/tap/TapHandler.java @@ -0,0 +1,28 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.tap; + +import com.google.gwt.event.shared.EventHandler; + +/** + * Handler for {@link TapEvent} events: + * + * + * @author Daniel Kurka + */ +public interface TapHandler extends EventHandler { + public void onTap(TapEvent event); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/HasTouchHandlers.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/HasTouchHandlers.java new file mode 100644 index 0000000..c111043 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/HasTouchHandlers.java @@ -0,0 +1,88 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.event.shared.HasHandlers; + +/** + * This is a convenience interface that includes all touch handlers defined by + * mgwt. + * + * @author kurt + * @version $Id: $ + */ +public interface HasTouchHandlers extends HasHandlers { + /** + *

+ * addTouchStartHandler + *

+ * + * @param handler a + * {@link com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler} + * object. + * @return a {@link com.google.gwt.event.shared.HandlerRegistration} object. + */ + public HandlerRegistration addTouchStartHandler(TouchStartHandler handler); + + /** + *

+ * addTouchMoveHandler + *

+ * + * @param handler a + * {@link com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler} + * object. + * @return a {@link com.google.gwt.event.shared.HandlerRegistration} object. + */ + public HandlerRegistration addTouchMoveHandler(TouchMoveHandler handler); + + /** + *

+ * addTouchCancelHandler + *

+ * + * @param handler a + * {@link com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler} + * object. + * @return a {@link com.google.gwt.event.shared.HandlerRegistration} object. + */ + public HandlerRegistration addTouchCancelHandler(TouchCancelHandler handler); + + /** + *

+ * addTouchEndHandler + *

+ * + * @param handler a + * {@link com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler} + * object. + * @return a {@link com.google.gwt.event.shared.HandlerRegistration} object. + */ + public HandlerRegistration addTouchEndHandler(TouchEndHandler handler); + + /** + *

+ * addTouchHandler + *

+ * + * @param handler a + * {@link com.googlecode.mgwt.dom.client.event.touch.TouchHandler} + * object. + * @return a {@link com.google.gwt.event.shared.HandlerRegistration} object. + */ + public HandlerRegistration addTouchHandler(TouchHandler handler); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/JavaTouch.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/JavaTouch.java new file mode 100644 index 0000000..1cb3b73 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/JavaTouch.java @@ -0,0 +1,43 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +public class JavaTouch implements Touch { + + private final int x; + private final int y; + private final int id; + + public JavaTouch(int x, int y, int id) { + this.x = x; + this.y = y; + this.id = id; + } + + @Override + public int getPageX() { + return x; + } + + @Override + public int getPageY() { + return y; + } + + @Override + public int getIdentifier() { + return id; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/JsTouch.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/JsTouch.java new file mode 100644 index 0000000..7cab68e --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/JsTouch.java @@ -0,0 +1,51 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +import com.google.gwt.core.client.JavaScriptObject; + +public final class JsTouch extends JavaScriptObject implements Touch { + /** + *

+ * Constructor for Touch. + *

+ */ + protected JsTouch() { + } + + /** + * The X position of the touch within the current document + * + * @return the current x position of the touch + */ + public final native int getPageX() /*-{ + return this.pageX; + }-*/; + + /** + * The Y position of the touch within the current document + * + * @return the current y position of the touch + */ + public final native int getPageY() /*-{ + return this.pageY; + }-*/; + + @Override + public native int getIdentifier() /*-{ + return this.identifier|| -1; + }-*/; +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/Touch.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/Touch.java new file mode 100644 index 0000000..9c05c44 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/Touch.java @@ -0,0 +1,41 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +/** + * The touch object inside a {@link TouchEvent} + * + * @author Daniel Kurka + * @version $Id: $ + */ +public interface Touch { + + /** + * The X position of the touch within the current document + * + * @return the current x position of the touch + */ + public int getPageX(); + + /** + * The Y position of the touch within the current document + * + * @return the current y position of the touch + */ + public int getPageY(); + + public int getIdentifier(); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchCancelEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchCancelEvent.java new file mode 100644 index 0000000..e4246d7 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchCancelEvent.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +/** + * This represents a native touchCanvel Event + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class TouchCancelEvent extends TouchEvent { + + private static final Type TYPE = new Type("touchcancel", new TouchCancelEvent()); + + /** + *

getType

+ * + * @return a Type object. + */ + public static Type getType() { + return TYPE; + } + + /** + * {@inheritDoc} + * + * Gets the event type associated with animation end events. + */ + @Override + public com.google.gwt.event.dom.client.DomEvent.Type getAssociatedType() { + return TYPE; + } + + /** + *

Constructor for TouchCancelEvent.

+ */ + protected TouchCancelEvent() { + + } + + /** {@inheritDoc} */ + @Override + protected void dispatch(TouchCancelHandler handler) { + handler.onTouchCanceled(this); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchCancelHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchCancelHandler.java new file mode 100644 index 0000000..3c6299a --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchCancelHandler.java @@ -0,0 +1,33 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +import com.google.gwt.event.shared.EventHandler; + +/** + * Handler for {@link TouchCancelEvent} events: + * + * @author Daniel Kurka + * @version $Id: $ + */ +public interface TouchCancelHandler extends EventHandler { + /** + * Called when a touch cancel event is fired. + * + * @param event the {@link TouchCancelEvent} that was fired + */ + public void onTouchCanceled(TouchCancelEvent event); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchEndEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchEndEvent.java new file mode 100644 index 0000000..2aa4dca --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchEndEvent.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +/** + * This represents a native touch end Event + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class TouchEndEvent extends TouchEvent { + + private static final Type TYPE = new Type("touchend", new TouchEndEvent()); + + /** + *

getType

+ * + * @return a Type object. + */ + public static Type getType() { + return TYPE; + } + + /** + * {@inheritDoc} + * + * Gets the event type associated with animation end events. + */ + @Override + public com.google.gwt.event.dom.client.DomEvent.Type getAssociatedType() { + return TYPE; + } + + /** + *

Constructor for TouchEndEvent.

+ */ + protected TouchEndEvent() { + + } + + /** {@inheritDoc} */ + @Override + protected void dispatch(TouchEndHandler handler) { + handler.onTouchEnd(this); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchEndHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchEndHandler.java new file mode 100644 index 0000000..a2ac728 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchEndHandler.java @@ -0,0 +1,33 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +import com.google.gwt.event.shared.EventHandler; + +/** + * Handler for {@link TouchEndHandler} events: + * + * @author Daniel Kurka + * @version $Id: $ + */ +public interface TouchEndHandler extends EventHandler { + /** + * Called when a touch end event is fired. + * + * @param event the {@link TouchEndEvent} that was fired + */ + public void onTouchEnd(TouchEndEvent event); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchEvent.java new file mode 100644 index 0000000..249994e --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchEvent.java @@ -0,0 +1,92 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +import com.google.gwt.core.client.JsArray; +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.event.dom.client.DomEvent; +import com.google.gwt.event.shared.EventHandler; +import com.googlecode.mgwt.collection.client.JsLightArray; +import com.googlecode.mgwt.collection.shared.LightArray; + +/** + * BaseClass for all TouchEvents + * + * @author Daniel Kurka + * @param the event handler to associate with this event + * @version $Id: $ + */ +public abstract class TouchEvent extends DomEvent { + + /** + *

+ * touches + *

+ * + * @deprecated use {@link #getTouches()} this method will be removed in a future release + * + * @return a {@link com.google.gwt.core.client.JsArray} object. + */ + @Deprecated + public JsArray touches() { + return touches(getNativeEvent()); + } + + public LightArray getTouches() { + return new JsLightArray(getNativeEvent().getTouches()); + } + + /** + *

+ * touches + *

+ * + * @param nativeEvent a {@link com.google.gwt.dom.client.NativeEvent} object. + * @return a {@link com.google.gwt.core.client.JsArray} object. + */ + protected native JsArray touches(NativeEvent nativeEvent) /*-{ + return nativeEvent.touches; + }-*/; + + /** + * get the changed touches + * + * @deprecated use {@link #getChangedTouches()} + * + * this method will be removed in a future release + * + * @return the array of changed touches + */ + @Deprecated + public JsArray changedTouches() { + return changedTouches(getNativeEvent()); + } + + public LightArray getChangedTouches() { + return new JsLightArray(getNativeEvent().getChangedTouches()); + } + + /** + *

+ * changedTouches + *

+ * + * @param nativeEvent a {@link com.google.gwt.dom.client.NativeEvent} object. + * @return a {@link com.google.gwt.core.client.JsArray} object. + */ + protected native JsArray changedTouches(NativeEvent nativeEvent) /*-{ + return nativeEvent.changedTouches; + }-*/; + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchHandler.java new file mode 100644 index 0000000..e4000c0 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchHandler.java @@ -0,0 +1,26 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +/** + * Handler for all touch events + * + * @author Daniel Kurka + * @version $Id: $ + */ +public interface TouchHandler extends TouchStartHandler, TouchMoveHandler, TouchEndHandler, TouchCancelHandler { + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchMoveEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchMoveEvent.java new file mode 100644 index 0000000..09198e9 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchMoveEvent.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +/** + * This represents a native touch move Event + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class TouchMoveEvent extends TouchEvent { + + private static final Type TYPE = new Type("touchmove", new TouchMoveEvent()); + + /** + *

getType

+ * + * @return a Type object. + */ + public static Type getType() { + return TYPE; + } + + /** + * {@inheritDoc} + * + * Gets the event type associated with animation end events. + */ + @Override + public com.google.gwt.event.dom.client.DomEvent.Type getAssociatedType() { + return TYPE; + } + + /** + *

Constructor for TouchMoveEvent.

+ */ + protected TouchMoveEvent() { + + } + + /** {@inheritDoc} */ + @Override + protected void dispatch(TouchMoveHandler handler) { + handler.onTouchMove(this); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchMoveHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchMoveHandler.java new file mode 100644 index 0000000..085e44c --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchMoveHandler.java @@ -0,0 +1,33 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +import com.google.gwt.event.shared.EventHandler; + +/** + * Handler for {@link TouchMoveEvent} events: + * + * @author Daniel Kurka + * @version $Id: $ + */ +public interface TouchMoveHandler extends EventHandler { + /** + * Called when a touch end move is fired. + * + * @param event the {@link TouchMoveEvent} that was fired + */ + public void onTouchMove(TouchMoveEvent event); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchStartEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchStartEvent.java new file mode 100644 index 0000000..4ee3275 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchStartEvent.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +/** + * This represents a native touch start Event + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class TouchStartEvent extends TouchEvent { + + private static final Type TYPE = new Type("touchstart", new TouchStartEvent()); + + /** + *

getType

+ * + * @return a Type object. + */ + public static Type getType() { + return TYPE; + } + + /** + * {@inheritDoc} + * + * Gets the event type associated with animation end events. + */ + @Override + public com.google.gwt.event.dom.client.DomEvent.Type getAssociatedType() { + return TYPE; + } + + /** + *

Constructor for TouchStartEvent.

+ */ + protected TouchStartEvent() { + + } + + /** {@inheritDoc} */ + @Override + protected void dispatch(TouchStartHandler handler) { + handler.onTouchStart(this); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchStartHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchStartHandler.java new file mode 100644 index 0000000..d9eec8a --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchStartHandler.java @@ -0,0 +1,33 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +import com.google.gwt.event.shared.EventHandler; + +/** + *

TouchStartHandler interface.

+ * + * @author kurt + * @version $Id: $ + */ +public interface TouchStartHandler extends EventHandler { + /** + *

onTouchStart

+ * + * @param event a {@link com.googlecode.mgwt.dom.client.event.touch.TouchStartEvent} object. + */ + public void onTouchStart(TouchStartEvent event); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchUtil.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchUtil.java new file mode 100644 index 0000000..785b61b --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/event/touch/TouchUtil.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.event.touch; + +public class TouchUtil { + public static Touch cloneTouch(Touch touch) { + return new JavaTouch(touch.getPageX(), touch.getPageY(), touch.getIdentifier()); + } +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/EventPropagator.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/EventPropagator.java new file mode 100644 index 0000000..5197309 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/EventPropagator.java @@ -0,0 +1,35 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer; + +import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.event.shared.HasHandlers; + +/** + * Propagate events + * + * @author Daniel Kurka + * + */ +public interface EventPropagator { + /** + * fire the given event on the given source + * + * @param source the source to fire the event on + * @param event the event to fire + */ + public void fireEvent(HasHandlers source, GwtEvent event); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/EventPropagatorMobileImpl.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/EventPropagatorMobileImpl.java new file mode 100644 index 0000000..43a40e7 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/EventPropagatorMobileImpl.java @@ -0,0 +1,66 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer; + +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.event.shared.HasHandlers; + +/** + * Propagate events from a source. There is an issue on mobile webkit which gets + * confused about events if an alert is shown from an event handler, see: + * http:// + * blog.daniel-kurka.de/2012/05/mobile-webkit-alert-dialog-breaks-touch.html + * + * This class provides a workaround by propagating events with a + * ScheduledCommand + * + * @author Daniel Kurka + * + */ +public class EventPropagatorMobileImpl implements EventPropagator { + + private static class SCommand implements ScheduledCommand { + private final HasHandlers source; + private final GwtEvent event; + + public SCommand(HasHandlers source, GwtEvent event) { + this.source = source; + this.event = event; + } + + @Override + public void execute() { + source.fireEvent(event); + + } + + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.recognizer.EventPropagator#fireEvent(com.google.gwt.event.shared.HasHandlers, com.google.gwt.event.shared.GwtEvent) + */ + @Override + public void fireEvent(final HasHandlers source, final GwtEvent event) { + // see issue 135 + // http://code.google.com/p/mgwt/issues/detail?id=135 + Scheduler.get().scheduleDeferred(new SCommand(source, event)); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/EventPropagatorStandardImpl.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/EventPropagatorStandardImpl.java new file mode 100644 index 0000000..9be745a --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/EventPropagatorStandardImpl.java @@ -0,0 +1,39 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer; + +import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.event.shared.HasHandlers; + +/** + * Propagate events to a source + * + * @author Daniel Kurka + * + */ +public class EventPropagatorStandardImpl implements EventPropagator { + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.recognizer.EventPropagator#fireEvent(com.google.gwt.event.shared.HasHandlers, com.google.gwt.event.shared.GwtEvent) + */ + @Override + public void fireEvent(HasHandlers source, GwtEvent event) { + source.fireEvent(event); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/SystemTimeProvider.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/SystemTimeProvider.java new file mode 100644 index 0000000..e7e2ee8 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/SystemTimeProvider.java @@ -0,0 +1,31 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer; + +/** + * A time provider that uses System.currentTimeMillis + * + * @author Daniel Kurka + * + */ +public class SystemTimeProvider implements TimeProvider { + + @Override + public long getTime() { + return System.currentTimeMillis(); + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java new file mode 100644 index 0000000..f0be3b8 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TapRecognizer.java @@ -0,0 +1,129 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.HasHandlers; +import com.google.gwt.user.client.Element; +import com.googlecode.mgwt.dom.client.event.tap.TapEvent; +import com.googlecode.mgwt.dom.client.event.touch.Touch; +import com.googlecode.mgwt.dom.client.event.touch.TouchCancelEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchEndEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartEvent; + +/** + * A recognizer that recognizes Tap events + * + * A Tap is the mobile equivalent of a click + * + * @author Daniel Kurka + * + */ +public class TapRecognizer implements TouchHandler { + + public static final int DEFAULT_DISTANCE = 15; + + private final int distance; + + private boolean touchCanceled; + + private boolean hasMoved; + + private int start_x; + + private int start_y; + + private Element targetElement; + + private final HasHandlers source; + + private EventPropagator eventPropagator; + + private static EventPropagator DEFAULT_EVENT_PROPAGATOR; + + public TapRecognizer(HasHandlers source) { + this(source, DEFAULT_DISTANCE); + } + + public TapRecognizer(HasHandlers source, int distance) { + if (source == null) + throw new IllegalArgumentException("source can not be null"); + if (distance < 0) + throw new IllegalArgumentException("distance has to be greater than zero"); + this.source = source; + this.distance = distance; + + } + + @Override + public void onTouchStart(TouchStartEvent event) { + touchCanceled = false; + hasMoved = false; + if(event.getNativeEvent() != null){ + targetElement = event.getNativeEvent().getEventTarget().cast(); + }else { + targetElement = null; + } + + start_x = event.getTouches().get(0).getPageX(); + start_y = event.getTouches().get(0).getPageY(); + } + + @Override + public void onTouchMove(TouchMoveEvent event) { + Touch touch = event.getTouches().get(0); + if (Math.abs(touch.getPageX() - start_x) > distance || Math.abs(touch.getPageY() - start_y) > distance) { + hasMoved = true; + } + + } + + @Override + public void onTouchEnd(TouchEndEvent event) { + if (!hasMoved && !touchCanceled) { + TapEvent tapEvent = new TapEvent(source, targetElement, start_x, start_y); + getEventPropagator().fireEvent(source, tapEvent); + } + + } + + @Override + public void onTouchCanceled(TouchCancelEvent event) { + touchCanceled = true; + + } + + public int getDistance() { + return distance; + } + + protected EventPropagator getEventPropagator() { + if (eventPropagator == null) { + if (DEFAULT_EVENT_PROPAGATOR == null) { + DEFAULT_EVENT_PROPAGATOR = GWT.create(EventPropagator.class); + } + eventPropagator = DEFAULT_EVENT_PROPAGATOR; + } + return eventPropagator; + } + + public Element getTargetElement() { + return targetElement; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TimeProvider.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TimeProvider.java new file mode 100644 index 0000000..4da6ba8 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TimeProvider.java @@ -0,0 +1,27 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer; + +/** + * A simple interface for making classes testable that depend on + * System.currentTimeMillis + * + * @author Daniel Kurka + * + */ +public interface TimeProvider { + public long getTime(); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TimerExecturGwtTimerImpl.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TimerExecturGwtTimerImpl.java new file mode 100644 index 0000000..7059b99 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TimerExecturGwtTimerImpl.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer; + +import com.google.gwt.user.client.Timer; + +/** + * Execute code with a GWT timer + * + * @author Daniel Kurka + * + */ +public class TimerExecturGwtTimerImpl implements TimerExecutor { + + private static class InternalTimer extends Timer { + + private final CodeToRun codeToRun; + + public InternalTimer(CodeToRun codeToRun) { + this.codeToRun = codeToRun; + } + + @Override + public void run() { + codeToRun.onExecution(); + + } + + } + + @Override + public void execute(final CodeToRun codeToRun, int time) { + new InternalTimer(codeToRun).schedule(time); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TimerExecutor.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TimerExecutor.java new file mode 100644 index 0000000..a9de3c3 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/TimerExecutor.java @@ -0,0 +1,32 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer; + +/** + * A simple interface to make classes testable that require timed code execution + * + * @author Daniel Kurka + * + */ +public interface TimerExecutor { + + public void execute(CodeToRun codeToRun, int time); + + public interface CodeToRun { + public void onExecution(); + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/HasLongTapHandlers.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/HasLongTapHandlers.java new file mode 100644 index 0000000..f92f80f --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/HasLongTapHandlers.java @@ -0,0 +1,35 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.longtap; + +import com.google.gwt.event.shared.HandlerRegistration; + +/** + * A widget that implements this interface provides support for registering for + * {@link LongTapEvent}s + * + * @author Daniel Kurka + * + */ +public interface HasLongTapHandlers { + /** + * Register for a {@link LongTapEvent} + * + * @param handler the handler to register + * @return the handler registration + */ + public HandlerRegistration addLongTapHandler(LongTapHandler handler); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapEvent.java new file mode 100644 index 0000000..9ef2f12 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapEvent.java @@ -0,0 +1,108 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.longtap; + +import com.google.gwt.event.shared.GwtEvent; +import com.googlecode.mgwt.collection.shared.LightArray; +import com.googlecode.mgwt.dom.client.event.touch.Touch; + +/** + * A long tap event is produced if the user touches an area of the display for a + * given time without moving his finger(s) + * + * @author Daniel Kurka + * + */ +public class LongTapEvent extends GwtEvent { + + private static final Type TYPE = new Type(); + + /** + * Returns the type of the event + * + * @return the type of the event + */ + public static Type getType() { + return TYPE; + } + + private final LightArray startPositions; + private final int numberOfFingers; + private final int time; + + /** + * Construct a LongTapEvent + * + * @param source - the source of the event + * @param numberOfFingers the number of fingers used + * @param time the time the fingers where touching + * @param startPositions the start position of each finger + */ + public LongTapEvent(Object source, int numberOfFingers, int time, LightArray startPositions) { + this.numberOfFingers = numberOfFingers; + this.time = time; + this.startPositions = startPositions; + setSource(source); + + } + + /* + * (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + /* + * (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) + */ + @Override + protected void dispatch(LongTapHandler handler) { + handler.onLongTap(this); + + } + + /** + * the number of fingers that created this event + * + * @return + */ + public int getNumberOfFingers() { + return numberOfFingers; + } + + /** + * the start position of all fingers + * + * @return the array of start positions + */ + public LightArray getStartPositions() { + return startPositions; + } + + /** + * the time the user held the fingers + * + * @return the time in milliseconds + */ + public int getTime() { + return time; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapHandler.java new file mode 100644 index 0000000..a8f751f --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapHandler.java @@ -0,0 +1,33 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.longtap; + +import com.google.gwt.event.shared.EventHandler; + +/** + * A Handler for {@link LongTapEvent}s + * + * @author Daniel Kurka + * + */ +public interface LongTapHandler extends EventHandler { + /** + * Called when an event is fired + * + * @param event the event + */ + public void onLongTap(LongTapEvent event); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapRecognizer.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapRecognizer.java new file mode 100644 index 0000000..d9092f4 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/longtap/LongTapRecognizer.java @@ -0,0 +1,314 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.longtap; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.HasHandlers; +import com.googlecode.mgwt.collection.shared.CollectionFactory; +import com.googlecode.mgwt.collection.shared.LightArray; +import com.googlecode.mgwt.dom.client.event.touch.Touch; +import com.googlecode.mgwt.dom.client.event.touch.TouchCancelEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchEndEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchUtil; +import com.googlecode.mgwt.dom.client.recognizer.EventPropagator; +import com.googlecode.mgwt.dom.client.recognizer.TimerExecturGwtTimerImpl; +import com.googlecode.mgwt.dom.client.recognizer.TimerExecutor; +import com.googlecode.mgwt.dom.client.recognizer.TimerExecutor.CodeToRun; + +/** + * This class can recognize long taps + * + * @author Daniel Kurka + * + */ +public class LongTapRecognizer implements TouchHandler { + + public static final int DEFAULT_WAIT_TIME_IN_MS = 1500; + public static final int DEFAULT_MAX_DISTANCE = 15; + + protected enum State { + INVALID, READY, FINGERS_DOWN, FINGERS_UP, WAITING + }; + + protected State state; + private final HasHandlers source; + private final int numberOfFingers; + private final int time; + + private LightArray startPositions; + private int touchCount; + private final int distance; + + private TimerExecutor timerExecutor; + + private EventPropagator eventPropagator; + + private static EventPropagator DEFAULT_EVENT_PROPAGATOR; + + /** + * Construct a LongTapRecognizer with that fires on one finger after 1.5s + * + * @param source the source on which to fire events on + */ + public LongTapRecognizer(HasHandlers source) { + this(source, 1); + } + + /** + * + * Construct a LongTapRecognizer with that after 1.5s + * + * @param source source the source on which to fire events on + * @param numberOfFingers the number of fingers to detect + */ + public LongTapRecognizer(HasHandlers source, int numberOfFingers) { + this(source, numberOfFingers, DEFAULT_WAIT_TIME_IN_MS); + } + + /** + * Construct a LongTapRecognizer + * + * @param source the source on which to fire events on + * @param numberOfFingers the number of fingers that should be detected + * @param time the time the fingers need to touch + */ + public LongTapRecognizer(HasHandlers source, int numberOfFingers, int time) { + this(source, numberOfFingers, time, DEFAULT_MAX_DISTANCE); + } + + /** + * Construct a LongTapRecognizer + * + * @param source the source on which to fire events on + * @param numberOfFingers the number of fingers that should be detected + * @param time the time the fingers need to touch + * @param maxDistance the maximum distance each finger is allowed to move + */ + public LongTapRecognizer(HasHandlers source, int numberOfFingers, int time, int maxDistance) { + + if (source == null) { + throw new IllegalArgumentException("source can not be null"); + } + if (numberOfFingers < 1) { + throw new IllegalArgumentException("numberOfFingers > 0"); + } + + if (time < 200) { + throw new IllegalArgumentException("time > 200"); + } + + if (maxDistance < 0) { + throw new IllegalArgumentException("maxDistance > 0"); + } + + this.source = source; + this.numberOfFingers = numberOfFingers; + this.time = time; + this.distance = maxDistance; + + state = State.READY; + startPositions = CollectionFactory.constructArray(); + touchCount = 0; + + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler#onTouchStart(com.googlecode.mgwt + * .dom.client.event.touch.TouchStartEvent) + */ + @Override + public void onTouchStart(TouchStartEvent event) { + + LightArray touches = event.getTouches(); + touchCount++; + + switch (state) { + case INVALID: + break; + case READY: + startPositions.push(TouchUtil.cloneTouch(touches.get(touchCount - 1))); + state = State.FINGERS_DOWN; + break; + case FINGERS_DOWN: + startPositions.push(TouchUtil.cloneTouch(touches.get(touchCount - 1))); + break; + case FINGERS_UP: + default: + state = State.INVALID; + break; + } + + if (touchCount == numberOfFingers) { + state = State.WAITING; + getTimerExecutor().execute(new CodeToRun() { + + @Override + public void onExecution() { + if (state != State.WAITING) { + // something else happened forget it + return; + } + + getEventPropagator().fireEvent(source, new LongTapEvent(source, numberOfFingers, time, startPositions)); + reset(); + + } + }, time); + } + + if (touchCount > numberOfFingers) { + state = State.INVALID; + } + + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler#onTouchMove(com.googlecode.mgwt + * .dom.client.event.touch.TouchMoveEvent) + */ + @Override + public void onTouchMove(TouchMoveEvent event) { + switch (state) { + case WAITING: + case FINGERS_DOWN: + case FINGERS_UP: + // compare positions + LightArray currentTouches = event.getTouches(); + for (int i = 0; i < currentTouches.length(); i++) { + Touch currentTouch = currentTouches.get(i); + for (int j = 0; j < startPositions.length(); j++) { + Touch startTouch = startPositions.get(j); + if (currentTouch.getIdentifier() == startTouch.getIdentifier()) { + if (Math.abs(currentTouch.getPageX() - startTouch.getPageX()) > distance || Math.abs(currentTouch.getPageY() - startTouch.getPageY()) > distance) { + state = State.INVALID; + break; + } + } + if (state == State.INVALID) { + break; + } + } + } + + break; + + default: + state = State.INVALID; + break; + } + + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler#onTouchEnd(com.googlecode.mgwt.dom + * .client.event.touch.TouchEndEvent) + */ + @Override + public void onTouchEnd(TouchEndEvent event) { + int currentTouches = event.getTouches().length(); + switch (state) { + case WAITING: + state = State.INVALID; + break; + + case FINGERS_DOWN: + state = State.FINGERS_UP; + break; + case FINGERS_UP: + // are we ready? + if (currentTouches == 0 && touchCount == numberOfFingers) { + // fire and reset + + reset(); + } + break; + + case INVALID: + default: + if (currentTouches == 0) + reset(); + break; + } + + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler#onTouchCanceled(com.googlecode + * .mgwt.dom.client.event.touch.TouchCancelEvent) + */ + @Override + public void onTouchCanceled(TouchCancelEvent event) { + state = State.INVALID; + int currentTouches = event.getTouches().length(); + if (currentTouches == 0) + reset(); + } + + /** + * set the timer executor - used for testing... + * + * @param timerExecutor the timer executor to use + */ + protected void setTimerExecutor(TimerExecutor timerExecutor) { + this.timerExecutor = timerExecutor; + } + + /** + * set the event propagator that is used by the recognizer - used for testing + * + * @param eventPropagator + */ + protected void setEventPropagator(EventPropagator eventPropagator) { + this.eventPropagator = eventPropagator; + + } + + protected TimerExecutor getTimerExecutor() { + if (timerExecutor == null) { + timerExecutor = new TimerExecturGwtTimerImpl(); + } + return timerExecutor; + } + + protected void reset() { + state = State.READY; + touchCount = 0; + } + + protected EventPropagator getEventPropagator() { + if (eventPropagator == null) { + if (DEFAULT_EVENT_PROPAGATOR == null) { + DEFAULT_EVENT_PROPAGATOR = GWT.create(EventPropagator.class); + } + eventPropagator = DEFAULT_EVENT_PROPAGATOR; + } + return eventPropagator; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/HasPinchHandlers.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/HasPinchHandlers.java new file mode 100644 index 0000000..d459a35 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/HasPinchHandlers.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.pinch; + +import com.google.gwt.event.shared.HandlerRegistration; + +/** + * A widget that implements this interface fires {@link PinchEvent}s + * + * @author Daniel Kurka + * + */ +public interface HasPinchHandlers { + /** + * register for {@link PinchEvent}s + * + * @param handler the handler to register + * @return the handler registration + */ + public HandlerRegistration addPinchHandler(PinchHandler handler); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/OffsetProvider.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/OffsetProvider.java new file mode 100644 index 0000000..2066e7f --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/OffsetProvider.java @@ -0,0 +1,40 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.pinch; + +/** + * {@link PinchRecognizer} needs to know about display settings to calculate a + * pinch properly, but it should not know about widgets. THis is an abstraction + * interface to encapsulate that knowledge + * + * @author Daniel + * + */ +public interface OffsetProvider { + /** + * the upper left corner of the widget + * + * @return the upper left corner in px + */ + public int getLeft(); + + /** + * the upper left corner of the widget + * + * @return the upper left corner in px + */ + public int getTop(); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/PinchEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/PinchEvent.java new file mode 100644 index 0000000..f5a996d --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/PinchEvent.java @@ -0,0 +1,107 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.pinch; + +import com.google.gwt.event.shared.GwtEvent; + +/** + * A {@link PinchEvent} is fired when a user moves to finger on the display. + * + * A pinch event is fired around a center point which is calculated by looking + * at the two fingers producing the event. + * + *

+ * if finger one is at x1, y1 and finger two is at x2, y2 the center point is + * (x1 + x2) / 2 and (y1 + y2) / 2 + *

+ * + * + * @author Daniel Kurka + * + */ +public class PinchEvent extends GwtEvent { + + private static final GwtEvent.Type TYPE = new Type(); + private final int x; + private final int y; + private final double scaleFactor; + + public static GwtEvent.Type getType() { + return TYPE; + } + + /** + * Construct a pinch event + * + * @param x the mid point of the pinch in x + * @param y the mid point of the pinch in y + * @param scaleFactor the new scaling factor + */ + public PinchEvent(int x, int y, double scaleFactor) { + this.x = x; + this.y = y; + this.scaleFactor = scaleFactor; + } + + /* + * (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + /* + * (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) + */ + @Override + protected void dispatch(PinchHandler handler) { + handler.onPinch(this); + + } + + /** + * The x position of the center point of the pinch. + * + * + * @return the x position + */ + public int getX() { + return x; + } + + /** + * The y position of the center point of the pinch. + * + * + * @return the y position + */ + public int getY() { + return y; + } + + /** + * the new scale factor that can be applied for getting a zoom effect + * + * @return the scale factor + */ + public double getScaleFactor() { + return scaleFactor; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/PinchHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/PinchHandler.java new file mode 100644 index 0000000..95690ff --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/PinchHandler.java @@ -0,0 +1,35 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.pinch; + +import com.google.gwt.event.shared.EventHandler; + +/** + * A Handler that receives {@link PinchEvent}s + * + * @author Daniel Kurka + * + */ +public interface PinchHandler extends EventHandler { + + /** + * Called if a {@link PinchEvent} occurs + * + * @param event the {@link PinchEvent} + */ + public void onPinch(PinchEvent event); + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/PinchRecognizer.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/PinchRecognizer.java new file mode 100644 index 0000000..ec9215d --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/PinchRecognizer.java @@ -0,0 +1,211 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.pinch; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.HasHandlers; +import com.googlecode.mgwt.dom.client.event.touch.Touch; +import com.googlecode.mgwt.dom.client.event.touch.TouchCancelEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchEndEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchUtil; +import com.googlecode.mgwt.dom.client.recognizer.EventPropagator; + +/** + * A PinchRecognizer tracks two finger on a screen that perform a zooming / pinching action + * + * @author Daniel Kurka + * + */ +public class PinchRecognizer implements TouchHandler { + + private static EventPropagator DEFAULT_EVENT_PROPAGATOR; + + private final HasHandlers source; + + private EventPropagator eventPropagator; + + private enum State { + READY, INVALID, ONE_FINGER, TWO_FINGER; + } + + private State state; + + private Touch touchStart1; + private Touch touchStart2; + + private int touchCount; + private double distance; + + private final OffsetProvider offsetProvider; + + /** + * Construct a {@link PinchRecognizer} + * + * @param source the source to fire events on + * @param offsetProvider the offset provider + */ + public PinchRecognizer(HasHandlers source, OffsetProvider offsetProvider) { + + if (source == null) { + throw new IllegalArgumentException("source can not be null"); + } + if (offsetProvider == null) { + throw new IllegalArgumentException("offsetProvider can not be null"); + } + + this.source = source; + this.offsetProvider = offsetProvider; + state = State.READY; + + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler#onTouchStart(com.googlecode.mgwt + * .dom.client.event.touch.TouchStartEvent) + */ + @Override + public void onTouchStart(TouchStartEvent event) { + touchCount++; + switch (state) { + case READY: + touchStart1 = TouchUtil.cloneTouch(event.getTouches().get(0)); + state = State.ONE_FINGER; + break; + case ONE_FINGER: + touchStart2 = TouchUtil.cloneTouch(event.getTouches().get(1)); + distance = (int) Math.sqrt(Math.pow(touchStart1.getPageX() - touchStart2.getPageX(), 2) + Math.pow(touchStart1.getPageY() - touchStart1.getPageY(), 2)); + state = State.TWO_FINGER; + break; + + default: + state = State.INVALID; + break; + } + + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler#onTouchMove(com.googlecode.mgwt + * .dom.client.event.touch.TouchMoveEvent) + */ + @Override + public void onTouchMove(TouchMoveEvent event) { + switch (state) { + case TWO_FINGER: + + Touch touch1 = event.getTouches().get(0); + Touch touch2 = event.getTouches().get(1); + + int left = offsetProvider.getLeft(); + int top = offsetProvider.getTop(); + + int x1 = touch1.getPageX() - left; + int y1 = touch1.getPageY() - top; + int x2 = touch2.getPageX() - left; + int y2 = touch2.getPageY() - top; + + double newDistance = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2)); + int x = (x1 + x2) / 2; + int y = (y1 + y2) / 2; + + getEventPropagator().fireEvent(source, new PinchEvent(x, y, distance / newDistance)); + distance = newDistance; + + break; + + default: + state = State.INVALID; + break; + } + + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler#onTouchEnd(com.googlecode.mgwt.dom + * .client.event.touch.TouchEndEvent) + */ + @Override + public void onTouchEnd(TouchEndEvent event) { + touchCount--; + if (touchCount <= 0) { + reset(); + } else { + if (state == State.TWO_FINGER) { + state = State.ONE_FINGER; + } else { + if (touchCount == 2) { + state = State.TWO_FINGER; + } + } + } + + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler#onTouchCanceled(com.googlecode + * .mgwt.dom.client.event.touch.TouchCancelEvent) + */ + @Override + public void onTouchCanceled(TouchCancelEvent event) { + touchCount--; + if (touchCount <= 0) { + reset(); + } else { + if (state == State.TWO_FINGER) { + state = State.ONE_FINGER; + } else { + if (touchCount == 2) { + state = State.TWO_FINGER; + } + } + } + } + + protected EventPropagator getEventPropagator() { + if (eventPropagator == null) { + if (DEFAULT_EVENT_PROPAGATOR == null) { + DEFAULT_EVENT_PROPAGATOR = GWT.create(EventPropagator.class); + } + eventPropagator = DEFAULT_EVENT_PROPAGATOR; + } + return eventPropagator; + } + + protected void setEventPropagator(EventPropagator eventPropagator) { + this.eventPropagator = eventPropagator; + + } + + private void reset() { + touchCount = 0; + state = State.READY; + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/UIObjectToOffsetProvider.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/UIObjectToOffsetProvider.java new file mode 100644 index 0000000..2a045ab --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/pinch/UIObjectToOffsetProvider.java @@ -0,0 +1,45 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.pinch; + +import com.google.gwt.user.client.ui.UIObject; + +/** + * Brigde from widget / UIObject to Offsetprovider + * + * @author Daniel Kurka + * + */ +public class UIObjectToOffsetProvider implements OffsetProvider { + + private final UIObject uiObject; + + public UIObjectToOffsetProvider(UIObject uiObject) { + this.uiObject = uiObject; + + } + + @Override + public int getLeft() { + return uiObject.getAbsoluteLeft(); + } + + @Override + public int getTop() { + return uiObject.getAbsoluteTop(); + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/HasSwipeHandlers.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/HasSwipeHandlers.java new file mode 100644 index 0000000..8fd858b --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/HasSwipeHandlers.java @@ -0,0 +1,51 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.swipe; + +import com.google.gwt.event.shared.HandlerRegistration; + +/** + * A widget that implements this interface sources {@link SwipeStartEvent}s, + * {@link SwipeMoveEvent}s and {@link SwipeEndEvent}s + * + * @author Daniel Kurka + * + */ +public interface HasSwipeHandlers { + /** + * register for a {@link SwipeStartEvent} + * + * @param handler the handler to register + * @return the {@link HandlerRegistration} + */ + public HandlerRegistration addSwipeStartHandler(SwipeStartHandler handler); + + /** + * register for a {@link SwipeMoveHandler} + * + * @param handler the handler to register + * @return the {@link HandlerRegistration} + */ + public HandlerRegistration addSwipeMoveHandler(SwipeMoveHandler handler); + + /** + * register for a {@link SwipeEndHandler} + * + * @param handler the handler to register + * @return the {@link HandlerRegistration} + */ + public HandlerRegistration addSwipeEndHandler(SwipeEndHandler handler); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeEndEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeEndEvent.java new file mode 100644 index 0000000..55218f2 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeEndEvent.java @@ -0,0 +1,86 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.swipe; + +import com.google.gwt.event.shared.GwtEvent; + +/** + * A {@link SwipeEndEvent} occurs when the user lifts his finger of the display + * + * @author Daniel Kurka + * + */ +public class SwipeEndEvent extends SwipeEvent { + + private final static GwtEvent.Type TYPE = new Type(); + private final boolean distanceReached; + private final int distance; + + public static GwtEvent.Type getType() { + return TYPE; + } + + /** + * Construct a swipe end event + * + * @param distanceReached was the minumum distance reached + * @param distance the distance that was covered by the finger + * @param direction the direction of the swipe + */ + public SwipeEndEvent(boolean distanceReached, int distance, SwipeEvent.DIRECTION direction) { + super(direction); + this.distanceReached = distanceReached; + this.distance = distance; + } + + /* + * (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + /* + * (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) + */ + @Override + protected void dispatch(SwipeEndHandler handler) { + handler.onSwipeEnd(this); + + } + + /** + * the distance the finger has covered in px + * + * @return the distance in px + */ + public int getDistance() { + return distance; + } + + /** + * is the minimum distance reached by this swipe + * + * @return true if minimum distance was reached + */ + public boolean isDistanceReached() { + return distanceReached; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeEndHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeEndHandler.java new file mode 100644 index 0000000..a357501 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeEndHandler.java @@ -0,0 +1,33 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.swipe; + +import com.google.gwt.event.shared.EventHandler; + +/** + * A {@link SwipeEndHandler} receives {@link SwipeEndEvent}s + * + * @author Daniel Kurka + * + */ +public interface SwipeEndHandler extends EventHandler { + /** + * Called when a {@link SwipeEndEvent} occurs + * + * @param event the event + */ + public void onSwipeEnd(SwipeEndEvent event); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeEvent.java new file mode 100644 index 0000000..d1b9035 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeEvent.java @@ -0,0 +1,55 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.swipe; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; + +/** + * base class for all swipte events + * + * @author Daniel Kurka + * + * @param Handler type of the event + */ +public abstract class SwipeEvent extends GwtEvent { + + public enum DIRECTION { + LEFT_TO_RIGHT, RIGHT_TO_LEFT, TOP_TO_BOTTOM, BOTTOM_TO_TOP; + } + + private final DIRECTION direction; + + /** + * Construct a swipe event with a given direction + * + * @param direction the direction to use + */ + public SwipeEvent(DIRECTION direction) { + this.direction = direction; + + } + + /** + * the direction of the event + * + * @return the direction + */ + public DIRECTION getDirection() { + return direction; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeMoveEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeMoveEvent.java new file mode 100644 index 0000000..a2131ee --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeMoveEvent.java @@ -0,0 +1,96 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.swipe; + +import com.google.gwt.event.shared.GwtEvent; +import com.googlecode.mgwt.dom.client.event.touch.Touch; + +/** + * A {@link SwipeMoveEvent} occurs when the user moves his finger over the + * display + * + * @author Daniel Kurka + * + */ +public class SwipeMoveEvent extends SwipeEvent { + + private final static GwtEvent.Type TYPE = new Type(); + private final boolean distanceReached; + private final int distance; + private final Touch touch; + + public static GwtEvent.Type getType() { + return TYPE; + } + + /** + * Construct a {@link SwipeMoveEvent} + * + * @param touch + * + * @param distanceReached is the minimum distance reached for this swipe + * @param distance the distance in px + * @param direction the direction of the swipe + */ + public SwipeMoveEvent(Touch touch, boolean distanceReached, int distance, SwipeEvent.DIRECTION direction) { + super(direction); + this.touch = touch; + this.distanceReached = distanceReached; + this.distance = distance; + } + + /* + * (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + /* + * (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) + */ + @Override + protected void dispatch(SwipeMoveHandler handler) { + handler.onSwipeMove(this); + + } + + /** + * the distance of this swipe + * + * @return the distance of this swipe in px + */ + public int getDistance() { + return distance; + } + + /** + * is the minimum distance reached + * + * @return true if the minimum distance reached + */ + public boolean isDistanceReached() { + return distanceReached; + } + + public Touch getTouch() { + return touch; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeMoveHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeMoveHandler.java new file mode 100644 index 0000000..ba9cf80 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeMoveHandler.java @@ -0,0 +1,33 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.swipe; + +import com.google.gwt.event.shared.EventHandler; + +/** + * A {@link SwipeMoveHandler} receives {@link SwipeMoveEvent}s + * + * @author Daniel Kurka + * + */ +public interface SwipeMoveHandler extends EventHandler { + /** + * called when a {@link SwipeMoveEvent} occurs + * + * @param event the event + */ + public void onSwipeMove(SwipeMoveEvent event); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeRecognizer.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeRecognizer.java new file mode 100644 index 0000000..5bb25a6 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeRecognizer.java @@ -0,0 +1,287 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.swipe; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.HasHandlers; +import com.googlecode.mgwt.dom.client.event.touch.Touch; +import com.googlecode.mgwt.dom.client.event.touch.TouchCancelEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchEndEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartEvent; +import com.googlecode.mgwt.dom.client.recognizer.EventPropagator; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeEvent.DIRECTION; + +public class SwipeRecognizer implements TouchHandler { + + private static EventPropagator DEFAULT_EVENT_PROPAGATOR; + + private final HasHandlers source; + + private EventPropagator eventPropagator; + + private final int minDistance; + + private final int threshold; + + private int touchCount; + + private enum State { + INVALID, READY, FINDER_DOWN, FOUND_DIRECTION + } + + private State state; + + private DIRECTION direction; + + private int lastDistance; + + private int x; + + private int y; + + /** + * construct a swipe recognizer + * + * @param source the source to fire events on + */ + public SwipeRecognizer(HasHandlers source) { + this(source, 40); + } + + /** + * construct a swipe recognizer + * + * @param source the source to fire events on + * @param minDistance the minimum distance to cover before this counts as a swipe + */ + public SwipeRecognizer(HasHandlers source, int minDistance) { + this(source, minDistance, 10); + } + + /** + * construct a swipe recognizer + * + * @param source the source to fire events on + * @param minDistance the minimum distance to cover before this counts as a swipe + * @param threshold the initial threshold before swipe start is fired + */ + public SwipeRecognizer(HasHandlers source, int minDistance, int threshold) { + if (source == null) + throw new IllegalArgumentException("source can not be null"); + + if (minDistance <= 0 || minDistance < threshold) { + throw new IllegalArgumentException("minDistance > 0 and minDistance > threshold"); + } + + if (threshold <= 0) { + throw new IllegalArgumentException("threshold > 0"); + } + + this.source = source; + this.minDistance = minDistance; + this.threshold = threshold; + this.touchCount = 0; + state = State.READY; + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler#onTouchStart(com.googlecode.mgwt + * .dom.client.event.touch.TouchStartEvent) + */ + @Override + public void onTouchStart(TouchStartEvent event) { + touchCount++; + + switch (state) { + case INVALID: + break; + + case READY: + state = State.FINDER_DOWN; + + x = event.getTouches().get(0).getPageX(); + y = event.getTouches().get(0).getPageY(); + break; + + case FINDER_DOWN: + default: + state = State.INVALID; + break; + } + + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler#onTouchMove(com.googlecode.mgwt + * .dom.client.event.touch.TouchMoveEvent) + */ + @Override + public void onTouchMove(TouchMoveEvent event) { + Touch touch = event.getTouches().get(0); + + switch (state) { + case INVALID: + + break; + case READY: + // WTF? + state = State.INVALID; + break; + case FINDER_DOWN: + + // log(" X: " + touch.getPageX() + " old: " + touchStart.getPageX() + " test: " + x); + + if (Math.abs(touch.getPageX() - x) >= threshold) { + state = State.FOUND_DIRECTION; + + direction = touch.getPageX() - x > 0 ? DIRECTION.LEFT_TO_RIGHT : DIRECTION.RIGHT_TO_LEFT; + + SwipeStartEvent swipeStartEvent = new SwipeStartEvent(touch, touch.getPageX() - x, direction); + + getEventPropagator().fireEvent(source, swipeStartEvent); + + } else { + if (Math.abs(touch.getPageY() - y) >= threshold) { + state = State.FOUND_DIRECTION; + + direction = touch.getPageY() - y > 0 ? DIRECTION.TOP_TO_BOTTOM : DIRECTION.BOTTOM_TO_TOP; + + SwipeStartEvent swipeStartEvent = new SwipeStartEvent(touch, touch.getPageY() - y, direction); + + getEventPropagator().fireEvent(source, swipeStartEvent); + + } + + } + break; + + case FOUND_DIRECTION: + + switch (direction) { + case TOP_TO_BOTTOM: + case BOTTOM_TO_TOP: + lastDistance = Math.abs(touch.getPageY() - y); + getEventPropagator().fireEvent(source, new SwipeMoveEvent(touch, lastDistance > minDistance, lastDistance, direction)); + break; + + case LEFT_TO_RIGHT: + case RIGHT_TO_LEFT: + lastDistance = Math.abs(touch.getPageX() - x); + getEventPropagator().fireEvent(source, new SwipeMoveEvent(touch, lastDistance > minDistance, lastDistance, direction)); + + break; + + default: + break; + } + + break; + + default: + break; + } + + } + + public native void log(String l)/*-{ + $wnd.console.log(l); + }-*/; + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler#onTouchEnd(com.googlecode.mgwt.dom + * .client.event.touch.TouchEndEvent) + */ + @Override + public void onTouchEnd(TouchEndEvent event) { + touchCount--; + + switch (state) { + case FOUND_DIRECTION: + getEventPropagator().fireEvent(source, new SwipeEndEvent(lastDistance > minDistance, lastDistance, direction)); + reset(); + break; + + default: + reset(); + break; + } + + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler#onTouchCanceled(com.googlecode + * .mgwt.dom.client.event.touch.TouchCancelEvent) + */ + @Override + public void onTouchCanceled(TouchCancelEvent event) { + touchCount--; + if (touchCount <= 0) + reset(); + + } + + /** + * the threshold before an event is fired (deadzone) + * + * @return the threshold in px + */ + public int getThreshold() { + return threshold; + } + + /** + * the distance that needs to be covered before counting as a swipe + * + * @return the distance in px + */ + public int getMinDistance() { + return minDistance; + } + + protected EventPropagator getEventPropagator() { + if (eventPropagator == null) { + if (DEFAULT_EVENT_PROPAGATOR == null) { + DEFAULT_EVENT_PROPAGATOR = GWT.create(EventPropagator.class); + } + eventPropagator = DEFAULT_EVENT_PROPAGATOR; + } + return eventPropagator; + } + + protected void setEventPropagator(EventPropagator eventPropagator) { + this.eventPropagator = eventPropagator; + + } + + private void reset() { + state = State.READY; + touchCount = 0; + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeStartEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeStartEvent.java new file mode 100644 index 0000000..d739cb4 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeStartEvent.java @@ -0,0 +1,85 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.swipe; + +import com.google.gwt.event.shared.GwtEvent; +import com.googlecode.mgwt.dom.client.event.touch.Touch; + +/** + * A {@link SwipeStartEvent} is fired when the user moves his finger over a + * certain amount on the display + * + * @author Daniel Kurka + * + */ +public class SwipeStartEvent extends SwipeEvent { + + private final static GwtEvent.Type TYPE = new Type(); + private final int distance; + private final Touch touch; + + public static GwtEvent.Type getType() { + return TYPE; + } + + /** + * Construct a {@link SwipeStartEvent} + * + * @param distance the distance the finger already moved + * @param j + * @param i + * @param direction the direction of the finger + */ + public SwipeStartEvent(Touch touch, int distance, SwipeEvent.DIRECTION direction) { + super(direction); + this.touch = touch; + this.distance = distance; + + } + + /* + * (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + /** + * The distance the finger moved before the event occured + * + * @return the distance in px + */ + public int getDistance() { + return distance; + } + + /* + * (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) + */ + @Override + protected void dispatch(SwipeStartHandler handler) { + handler.onSwipeStart(this); + + } + + public Touch getTouch() { + return touch; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeStartHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeStartHandler.java new file mode 100644 index 0000000..e9b47dc --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/swipe/SwipeStartHandler.java @@ -0,0 +1,35 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.swipe; + +import com.google.gwt.event.shared.EventHandler; + +/** + * A {@link SwipeStartHandler} receives {@link SwipeStartEvent}s + * + * @author Daniel Kurka + * + */ +public interface SwipeStartHandler extends EventHandler { + + /** + * called when a {@link SwipeStartEvent} occurs + * + * @param event the event + */ + void onSwipeStart(SwipeStartEvent event); + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/tap/MultiTapEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/tap/MultiTapEvent.java new file mode 100644 index 0000000..6f5071c --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/tap/MultiTapEvent.java @@ -0,0 +1,99 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.tap; + +import com.google.gwt.event.shared.GwtEvent; +import com.googlecode.mgwt.collection.shared.LightArray; +import com.googlecode.mgwt.dom.client.event.touch.Touch; + +/** + * A {@link MultiTapEvent} occurs if the taps multiple times on the screen + * + * @author Daniel Kurka + * + */ +public class MultiTapEvent extends GwtEvent { + + private static final GwtEvent.Type TYPE = new Type(); + + public static GwtEvent.Type getType() { + return TYPE; + } + + private final int numberOfFingers; + private final LightArray> touchStarts; + private final int numberOfTaps; + + /** + * Construct a Multitap event + * + * @param numberOfFingers the number of fingers that tapped on the screen + * @param numberOfTaps the number of times the screen was tapped + * @param touchStarts the position of the fingers that started the taps + */ + public MultiTapEvent(int numberOfFingers, int numberOfTaps, LightArray> touchStarts) { + this.numberOfFingers = numberOfFingers; + this.numberOfTaps = numberOfTaps; + this.touchStarts = touchStarts; + } + + /** + * get the number of fingers that tapped on the screen + * + * @return the number of fingers that tapped on the screen + */ + public int getNumberOfFinders() { + return numberOfFingers; + } + + /** + * get the position of the fingers that started the taps + * + * @return the position of the fingers that started the taps + */ + public LightArray> getTouchStarts() { + return touchStarts; + } + + /** + * get the number of times the screen was tapped + * + * @return the number of times the screen was tapped + */ + public int getNumberOfTabs() { + return numberOfTaps; + } + + /* + * (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + /* + * (non-Javadoc) + * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler) + */ + @Override + protected void dispatch(MultiTapHandler handler) { + handler.onMultiTap(this); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/tap/MultiTapHandler.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/tap/MultiTapHandler.java new file mode 100644 index 0000000..196dd6c --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/tap/MultiTapHandler.java @@ -0,0 +1,33 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.tap; + +import com.google.gwt.event.shared.EventHandler; + +/** + * A {@link MultiTapHandler} receives {@link MultiTapEvent}s + * + * @author Daniel Kurka + * + */ +public interface MultiTapHandler extends EventHandler { + /** + * called when an {@link MultiTapEvent} occurs. + * + * @param event the event + */ + public void onMultiTap(MultiTapEvent event); +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/tap/MultiTapRecognizer.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/tap/MultiTapRecognizer.java new file mode 100644 index 0000000..5a29782 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/dom/client/recognizer/tap/MultiTapRecognizer.java @@ -0,0 +1,305 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.dom.client.recognizer.tap; + +import com.google.gwt.event.shared.HasHandlers; +import com.googlecode.mgwt.collection.shared.CollectionFactory; +import com.googlecode.mgwt.collection.shared.LightArray; +import com.googlecode.mgwt.dom.client.event.touch.Touch; +import com.googlecode.mgwt.dom.client.event.touch.TouchCancelEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchEndEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchUtil; +import com.googlecode.mgwt.dom.client.recognizer.SystemTimeProvider; +import com.googlecode.mgwt.dom.client.recognizer.TimeProvider; + +/** + * A {@link MultiTapRecognizer} recognizes multiple taps with multiple fingers on the screen + * + * @author Daniel Kurka + * + */ +public class MultiTapRecognizer implements TouchHandler { + + public static final int DEFAULT_DISTANCE = 15; + public static final int DEFAULT_TIME_IN_MS = 300; + + private final HasHandlers source; + private final int distance; + private final int time; + private final int numberOfTabs; + + private int touchCount; + + private LightArray touches; + private final int numberOfFingers; + + private TimeProvider timeProvider; + + private enum State { + READY, FINGERS_GOING_DOWN, FINGERS_GOING_UP, INVALID + } + + private State state; + private int foundTaps; + private int touchMax; + private long lastTime; + + private LightArray> savedStartTouches; + + /** + * Construct a {@link MultiTapRecognizer} + * + * @param source the source on which behalf to fire events on + * @param numberOfFingers the number of fingers needed for a tap + */ + public MultiTapRecognizer(HasHandlers source, int numberOfFingers) { + this(source, numberOfFingers, 1, DEFAULT_DISTANCE, DEFAULT_TIME_IN_MS); + } + + /** + * Construct a {@link MultiTapRecognizer} + * + * @param source the source on which behalf to fire events on + * @param numberOfFingers the number of fingers needed for a tap + * @param numberOfTabs the number of times all fingers have to touch and leave the display + */ + public MultiTapRecognizer(HasHandlers source, int numberOfFingers, int numberOfTabs) { + this(source, numberOfFingers, numberOfTabs, DEFAULT_DISTANCE, DEFAULT_TIME_IN_MS); + } + + /** + * Construct a {@link MultiTapRecognizer} + * + * @param source the source on which behalf to fire events on + * @param numberOfFingers the number of fingers needed for a tap + * @param numberOfTabs the number of times all fingers have to touch and leave the display + * @param distance the maximum distance a finger can move on the display + */ + public MultiTapRecognizer(HasHandlers source, int numberOfFingers, int numberOfTabs, int distance) { + this(source, numberOfFingers, numberOfTabs, distance, DEFAULT_TIME_IN_MS); + } + + /** + * Construct a {@link MultiTapRecognizer} + * + * @param source the source on which behalf to fire events on + * @param numberOfFingers the number of fingers needed for a tap + * @param numberOfTabs the number of times all fingers have to touch and leave the display + * @param distance the maximum distance a finger can move on the display + * @param time the maximum amount of time for the gesture to happen + */ + public MultiTapRecognizer(HasHandlers source, int numberOfFingers, int numberOfTabs, int distance, int time) { + + if (source == null) + throw new IllegalArgumentException("source can not be null"); + + if (numberOfFingers < 1) { + throw new IllegalArgumentException("numberOfFingers > 0"); + } + + if (numberOfTabs < 1) { + throw new IllegalArgumentException("numberOfTabs > 0"); + } + + if (distance < 0) + throw new IllegalArgumentException("distance > 0"); + + if (time < 1) { + throw new IllegalArgumentException("time > 0"); + } + this.source = source; + this.numberOfFingers = numberOfFingers; + this.numberOfTabs = numberOfTabs; + this.distance = distance; + this.time = time; + touchCount = 0; + touches = CollectionFactory.constructArray(); + savedStartTouches = CollectionFactory.constructArray(); + state = State.READY; + foundTaps = 0; + timeProvider = new SystemTimeProvider(); + + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler#onTouchStart(com.googlecode.mgwt + * .dom.client.event.touch.TouchStartEvent) + */ + @Override + public void onTouchStart(TouchStartEvent event) { + touchCount++; + LightArray currentTouches = event.getTouches(); + + switch (state) { + case READY: + touches.push(TouchUtil.cloneTouch(currentTouches.get(touchCount - 1))); + state = State.FINGERS_GOING_DOWN; + break; + + case FINGERS_GOING_DOWN: + touches.push(TouchUtil.cloneTouch(currentTouches.get(touchCount - 1))); + break; + + case FINGERS_GOING_UP: + default: + state = State.INVALID; + break; + } + + if (touchCount > numberOfFingers) { + state = State.INVALID; + } + + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler#onTouchMove(com.googlecode.mgwt + * .dom.client.event.touch.TouchMoveEvent) + */ + @Override + public void onTouchMove(TouchMoveEvent event) { + switch (state) { + case FINGERS_GOING_DOWN: + case FINGERS_GOING_UP: + // compare positions + LightArray currentTouches = event.getTouches(); + for (int i = 0; i < currentTouches.length(); i++) { + Touch currentTouch = currentTouches.get(i); + for (int j = 0; j < touches.length(); j++) { + Touch startTouch = touches.get(j); + if (currentTouch.getIdentifier() == startTouch.getIdentifier()) { + if (Math.abs(currentTouch.getPageX() - startTouch.getPageX()) > distance || Math.abs(currentTouch.getPageY() - startTouch.getPageY()) > distance) { + state = State.INVALID; + break; + } + } + if (state == State.INVALID) { + break; + } + } + } + + break; + + default: + break; + } + + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler#onTouchEnd(com.googlecode.mgwt.dom + * .client.event.touch.TouchEndEvent) + */ + @Override + public void onTouchEnd(TouchEndEvent event) { + + switch (state) { + case FINGERS_GOING_DOWN: + state = State.FINGERS_GOING_UP; + touchMax = touchCount; + + touchCount--; + handleTouchEnd(); + break; + case FINGERS_GOING_UP: + touchCount--; + handleTouchEnd(); + break; + + case INVALID: + case READY: + savedStartTouches = CollectionFactory.constructArray(); + if (event.getTouches().length() == 0) + reset(); + break; + default: + reset(); + break; + } + + } + + /* + * (non-Javadoc) + * + * @see + * com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler#onTouchCanceled(com.googlecode + * .mgwt.dom.client.event.touch.TouchCancelEvent) + */ + @Override + public void onTouchCanceled(TouchCancelEvent event) { + state = State.INVALID; + reset(); + + } + + protected void handleTouchEnd() { + if (touchCount == 0) { + // found one successful tap + if (foundTaps > 0) { + // check time otherwise invalid + if (timeProvider.getTime() - lastTime > time) { + savedStartTouches = CollectionFactory.constructArray(); + reset(); + return; + } + } + foundTaps++; + lastTime = timeProvider.getTime(); + + // remember touches + savedStartTouches.push(touches); + + if (foundTaps == numberOfTabs) { + + MultiTapEvent multiTapEvent = new MultiTapEvent(touchMax, numberOfTabs, savedStartTouches); + source.fireEvent(multiTapEvent); + savedStartTouches = CollectionFactory.constructArray(); + reset(); + } else { + state = State.READY; + touches = CollectionFactory.constructArray(); + } + + } + } + + protected void reset() { + touchCount = 0; + foundTaps = 0; + touches = CollectionFactory.constructArray(); + state = State.READY; + } + + protected void setTimeProvider(TimeProvider timeProvider) { + if (timeProvider == null) { + throw new IllegalArgumentException("timeprovider can not be null"); + } + this.timeProvider = timeProvider; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/UI.gwt.xml b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/UI.gwt.xml new file mode 100644 index 0000000..82c980e --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/UI.gwt.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/util/NoopHandlerRegistration.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/util/NoopHandlerRegistration.java new file mode 100644 index 0000000..ad3bb83 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/util/NoopHandlerRegistration.java @@ -0,0 +1,34 @@ +/* + * + * Copyright 2011 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.util; + +import com.google.gwt.event.shared.HandlerRegistration; + +/** + * A handler registration that does nothing on remove handler + * + * @author Daniel Kurka + * + */ +public class NoopHandlerRegistration implements HandlerRegistration { + + @Override + public void removeHandler() { + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/BeforeScrollEndEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/BeforeScrollEndEvent.java new file mode 100644 index 0000000..f32b7cc --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/BeforeScrollEndEvent.java @@ -0,0 +1,54 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.event.scroll; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchEvent; + +public class BeforeScrollEndEvent extends GwtEvent { + + public interface Handler extends EventHandler { + public void onBeforeScrollStart(BeforeScrollEndEvent event); + } + + private static GwtEvent.Type TYPE = new Type(); + private final TouchEvent event; + + public BeforeScrollEndEvent(TouchEvent event) { + this.event = event; + } + + public static GwtEvent.Type getTYPE() { + return TYPE; + } + + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(Handler handler) { + handler.onBeforeScrollStart(this); + + } + + public TouchEvent getEvent() { + return event; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/BeforeScrollMoveEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/BeforeScrollMoveEvent.java new file mode 100644 index 0000000..3e8b44a --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/BeforeScrollMoveEvent.java @@ -0,0 +1,55 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.event.scroll; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveEvent; + +public class BeforeScrollMoveEvent extends GwtEvent { + + public interface Handler extends EventHandler { + public void onBeforeScrollMove(BeforeScrollMoveEvent event); + } + + private static GwtEvent.Type TYPE = new Type(); + private final TouchMoveEvent event; + + public BeforeScrollMoveEvent(TouchMoveEvent event) { + this.event = event; + + } + + public static GwtEvent.Type getTYPE() { + return TYPE; + } + + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(Handler handler) { + handler.onBeforeScrollMove(this); + + } + + public TouchMoveEvent getEvent() { + return event; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/BeforeScrollStartEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/BeforeScrollStartEvent.java new file mode 100644 index 0000000..c376079 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/BeforeScrollStartEvent.java @@ -0,0 +1,54 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.event.scroll; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartEvent; + +public class BeforeScrollStartEvent extends GwtEvent { + + public interface Handler extends EventHandler { + public void onBeforeScrollStart(BeforeScrollStartEvent event); + } + + private static GwtEvent.Type TYPE = new Type(); + private final TouchStartEvent event; + + public BeforeScrollStartEvent(TouchStartEvent event) { + this.event = event; + } + + public static GwtEvent.Type getTYPE() { + return TYPE; + } + + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(Handler handler) { + handler.onBeforeScrollStart(this); + + } + + public TouchStartEvent getEvent() { + return event; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollAnimationEndEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollAnimationEndEvent.java new file mode 100644 index 0000000..7ebdd8b --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollAnimationEndEvent.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.event.scroll; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; + +public class ScrollAnimationEndEvent extends GwtEvent { + + public interface Handler extends EventHandler { + public void onScrollAnimationEnd(ScrollAnimationEndEvent event); + } + + private static GwtEvent.Type TYPE = new Type(); + + public ScrollAnimationEndEvent() { + + } + + public static GwtEvent.Type getTYPE() { + return TYPE; + } + + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(Handler handler) { + handler.onScrollAnimationEnd(this); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollAnimationMoveEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollAnimationMoveEvent.java new file mode 100644 index 0000000..454b9c8 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollAnimationMoveEvent.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.event.scroll; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; + +public class ScrollAnimationMoveEvent extends GwtEvent { + + public interface Handler extends EventHandler { + public void onScrollAnimationMove(ScrollAnimationMoveEvent event); + } + + private static GwtEvent.Type TYPE = new Type(); + + public ScrollAnimationMoveEvent() { + + } + + public static GwtEvent.Type getTYPE() { + return TYPE; + } + + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(Handler handler) { + handler.onScrollAnimationMove(this); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollAnimationStartEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollAnimationStartEvent.java new file mode 100644 index 0000000..45be86d --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollAnimationStartEvent.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.event.scroll; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; + +public class ScrollAnimationStartEvent extends GwtEvent { + + public interface Handler extends EventHandler { + public void onScrollAnimationStart(ScrollAnimationStartEvent event); + } + + private static GwtEvent.Type TYPE = new Type(); + + public ScrollAnimationStartEvent() { + + } + + public static GwtEvent.Type getTYPE() { + return TYPE; + } + + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(Handler handler) { + handler.onScrollAnimationStart(this); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollEndEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollEndEvent.java new file mode 100644 index 0000000..d9594e8 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollEndEvent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.event.scroll; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; + +public class ScrollEndEvent extends GwtEvent { + + public interface Handler extends EventHandler { + public void onScrollEnd(ScrollEndEvent event); + } + + private static GwtEvent.Type TYPE = new Type(); + + public static GwtEvent.Type getTYPE() { + return TYPE; + } + + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(Handler handler) { + handler.onScrollEnd(this); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollMoveEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollMoveEvent.java new file mode 100644 index 0000000..48b3b05 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollMoveEvent.java @@ -0,0 +1,54 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.event.scroll; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveEvent; + +public class ScrollMoveEvent extends GwtEvent { + + public interface Handler extends EventHandler { + public void onScrollMove(ScrollMoveEvent event); + } + + private static GwtEvent.Type TYPE = new Type(); + private final TouchMoveEvent event; + + public ScrollMoveEvent(TouchMoveEvent event) { + this.event = event; + } + + public static GwtEvent.Type getTYPE() { + return TYPE; + } + + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(Handler handler) { + handler.onScrollMove(this); + + } + + public TouchMoveEvent getEvent() { + return event; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollRefreshEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollRefreshEvent.java new file mode 100644 index 0000000..84a11ab --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollRefreshEvent.java @@ -0,0 +1,44 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.event.scroll; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; + +public class ScrollRefreshEvent extends GwtEvent { + + public interface Handler extends EventHandler { + public void onScrollRefresh(ScrollRefreshEvent event); + } + + private static GwtEvent.Type TYPE = new Type(); + + public static GwtEvent.Type getTYPE() { + return TYPE; + } + + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(Handler handler) { + handler.onScrollRefresh(this); + + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollStartEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollStartEvent.java new file mode 100644 index 0000000..a11ca38 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollStartEvent.java @@ -0,0 +1,55 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.event.scroll; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartEvent; + +public class ScrollStartEvent extends GwtEvent { + + public interface Handler extends EventHandler { + public void onScrollStart(ScrollStartEvent event); + } + + private static GwtEvent.Type TYPE = new Type(); + private final TouchStartEvent event; + + public ScrollStartEvent(TouchStartEvent event) { + this.event = event; + + } + + public static GwtEvent.Type getTYPE() { + return TYPE; + } + + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(Handler handler) { + handler.onScrollStart(this); + + } + + public TouchStartEvent getEvent() { + return event; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollTouchEndEvent.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollTouchEndEvent.java new file mode 100644 index 0000000..7a18edb --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/event/scroll/ScrollTouchEndEvent.java @@ -0,0 +1,55 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.event.scroll; + +import com.google.gwt.event.shared.EventHandler; +import com.google.gwt.event.shared.GwtEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartEvent; + +public class ScrollTouchEndEvent extends GwtEvent { + + public interface Handler extends EventHandler { + public void onScrollTouchEnd(ScrollTouchEndEvent event); + } + + private static GwtEvent.Type TYPE = new Type(); + private final TouchStartEvent event; + + public ScrollTouchEndEvent(TouchStartEvent event) { + this.event = event; + + } + + public static GwtEvent.Type getTYPE() { + return TYPE; + } + + @Override + public com.google.gwt.event.shared.GwtEvent.Type getAssociatedType() { + return TYPE; + } + + @Override + protected void dispatch(Handler handler) { + handler.onScrollTouchEnd(this); + + } + + public TouchStartEvent getEvent() { + return event; + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/GestureUtility.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/GestureUtility.java new file mode 100644 index 0000000..8ad35c7 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/GestureUtility.java @@ -0,0 +1,114 @@ +/* + * Copyright 2012 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.touch; + +import com.google.gwt.user.client.ui.UIObject; +import com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers; +import com.googlecode.mgwt.dom.client.recognizer.TapRecognizer; +import com.googlecode.mgwt.dom.client.recognizer.longtap.LongTapRecognizer; +import com.googlecode.mgwt.dom.client.recognizer.pinch.PinchRecognizer; +import com.googlecode.mgwt.dom.client.recognizer.pinch.UIObjectToOffsetProvider; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeRecognizer; + +/** + * {@link GestureUtility} is a utility class for adding standard recognizers to a widget + * + * @author Daniel Kurka + * + */ +public class GestureUtility { + private TapRecognizer tapRecognizer; + private final HasTouchHandlers source; + private LongTapRecognizer longTapRecognizer; + private SwipeRecognizer swipeRecognizer; + private PinchRecognizer pinchRecognizer; + + /** + * Construct a {@link GestureUtility} for a given source + * + * @param source the source to use + */ + public GestureUtility(HasTouchHandlers source) { + assert source != null; + this.source = source; + } + + /** + * ensure that there is a registered {@link TapRecognizer} on the source + */ + public void ensureTapRecognizer() { + if (tapRecognizer != null) + return; + + tapRecognizer = new TapRecognizer(source); + source.addTouchHandler(tapRecognizer); + } + + /** + * ensure that there is a registered {@link LongTapRecognizer} on the source + */ + public void ensureLongTapRecognizer() { + if (longTapRecognizer != null) { + return; + } + + longTapRecognizer = new LongTapRecognizer(source); + source.addTouchHandler(longTapRecognizer); + + } + + /** + * ensure that there is a registered {@link SwipeRecognizer} on the source + */ + public void ensureSwipeRecognizer() { + if (swipeRecognizer != null) { + return; + } + + swipeRecognizer = new SwipeRecognizer(source); + source.addTouchHandler(swipeRecognizer); + + } + + /** + * ensure that there is a registered {@link PinchRecognizer} on the source + * + * @param object the {@link UIObject} that is used for offset + * + */ + public void ensurePinchRecognizer(UIObject object) { + if (pinchRecognizer != null) { + return; + } + + pinchRecognizer = new PinchRecognizer(source, new UIObjectToOffsetProvider(object)); + source.addTouchHandler(pinchRecognizer); + + } + + /** + * ensure that there is a registered {@link LongTapRecognizer} on the source + */ + public void ensureLongTapHandler() { + if (longTapRecognizer != null) { + return; + } + + longTapRecognizer = new LongTapRecognizer(source); + source.addTouchHandler(longTapRecognizer); + + } +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchDelegate.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchDelegate.java new file mode 100644 index 0000000..2bf3c1b --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchDelegate.java @@ -0,0 +1,163 @@ +/* + * Copyright 2011 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.touch; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.Widget; +import com.googlecode.mgwt.dom.client.event.mouse.HandlerRegistrationCollection; +import com.googlecode.mgwt.dom.client.event.tap.HasTapHandlers; +import com.googlecode.mgwt.dom.client.event.tap.TapEvent; +import com.googlecode.mgwt.dom.client.event.tap.TapHandler; +import com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers; +import com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler; +import com.googlecode.mgwt.dom.client.recognizer.longtap.HasLongTapHandlers; +import com.googlecode.mgwt.dom.client.recognizer.longtap.LongTapEvent; +import com.googlecode.mgwt.dom.client.recognizer.longtap.LongTapHandler; +import com.googlecode.mgwt.dom.client.recognizer.pinch.HasPinchHandlers; +import com.googlecode.mgwt.dom.client.recognizer.pinch.PinchEvent; +import com.googlecode.mgwt.dom.client.recognizer.pinch.PinchHandler; +import com.googlecode.mgwt.dom.client.recognizer.swipe.HasSwipeHandlers; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeEndEvent; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeEndHandler; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeMoveEvent; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeMoveHandler; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeStartEvent; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeStartHandler; + +/** + * A TouchDelegate can be used to source touch events from a widget that does + * not support {@link HasTouchHandlers} + * + * @author Daniel Kurka + * @version $Id: $ + */ + +public class TouchDelegate implements HasTouchHandlers, HasTapHandlers, HasSwipeHandlers, HasPinchHandlers, HasLongTapHandlers { + + protected final GestureUtility gestureUtility; + private static final TouchWidgetImpl impl = GWT.create(TouchWidgetImpl.class); + private final Widget w; + + /** + * Construct a touchDelegate + * + * @param w the widget to source touchevents from + */ + public TouchDelegate(Widget w) { + this.w = w; + gestureUtility = new GestureUtility(this); + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers#addTouchStartHandler(com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchStartHandler(TouchStartHandler handler) { + return impl.addTouchStartHandler(w, handler); + + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers#addTouchMoveHandler(com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchMoveHandler(TouchMoveHandler handler) { + return impl.addTouchMoveHandler(w, handler); + + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers#addTouchCancelHandler(com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchCancelHandler(TouchCancelHandler handler) { + return impl.addTouchCancelHandler(w, handler); + + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers#addTouchEndHandler(com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchEndHandler(TouchEndHandler handler) { + return impl.addTouchEndHandler(w, handler); + + } + + @Override + public HandlerRegistration addTapHandler(TapHandler handler) { + gestureUtility.ensureTapRecognizer(); + return w.addHandler(handler, TapEvent.getType()); + } + + public HandlerRegistration addTouchHandler(TouchHandler handler) { + HandlerRegistrationCollection handlerRegistrationCollection = new HandlerRegistrationCollection(); + + handlerRegistrationCollection.addHandlerRegistration(addTouchCancelHandler(handler)); + handlerRegistrationCollection.addHandlerRegistration(addTouchStartHandler(handler)); + handlerRegistrationCollection.addHandlerRegistration(addTouchEndHandler(handler)); + handlerRegistrationCollection.addHandlerRegistration(addTouchMoveHandler(handler)); + return handlerRegistrationCollection; + } + + @Override + public void fireEvent(GwtEvent event) { + w.fireEvent(event); + + } + + public HandlerRegistration addSwipeStartHandler(SwipeStartHandler handler) { + gestureUtility.ensureSwipeRecognizer(); + return w.addHandler(handler, SwipeStartEvent.getType()); + } + + public HandlerRegistration addSwipeMoveHandler(SwipeMoveHandler handler) { + gestureUtility.ensureSwipeRecognizer(); + return w.addHandler(handler, SwipeMoveEvent.getType()); + } + + public HandlerRegistration addSwipeEndHandler(SwipeEndHandler handler) { + gestureUtility.ensureSwipeRecognizer(); + return w.addHandler(handler, SwipeEndEvent.getType()); + } + + @Override + public HandlerRegistration addPinchHandler(PinchHandler handler) { + gestureUtility.ensurePinchRecognizer(w); + return w.addHandler(handler, PinchEvent.getType()); + } + + @Override + public HandlerRegistration addLongTapHandler(LongTapHandler handler) { + gestureUtility.ensureLongTapHandler(); + return w.addHandler(handler, LongTapEvent.getType()); + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchPanel.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchPanel.java new file mode 100644 index 0000000..f5cc6c6 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchPanel.java @@ -0,0 +1,163 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.touch; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.FlowPanel; +import com.googlecode.mgwt.dom.client.event.mouse.HandlerRegistrationCollection; +import com.googlecode.mgwt.dom.client.event.tap.HasTapHandlers; +import com.googlecode.mgwt.dom.client.event.tap.TapEvent; +import com.googlecode.mgwt.dom.client.event.tap.TapHandler; +import com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers; +import com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler; +import com.googlecode.mgwt.dom.client.recognizer.longtap.HasLongTapHandlers; +import com.googlecode.mgwt.dom.client.recognizer.longtap.LongTapEvent; +import com.googlecode.mgwt.dom.client.recognizer.longtap.LongTapHandler; +import com.googlecode.mgwt.dom.client.recognizer.pinch.HasPinchHandlers; +import com.googlecode.mgwt.dom.client.recognizer.pinch.PinchEvent; +import com.googlecode.mgwt.dom.client.recognizer.pinch.PinchHandler; +import com.googlecode.mgwt.dom.client.recognizer.swipe.HasSwipeHandlers; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeEndEvent; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeEndHandler; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeMoveEvent; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeMoveHandler; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeStartEvent; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeStartHandler; + +/** + * A simple panel that supports {@link TouchEvent} + * + * @author Daniel Kurka + * + */ + +public class TouchPanel extends FlowPanel implements HasTouchHandlers, HasTapHandlers, HasPinchHandlers, HasSwipeHandlers, HasLongTapHandlers { + + private static final TouchWidgetImpl impl = GWT.create(TouchWidgetImpl.class); + + protected final GestureUtility gestureUtility; + + /** + * Construct a touch panel + */ + public TouchPanel() { + gestureUtility = new GestureUtility(this); + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers#addTouchStartHandler(com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchStartHandler(TouchStartHandler handler) { + return impl.addTouchStartHandler(this, handler); + + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers#addTouchMoveHandler(com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchMoveHandler(TouchMoveHandler handler) { + return impl.addTouchMoveHandler(this, handler); + + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers#addTouchCancelHandler(com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchCancelHandler(TouchCancelHandler handler) { + return impl.addTouchCancelHandler(this, handler); + + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers#addTouchEndHandler(com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchEndHandler(TouchEndHandler handler) { + return impl.addTouchEndHandler(this, handler); + + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers#addTouchHandler(com.googlecode.mgwt.dom.client.event.touch.TouchHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchHandler(TouchHandler handler) { + HandlerRegistrationCollection handlerRegistrationCollection = new HandlerRegistrationCollection(); + + handlerRegistrationCollection.addHandlerRegistration(addTouchCancelHandler(handler)); + handlerRegistrationCollection.addHandlerRegistration(addTouchStartHandler(handler)); + handlerRegistrationCollection.addHandlerRegistration(addTouchEndHandler(handler)); + handlerRegistrationCollection.addHandlerRegistration(addTouchMoveHandler(handler)); + return handlerRegistrationCollection; + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.recognizer.HasTapHandlers#addTapHandler(com.googlecode.mgwt.dom.client.recognizer.TapHandler) + */ + @Override + public HandlerRegistration addTapHandler(TapHandler handler) { + gestureUtility.ensureTapRecognizer(); + return addHandler(handler, TapEvent.getType()); + } + + public HandlerRegistration addSwipeStartHandler(SwipeStartHandler handler) { + gestureUtility.ensureSwipeRecognizer(); + return addHandler(handler, SwipeStartEvent.getType()); + } + + public HandlerRegistration addSwipeMoveHandler(SwipeMoveHandler handler) { + gestureUtility.ensureSwipeRecognizer(); + return addHandler(handler, SwipeMoveEvent.getType()); + } + + public HandlerRegistration addSwipeEndHandler(SwipeEndHandler handler) { + gestureUtility.ensureSwipeRecognizer(); + return addHandler(handler, SwipeEndEvent.getType()); + } + + @Override + public HandlerRegistration addPinchHandler(PinchHandler handler) { + gestureUtility.ensurePinchRecognizer(this); + return addHandler(handler, PinchEvent.getType()); + } + + @Override + public HandlerRegistration addLongTapHandler(LongTapHandler handler) { + gestureUtility.ensureLongTapHandler(); + return addHandler(handler, LongTapEvent.getType()); + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidget.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidget.java new file mode 100644 index 0000000..1931382 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidget.java @@ -0,0 +1,173 @@ +/* + * Copyright 2010 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.touch; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.Widget; +import com.googlecode.mgwt.dom.client.event.mouse.HandlerRegistrationCollection; +import com.googlecode.mgwt.dom.client.event.tap.HasTapHandlers; +import com.googlecode.mgwt.dom.client.event.tap.TapEvent; +import com.googlecode.mgwt.dom.client.event.tap.TapHandler; +import com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers; +import com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler; +import com.googlecode.mgwt.dom.client.recognizer.longtap.HasLongTapHandlers; +import com.googlecode.mgwt.dom.client.recognizer.longtap.LongTapEvent; +import com.googlecode.mgwt.dom.client.recognizer.longtap.LongTapHandler; +import com.googlecode.mgwt.dom.client.recognizer.pinch.HasPinchHandlers; +import com.googlecode.mgwt.dom.client.recognizer.pinch.PinchEvent; +import com.googlecode.mgwt.dom.client.recognizer.pinch.PinchHandler; +import com.googlecode.mgwt.dom.client.recognizer.swipe.HasSwipeHandlers; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeEndEvent; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeEndHandler; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeMoveEvent; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeMoveHandler; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeStartEvent; +import com.googlecode.mgwt.dom.client.recognizer.swipe.SwipeStartHandler; + +/** + * Base class for all widgets that support touch events Childclasses are + * responsible for setting the dom element + * + * @author Daniel Kurka + */ + +public abstract class TouchWidget extends Widget implements HasTouchHandlers, HasTapHandlers, HasSwipeHandlers, HasPinchHandlers, HasLongTapHandlers { + + private static final TouchWidgetImpl impl = GWT.create(TouchWidgetImpl.class); + + protected final GestureUtility gestureUtility; + + /** + *

+ * Constructor for TouchWidget. + *

+ */ + public TouchWidget() { + gestureUtility = new GestureUtility(this); + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers#addTouchStartHandler(com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchStartHandler(TouchStartHandler handler) { + return impl.addTouchStartHandler(this, handler); + + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers#addTouchMoveHandler(com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchMoveHandler(TouchMoveHandler handler) { + return impl.addTouchMoveHandler(this, handler); + + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers#addTouchCancelHandler(com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchCancelHandler(TouchCancelHandler handler) { + return impl.addTouchCancelHandler(this, handler); + + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers#addTouchEndHandler(com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchEndHandler(TouchEndHandler handler) { + return impl.addTouchEndHandler(this, handler); + + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.dom.client.event.touch.HasTouchHandlers#addTouchHandler(com.googlecode.mgwt.dom.client.event.touch.TouchHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchHandler(TouchHandler handler) { + HandlerRegistrationCollection handlerRegistrationCollection = new HandlerRegistrationCollection(); + + handlerRegistrationCollection.addHandlerRegistration(addTouchCancelHandler(handler)); + handlerRegistrationCollection.addHandlerRegistration(addTouchStartHandler(handler)); + handlerRegistrationCollection.addHandlerRegistration(addTouchEndHandler(handler)); + handlerRegistrationCollection.addHandlerRegistration(addTouchMoveHandler(handler)); + return handlerRegistrationCollection; + } + + /** + *

+ * addTapHandler + *

+ * + * @param handler a + * {@link com.googlecode.mgwt.dom.client.event.tap.TapHandler} + * object. + * @return a {@link com.google.gwt.event.shared.HandlerRegistration} object. + */ + + public HandlerRegistration addTapHandler(TapHandler handler) { + gestureUtility.ensureTapRecognizer(); + return addHandler(handler, TapEvent.getType()); + } + + @Override + public HandlerRegistration addSwipeStartHandler(SwipeStartHandler handler) { + gestureUtility.ensureSwipeRecognizer(); + return addHandler(handler, SwipeStartEvent.getType()); + } + + @Override + public HandlerRegistration addSwipeMoveHandler(SwipeMoveHandler handler) { + gestureUtility.ensureSwipeRecognizer(); + return addHandler(handler, SwipeMoveEvent.getType()); + } + + @Override + public HandlerRegistration addSwipeEndHandler(SwipeEndHandler handler) { + gestureUtility.ensureSwipeRecognizer(); + return addHandler(handler, SwipeEndEvent.getType()); + } + + @Override + public HandlerRegistration addPinchHandler(PinchHandler handler) { + gestureUtility.ensurePinchRecognizer(this); + return addHandler(handler, PinchEvent.getType()); + } + + @Override + public HandlerRegistration addLongTapHandler(LongTapHandler handler) { + gestureUtility.ensureLongTapHandler(); + return addHandler(handler, LongTapEvent.getType()); + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetDesktopImpl.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetDesktopImpl.java new file mode 100644 index 0000000..469a5ce --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetDesktopImpl.java @@ -0,0 +1,86 @@ +/* + * Copyright 2011 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.touch; + +import com.google.gwt.event.dom.client.MouseDownEvent; +import com.google.gwt.event.dom.client.MouseMoveEvent; +import com.google.gwt.event.dom.client.MouseUpEvent; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.Widget; +import com.googlecode.mgwt.dom.client.event.mouse.HandlerRegistrationCollection; +import com.googlecode.mgwt.dom.client.event.mouse.TouchEndToMouseUpHandler; +import com.googlecode.mgwt.dom.client.event.mouse.TouchMoveToMouseMoveHandler; +import com.googlecode.mgwt.dom.client.event.mouse.TouchStartToMouseDownHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler; +import com.googlecode.mgwt.ui.client.util.NoopHandlerRegistration; + +/** + * The implementation for mouse devices of {@link TouchWidgetImpl} + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class TouchWidgetDesktopImpl implements TouchWidgetImpl { + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.ui.client.widget.touch.TouchWidgetImpl#addTouchStartHandler(com.google.gwt.user.client.ui.Widget, com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchStartHandler(Widget w, TouchStartHandler handler) { + return w.addDomHandler(new TouchStartToMouseDownHandler(handler), MouseDownEvent.getType()); + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.ui.client.widget.touch.TouchWidgetImpl#addTouchMoveHandler(com.google.gwt.user.client.ui.Widget, com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchMoveHandler(Widget w, TouchMoveHandler handler) { + TouchMoveToMouseMoveHandler touchMoveToMouseMoveHandler = new TouchMoveToMouseMoveHandler(handler); + HandlerRegistrationCollection handlerRegistrationCollection = new HandlerRegistrationCollection(); + handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseDownEvent.getType())); + handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseUpEvent.getType())); + handlerRegistrationCollection.addHandlerRegistration(w.addDomHandler(touchMoveToMouseMoveHandler, MouseMoveEvent.getType())); + return handlerRegistrationCollection; + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.ui.client.widget.touch.TouchWidgetImpl#addTouchCancelHandler(com.google.gwt.user.client.ui.Widget, com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchCancelHandler(Widget w, TouchCancelHandler handler) { + return new NoopHandlerRegistration(); + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.ui.client.widget.touch.TouchWidgetImpl#addTouchEndHandler(com.google.gwt.user.client.ui.Widget, com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchEndHandler(Widget w, TouchEndHandler handler) { + return w.addDomHandler(new TouchEndToMouseUpHandler(handler), MouseUpEvent.getType()); + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetImpl.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetImpl.java new file mode 100644 index 0000000..8de0548 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetImpl.java @@ -0,0 +1,69 @@ +/* + * Copyright 2011 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.touch; + +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.Widget; +import com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler; + +/** + * The touch widget interface is used to abstract implementation details for + * adding touch handlers on touch devices / mouse devices + * + * @author Daniel Kurka + * @version $Id: $ + */ +public interface TouchWidgetImpl { + /** + * Add a touch start handler to a widget + * + * @param w the widget that the handler should be added to + * @param handler the handler to add + * @return the handlerregistration + */ + public HandlerRegistration addTouchStartHandler(Widget w, TouchStartHandler handler); + + /** + * Add a touch move handler to a widget + * + * @param w the widget that the handler should be added to + * @param handler the handler to add + * @return the handlerregistration + */ + public HandlerRegistration addTouchMoveHandler(Widget w, TouchMoveHandler handler); + + /** + * Add a touch cancel handler to a widget + * + * @param w the widget that the handler should be added to + * @param handler the handler to add + * @return the handlerregistration + */ + public HandlerRegistration addTouchCancelHandler(Widget w, TouchCancelHandler handler); + + /** + * Add a touch end handler to a widget + * + * @param w the widget that the handler should be added to + * @param handler the handler to add + * @return the handlerregistration + */ + public HandlerRegistration addTouchEndHandler(Widget w, TouchEndHandler handler); + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetMobileImpl.java b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetMobileImpl.java new file mode 100644 index 0000000..67fc465 --- /dev/null +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/com/googlecode/mgwt/ui/client/widget/touch/TouchWidgetMobileImpl.java @@ -0,0 +1,77 @@ +/* + * Copyright 2011 Daniel Kurka + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.googlecode.mgwt.ui.client.widget.touch; + +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.user.client.ui.Widget; +import com.googlecode.mgwt.dom.client.event.touch.TouchCancelEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchEndEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartEvent; +import com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler; + +/** + * The implementation for touch devices of {@link TouchWidgetImpl} + * + * @author Daniel Kurka + * @version $Id: $ + */ +public class TouchWidgetMobileImpl implements TouchWidgetImpl { + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.ui.client.widget.touch.TouchWidgetImpl#addTouchStartHandler(com.google.gwt.user.client.ui.Widget, com.googlecode.mgwt.dom.client.event.touch.TouchStartHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchStartHandler(Widget w, TouchStartHandler handler) { + return w.addDomHandler(handler, TouchStartEvent.getType()); + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.ui.client.widget.touch.TouchWidgetImpl#addTouchMoveHandler(com.google.gwt.user.client.ui.Widget, com.googlecode.mgwt.dom.client.event.touch.TouchMoveHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchMoveHandler(Widget w, TouchMoveHandler handler) { + return w.addDomHandler(handler, TouchMoveEvent.getType()); + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.ui.client.widget.touch.TouchWidgetImpl#addTouchCancelHandler(com.google.gwt.user.client.ui.Widget, com.googlecode.mgwt.dom.client.event.touch.TouchCancelHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchCancelHandler(Widget w, TouchCancelHandler handler) { + return w.addDomHandler(handler, TouchCancelEvent.getType()); + } + + /* + * (non-Javadoc) + * @see com.googlecode.mgwt.ui.client.widget.touch.TouchWidgetImpl#addTouchEndHandler(com.google.gwt.user.client.ui.Widget, com.googlecode.mgwt.dom.client.event.touch.TouchEndHandler) + */ + /** {@inheritDoc} */ + @Override + public HandlerRegistration addTouchEndHandler(Widget w, TouchEndHandler handler) { + return w.addDomHandler(handler, TouchEndEvent.getType()); + } + +} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/CommonWidgetSet.gwt.xml b/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/CommonWidgetSet.gwt.xml index ef9fe98..5261441 100644 --- a/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/CommonWidgetSet.gwt.xml +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/CommonWidgetSet.gwt.xml @@ -3,8 +3,6 @@ - - @@ -14,9 +12,37 @@ + + + + + + + + + + + + + + + + @@ -30,16 +56,4 @@ - - - - - - - - - - - - diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/actionbar/connector/ActionbarConnector.java b/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/actionbar/connector/ActionbarConnector.java index d18c071..ea1799c 100644 --- a/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/actionbar/connector/ActionbarConnector.java +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/actionbar/connector/ActionbarConnector.java @@ -50,7 +50,7 @@ import com.google.gwt.event.shared.SimpleEventBus; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Widget; import com.google.web.bindery.event.shared.EventBus; -import com.googlecode.mgwt.ui.client.MGWT; +import com.vaadin.client.BrowserInfo; import com.vaadin.client.communication.RpcProxy; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; @@ -69,7 +69,7 @@ public class ActionbarConnector extends AbstractComponentConnector implements Ac private final ActionbarServerRpc rpc = RpcProxy.create(ActionbarServerRpc.class, this); - private final boolean isTablet = !(MGWT.getOsDetection().isDesktop() || Window.Location.getQueryString().indexOf("tablet=true") >= 0); + private final boolean isTablet = (BrowserInfo.get().isTouchDevice() || Window.Location.getQueryString().indexOf("tablet=true") >= 0); private final StateChangeHandler sectionRearrangementHandler = new StateChangeHandler() { @Override diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/layout/thumbnaillayout/widget/Slider.java b/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/layout/thumbnaillayout/widget/Slider.java index 8c915b1..bf3d8a6 100644 --- a/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/layout/thumbnaillayout/widget/Slider.java +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/layout/thumbnaillayout/widget/Slider.java @@ -34,25 +34,22 @@ package info.magnolia.ui.vaadin.gwt.client.layout.thumbnaillayout.widget; import info.magnolia.ui.vaadin.gwt.client.icon.widget.IconWidget; -import info.magnolia.ui.vaadin.gwt.client.mgwt.SliderClientBundle; -import com.google.gwt.core.shared.GWT; import com.google.gwt.dom.client.Style; import com.google.gwt.event.logical.shared.HasValueChangeHandlers; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.FlowPanel; -import com.googlecode.mgwt.ui.client.widget.MSlider; /** * Simple client-side slider widget, wraps mgwt's slider. */ public class Slider extends Composite implements HasValueChangeHandlers { - private final SliderClientBundle cssBundle = GWT.create(SliderClientBundle.class); + //private final SliderClientBundle cssBundle = GWT.create(SliderClientBundle.class); - private final MSlider slider = new MSlider(cssBundle.css()); + //private final MSlider slider = new MSlider(cssBundle.css()); private FlowPanel panel = new FlowPanel(); @@ -67,14 +64,15 @@ public class Slider extends Composite implements HasValueChangeHandlers panel.getElement().getStyle().setPadding(10, Style.Unit.PX); panel.add(iconSizeSmall); - panel.add(slider); + //panel.add(slider); - slider.setWidth("125px"); + //slider.setWidth("125px"); initWidget(panel); } @Override public HandlerRegistration addValueChangeHandler(ValueChangeHandler integerValueChangeHandler) { - return slider.addValueChangeHandler(integerValueChangeHandler); + //return slider.addValueChangeHandler(integerValueChangeHandler); + return null; } } diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/mgwt/SliderClientBundle.java b/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/mgwt/SliderClientBundle.java index dc06090..dea40f2 100644 --- a/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/mgwt/SliderClientBundle.java +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/mgwt/SliderClientBundle.java @@ -34,7 +34,6 @@ package info.magnolia.ui.vaadin.gwt.client.mgwt; import com.google.gwt.resources.client.ClientBundle; -import com.googlecode.mgwt.ui.client.theme.base.SliderCss; /** * Bundle to serve resources for mgwt slider widget. @@ -44,6 +43,6 @@ public interface SliderClientBundle extends ClientBundle { final static String publicPath = "info/magnolia/ui/vaadin/gwt/public/"; @Source(publicPath + "mgwt/slider.css") - SliderCss css(); + void css(); } diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/touchwidget/VMgwtStylesUI.java b/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/touchwidget/VMgwtStylesUI.java deleted file mode 100644 index 0b20256..0000000 --- a/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/touchwidget/VMgwtStylesUI.java +++ /dev/null @@ -1,448 +0,0 @@ -/** - * This file Copyright (c) 2012-2014 Magnolia International - * Ltd. (http://www.magnolia-cms.com). All rights reserved. - * - * - * This file is dual-licensed under both the Magnolia - * Network Agreement and the GNU General Public License. - * You may elect to use one or the other of these licenses. - * - * This file is distributed in the hope that it will be - * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT. - * Redistribution, except as permitted by whichever of the GPL - * or MNA you select, is prohibited. - * - * 1. For the GPL license (GPL), you can redistribute and/or - * modify this file under the terms of the GNU General - * Public License, Version 3, as published by the Free Software - * Foundation. You should have received a copy of the GNU - * General Public License, Version 3 along with this program; - * if not, write to the Free Software Foundation, Inc., 51 - * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * 2. For the Magnolia Network Agreement (MNA), this file - * and the accompanying materials are made available under the - * terms of the MNA which accompanies this distribution, and - * is available at http://www.magnolia-cms.com/mna.html - * - * Any modifications to this file must keep this entire header - * intact. - * - */ -package info.magnolia.ui.vaadin.gwt.client.touchwidget; - -import com.google.gwt.resources.client.DataResource; -import com.google.gwt.resources.client.ImageResource; -import com.google.gwt.resources.client.TextResource; -import com.googlecode.mgwt.ui.client.MGWTStyle; -import com.googlecode.mgwt.ui.client.theme.MGWTClientBundle; -import com.googlecode.mgwt.ui.client.theme.MGWTTheme; -import com.googlecode.mgwt.ui.client.theme.base.ButtonBarButtonCss; -import com.googlecode.mgwt.ui.client.theme.base.ButtonBarCss; -import com.googlecode.mgwt.ui.client.theme.base.ButtonCss; -import com.googlecode.mgwt.ui.client.theme.base.CarouselCss; -import com.googlecode.mgwt.ui.client.theme.base.CheckBoxCss; -import com.googlecode.mgwt.ui.client.theme.base.DialogCss; -import com.googlecode.mgwt.ui.client.theme.base.GroupingList; -import com.googlecode.mgwt.ui.client.theme.base.HeaderCss; -import com.googlecode.mgwt.ui.client.theme.base.InputCss; -import com.googlecode.mgwt.ui.client.theme.base.LayoutCss; -import com.googlecode.mgwt.ui.client.theme.base.ListCss; -import com.googlecode.mgwt.ui.client.theme.base.MSearchBoxCss; -import com.googlecode.mgwt.ui.client.theme.base.MainCss; -import com.googlecode.mgwt.ui.client.theme.base.PanelCss; -import com.googlecode.mgwt.ui.client.theme.base.ProgressBarCss; -import com.googlecode.mgwt.ui.client.theme.base.ProgressIndicatorCss; -import com.googlecode.mgwt.ui.client.theme.base.PullToRefreshCss; -import com.googlecode.mgwt.ui.client.theme.base.ScrollPanelCss; -import com.googlecode.mgwt.ui.client.theme.base.SliderCss; -import com.googlecode.mgwt.ui.client.theme.base.TabBarCss; -import com.googlecode.mgwt.ui.client.theme.base.UtilCss; - -/** - * Special {@link com.vaadin.client.ui.VUI} extension to prevent MGWT from injecting its theme styles, which would otherwise potentially - * override some essential styles in AdminCentral. - */ -public class VMgwtStylesUI extends VNonScrollableUI { - - public VMgwtStylesUI() { - MGWTStyle.setTheme(new MGWTTheme() { - - private MGWTClientBundle bundle; - - @Override - public MGWTClientBundle getMGWTClientBundle() { - return bundle; - } - - { - bundle = new MGWTDummyClientBundle(); - } - - }); - } - - /** - * Dummy theme bundle with no style injection - especially for main. - */ - private final class MGWTDummyClientBundle implements MGWTClientBundle { - - @Override - public TextResource utilTextResource() { - return null; - } - - @Override - public ImageResource tabBarSearchImage() { - return null; - } - - @Override - public ImageResource tabBarMostViewedImage() { - return null; - } - - @Override - public ImageResource tabBarMostRecentImage() { - return null; - } - - @Override - public ImageResource tabBarMoreImage() { - return null; - } - - @Override - public ImageResource tabBarHistoryImage() { - return null; - } - - @Override - public ImageResource tabBarFeaturedImage() { - return null; - } - - @Override - public ImageResource tabBarFavoritesImage() { - return null; - } - - @Override - public ImageResource tabBarDownloadsImage() { - return null; - } - - @Override - public ImageResource tabBarContactsImage() { - return null; - } - - @Override - public ImageResource tabBarBookMarkImage() { - return null; - } - - @Override - public DataResource spinnerWhiteImage() { - return null; - } - - @Override - public DataResource spinnerImage() { - return null; - } - - @Override - public DataResource searchSearchImage() { - return null; - } - - @Override - public DataResource searchClearTouchedImage() { - return null; - } - - @Override - public DataResource searchClearImage() { - return null; - } - - @Override - public DataResource listArrow() { - return null; - } - - @Override - public DataResource inputCheckImage() { - return null; - } - - @Override - public UtilCss getUtilCss() { - return null; - } - - @Override - public TabBarCss getTabBarCss() { - return null; - } - - @Override - public SliderCss getSliderCss() { - return null; - } - - @Override - public MSearchBoxCss getSearchBoxCss() { - return null; - } - - @Override - public ScrollPanelCss getScrollPanelCss() { - return null; - } - - @Override - public PullToRefreshCss getPullToRefreshCss() { - return null; - } - - @Override - public ProgressIndicatorCss getProgressIndicatorCss() { - return null; - } - - @Override - public ProgressBarCss getProgressBarCss() { - return null; - } - - @Override - public PanelCss getPanelCss() { - return null; - } - - @Override - public MainCss getMainCss() { - return new MainCss() { - - @Override - public boolean ensureInjected() { - return false; - } - - @Override - public String getName() { - return "getMainCss"; - } - - @Override - public String getText() { - return ""; - } - }; - } - - @Override - public ListCss getListCss() { - return null; - } - - @Override - public LayoutCss getLayoutCss() { - return null; - } - - @Override - public InputCss getInputCss() { - return null; - } - - @Override - public HeaderCss getHeaderCss() { - return null; - } - - @Override - public GroupingList getGroupingList() { - return null; - } - - @Override - public DialogCss getDialogCss() { - return null; - } - - @Override - public CheckBoxCss getCheckBoxCss() { - return null; - } - - @Override - public CarouselCss getCarouselCss() { - return null; - } - - @Override - public ButtonCss getButtonCss() { - return null; - } - - @Override - public ImageResource getButtonBarTrashImage() { - return null; - } - - @Override - public ImageResource getButtonBarStopImage() { - return null; - } - - @Override - public ImageResource getButtonBarSearchImage() { - return null; - } - - @Override - public ImageResource getButtonBarRewindImage() { - return null; - } - - @Override - public ImageResource getButtonBarReplyImage() { - return null; - } - - @Override - public ImageResource getButtonBarRefreshImage() { - return null; - } - - @Override - public ImageResource getButtonBarPreviousSlideImage() { - return null; - } - - @Override - public ImageResource getButtonBarPlusImage() { - return null; - } - - @Override - public ImageResource getButtonBarPlayImage() { - return null; - } - - @Override - public ImageResource getButtonBarPauseImage() { - return null; - } - - @Override - public ImageResource getButtonBarOrganizeImage() { - return null; - } - - @Override - public ImageResource getButtonBarNextSlideImage() { - return null; - } - - @Override - public ImageResource getButtonBarNewImage() { - return null; - } - - @Override - public ImageResource getButtonBarMinusImage() { - return null; - } - - @Override - public ImageResource getButtonBarLocateImage() { - return null; - } - - @Override - public ImageResource getButtonBarInfoImage() { - return null; - } - - @Override - public ImageResource getButtonBarHighlightImage() { - return null; - } - - @Override - public ImageResource getButtonBarFastForwardImage() { - return null; - } - - @Override - public ButtonBarCss getButtonBarCss() { - return null; - } - - @Override - public ImageResource getButtonBarComposeImage() { - return null; - } - - @Override - public ImageResource getButtonBarCameraImage() { - return null; - } - - @Override - public ButtonBarButtonCss getButtonBarButtonCss() { - return null; - } - - @Override - public ImageResource getButtonBarBookmarkImage() { - return null; - } - - @Override - public ImageResource getButtonBarArrowUpImage() { - return null; - } - - @Override - public ImageResource getButtonBarArrowRightImage() { - return null; - } - - @Override - public ImageResource getButtonBarArrowLeftImage() { - return null; - } - - @Override - public ImageResource getButtonBarArrowDownImage() { - return null; - } - - @Override - public ImageResource getButtonBarActionImage() { - return null; - } - - @Override - public DataResource errorImage() { - return null; - } - - @Override - public DataResource android_check_not_checked() { - return null; - } - - @Override - public DataResource android_check_checked() { - return null; - } - } -} diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/touchwidget/VMobileSafariUI.java b/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/touchwidget/VMobileSafariUI.java index 8e5b95e..c523ce4 100644 --- a/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/touchwidget/VMobileSafariUI.java +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/gwt/client/touchwidget/VMobileSafariUI.java @@ -46,7 +46,7 @@ import com.googlecode.mgwt.dom.client.event.touch.TouchStartEvent; * Special implementation of {@link com.vaadin.client.ui.VUI} that would preinitialize MGWT touch events, so that those will not interfere * with native GWT touch events. */ -public class VMobileSafariUI extends VMgwtStylesUI { +public class VMobileSafariUI extends VNonScrollableUI { private HandlerManager handlerManager; diff --git a/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/switcher/Switcher.java b/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/switcher/Switcher.java index 1b6dce0..8ac7506 100644 --- a/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/switcher/Switcher.java +++ b/magnolia-ui-vaadin-common-widgets/src/main/java/info/magnolia/ui/vaadin/switcher/Switcher.java @@ -401,6 +401,7 @@ public class Switcher extends CustomField implements Container.Viewer { if (newValue == null) { setButtonEnabled(back, false); setButtonEnabled(forward, false); + return; } diff --git a/magnolia-ui-vaadin-widgetset/src/main/java/info/magnolia/ui/vaadin/gwt/MagnoliaWidgetSet.gwt.xml b/magnolia-ui-vaadin-widgetset/src/main/java/info/magnolia/ui/vaadin/gwt/MagnoliaWidgetSet.gwt.xml index e482fb2..04c4064 100644 --- a/magnolia-ui-vaadin-widgetset/src/main/java/info/magnolia/ui/vaadin/gwt/MagnoliaWidgetSet.gwt.xml +++ b/magnolia-ui-vaadin-widgetset/src/main/java/info/magnolia/ui/vaadin/gwt/MagnoliaWidgetSet.gwt.xml @@ -11,10 +11,8 @@ - - - - + + -- 1.8.3.4 (Apple Git-47)