@Override public void init() { // allow multiple rows selection tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); // listener for items selection change tableView .getSelectionModel() .getSelectedIndices() .addListener( (ListChangeListener<Integer>) change -> { if (change.getList().size() > 0) { setContextMenuState(true, true, true, true); } else { setContextMenuState(false, false, false, false); } }); // prevent table columns reordering tableView .getColumns() .addListener( (ListChangeListener<TableColumn<FileItem, ?>>) change -> { change.next(); if (change.wasReplaced()) { tableView.getColumns().clear(); tableView.getColumns().addAll(selectColumn, filenameColumn, filepathColumn); } }); // set column as a CheckBox column selectColumn.setCellFactory( cellData -> { CheckBoxTableCell<FileItem, Boolean> checkBoxTableCell = new CheckBoxTableCell<>(); // set value changed listener checkBoxTableCell.setSelectedStateCallback( index -> tableView.getItems().get(index).selectedProperty()); return checkBoxTableCell; }); // add checkbox to column heading selectFilesCheckBox = new CheckBox(); selectFilesCheckBox.setDisable(true); selectColumn.setGraphic(selectFilesCheckBox); selectFilesCheckBox .selectedProperty() .addListener( (observable, oldValue, newValue) -> { synchronized (LOCK) { tableView.getItems().forEach(fileItem -> fileItem.setSelected(newValue)); } }); // set value of cells in column selectColumn.setCellValueFactory(cellData -> cellData.getValue().selectedProperty()); filenameColumn.setCellValueFactory(cellData -> cellData.getValue().filenameProperty()); filepathColumn.setCellValueFactory(cellData -> cellData.getValue().filepathProperty()); }
// METODO ENCARGADO DE HABILITAR LOS CAMPOS PARA UN NUEVO EMPLEADO @FXML private void nuevoEmpleado(ActionEvent event) { limpiarCamposEmp(); txtNombreEmpleado.setEditable(true); txtApellidoEmpleado.setEditable(true); ckbGerente.setDisable(false); ckbJefeDeBodega.setDisable(false); ckbGerente.setSelected(true); txtTelefonoEmpleado.setEditable(true); txtEmailEmpleado.setEditable(true); rbEstadoActivoEmpleado.setDisable(false); btnGuardarEmpleado.setDisable(false); btnNuevoEmpleado.setDisable(true); }
@Override public void clearForm() { modTrans = null; amountField.setDecimal(BigDecimal.ZERO); reconciledButton.setDisable(false); reconciledButton.setSelected(false); reconciledButton.setIndeterminate(false); if (payeeTextField != null) { // transfer slips do not use the payee field payeeTextField.setEditable(true); payeeTextField.clear(); } datePicker.setEditable(true); if (!Options.rememberLastDateProperty().get()) { datePicker.setValue(LocalDate.now()); } memoTextField.clear(); numberComboBox.setValue(null); numberComboBox.setDisable(false); attachmentPane.clear(); }
// METODO ENCARGADO DE CARGAR LOS DATOS AL FORMULARIO EEMPLEADOS SEGUN EL ITEM SELECCIONADO private void cargarDatosEmpleadoAlFormulario(String dato) { ResultSet cargaDatosParaFormularioEmpeados = usuarioDao.datosParaFormularioEmpleados(dato); try { while (cargaDatosParaFormularioEmpeados.next()) { txtNombreEmpleado.setText( cargaDatosParaFormularioEmpeados.getString("NOMBRE_USUARIO").trim()); txtApellidoEmpleado.setText(cargaDatosParaFormularioEmpeados.getString("APELLIDOS").trim()); rbEstadoActivoEmpleado.setDisable(false); rbEstadoInactivoEmpleado.setDisable(false); String cargo = cargaDatosParaFormularioEmpeados.getString("CARGO").trim(); ckbGerente.setDisable(false); ckbJefeDeBodega.setDisable(false); if (cargo.equals("Gerente")) { ckbGerente.setSelected(true); } else { ckbJefeDeBodega.setSelected(true); } txtTelefonoEmpleado.setText(cargaDatosParaFormularioEmpeados.getString("TELEFONO").trim()); txtEmailEmpleado.setText(cargaDatosParaFormularioEmpeados.getString("E_MAIL").trim()); int estadoEmpleado = cargaDatosParaFormularioEmpeados.getInt("ESTADOID"); rbEstadoActivoEmpleado.setDisable(false); rbEstadoInactivoEmpleado.setDisable(false); if (estadoEmpleado == 1) { rbEstadoActivoEmpleado.setSelected(true); } else { rbEstadoInactivoEmpleado.setSelected(true); } } cargaDatosParaFormularioEmpeados.close(); } catch (SQLException ex) { System.out.println("Error " + ex); } txtNombreEmpleado.setEditable(true); txtApellidoEmpleado.setEditable(true); txtTelefonoEmpleado.setEditable(true); txtEmailEmpleado.setEditable(true); btnModificarEmpleado.setDisable(false); ckbGerente.setDisable(true); ckbJefeDeBodega.setDisable(true); }
private void limpiarCamposEmp() { txtNombreEmpleado.setText(""); txtNombreEmpleado.setEditable(false); txtApellidoEmpleado.setText(""); txtApellidoEmpleado.setEditable(false); ckbGerente.setSelected(false); ckbGerente.setDisable(true); ckbJefeDeBodega.setSelected(false); ckbJefeDeBodega.setDisable(true); txtTelefonoEmpleado.setText(""); txtTelefonoEmpleado.setEditable(false); txtEmailEmpleado.setText(""); txtEmailEmpleado.setEditable(false); rbEstadoActivoEmpleado.setSelected(false); rbEstadoActivoEmpleado.setDisable(true); rbEstadoInactivoEmpleado.setSelected(false); rbEstadoInactivoEmpleado.setDisable(true); }
@SuppressWarnings("unchecked") @FXML private void handleButtonAction(ActionEvent event) { // createTree(); // create root TreeItem<String> root = new TreeItem<>("Output Structure"); // root.setExpanded(true); // create child TreeItem<String> item1 = new TreeItem<>("Data collect"); TreeItem<String> item1c1 = new TreeItem<>("Data Base"); TreeItem<String> item1c2 = new TreeItem<>("Field Trip"); TreeItem<String> item1c3 = new TreeItem<>("Darwin01"); item1.getChildren().addAll(item1c1, item1c2, item1c3); // item1.setExpanded(false); TreeItem<String> item2 = new TreeItem<>("Scanline"); TreeItem<String> item2C1 = new TreeItem<>("Power Law"); TreeItem<String> item2C2 = new TreeItem<>("New data"); item2.getChildren().addAll(item2C1, item2C2); TreeItem<String> item3 = new TreeItem<>("Modeling"); TreeItem<String> item3C1 = new TreeItem<>("2D"); TreeItem<String> item3C2 = new TreeItem<>("3D"); item3.getChildren().addAll(item3C1, item3C2); // itemChild2.setExpanded(false); // root is the parent of itemChild root.getChildren().addAll(item1, item2, item3); treeview_outs .getSelectionModel() .selectedItemProperty() .addListener( (v, oldvalue, newvalue) -> { if (newvalue != null) { System.out.println(newvalue.toString()); } }); treeview_outs.setRoot(root); grid_output_project.setDisable(true); check_output_newproject.setDisable(false); }
/** * Logs the current user out of the application and returns to the Login scene. * * @param event * @throws IOException * @throws ClassNotFoundException */ @FXML public void logout(ActionEvent event) throws IOException, ClassNotFoundException { verified.setDisable(false); goToScreen1(event); }
private void setSelectButtonsState( boolean selectAllState, boolean invertSelectionState, boolean filterState) { selectFilesCheckBox.setDisable(!selectAllState); invertSelectionButton.setDisable(!invertSelectionState); filterFilesButton.setDisable(!filterState); }
public void init(Model model, Terminal terminal) { // ==============================================// // ================ DECODING SETUP ==============// // ==============================================// // Populate decoding options combobox layoutOptionsComboBox.getItems().setAll(Display.LayoutOptions.values()); // Add listener to combobox layoutOptionsComboBox.setOnAction( event -> { // Bind the decoder decoding option to what has been selected in the // combobox terminal.txRx.display.selLayoutOption.set( layoutOptionsComboBox.getSelectionModel().getSelectedItem()); }); // Set default layoutOptionsComboBox.getSelectionModel().select(terminal.txRx.display.selLayoutOption.get()); TooltipUtil.addDefaultTooltip( layoutOptionsComboBox, "Separate mode displays a separate pane for RX data (top), and TX data (bottom). Combined mode shows one pane for both RX and TX data (if local echo is enabled). Combined mode with local echo turned on behaves similarly to a terminal."); // ==============================================// // ============= SETUP LOCAL TX ECHO ============// // ==============================================// // Bind the model boolean to the checkbox terminal.txRx.display.localTxEcho.bind(localTxEchoCheckBox.selectedProperty()); TooltipUtil.addDefaultTooltip( localTxEchoCheckBox, "If enabled, sent TX data will be copied (echoed) into the RX display."); // ==============================================// // =============== BACKSPACE SETUP ==============// // ==============================================// Bindings.bindBidirectional( backspaceRemovesLastTypedCharCheckBox.selectedProperty(), terminal.txRx.display.backspaceRemovesLastTypedChar); // Enable this checkbox only if the selected TX sending option is // on press on the "enter" key (this is the only way that this functionality makes sense) ChangeListener<Formatting.TxCharSendingOptions> changeListener = (observable, oldValue, newValue) -> { switch (newValue) { case SEND_TX_CHARS_IMMEDIATELY: backspaceRemovesLastTypedCharCheckBox.setDisable(true); break; case SEND_TX_CHARS_ON_ENTER: backspaceRemovesLastTypedCharCheckBox.setDisable(false); break; default: throw new RuntimeException("TxCharSendingOptions option not recognised."); } }; terminal.txRx.formatting.selTxCharSendingOption.addListener(changeListener); // Update disabled state to default changeListener.changed( terminal.txRx.formatting.selTxCharSendingOption, terminal.txRx.formatting.selTxCharSendingOption.get(), terminal.txRx.formatting.selTxCharSendingOption.get()); TooltipUtil.addDefaultTooltip( backspaceRemovesLastTypedCharCheckBox, "Enabling this will allow you to use backspace to delete TX chars before they are sent (on applicable if 'Send TX chars on enter' is selected). Disabling this will instead send the backspace character to the COM port."); // ==============================================// // ================ SETUP WRAPPING ==============// // ==============================================// // Bind "wrapping enabled" checkbox to model terminal.txRx.display.wrappingEnabled.bind(wrappingCheckBox.selectedProperty()); TooltipUtil.addDefaultTooltip( wrappingCheckBox, "Enable this to wrap at a certain pixel width (as defined below). If this is disabled, long lines of TX/RX text will cause horizontal scroll-bars to appear."); // Upon pressing enter or loosing focus, try and convert the wrapping width value and // update the model wrappingWidthTextField.onApply.addListener( (observable, oldValue, newValue) -> { // Convert wrapping width string into double, and then perform // sanity checks Double wrappingWidth; try { wrappingWidth = Double.parseDouble(newValue); } catch (NumberFormatException e) { model.status.addErr("Wrapping width was not a valid number."); wrappingWidth = 0.0; } if (wrappingWidth <= 0.0) { model.status.addErr("Wrapping width must be greater than 0."); wrappingWidth = 0.0; } terminal.txRx.display.wrappingWidth.set(wrappingWidth); }); // Set default value from model // (we assume the value in the model to be valid and no checking needed) wrappingWidthTextField .textProperty() .set(Double.toString(terminal.txRx.display.wrappingWidth.get())); // Disable the wrapping width textfield if wrapping is disabled. terminal.txRx.display.wrappingEnabled.addListener( (observable, oldValue, newValue) -> { wrappingWidthTextField.setDisable(!newValue); }); // Set default state wrappingWidthTextField.setDisable(!terminal.txRx.display.wrappingEnabled.get()); TooltipUtil.addDefaultTooltip( wrappingWidthTextField, "The width (in pixels) that you want TX/RX data to wrap at."); // ==============================================// // ============== BUFFER-SIZE SETUP =============// // ==============================================// // Perform a bi-directional bind, with custom string-to-number conversion which takes care // of any errors. Bindings.bindBidirectional( bufferSizeTextField.onApply, terminal.txRx.display.bufferSizeChars, new NumberStringConverter() { @Override public Number fromString(String value) { // Convert wrapping width string into double, and then perform // sanity checks Integer intValue; try { intValue = Integer.parseInt(value); } catch (NumberFormatException e) { model.status.addErr("Buffer size is not a valid integer."); return terminal.txRx.display.DEFAULT_BUFFER_SIZE_CHARS; } if (intValue <= 0.0) { model.status.addErr("Buffer size must be greater than 0."); return terminal.txRx.display.DEFAULT_BUFFER_SIZE_CHARS; } return intValue; } @Override public String toString(Number value) { return ((Integer) value).toString(); } }); // Add validation support for the buffer size ValidationSupport support = new ValidationSupport(); Validator<String> validator = (Control control, String value) -> { boolean condition; try { Integer.parseInt(value); condition = false; } catch (RuntimeException e) { condition = true; } return ValidationResult.fromMessageIf( control, "Not a valid integer", Severity.ERROR, condition); }; support.registerValidator(bufferSizeTextField, true, validator); TooltipUtil.addDefaultTooltip( bufferSizeTextField, "The max. number of characters to store in the TX and RX panes. Once the num. of characters exceeds this limit, the oldest characters are removed from the UI (this does not affect logging)."); // ==============================================// // =========== SCROLL BEHAVIOUR SETUP ===========// // ==============================================// // ToggleGroupValue<Display.ScrollBehaviour> scrollBehaviourToggleGroup = new // ToggleGroupValue(); // scrollBehaviourToggleGroup.add(scrollBehaviourStandardRadioButton, // Display.ScrollBehaviour.STANDARD); // scrollBehaviourToggleGroup.add(scrollBehaviourSmartRadioButton, // Display.ScrollBehaviour.SMART); // // Bindings.bindBidirectional(scrollBehaviourToggleGroup.valueProperty(), // terminal.txRx.display.scrollBehaviour); // // TooltipUtil.addDefaultTooltip(scrollBehaviourStandardRadioButton, "When the RX buffer // is full, the RX pane will not scroll automatically to keep the same lines of RX text in // view."); // TooltipUtil.addDefaultTooltip(scrollBehaviourSmartRadioButton, "When the RX buffer is // full, the RX pane will scroll automatically to keep the same lines of RX text in view (only // when scroll-to-bottom is not currently active)."); }