Java Code Examples for javafx.beans.value.ChangeListener#changed()
The following examples show how to use
javafx.beans.value.ChangeListener#changed() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetMultimapExpressionHelper.java From gef with Eclipse Public License 2.0 | 6 votes |
private void notifyListeners(ObservableSetMultimap<K, V> oldValue, ObservableSetMultimap<K, V> currentValue) { if (currentValue != oldValue) { notifyInvalidationListeners(); if (changeListeners != null) { try { lockChangeListeners = true; for (ChangeListener<? super ObservableSetMultimap<K, V>> l : changeListeners) { l.changed(observableValue, oldValue, currentValue); } } finally { lockChangeListeners = false; } } if (oldValue == null || !oldValue.equals(currentValue)) { notifySetMultimapListeners(oldValue, currentValue); } } }
Example 2
Source File: SetExpressionHelperEx.java From gef with Eclipse Public License 2.0 | 6 votes |
private void notifyListeners(ObservableSet<E> oldValue, ObservableSet<E> currentValue) { if (currentValue != oldValue) { notifyInvalidationListeners(); if (changeListeners != null) { try { lockChangeListeners = true; for (ChangeListener<? super ObservableSet<E>> l : changeListeners) { l.changed(observableValue, oldValue, currentValue); } } finally { lockChangeListeners = false; } } if (oldValue == null || !oldValue.equals(currentValue)) { notifySetListeners(oldValue, currentValue); } } }
Example 3
Source File: ListExpressionHelperEx.java From gef with Eclipse Public License 2.0 | 6 votes |
private void notifyListeners(ObservableList<E> oldValue, ObservableList<E> currentValue) { if (currentValue != oldValue) { notifyInvalidationListeners(); if (changeListeners != null) { try { lockChangeListeners = true; for (ChangeListener<? super ObservableList<E>> l : changeListeners) { l.changed(observableValue, oldValue, currentValue); } } finally { lockChangeListeners = false; } } if (oldValue == null || !oldValue.equals(currentValue)) { notifyListListeners(oldValue, currentValue); } } }
Example 4
Source File: MultisetExpressionHelper.java From gef with Eclipse Public License 2.0 | 6 votes |
private void notifyListeners(ObservableMultiset<E> oldValue, ObservableMultiset<E> currentValue) { if (currentValue != oldValue) { notifyInvalidationListeners(); if (changeListeners != null) { try { lockChangeListeners = true; for (ChangeListener<? super ObservableMultiset<E>> l : changeListeners) { l.changed(observableValue, oldValue, currentValue); } } finally { lockChangeListeners = false; } } if (oldValue == null || !oldValue.equals(currentValue)) { notifyMultisetListeners(oldValue, currentValue); } } }
Example 5
Source File: MapExpressionHelperEx.java From gef with Eclipse Public License 2.0 | 6 votes |
private void notifyListeners(ObservableMap<K, V> oldValue, ObservableMap<K, V> currentValue) { if (currentValue != oldValue) { notifyInvalidationListeners(); if (changeListeners != null) { try { lockChangeListeners = true; for (ChangeListener<? super ObservableMap<K, V>> l : changeListeners) { l.changed(observableValue, oldValue, currentValue); } } finally { lockChangeListeners = false; } } if (oldValue == null || !oldValue.equals(currentValue)) { notifyMapListeners(oldValue, currentValue); } } }
Example 6
Source File: ScrollGesture.java From gef with Eclipse Public License 2.0 | 5 votes |
@Override protected void doActivate() { for (final IViewer viewer : getDomain().getViewers().values()) { // register a viewer focus change listener ChangeListener<Boolean> viewerFocusChangeListener = createFocusChangeListener( viewer); viewer.viewerFocusedProperty() .addListener(viewerFocusChangeListener); viewerFocusChangeListeners.put(viewer, viewerFocusChangeListener); ChangeListener<? super Scene> sceneListener = (exp, oldScene, newScene) -> { if (oldScene != null) { unhookScene(viewer); } if (newScene != null) { hookScene(newScene, viewer); } }; ObjectExpression<Scene> sceneProperty = viewer.getCanvas() .sceneProperty(); sceneProperty.addListener(sceneListener); if (sceneProperty.get() != null) { sceneListener.changed(sceneProperty, null, sceneProperty.get()); } } }
Example 7
Source File: AbstractGesture.java From gef with Eclipse Public License 2.0 | 5 votes |
/** * This method is called when a valid {@link IDomain} is attached to this * gesture so that you can register event listeners for various inputs * (keyboard, mouse) or model changes (selection, scroll offset / viewport). */ protected void doActivate() { ChangeListener<? super Scene> sceneListener = (exp, oldScene, newScene) -> { if (oldScene != null) { // Check that no other viewer still uses that scene before // unhooking it if (getDomain().getViewers().values().stream() .noneMatch(v -> v.getCanvas().getScene() == oldScene)) { unhookScene(oldScene); } } if (newScene != null) { hookScene(newScene); } }; for (final IViewer viewer : getDomain().getViewers().values()) { // register a viewer focus change listener ChangeListener<Boolean> viewerFocusChangeListener = createFocusChangeListener( viewer); viewer.viewerFocusedProperty() .addListener(viewerFocusChangeListener); viewerFocusChangeListeners.put(viewer, viewerFocusChangeListener); // ensure re-hooking in response to Scene changes ObjectExpression<Scene> sceneProperty = viewer.getCanvas() .sceneProperty(); sceneProperty.addListener(sceneListener); sceneChangeListeners.put(sceneProperty, sceneListener); if (sceneProperty.get() != null) { sceneListener.changed(sceneProperty, null, sceneProperty.get()); } } }
Example 8
Source File: MainWindow.java From markdown-writer-fx with BSD 2-Clause "Simplified" License | 5 votes |
/** * Creates a boolean property that is bound to another boolean value * of the active editor's SmartEdit. */ private BooleanProperty createActiveEditBooleanProperty(Function<SmartEdit, ObservableBooleanValue> func) { BooleanProperty b = new SimpleBooleanProperty() { @Override public void set(boolean newValue) { // invoked when the user invokes an action // do not try to change SmartEdit properties because this // would throw a "bound value cannot be set" exception } }; ChangeListener<? super FileEditor> listener = (observable, oldFileEditor, newFileEditor) -> { b.unbind(); if (newFileEditor != null) { if (newFileEditor.getEditor() != null) b.bind(func.apply(newFileEditor.getEditor().getSmartEdit())); else { newFileEditor.editorProperty().addListener((ob, o, n) -> { b.bind(func.apply(n.getSmartEdit())); }); } } else b.set(false); }; FileEditor fileEditor = fileEditorTabPane.getActiveFileEditor(); listener.changed(null, null, fileEditor); fileEditorTabPane.activeFileEditorProperty().addListener(listener); return b; }
Example 9
Source File: WaterfallPerformanceSample.java From chart-fx with Apache License 2.0 | 4 votes |
private ToolBar getDataSetToolBar(Chart chart) { ToolBar dataSetToolBar = new ToolBar(); inputSource.getSelectionModel().select(0); inputSource.getSelectionModel().selectedItemProperty().addListener((ch, o, n) -> dataSet.setInputSource(n)); frameSize.valueProperty().addListener((ch, o, n) -> updateTimer(true)); frameSize.setEditable(true); frameSize.setPrefWidth(80); frameCount.valueProperty().addListener((ch, o, n) -> updateTimer(true)); frameCount.setEditable(true); frameCount.setPrefWidth(80); final Label canvasDimension = new Label(); ChangeListener<Number> canvasListener = (ch, o, n) -> canvasDimension.setText("canvas = " + chart.getCanvas().getWidth() + " x " + chart.getCanvas().getHeight() + " pixels"); final Label dataSetDimension = new Label(); dataSetDimension.setText( dataSet.getDataCount(DataSet.DIM_X) + " x " + dataSet.getDataCount(DataSet.DIM_Y) + " data points"); dataSet.addListener(evt -> { final int dimX = dataSet.getDataCount(DataSet.DIM_X); final int dimY = dataSet.getDataCount(DataSet.DIM_Y); Platform.runLater(() -> { dataSetDimension.setText(dimX + " x " + dimY + " data points"); canvasDimension.setText( "canvas = " + chart.getCanvas().getWidth() + " x " + chart.getCanvas().getHeight() + " pixels"); }); }); mute.setSelected(dataSet.isOutputMuted()); mute.selectedProperty().addListener((ch, o, n) -> dataSet.setOutputMuted(n)); canvasListener.changed(null, null, null); chart.widthProperty().addListener(canvasListener); chart.heightProperty().addListener(canvasListener); final Pane spacer = new Pane(); HBox.setHgrow(spacer, Priority.ALWAYS); dataSetToolBar.getItems().addAll(new Label("DataSet Settings:"), // new Label("input source:"), inputSource, // new Label("frame size:"), frameSize, // new Label("frame count:"), frameCount, mute, spacer, new HBox(canvasDimension, dataSetDimension)); return dataSetToolBar; }
Example 10
Source File: ThemePanel.java From Quelea with GNU General Public License v3.0 | 4 votes |
/** * Create and initialise the theme panel. * <p> * @param wordsArea the text area to use for words. If null, sample lyrics * will be used. */ public ThemePanel(InlineCssTextArea wordsArea, Button confirmButton, boolean showThemeCopyPanel) { this.confirmButton = confirmButton; positionSelector = new DisplayPositionSelector(this); positionSelector.prefWidthProperty().bind(widthProperty()); positionSelector.prefHeightProperty().bind(heightProperty()); DisplayCanvas canvas = new DisplayCanvas(false, false, false, new DisplayCanvas.CanvasUpdater() { @Override public void updateCallback() { updateTheme(true); } }, Priority.LOW); preview = new DisplayPreview(canvas); VBox centrePane = new VBox(); Label label = new Label(" " + LabelGrabber.INSTANCE.getLabel("hover.for.position.label") + ":"); if (!QueleaProperties.get().getUseDarkTheme()) { label.setStyle("-fx-text-fill:#666666;"); centrePane.setStyle("-fx-background-color:#dddddd;"); } centrePane.getChildren().add(label); StackPane themePreviewPane = new StackPane(); themePreviewPane.getStyleClass().add("text-area"); themePreviewPane.getChildren().add(preview); themePreviewPane.getChildren().add(positionSelector); centrePane.getChildren().add(themePreviewPane); setCenter(centrePane); final WordDrawer drawer; if (canvas.isStageView()) { drawer = new StageDrawer(); } else { drawer = new LyricDrawer(); } drawer.setCanvas(canvas); text = SAMPLE_LYRICS; if (wordsArea != null) { ChangeListener<String> cl = (ov, t, newText) -> { SongDisplayable dummy = new SongDisplayable("", ""); dummy.setLyrics(newText); TextSection[] sections = dummy.getSections(); if (sections.length > 0 && sections[0].getText(false, false).length > 0) { text = sections[0].getText(false, false); } else { text = SAMPLE_LYRICS; } if (isEmpty(text)) { text = SAMPLE_LYRICS; } updateTheme(false); }; wordsArea.textProperty().addListener(cl); cl.changed(null, null, wordsArea.getText()); } VBox northBox = new VBox(); HBox themeSelectPanel = new HBox(); themeSelectPanel.setPadding(new Insets(5)); Label themeSelectLabel = new Label(LabelGrabber.INSTANCE.getLabel("theme.copy.label") + ": "); themeSelectLabel.setPadding(new Insets(3,0,0,0)); themeCombo = new ComboBox<>(); themeCombo.setItems(ThemeUtils.getThemes()); Button copyButton = new Button(LabelGrabber.INSTANCE.getLabel("copy")); copyButton.setOnAction(event -> { setTheme(themeCombo.getValue()); }); themeSelectPanel.setSpacing(5); themeSelectPanel.getChildren().addAll(themeSelectLabel, themeCombo, copyButton); themeToolbar = new ThemeToolbar(this); if(showThemeCopyPanel) { northBox.getChildren().add(themeSelectPanel); } northBox.getChildren().add(themeToolbar); setTop(northBox); updateTheme(false); setMaxSize(800, 600); }
Example 11
Source File: TypeStrokeGesture.java From gef with Eclipse Public License 2.0 | 4 votes |
@Override protected void doActivate() { for (final IViewer viewer : getDomain().getViewers().values()) { // store the key that is initially pressed so that we can wait for // it to be released final Set<KeyCode> pressedKeys = new HashSet<>(); // register a viewer focus change listener to release the initially // pressed key when the window loses focus ChangeListener<Boolean> viewerFocusChangeListener = new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { // cannot abort if no activeViewer if (activeViewer == null) { return; } // check if any viewer is focused for (IViewer v : getDomain().getViewers().values()) { if (v.isViewerFocused()) { return; } } // cancel target policies for (IOnStrokeHandler policy : getActiveHandlers( activeViewer)) { policy.abortPress(); } // clear active policies clearActiveHandlers(activeViewer); activeViewer = null; // close execution transaction getDomain() .closeExecutionTransaction(TypeStrokeGesture.this); // unset pressed keys pressedKeys.clear(); } }; viewer.viewerFocusedProperty() .addListener(viewerFocusChangeListener); viewerFocusChangeListeners.put(viewer, viewerFocusChangeListener); ChangeListener<? super Scene> sceneListener = (exp, oldScene, newScene) -> { if (oldScene != null) { // Check that no other viewer still uses that scene before // unhooking it if (getDomain().getViewers().values().stream().noneMatch( v -> v.getCanvas().getScene() == oldScene)) { unhook(oldScene); } } if (newScene != null) { hookScene(newScene, pressedKeys); } }; ObjectExpression<Scene> sceneProperty = viewer.getCanvas() .sceneProperty(); sceneProperty.addListener(sceneListener); if (sceneProperty.get() != null) { sceneListener.changed(sceneProperty, null, sceneProperty.get()); } } }