|
17 | 17 |
|
18 | 18 |
|
19 | 19 | import javafx.beans.value.ObservableValue;
|
| 20 | +import javafx.event.ActionEvent; |
20 | 21 | import javafx.event.Event;
|
21 | 22 | import javafx.event.EventType;
|
22 | 23 | import javafx.scene.Node;
|
23 | 24 | import javafx.scene.Scene;
|
| 25 | +import javafx.scene.control.ContextMenu; |
| 26 | +import javafx.scene.control.MenuItem; |
24 | 27 | import rx.Observable;
|
25 |
| -import rx.javafx.sources.Change; |
26 |
| -import rx.javafx.sources.NodeEventSource; |
27 |
| -import rx.javafx.sources.ObservableValueSource; |
28 |
| -import rx.javafx.sources.SceneEventSource; |
| 28 | +import rx.javafx.sources.*; |
29 | 29 |
|
30 | 30 |
|
31 | 31 | public enum JavaFxObservable {
|
@@ -74,4 +74,34 @@ public static <T> Observable<Change<T>> fromObservableValueChanges(final Observa
|
74 | 74 | public static <T extends Event> Observable<T> fromSceneEvents(final Scene scene, final EventType<T> eventType) {
|
75 | 75 | return SceneEventSource.fromSceneEvents(scene,eventType);
|
76 | 76 | }
|
| 77 | + |
| 78 | + /** |
| 79 | + * Creates an observable corresponding to javafx Node action events. |
| 80 | + * |
| 81 | + * @param node The target of the ActionEvents |
| 82 | + * @return An Observable of UI ActionEvents |
| 83 | + */ |
| 84 | + public static Observable<ActionEvent> fromActionEvents(final Node node) { |
| 85 | + return ActionEventSource.fromActionEvents(node); |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Creates an observable corresponding to javafx ContextMenu action events. |
| 90 | + * |
| 91 | + * @param contextMenu The target of the ActionEvents |
| 92 | + * @return An Observable of UI ActionEvents |
| 93 | + */ |
| 94 | + public static Observable<ActionEvent> fromActionEvents(final ContextMenu contextMenu) { |
| 95 | + return ActionEventSource.fromActionEvents(contextMenu); |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * Creates an observable corresponding to javafx MenuItem action events. |
| 100 | + * |
| 101 | + * @param menuItem The target of the ActionEvents |
| 102 | + * @return An Observable of UI ActionEvents |
| 103 | + */ |
| 104 | + public static Observable<ActionEvent> fromActionEvents(final MenuItem menuItem) { |
| 105 | + return ActionEventSource.fromActionEvents(menuItem); |
| 106 | + } |
77 | 107 | }
|
0 commit comments