List of usage examples for javafx.beans.value ChangeListener ChangeListener
ChangeListener
From source file:com.rvantwisk.cnctools.controllers.PostProcessorsController.java
@FXML void initialize() { v_postprocessorList.setItems(projectModel.postProcessorsProperty()); if (mode == Mode.SELECT) { btnUse.setVisible(true);/* w w w . j av a 2 s.c om*/ } else { btnUse.setVisible(false); } // toolConfig.con postProcessor.disableProperty() .bind(v_postprocessorList.getSelectionModel().selectedItemProperty().isNull()); btnCopy.disableProperty().bind(v_postprocessorList.getSelectionModel().selectedItemProperty().isNull()); btnDelete.disableProperty().bind(v_postprocessorList.getSelectionModel().selectedItemProperty().isNull()); // When the user selects a item in the list then update the tool panel v_postprocessorList.getSelectionModel().selectedItemProperty() .addListener(new ChangeListener<CNCToolsPostProcessConfig>() { @Override public void changed(ObservableValue<? extends CNCToolsPostProcessConfig> observable, CNCToolsPostProcessConfig oldValue, CNCToolsPostProcessConfig newValue) { if (v_postprocessorList.getSelectionModel().selectedItemProperty().get() == null) { postProcessor.setData(null); // toolParametersController.setTool(new ToolParameter("", ToolParameter.Units.MM, new EndMill(6.0))); } else { postProcessor.setData(newValue); } } }); // Set text in ListView v_postprocessorList.setCellFactory( new Callback<ListView<CNCToolsPostProcessConfig>, ListCell<CNCToolsPostProcessConfig>>() { @Override public ListCell<CNCToolsPostProcessConfig> call(ListView<CNCToolsPostProcessConfig> p) { ListCell<CNCToolsPostProcessConfig> cell = new ListCell<CNCToolsPostProcessConfig>() { @Override protected void updateItem(CNCToolsPostProcessConfig t, boolean bln) { super.updateItem(t, bln); this.textProperty().unbind(); if (t != null) { textProperty().bind(t.nameProperty()); } else { textProperty().setValue(""); } } }; return cell; } }); int index = projectModel.postProcessorsProperty().indexOf(postProcessConfig); v_postprocessorList.getSelectionModel().select(index); }
From source file:org.noroomattheinn.visibletesla.MainController.java
/** * Called by the main application to allow us to store away the fxApp context * and perform any other fxApp startup tasks. In particular, we (1) distribute * fxApp context to all of the controllers, and (2) we set a listener for login * completion and try and automatic login. *///from w w w . ja v a2 s.co m void start(App theApp, VTVehicle v, VTData data, Prefs prefs) { this.app = theApp; this.vtVehicle = v; // This is defined in BaseController this.vtData = data; // This is defined in BaseController this.prefs = prefs; // This is defined in BaseController logAppInfo(); addSystemSpecificHandlers(app.stage); refreshTitle(); app.stage.getIcons().add(new Image(getClass().getClassLoader() .getResourceAsStream("org/noroomattheinn/TeslaResources/Icon-72@2x.png"))); tabPane.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Tab>() { @Override public void changed(ObservableValue<? extends Tab> ov, Tab t, Tab t1) { BaseController c = controllerFromTab(t1); if (c != null) { c.activate(); } } }); tabs = Arrays.asList(prefsTab, loginTab, schedulerTab, graphTab, chargeTab, hvacTab, locationTab, overviewTab, tripsTab, notifierTab); for (Tab t : tabs) { controllerFromTab(t).setAppContext(theApp, v, data, prefs); } // Handle font scaling int fontScale = prefs.fontScale.get(); if (fontScale != 100) { for (Tab t : tabs) { Node n = t.getContent(); n.setStyle(String.format("-fx-font-size: %d%%;", fontScale)); } } showDisclaimer(); // Watch for changes to the inactivity mode and state in order to update the UI App.addTracker(app.api.mode, new Runnable() { @Override public void run() { setAppModeMenu(); } }); App.addTracker(app.api.state, new Runnable() { @Override public void run() { refreshTitle(); } }); // Kick off the login process LoginController lc = Utils.cast(controllerFromTab(loginTab)); App.addTracker(lc.loggedIn, new LoginStateChange(lc.loggedIn, false)); lc.activate(); }
From source file:pl.baczkowicz.mqttspy.ui.controllers.NewPublicationController.java
public void initialize(URL location, ResourceBundle resources) { timeBasedFilter = new TimeBasedKeyEventFilter(500); publicationTopicText.setItems(publicationTopics); formatGroup.getToggles().get(0).setUserData(ConversionMethod.PLAIN); formatGroup.getToggles().get(1).setUserData(ConversionMethod.HEX_DECODE); formatGroup.getToggles().get(2).setUserData(ConversionMethod.BASE_64_DECODE); formatGroup.selectToggle(formatGroup.getToggles().get(0)); formatGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override//from w w w . java2s .com public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) { // If plain has been selected if (newValue != null) { switch ((ConversionMethod) formatGroup.getSelectedToggle().getUserData()) { case BASE_64_DECODE: showAsBase64(); break; case HEX_DECODE: showAsHex(); break; case PLAIN: showAsPlain(); break; default: break; } } } }); publicationTopicText.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent keyEvent) { switch (keyEvent.getCode()) { case ENTER: { if (connected && timeBasedFilter.processEvent(keyEvent)) { publish(); keyEvent.consume(); } break; } case DIGIT0: { restoreFromKeypress(keyEvent, 0); break; } case DIGIT1: { restoreFromKeypress(keyEvent, 1); break; } case DIGIT2: { restoreFromKeypress(keyEvent, 2); break; } case DIGIT3: { restoreFromKeypress(keyEvent, 3); break; } case DIGIT4: { restoreFromKeypress(keyEvent, 4); break; } case DIGIT5: { restoreFromKeypress(keyEvent, 5); break; } case DIGIT6: { restoreFromKeypress(keyEvent, 6); break; } case DIGIT7: { restoreFromKeypress(keyEvent, 7); break; } case DIGIT8: { restoreFromKeypress(keyEvent, 8); break; } case DIGIT9: { restoreFromKeypress(keyEvent, 9); break; } default: break; } } }); publicationData.setWrapText(true); publicationData.setOnKeyReleased(new EventHandler<Event>() { @Override public void handle(Event event) { final BaseMqttMessage values = readMessage(false, true); String payload = ""; if (values != null) { payload = values.getPayload(); } MqttMessageController.populatePayloadLength(lengthLabel, null, payload.length()); lengthLabel.getStyleClass().removeAll("newLinesPresent", "noNewLines"); if (payload.contains(ConversionUtils.LINE_SEPARATOR_LINUX) || payload.contains(ConversionUtils.LINE_SEPARATOR_WIN) || payload.contains(ConversionUtils.LINE_SEPARATOR_MAC)) { lengthLabel.getStyleClass().add("newLinesPresent"); } else { lengthLabel.getStyleClass().add("noNewLines"); } } }); publishScript.getToggles().get(0).setUserData(null); publishScript.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) { if (newValue.getUserData() == null) { publishButton.setText("Publish"); } else { publishButton.setText( "Publish" + System.lineSeparator() + "with" + System.lineSeparator() + "script"); } } }); publishButton.setTooltip( new Tooltip("Publish message [" + MqttViewManager.newPublication.getDisplayText() + "]")); }
From source file:com.anavationllc.o2jb.ConfigurationApp.java
private static void addTextLimiter(final TextField tf, final int maxLength) { tf.textProperty().addListener(new ChangeListener<String>() { @Override/*from w w w . j a v a 2 s .c o m*/ public void changed(final ObservableValue<? extends String> ov, final String oldValue, final String newValue) { if (tf.getText().length() > maxLength) { String s = tf.getText().substring(0, maxLength); tf.setText(s); } } }); }
From source file:com.mycompany.trafficimportfileconverter2.Main2Controller.java
/** * Initializes the controller class.//from w ww . j a v a 2 s . c o m */ @Override public void initialize(URL url, ResourceBundle rb) { prefs = Preferences.userNodeForPackage(this.getClass()); initDateArrays(); dirchooser = new DirectoryChooser(); outputDir.addListener(new ChangeListener<File>() { @Override public void changed(ObservableValue<? extends File> observable, File oldValue, File newValue) { lblOutputLoc.setText(newValue.getAbsolutePath()); prefs.put(OUTPUT_DIR_LOC, newValue.getAbsolutePath()); } }); setOutputDir(safeFileSet(new File(prefs.get(OUTPUT_DIR_LOC, "./")))); try { dirchooser.setInitialDirectory(getOutputDir()); } catch (Exception e) { System.out.println("Error setting init dir: " + e); e.printStackTrace(); } filechooser = new FileChooser(); try { filechooser.setInitialDirectory(new File(prefs.get(INPUT_DIR_LOC, "./"))); } catch (Exception e) { System.out.println("Error setting init directory of file chooser: " + e); e.printStackTrace(); } setExtension(prefs.get(EXTENSION, ".gen")); /* Save in preferences default getting file location every time the input file is reselected. */ inputFile.addListener(new ChangeListener<File>() { @Override public void changed(ObservableValue<? extends File> observable, File oldValue, File newValue) { lblInputFile.setText(newValue.getAbsolutePath()); prefs.put(INPUT_DIR_LOC, newValue.getParent()); reloadFileData(newValue); } }); txtAreaOutput.textProperty().addListener(new ChangeListener<Object>() { @Override public void changed(ObservableValue<?> observable, Object oldValue, Object newValue) { txtAreaOutput.setScrollTop(Double.MAX_VALUE); //this will scroll to the bottom //use Double.MIN_VALUE to scroll to the top } }); filechooser.getExtensionFilters().add(new ExtensionFilter("Tab Separated Values", "*.tsv", "*.TSV")); autoSearch(); log("Help document located:"); log(helpurl); }
From source file:ch.unibas.fittingwizard.presentation.fitting.FitResultPage.java
private void setupTable() { atomsTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<FitResultViewModel>() { @Override/*from www . j a va2s . co m*/ public void changed(ObservableValue<? extends FitResultViewModel> observableValue, FitResultViewModel fitResultViewModel, FitResultViewModel type) { setSelectedAtomType(type); } }); atomTypeColumn.setCellValueFactory(new PropertyValueFactory<FitResultViewModel, String>("atomTypeName")); for (final String chargeType : ChargeTypes.all) { TableColumn<FitResultViewModel, FitResultViewModel.FitValue> column = new TableColumn<>(chargeType); column.setPrefWidth(80); column.setMinWidth(80); column.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<FitResultViewModel, FitResultViewModel.FitValue>, ObservableValue<FitResultViewModel.FitValue>>() { @Override public ObservableValue<FitResultViewModel.FitValue> call( TableColumn.CellDataFeatures<FitResultViewModel, FitResultViewModel.FitValue> data) { return data.getValue().getChargeValueFor(chargeType); } }); column.setCellFactory(new ColoredCellCallback()); atomsTable.getColumns().add(column); } }
From source file:com.rvantwisk.cnctools.operations.facing.FacingController.java
@FXML void initialize() { assert cutDirection != null : "fx:id=\"cutDirection\" was not injected: check your FXML file 'Facing.fxml'."; assert edgeDirection != null : "fx:id=\"edgeDirection\" was not injected: check your FXML file 'Facing.fxml'."; assert gCodeViewerControl != null : "fx:id=\"gCodeViewerControl\" was not injected: check your FXML file 'Facing.fxml'."; assert iClimb != null : "fx:id=\"iClimb\" was not injected: check your FXML file 'Facing.fxml'."; assert iConv != null : "fx:id=\"iConv\" was not injected: check your FXML file 'Facing.fxml'."; assert iCutStrategy != null : "fx:id=\"iCutStrategy\" was not injected: check your FXML file 'Facing.fxml'."; assert iEdgeCleanup != null : "fx:id=\"iEdgeCleanup\" was not injected: check your FXML file 'Facing.fxml'."; assert iEdgeClimb != null : "fx:id=\"iEdgeClimb\" was not injected: check your FXML file 'Facing.fxml'."; assert iEdgeConv != null : "fx:id=\"iEdgeConv\" was not injected: check your FXML file 'Facing.fxml'."; assert iPartReference != null : "fx:id=\"iPartReference\" was not injected: check your FXML file 'Facing.fxml'."; assert iXLength != null : "fx:id=\"iXLength\" was not injected: check your FXML file 'Facing.fxml'."; assert iYLength != null : "fx:id=\"iYLength\" was not injected: check your FXML file 'Facing.fxml'."; assert iZFinal != null : "fx:id=\"iZFinal\" was not injected: check your FXML file 'Facing.fxml'."; assert iZSafe != null : "fx:id=\"iZSafe\" was not injected: check your FXML file 'Facing.fxml'."; assert iZTop != null : "fx:id=\"iZTop\" was not injected: check your FXML file 'Facing.fxml'."; assert selectOrEditTool != null : "fx:id=\"selectOrEditTool\" was not injected: check your FXML file 'Facing.fxml'."; iCutStrategy.getItems().clear();//from ww w. j a v a 2 s. c om iCutStrategy.getItems().addAll(FacingModel.CONFIGLIST); modelToForm(); selectOrEditTool.addEventHandler(ToolChangedEvent.TOOL_CHANGED_EVENT, new EventHandler<ToolChangedEvent>() { @Override public void handle(ToolChangedEvent toolChangedEvent) { generateGCode(); } }); iXLength.dimensionProperty().valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { generateGCode(); } }); iYLength.dimensionProperty().valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { generateGCode(); } }); iZFinal.dimensionProperty().valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { generateGCode(); } }); iZSafe.dimensionProperty().valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { generateGCode(); } }); iZTop.dimensionProperty().valueProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) { generateGCode(); } }); iEdgeCleanup.selectedProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean aBoolean2) { generateGCode(); } }); edgeDirection.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observableValue, Toggle toggle, Toggle toggle2) { generateGCode(); } }); cutDirection.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observableValue, Toggle toggle, Toggle toggle2) { generateGCode(); } }); iCutStrategy.valueProperty().addListener(new ChangeListener<FacingModel.Configuration>() { @Override public void changed(ObservableValue<? extends FacingModel.Configuration> observableValue, FacingModel.Configuration configuration, FacingModel.Configuration configuration2) { generateGCode(); } }); iPartReference.valueProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observableValue, String s, String s2) { generateGCode(); } }); generateGCode(); }
From source file:Main.java
public ComplaintsPage() { super("Complaints"); nextButton.setDisable(true);// w w w.j ava 2s.c o m finishButton.setDisable(true); yes.setToggleGroup(options); no.setToggleGroup(options); options.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observableValue, Toggle oldToggle, Toggle newToggle) { nextButton.setDisable(false); finishButton.setDisable(false); } }); }
From source file:org.sleuthkit.autopsy.imageanalyzer.gui.MetaDataPane.java
@Override public void setFile(Long fileID) { this.fileID = fileID; if (fileID == null) { Platform.runLater(() -> {/*from w ww. ja v a 2 s .c om*/ imageView.setImage(null); tableView.getItems().clear(); getBorderable().setBorder(null); }); } else { try { file = controller.getFileFromId(fileID); updateUI(); file.categoryProperty().addListener(new ChangeListener<Category>() { @Override public void changed(ObservableValue<? extends Category> ov, Category t, final Category t1) { updateUI(); } }); } catch (TskCoreException ex) { Exceptions.printStackTrace(ex); } } }
From source file:dsfixgui.view.DSFSavesPane.java
private void initializeEventHandlers() { applySettingsButton.setOnAction(e -> { ui.applyDSFConfig();//from w w w. ja va 2 s . c om }); restoreDefaultsButton.setOnAction(e -> { ContinueDialog cD = new ContinueDialog(300.0, 80.0, DIALOG_TITLE_RESET, DIALOG_MSG_RESTORE_SETTINGS, DIALOG_BUTTON_TEXTS[2], DIALOG_BUTTON_TEXTS[1]); if (cD.show()) { config.restoreDefaultSaveOptions(); ui.refreshUI(); } }); saveBackupsPicker.setOnAction(e -> { if (saveBackupsPicker.getValue().equals(DISABLE_ENABLE[0])) { saveIntervalField.setDisable(true); maxSavesField.setDisable(true); config.enableBackups.set(0); } else { saveIntervalField.setDisable(false); maxSavesField.setDisable(false); config.enableBackups.set(1); } }); saveIntervalField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || Integer.parseInt(newText) < 600) { saveIntervalField.pseudoClassStateChanged(INVALID_INPUT, true); saveIntervalField.setTooltip(new Tooltip(INPUT_GREATER_THAN_EQ + "600")); } else { saveIntervalField.pseudoClassStateChanged(INVALID_INPUT, false); saveIntervalField.setTooltip(new Tooltip("")); config.backupInterval.set(Integer.parseInt(newText)); } } catch (NumberFormatException nFE) { ui.printConsole(INPUT_TOO_LARGE); saveIntervalField.setText(""); } } }); maxSavesField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || Integer.parseInt(newText) < 1) { maxSavesField.pseudoClassStateChanged(INVALID_INPUT, true); maxSavesField.setTooltip(new Tooltip(INPUT_GREATER_THAN_EQ + "1")); } else { maxSavesField.pseudoClassStateChanged(INVALID_INPUT, false); maxSavesField.setTooltip(new Tooltip("")); config.maxBackups.set(Integer.parseInt(newText)); } } catch (NumberFormatException nFE) { ui.printConsole(INPUT_TOO_LARGE); maxSavesField.setText(""); } } }); }