From 0c9fb18384a57b0b8d70e38835d93eb3f5a2c1f9 Mon Sep 17 00:00:00 2001 From: Sebastien Bordes Date: Tue, 29 Apr 2014 19:43:11 +0200 Subject: [PATCH] Fixes #108 #109 Relocate EventType enumeration to shorten usage declaration and array type to annoation value --- .../af/core/ui/annotation/OnAction.java | 36 +--------- .../af/core/ui/annotation/OnDrag.java | 57 +--------------- .../af/core/ui/annotation/OnFinished.java | 36 +--------- .../jrebirth/af/core/ui/annotation/OnKey.java | 45 +------------ .../af/core/ui/annotation/OnMouse.java | 66 +----------------- .../af/core/ui/annotation/OnRotate.java | 45 +------------ .../af/core/ui/annotation/OnScroll.java | 45 +------------ .../af/core/ui/annotation/OnSwipe.java | 50 ++------------ .../af/core/ui/annotation/OnTouch.java | 48 +------------ .../af/core/ui/annotation/OnWindow.java | 51 +------------- .../af/core/ui/annotation/OnZoom.java | 45 +------------ .../af/core/ui/annotation/type/Action.java | 37 ++++++++++ .../af/core/ui/annotation/type/Drag.java | 58 ++++++++++++++++ .../af/core/ui/annotation/type/Finished.java | 37 ++++++++++ .../af/core/ui/annotation/type/Key.java | 46 +++++++++++++ .../af/core/ui/annotation/type/Mouse.java | 67 +++++++++++++++++++ .../af/core/ui/annotation/type/Rotate.java | 46 +++++++++++++ .../af/core/ui/annotation/type/Scroll.java | 46 +++++++++++++ .../af/core/ui/annotation/type/Swipe.java | 49 ++++++++++++++ .../af/core/ui/annotation/type/Touch.java | 49 ++++++++++++++ .../af/core/ui/annotation/type/Window.java | 52 ++++++++++++++ .../af/core/ui/annotation/type/Zoom.java | 46 +++++++++++++ .../ui/handler/AnnotationEventHandler.java | 6 +- .../af/core/ui/annotation/AnnotationView.java | 12 ++-- 24 files changed, 576 insertions(+), 499 deletions(-) create mode 100644 org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Action.java create mode 100644 org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Drag.java create mode 100644 org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Finished.java create mode 100644 org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Key.java create mode 100644 org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Mouse.java create mode 100644 org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Rotate.java create mode 100644 org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Scroll.java create mode 100644 org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Swipe.java create mode 100644 org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Touch.java create mode 100644 org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Window.java create mode 100644 org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Zoom.java diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnAction.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnAction.java index 91f372961..006ccb6c9 100644 --- a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnAction.java +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnAction.java @@ -25,7 +25,8 @@ import javafx.event.ActionEvent; import javafx.event.Event; -import javafx.event.EventType; + +import org.jrebirth.af.core.ui.annotation.type.Action; /** * This annotation is used to automatically attached an action event handler to a property node. @@ -37,43 +38,12 @@ @Documented public @interface OnAction { - /** - * The Action event type.
- * The Action type will be appended to method name to use. - */ - enum ActionType implements EnumEventType { - - /** Unique Action event type. */ - Action(ActionEvent.ACTION); - - /** The JavaFX internal api name. */ - private EventType eventType; - - /** - * Default constructor used to link the apiName. - * - * @param eventType the javafx event type - */ - private ActionType(final EventType eventType) { - this.eventType = eventType; - } - - /** - * {@inheritDoc} - */ - @Override - public EventType eventType() { - return this.eventType; - } - - } - /** * Define the event type to manage. * * The default value is ActionType.Action, no other type can be defined */ - ActionType[] value() default ActionType.Action; + Action[] value() default Action.Action; /** * Define a unique name used to avoid sharing same handler. diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnDrag.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnDrag.java index 8daa1a226..1417c5ead 100644 --- a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnDrag.java +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnDrag.java @@ -24,9 +24,10 @@ import java.lang.annotation.Target; import javafx.event.Event; -import javafx.event.EventType; import javafx.scene.input.DragEvent; +import org.jrebirth.af.core.ui.annotation.type.Drag; + /** * This annotation is used to automatically attached a Drag event handler to a property node. * @@ -37,64 +38,12 @@ @Documented public @interface OnDrag { - /** - * The Drag event type.
- * The Drag type will be appended to method name to use. - */ - enum DragType implements EnumEventType { - - /** Any Drag Event. */ - Any(DragEvent.ANY), - - /** Drag done event. */ - Done(DragEvent.DRAG_DONE), - - /** Drag dropped event. */ - Dropped(DragEvent.DRAG_DROPPED), - - /** Drag entered event. */ - Entered(DragEvent.DRAG_ENTERED), - - /** Drag entered target event. */ - EnteredTarget(DragEvent.DRAG_ENTERED_TARGET), - - /** Drag exited event. */ - Exited(DragEvent.DRAG_EXITED), - - /** Drag exited target event. */ - ExitedTarget(DragEvent.DRAG_EXITED_TARGET), - - /** Drag over event. */ - Over(DragEvent.DRAG_OVER); - - /** The JavaFX internal api name. */ - private EventType eventType; - - /** - * Default constructor used to link the apiName. - * - * @param eventType the javafx event type - */ - private DragType(final EventType eventType) { - this.eventType = eventType; - } - - /** - * {@inheritDoc} - */ - @Override - public EventType eventType() { - return this.eventType; - } - - } - /** * Define the event type to manage. * * The default value is DragType.Any */ - DragType value() default DragType.Any; + Drag[] value() default Drag.Any; /** * Define a unique name used to avoid sharing same handler. diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnFinished.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnFinished.java index ed2ba32d4..1a0322656 100644 --- a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnFinished.java +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnFinished.java @@ -25,7 +25,8 @@ import javafx.event.ActionEvent; import javafx.event.Event; -import javafx.event.EventType; + +import org.jrebirth.af.core.ui.annotation.type.Finished; /** * This annotation is used to automatically attached a Finished event handler to an Animation. @@ -37,43 +38,12 @@ @Documented public @interface OnFinished { - /** - * The Finished event type.
- * The Finished type will be appended to method name to use. - */ - enum FinishedType implements EnumEventType { - - /** Unique Action event type. */ - Action(ActionEvent.ACTION); - - /** The JavaFX internal api name. */ - private EventType eventType; - - /** - * Default constructor used to link the apiName. - * - * @param eventType the javafx event type - */ - private FinishedType(final EventType eventType) { - this.eventType = eventType; - } - - /** - * {@inheritDoc} - */ - @Override - public EventType eventType() { - return this.eventType; - } - - } - /** * Define the event type to manage. * * The default value is FinishedType.Action, no other type can be defined */ - FinishedType[] value() default FinishedType.Action; + Finished[] value() default Finished.Action; /** * Define a unique name used to avoid sharing same handler. diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnKey.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnKey.java index fe270d5e5..0a852a5dd 100644 --- a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnKey.java +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnKey.java @@ -24,9 +24,10 @@ import java.lang.annotation.Target; import javafx.event.Event; -import javafx.event.EventType; import javafx.scene.input.KeyEvent; +import org.jrebirth.af.core.ui.annotation.type.Key; + /** * This annotation is used to automatically attached a Key event handler to a property node. * @@ -37,52 +38,12 @@ @Documented public @interface OnKey { - /** - * The Key event type.
- * The Key type will be appended to method name to use. - */ - enum KeyType implements EnumEventType { - - /** Any Key Event. */ - Any(KeyEvent.ANY), - - /** Key pressed event. */ - Pressed(KeyEvent.KEY_PRESSED), - - /** Key released event. */ - Released(KeyEvent.KEY_RELEASED), - - /** Key typed event. */ - Typed(KeyEvent.KEY_TYPED); - - /** The JavaFX internal api name. */ - private EventType eventType; - - /** - * Default constructor used to link the apiName. - * - * @param eventType the javafx event type - */ - private KeyType(final EventType eventType) { - this.eventType = eventType; - } - - /** - * {@inheritDoc} - */ - @Override - public EventType eventType() { - return this.eventType; - } - - } - /** * Define the event type to manage. * * The default value is KeyType.Any */ - KeyType value() default KeyType.Any; + Key[] value() default Key.Any; /** * Define a unique name used to avoid sharing same handler. diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnMouse.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnMouse.java index 51a3e5c77..cbae4d3ea 100644 --- a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnMouse.java +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnMouse.java @@ -24,9 +24,10 @@ import java.lang.annotation.Target; import javafx.event.Event; -import javafx.event.EventType; import javafx.scene.input.MouseEvent; +import org.jrebirth.af.core.ui.annotation.type.Mouse; + /** * This annotation is used to automatically attached a Mouse event handler to a property node. * @@ -37,73 +38,12 @@ @Documented public @interface OnMouse { - /** - * The Mouse event type.
- * The mouse type will be appended to method name to use. - */ - enum MouseType implements EnumEventType { - - /** Any Rotate Event. */ - Any(MouseEvent.ANY), - - /** Mouse drag detected event. */ - DragDetected(MouseEvent.DRAG_DETECTED), - - /** Mouse clicked event. */ - Clicked(MouseEvent.MOUSE_CLICKED), - - /** Mouse dragged event. */ - Dragged(MouseEvent.MOUSE_DRAGGED), - - /** Mouse entered event. */ - Entered(MouseEvent.MOUSE_ENTERED), - - /** Mouse entered target event. */ - EnteredTarget(MouseEvent.MOUSE_ENTERED_TARGET), - - /** Mouse exited event. */ - Exited(MouseEvent.MOUSE_EXITED), - - /** Mouse exited target event. */ - ExitedTarget(MouseEvent.MOUSE_EXITED_TARGET), - - /** Mouse moved event. */ - Moved(MouseEvent.MOUSE_MOVED), - - /** Mouse pressed event. */ - Pressed(MouseEvent.MOUSE_PRESSED), - - /** Mouse released event. */ - Released(MouseEvent.MOUSE_RELEASED); - - /** The JavaFX internal api name. */ - private EventType eventType; - - /** - * Default constructor used to link the apiName. - * - * @param eventType the javafx event type - */ - private MouseType(final EventType eventType) { - this.eventType = eventType; - } - - /** - * {@inheritDoc} - */ - @Override - public EventType eventType() { - return this.eventType; - } - - } - /** * Define the event type to manage. * * The default value is MouseType.Any */ - MouseType[] value() default MouseType.Any; + Mouse[] value() default Mouse.Any; /** * Define a unique name used to avoid sharing same handler. diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnRotate.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnRotate.java index 76545009d..c81c8e5ae 100644 --- a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnRotate.java +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnRotate.java @@ -24,9 +24,10 @@ import java.lang.annotation.Target; import javafx.event.Event; -import javafx.event.EventType; import javafx.scene.input.RotateEvent; +import org.jrebirth.af.core.ui.annotation.type.Rotate; + /** * This annotation is used to automatically attached a Rotate event handler to a property node. * @@ -37,52 +38,12 @@ @Documented public @interface OnRotate { - /** - * The Rotate event type.
- * The rotate type will be appended to method name to use. - */ - enum RotateType implements EnumEventType { - - /** Any Rotate Event. */ - Any(RotateEvent.ANY), - - /** Rotation started event. */ - Started(RotateEvent.ROTATION_STARTED), - - /** Rotate event. */ - Rotate(RotateEvent.ROTATE), - - /** Rotation finished event. */ - Finished(RotateEvent.ROTATION_FINISHED); - - /** The JavaFX internal api name. */ - private EventType eventType; - - /** - * Default constructor used to link the apiName. - * - * @param eventType the javafx event type - */ - private RotateType(final EventType eventType) { - this.eventType = eventType; - } - - /** - * {@inheritDoc} - */ - @Override - public EventType eventType() { - return this.eventType; - } - - } - /** * Define the event type to manage. * * The default value is RotateType.Any */ - RotateType[] value() default RotateType.Any; + Rotate[] value() default Rotate.Any; /** * Define a unique name used to avoid sharing same handler. diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnScroll.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnScroll.java index 3ecd29fdb..2efa0a2b8 100644 --- a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnScroll.java +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnScroll.java @@ -24,9 +24,10 @@ import java.lang.annotation.Target; import javafx.event.Event; -import javafx.event.EventType; import javafx.scene.input.ScrollEvent; +import org.jrebirth.af.core.ui.annotation.type.Scroll; + /** * This annotation is used to automatically attached an Scroll event handler to a property node. * @@ -37,52 +38,12 @@ @Documented public @interface OnScroll { - /** - * The Scroll event type.
- * The scroll type will be appended to method name to use. - */ - enum ScrollType implements EnumEventType { - - /** Any Scroll Event. */ - Any(ScrollEvent.ANY), - - /** Scroll started event. */ - Started(ScrollEvent.SCROLL_STARTED), - - /** Scroll event. */ - Rotate(ScrollEvent.SCROLL), - - /** Scroll finished event. */ - Finished(ScrollEvent.SCROLL_FINISHED); - - /** The JavaFX internal api name. */ - private EventType eventType; - - /** - * Default constructor used to link the apiName. - * - * @param eventType the javafx event type - */ - private ScrollType(final EventType eventType) { - this.eventType = eventType; - } - - /** - * {@inheritDoc} - */ - @Override - public EventType eventType() { - return this.eventType; - } - - } - /** * Define the event type to manage. * * The default value is ScrollType.Any */ - ScrollType[] value() default ScrollType.Any; + Scroll[] value() default Scroll.Any; /** * Define a unique name used to avoid sharing same handler. diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnSwipe.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnSwipe.java index dec30f717..a185bcff1 100644 --- a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnSwipe.java +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnSwipe.java @@ -24,11 +24,12 @@ import java.lang.annotation.Target; import javafx.event.Event; -import javafx.event.EventType; import javafx.scene.input.SwipeEvent; +import org.jrebirth.af.core.ui.annotation.type.Swipe; + /** - * This annotation is used to automatically attached a Zoom event handler to a property node. + * This annotation is used to automatically attached a Swipe event handler to a property node. * * @author Sébastien Bordes */ @@ -37,55 +38,12 @@ @Documented public @interface OnSwipe { - /** - * The Swipe event type.
- * The swipe type will be appended to method name to use. - */ - enum SwipeType implements EnumEventType { - - /** Any Swipe Event. */ - Any(SwipeEvent.ANY), - - /** Swipe Up event. */ - Up(SwipeEvent.SWIPE_UP), - - /** Swipe Down event. */ - Down(SwipeEvent.SWIPE_DOWN), - - /** Swipe Left event. */ - Left(SwipeEvent.SWIPE_LEFT), - - /** Swipe Right event. */ - Right(SwipeEvent.SWIPE_RIGHT); - - /** The JavaFX internal api name. */ - private EventType eventType; - - /** - * Default constructor used to link the apiName. - * - * @param eventType the javafx event type - */ - private SwipeType(final EventType eventType) { - this.eventType = eventType; - } - - /** - * {@inheritDoc} - */ - @Override - public EventType eventType() { - return this.eventType; - } - - } - /** * Define the event type to manage. * * The default value is SwipeType.Any */ - SwipeType[] value() default SwipeType.Any; + Swipe[] value() default Swipe.Any; /** * Define a unique name used to avoid sharing same handler. diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnTouch.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnTouch.java index 12d2534c5..619ed0cbd 100644 --- a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnTouch.java +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnTouch.java @@ -24,9 +24,10 @@ import java.lang.annotation.Target; import javafx.event.Event; -import javafx.event.EventType; import javafx.scene.input.TouchEvent; +import org.jrebirth.af.core.ui.annotation.type.Touch; + /** * This annotation is used to automatically attached a touch event handler to a property node. * @@ -37,55 +38,12 @@ @Documented public @interface OnTouch { - /** - * The Touch event type.
- * The Touch type will be appended to method name to use. - */ - enum TouchType implements EnumEventType { - - /** Any Swipe Event. */ - Any(TouchEvent.ANY), - - /** Touch pressed event. */ - Pressed(TouchEvent.TOUCH_PRESSED), - - /** Touch released event. */ - Released(TouchEvent.TOUCH_RELEASED), - - /** Touch moved event. */ - Moved(TouchEvent.TOUCH_MOVED), - - /** Touch stationary event. */ - Stationary(TouchEvent.TOUCH_STATIONARY); - - /** The JavaFX internal api name. */ - private EventType eventType; - - /** - * Default constructor used to link the apiName. - * - * @param eventType the javafx event type - */ - private TouchType(final EventType eventType) { - this.eventType = eventType; - } - - /** - * {@inheritDoc} - */ - @Override - public EventType eventType() { - return this.eventType; - } - - } - /** * Define the event type to manage. * * The default value is TouchType.Any */ - TouchType[] value() default TouchType.Any; + Touch[] value() default Touch.Any; /** * Define a unique name used to avoid sharing same handler. diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnWindow.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnWindow.java index 937b76d6e..9d15de4ae 100644 --- a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnWindow.java +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnWindow.java @@ -24,9 +24,10 @@ import java.lang.annotation.Target; import javafx.event.Event; -import javafx.event.EventType; import javafx.stage.WindowEvent; +import org.jrebirth.af.core.ui.annotation.type.Window; + /** * This annotation is used to automatically attached a window event handler to a property node. * @@ -37,58 +38,12 @@ @Documented public @interface OnWindow { - /** - * The Window event type.
- * The window type will be appended to method name to use. - */ - enum WindowType implements EnumEventType { - - /** Any Swipe Event. */ - Any(WindowEvent.ANY), - - /** Window close requested event. */ - CloseRequest(WindowEvent.WINDOW_CLOSE_REQUEST), - - /** Window hidden event. */ - Hidden(WindowEvent.WINDOW_HIDDEN), - - /** Window hiding event. */ - Hiding(WindowEvent.WINDOW_HIDING), - - /** Window showing event. */ - Showing(WindowEvent.WINDOW_SHOWING), - - /** Window shown event. */ - Shown(WindowEvent.WINDOW_SHOWN); - - /** The JavaFX internal api name. */ - private EventType eventType; - - /** - * Default constructor used to link the apiName. - * - * @param eventType the javafx event type - */ - private WindowType(final EventType eventType) { - this.eventType = eventType; - } - - /** - * {@inheritDoc} - */ - @Override - public EventType eventType() { - return this.eventType; - } - - } - /** * Define the event type to manage. * * The default value is WindowType.Any */ - WindowType value() default WindowType.Any; + Window[] value() default Window.Any; /** * Define a unique name used to avoid sharing same handler. diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnZoom.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnZoom.java index f7fb038f6..495f5f09e 100644 --- a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnZoom.java +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/OnZoom.java @@ -24,9 +24,10 @@ import java.lang.annotation.Target; import javafx.event.Event; -import javafx.event.EventType; import javafx.scene.input.ZoomEvent; +import org.jrebirth.af.core.ui.annotation.type.Zoom; + /** * This annotation is used to automatically attached a Zoom event handler to a property node. * @@ -37,52 +38,12 @@ @Documented public @interface OnZoom { - /** - * The Zoom event type.
- * The zoom type will be appended to method name to use. - */ - public enum ZoomType implements EnumEventType { - - /** Any Zoom Event. */ - Any(ZoomEvent.ANY), - - /** Zoom started event. */ - Started(ZoomEvent.ZOOM_STARTED), - - /** Zoom event. */ - Zoom(ZoomEvent.ZOOM), - - /** Zoom finished event. */ - Finished(ZoomEvent.ZOOM_FINISHED); - - /** The JavaFX internal api name. */ - private EventType eventType; - - /** - * Default constructor used to link the apiName. - * - * @param eventType the javafx event type - */ - private ZoomType(final EventType eventType) { - this.eventType = eventType; - } - - /** - * {@inheritDoc} - */ - @Override - public EventType eventType() { - return this.eventType; - } - - } - /** * Define the event type to manage. * * The default value is ZoomType.Any */ - ZoomType[] value() default ZoomType.Any; + Zoom[] value() default Zoom.Any; /** * Define a unique name used to avoid sharing same handler. diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Action.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Action.java new file mode 100644 index 000000000..df28e80ba --- /dev/null +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Action.java @@ -0,0 +1,37 @@ +package org.jrebirth.af.core.ui.annotation.type; + +import javafx.event.ActionEvent; +import javafx.event.EventType; + +import org.jrebirth.af.core.ui.annotation.EnumEventType; + +/** + * The Action event type.
+ * The Action type will be appended to method name to use. + */ +public enum Action implements EnumEventType { + + /** Unique Action event type. */ + Action(ActionEvent.ACTION); + + /** The JavaFX internal api name. */ + private EventType eventType; + + /** + * Default constructor used to link the apiName. + * + * @param eventType the javafx event type + */ + private Action(final EventType eventType) { + this.eventType = eventType; + } + + /** + * {@inheritDoc} + */ + @Override + public EventType eventType() { + return this.eventType; + } + +} \ No newline at end of file diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Drag.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Drag.java new file mode 100644 index 000000000..b234817cc --- /dev/null +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Drag.java @@ -0,0 +1,58 @@ +package org.jrebirth.af.core.ui.annotation.type; + +import javafx.event.EventType; +import javafx.scene.input.DragEvent; + +import org.jrebirth.af.core.ui.annotation.EnumEventType; + +/** + * The Drag event type.
+ * The Drag type will be appended to method name to use. + */ +public enum Drag implements EnumEventType { + + /** Any Drag Event. */ + Any(DragEvent.ANY), + + /** Drag done event. */ + Done(DragEvent.DRAG_DONE), + + /** Drag dropped event. */ + Dropped(DragEvent.DRAG_DROPPED), + + /** Drag entered event. */ + Entered(DragEvent.DRAG_ENTERED), + + /** Drag entered target event. */ + EnteredTarget(DragEvent.DRAG_ENTERED_TARGET), + + /** Drag exited event. */ + Exited(DragEvent.DRAG_EXITED), + + /** Drag exited target event. */ + ExitedTarget(DragEvent.DRAG_EXITED_TARGET), + + /** Drag over event. */ + Over(DragEvent.DRAG_OVER); + + /** The JavaFX internal api name. */ + private EventType eventType; + + /** + * Default constructor used to link the apiName. + * + * @param eventType the javafx event type + */ + private Drag(final EventType eventType) { + this.eventType = eventType; + } + + /** + * {@inheritDoc} + */ + @Override + public EventType eventType() { + return this.eventType; + } + +} \ No newline at end of file diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Finished.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Finished.java new file mode 100644 index 000000000..b419c031c --- /dev/null +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Finished.java @@ -0,0 +1,37 @@ +package org.jrebirth.af.core.ui.annotation.type; + +import javafx.event.ActionEvent; +import javafx.event.EventType; + +import org.jrebirth.af.core.ui.annotation.EnumEventType; + +/** + * The Finished event type.
+ * The Finished type will be appended to method name to use. + */ +public enum Finished implements EnumEventType { + + /** Unique Action event type. */ + Action(ActionEvent.ACTION); + + /** The JavaFX internal api name. */ + private EventType eventType; + + /** + * Default constructor used to link the apiName. + * + * @param eventType the javafx event type + */ + private Finished(final EventType eventType) { + this.eventType = eventType; + } + + /** + * {@inheritDoc} + */ + @Override + public EventType eventType() { + return this.eventType; + } + +} \ No newline at end of file diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Key.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Key.java new file mode 100644 index 000000000..31578d4a8 --- /dev/null +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Key.java @@ -0,0 +1,46 @@ +package org.jrebirth.af.core.ui.annotation.type; + +import javafx.event.EventType; +import javafx.scene.input.KeyEvent; + +import org.jrebirth.af.core.ui.annotation.EnumEventType; + +/** + * The Key event type.
+ * The Key type will be appended to method name to use. + */ +public enum Key implements EnumEventType { + + /** Any Key Event. */ + Any(KeyEvent.ANY), + + /** Key pressed event. */ + Pressed(KeyEvent.KEY_PRESSED), + + /** Key released event. */ + Released(KeyEvent.KEY_RELEASED), + + /** Key typed event. */ + Typed(KeyEvent.KEY_TYPED); + + /** The JavaFX internal api name. */ + private EventType eventType; + + /** + * Default constructor used to link the apiName. + * + * @param eventType the javafx event type + */ + private Key(final EventType eventType) { + this.eventType = eventType; + } + + /** + * {@inheritDoc} + */ + @Override + public EventType eventType() { + return this.eventType; + } + +} \ No newline at end of file diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Mouse.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Mouse.java new file mode 100644 index 000000000..40ad20fa4 --- /dev/null +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Mouse.java @@ -0,0 +1,67 @@ +package org.jrebirth.af.core.ui.annotation.type; + +import javafx.event.EventType; +import javafx.scene.input.MouseEvent; + +import org.jrebirth.af.core.ui.annotation.EnumEventType; + +/** + * The Mouse event type.
+ * The mouse type will be appended to method name to use. + */ +public enum Mouse implements EnumEventType { + + /** Any Rotate Event. */ + Any(MouseEvent.ANY), + + /** Mouse drag detected event. */ + DragDetected(MouseEvent.DRAG_DETECTED), + + /** Mouse clicked event. */ + Clicked(MouseEvent.MOUSE_CLICKED), + + /** Mouse dragged event. */ + Dragged(MouseEvent.MOUSE_DRAGGED), + + /** Mouse entered event. */ + Entered(MouseEvent.MOUSE_ENTERED), + + /** Mouse entered target event. */ + EnteredTarget(MouseEvent.MOUSE_ENTERED_TARGET), + + /** Mouse exited event. */ + Exited(MouseEvent.MOUSE_EXITED), + + /** Mouse exited target event. */ + ExitedTarget(MouseEvent.MOUSE_EXITED_TARGET), + + /** Mouse moved event. */ + Moved(MouseEvent.MOUSE_MOVED), + + /** Mouse pressed event. */ + Pressed(MouseEvent.MOUSE_PRESSED), + + /** Mouse released event. */ + Released(MouseEvent.MOUSE_RELEASED); + + /** The JavaFX internal api name. */ + private EventType eventType; + + /** + * Default constructor used to link the apiName. + * + * @param eventType the javafx event type + */ + private Mouse(final EventType eventType) { + this.eventType = eventType; + } + + /** + * {@inheritDoc} + */ + @Override + public EventType eventType() { + return this.eventType; + } + +} \ No newline at end of file diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Rotate.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Rotate.java new file mode 100644 index 000000000..9bb86df3d --- /dev/null +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Rotate.java @@ -0,0 +1,46 @@ +package org.jrebirth.af.core.ui.annotation.type; + +import javafx.event.EventType; +import javafx.scene.input.RotateEvent; + +import org.jrebirth.af.core.ui.annotation.EnumEventType; + +/** + * The Rotate event type.
+ * The rotate type will be appended to method name to use. + */ +public enum Rotate implements EnumEventType { + + /** Any Rotate Event. */ + Any(RotateEvent.ANY), + + /** Rotation started event. */ + Started(RotateEvent.ROTATION_STARTED), + + /** Rotate event. */ + Rotate(RotateEvent.ROTATE), + + /** Rotation finished event. */ + Finished(RotateEvent.ROTATION_FINISHED); + + /** The JavaFX internal api name. */ + private EventType eventType; + + /** + * Default constructor used to link the apiName. + * + * @param eventType the javafx event type + */ + private Rotate(final EventType eventType) { + this.eventType = eventType; + } + + /** + * {@inheritDoc} + */ + @Override + public EventType eventType() { + return this.eventType; + } + +} \ No newline at end of file diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Scroll.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Scroll.java new file mode 100644 index 000000000..7f033653d --- /dev/null +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Scroll.java @@ -0,0 +1,46 @@ +package org.jrebirth.af.core.ui.annotation.type; + +import javafx.event.EventType; +import javafx.scene.input.ScrollEvent; + +import org.jrebirth.af.core.ui.annotation.EnumEventType; + +/** + * The Scroll event type.
+ * The scroll type will be appended to method name to use. + */ +public enum Scroll implements EnumEventType { + + /** Any Scroll Event. */ + Any(ScrollEvent.ANY), + + /** Scroll started event. */ + Started(ScrollEvent.SCROLL_STARTED), + + /** Scroll event. */ + Rotate(ScrollEvent.SCROLL), + + /** Scroll finished event. */ + Finished(ScrollEvent.SCROLL_FINISHED); + + /** The JavaFX internal api name. */ + private EventType eventType; + + /** + * Default constructor used to link the apiName. + * + * @param eventType the javafx event type + */ + private Scroll(final EventType eventType) { + this.eventType = eventType; + } + + /** + * {@inheritDoc} + */ + @Override + public EventType eventType() { + return this.eventType; + } + +} \ No newline at end of file diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Swipe.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Swipe.java new file mode 100644 index 000000000..b0c303291 --- /dev/null +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Swipe.java @@ -0,0 +1,49 @@ +package org.jrebirth.af.core.ui.annotation.type; + +import javafx.event.EventType; +import javafx.scene.input.SwipeEvent; + +import org.jrebirth.af.core.ui.annotation.EnumEventType; + +/** + * The Swipe event type.
+ * The swipe type will be appended to method name to use. + */ +public enum Swipe implements EnumEventType { + + /** Any Swipe Event. */ + Any(SwipeEvent.ANY), + + /** Swipe Up event. */ + Up(SwipeEvent.SWIPE_UP), + + /** Swipe Down event. */ + Down(SwipeEvent.SWIPE_DOWN), + + /** Swipe Left event. */ + Left(SwipeEvent.SWIPE_LEFT), + + /** Swipe Right event. */ + Right(SwipeEvent.SWIPE_RIGHT); + + /** The JavaFX internal api name. */ + private EventType eventType; + + /** + * Default constructor used to link the apiName. + * + * @param eventType the javafx event type + */ + private Swipe(final EventType eventType) { + this.eventType = eventType; + } + + /** + * {@inheritDoc} + */ + @Override + public EventType eventType() { + return this.eventType; + } + +} \ No newline at end of file diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Touch.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Touch.java new file mode 100644 index 000000000..f38417677 --- /dev/null +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Touch.java @@ -0,0 +1,49 @@ +package org.jrebirth.af.core.ui.annotation.type; + +import javafx.event.EventType; +import javafx.scene.input.TouchEvent; + +import org.jrebirth.af.core.ui.annotation.EnumEventType; + +/** + * The Touch event type.
+ * The Touch type will be appended to method name to use. + */ +public enum Touch implements EnumEventType { + + /** Any Swipe Event. */ + Any(TouchEvent.ANY), + + /** Touch pressed event. */ + Pressed(TouchEvent.TOUCH_PRESSED), + + /** Touch released event. */ + Released(TouchEvent.TOUCH_RELEASED), + + /** Touch moved event. */ + Moved(TouchEvent.TOUCH_MOVED), + + /** Touch stationary event. */ + Stationary(TouchEvent.TOUCH_STATIONARY); + + /** The JavaFX internal api name. */ + private EventType eventType; + + /** + * Default constructor used to link the apiName. + * + * @param eventType the javafx event type + */ + private Touch(final EventType eventType) { + this.eventType = eventType; + } + + /** + * {@inheritDoc} + */ + @Override + public EventType eventType() { + return this.eventType; + } + +} \ No newline at end of file diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Window.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Window.java new file mode 100644 index 000000000..267a8092f --- /dev/null +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Window.java @@ -0,0 +1,52 @@ +package org.jrebirth.af.core.ui.annotation.type; + +import javafx.event.EventType; +import javafx.stage.WindowEvent; + +import org.jrebirth.af.core.ui.annotation.EnumEventType; + +/** + * The Window event type.
+ * The window type will be appended to method name to use. + */ +public enum Window implements EnumEventType { + + /** Any Swipe Event. */ + Any(WindowEvent.ANY), + + /** Window close requested event. */ + CloseRequest(WindowEvent.WINDOW_CLOSE_REQUEST), + + /** Window hidden event. */ + Hidden(WindowEvent.WINDOW_HIDDEN), + + /** Window hiding event. */ + Hiding(WindowEvent.WINDOW_HIDING), + + /** Window showing event. */ + Showing(WindowEvent.WINDOW_SHOWING), + + /** Window shown event. */ + Shown(WindowEvent.WINDOW_SHOWN); + + /** The JavaFX internal api name. */ + private EventType eventType; + + /** + * Default constructor used to link the apiName. + * + * @param eventType the javafx event type + */ + private Window(final EventType eventType) { + this.eventType = eventType; + } + + /** + * {@inheritDoc} + */ + @Override + public EventType eventType() { + return this.eventType; + } + +} \ No newline at end of file diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Zoom.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Zoom.java new file mode 100644 index 000000000..9345c4910 --- /dev/null +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/annotation/type/Zoom.java @@ -0,0 +1,46 @@ +package org.jrebirth.af.core.ui.annotation.type; + +import javafx.event.EventType; +import javafx.scene.input.ZoomEvent; + +import org.jrebirth.af.core.ui.annotation.EnumEventType; + +/** + * The Zoom event type.
+ * The zoom type will be appended to method name to use. + */ +public enum Zoom implements EnumEventType { + + /** Any Zoom Event. */ + Any(ZoomEvent.ANY), + + /** Zoom started event. */ + Started(ZoomEvent.ZOOM_STARTED), + + /** Zoom event. */ + Zoom(ZoomEvent.ZOOM), + + /** Zoom finished event. */ + Finished(ZoomEvent.ZOOM_FINISHED); + + /** The JavaFX internal api name. */ + private EventType eventType; + + /** + * Default constructor used to link the apiName. + * + * @param eventType the javafx event type + */ + private Zoom(final EventType eventType) { + this.eventType = eventType; + } + + /** + * {@inheritDoc} + */ + @Override + public EventType eventType() { + return this.eventType; + } + +} \ No newline at end of file diff --git a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/handler/AnnotationEventHandler.java b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/handler/AnnotationEventHandler.java index 7c37804e9..31f4efca0 100644 --- a/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/handler/AnnotationEventHandler.java +++ b/org.jrebirth.af/core/src/main/java/org/jrebirth/af/core/ui/handler/AnnotationEventHandler.java @@ -31,8 +31,8 @@ import org.jrebirth.af.core.resource.provided.JRebirthParameters; import org.jrebirth.af.core.ui.UIMessages; import org.jrebirth.af.core.ui.annotation.EnumEventType; -import org.jrebirth.af.core.ui.annotation.OnAction; -import org.jrebirth.af.core.ui.annotation.OnKey; +import org.jrebirth.af.core.ui.annotation.type.Action; +import org.jrebirth.af.core.ui.annotation.type.Key; import org.jrebirth.af.core.util.ClassUtility; /** @@ -124,7 +124,7 @@ private String buildHandlingMethodName(final EnumEventType annotationType) { // Don't change the case for all other letters methodName.append(this.annotation.annotationType().getSimpleName().substring(1)); // Append if necessary the sub type if not equals to any - methodName.append(OnKey.KeyType.Any.name().equals(annotationType.toString()) || OnAction.ActionType.Action.name().equals(annotationType.toString()) ? "" : annotationType.name()); + methodName.append(Key.Any.name().equals(annotationType.toString()) || Action.Action.name().equals(annotationType.toString()) ? "" : annotationType.name()); // Add suffix if handling method is named final String uniqueName = getAnnotationName(); diff --git a/org.jrebirth.af/core/src/test/java/org/jrebirth/af/core/ui/annotation/AnnotationView.java b/org.jrebirth.af/core/src/test/java/org/jrebirth/af/core/ui/annotation/AnnotationView.java index 3155ece8b..5620d430d 100644 --- a/org.jrebirth.af/core/src/test/java/org/jrebirth/af/core/ui/annotation/AnnotationView.java +++ b/org.jrebirth.af/core/src/test/java/org/jrebirth/af/core/ui/annotation/AnnotationView.java @@ -25,8 +25,8 @@ import org.jrebirth.af.core.ui.DefaultView; import org.jrebirth.af.core.ui.annotation.OnRotate; import org.jrebirth.af.core.ui.annotation.OnSwipe; -import org.jrebirth.af.core.ui.annotation.OnRotate.RotateType; -import org.jrebirth.af.core.ui.annotation.OnSwipe.SwipeType; +import org.jrebirth.af.core.ui.annotation.type.Rotate; +import org.jrebirth.af.core.ui.annotation.type.Swipe; /** * @@ -41,10 +41,10 @@ public final class AnnotationView extends DefaultView