37 */
38 public class ScrollToEvent<T> extends Event {
39 // /**
40 // * This event occurs if the user requests scrolling a node into view.
41 // */
42 // @SuppressWarnings("unchecked")
43 // public static EventType<ScrollToEvent<Node>> scrollToNode() {
44 // return SCROLL_TO_NODE;
45 // }
46 // private static final EventType<ScrollToEvent<Node>> SCROLL_TO_NODE =
47 // new EventType<ScrollToEvent<Node>>(ScrollToEvent.ANY, "SCROLL_TO_NODE");
48
49 /**
50 * Common supertype for all scroll-to event types.
51 */
52 public static final EventType<ScrollToEvent> ANY =
53 new EventType<ScrollToEvent> (Event.ANY, "SCROLL_TO");
54
55 /**
56 * This event occurs if the user requests scrolling a given index into view.
57 */
58 public static EventType<ScrollToEvent<Integer>> scrollToTopIndex() {
59 return SCROLL_TO_TOP_INDEX;
60 }
61 private static final EventType<ScrollToEvent<Integer>> SCROLL_TO_TOP_INDEX =
62 new EventType<ScrollToEvent<Integer>>(ScrollToEvent.ANY, "SCROLL_TO_TOP_INDEX");
63
64
65 /**
66 * This event occurs if the user requests scrolling a {@link TableColumnBase}
67 * (i.e. {@link TableColumn} or {@link TreeTableColumn}) into view.
68 */
69 @SuppressWarnings("unchecked")
70 public static <T extends TableColumnBase<?, ?>> EventType<ScrollToEvent<T>> scrollToColumn() {
71 return (EventType<ScrollToEvent<T>>) SCROLL_TO_COLUMN;
72 }
73 private static final EventType<?> SCROLL_TO_COLUMN =
74 new EventType<>(ScrollToEvent.ANY, "SCROLL_TO_COLUMN");
75
76 private static final long serialVersionUID = -8557345736849482516L;
77
78 private final T scrollTarget;
79
80 /**
81 * Construct a new {@code Event} with the specified event source, target
82 * and type. If the source or target is set to {@code null}, it is replaced
83 * by the {@code NULL_SOURCE_TARGET} value.
84 *
85 * @param source the event source which sent the event
86 * @param target the event source which sent the event
87 * @param type the event type
88 * @param target the target of the scroll to operation
89 */
90 public ScrollToEvent(@NamedArg("source") Object source, @NamedArg("target") EventTarget target, @NamedArg("type") EventType<ScrollToEvent<T>> type, @NamedArg("scrollTarget") T scrollTarget) {
91 super(source, target, type);
92 assert scrollTarget != null;
93 this.scrollTarget = scrollTarget;
94
95 }
96
97 public T getScrollTarget() {
98 return scrollTarget;
99 }
100 }
|
37 */
38 public class ScrollToEvent<T> extends Event {
39 // /**
40 // * This event occurs if the user requests scrolling a node into view.
41 // */
42 // @SuppressWarnings("unchecked")
43 // public static EventType<ScrollToEvent<Node>> scrollToNode() {
44 // return SCROLL_TO_NODE;
45 // }
46 // private static final EventType<ScrollToEvent<Node>> SCROLL_TO_NODE =
47 // new EventType<ScrollToEvent<Node>>(ScrollToEvent.ANY, "SCROLL_TO_NODE");
48
49 /**
50 * Common supertype for all scroll-to event types.
51 */
52 public static final EventType<ScrollToEvent> ANY =
53 new EventType<ScrollToEvent> (Event.ANY, "SCROLL_TO");
54
55 /**
56 * This event occurs if the user requests scrolling a given index into view.
57 * @return the scroll to event type
58 */
59 public static EventType<ScrollToEvent<Integer>> scrollToTopIndex() {
60 return SCROLL_TO_TOP_INDEX;
61 }
62 private static final EventType<ScrollToEvent<Integer>> SCROLL_TO_TOP_INDEX =
63 new EventType<ScrollToEvent<Integer>>(ScrollToEvent.ANY, "SCROLL_TO_TOP_INDEX");
64
65
66 /**
67 * This event occurs if the user requests scrolling a {@link TableColumnBase}
68 * (i.e. {@link TableColumn} or {@link TreeTableColumn}) into view.
69 * @param <T> the type
70 * @return the scroll to event type
71 */
72 @SuppressWarnings("unchecked")
73 public static <T extends TableColumnBase<?, ?>> EventType<ScrollToEvent<T>> scrollToColumn() {
74 return (EventType<ScrollToEvent<T>>) SCROLL_TO_COLUMN;
75 }
76 private static final EventType<?> SCROLL_TO_COLUMN =
77 new EventType<>(ScrollToEvent.ANY, "SCROLL_TO_COLUMN");
78
79 private static final long serialVersionUID = -8557345736849482516L;
80
81 private final T scrollTarget;
82
83 /**
84 * Construct a new {@code Event} with the specified event source, target
85 * and type. If the source or target is set to {@code null}, it is replaced
86 * by the {@code NULL_SOURCE_TARGET} value.
87 *
88 * @param source the event source which sent the event
89 * @param target the event source which sent the event
90 * @param type the event type
91 * @param scrollTarget the target of the scroll to operation
92 */
93 public ScrollToEvent(@NamedArg("source") Object source, @NamedArg("target") EventTarget target, @NamedArg("type") EventType<ScrollToEvent<T>> type, @NamedArg("scrollTarget") T scrollTarget) {
94 super(source, target, type);
95 assert scrollTarget != null;
96 this.scrollTarget = scrollTarget;
97
98 }
99
100 public T getScrollTarget() {
101 return scrollTarget;
102 }
103 }
|