Search in sources :

Example 16 with RadioButton

use of javafx.scene.control.RadioButton in project SmartCity-Market by TechnionYP5777.

the class ManagePackagesTab method initialize.

@Override
public void initialize(URL location, ResourceBundle __) {
    barcodeEventHandler.register(this);
    barcodeTextField.textProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.matches("\\d*"))
            barcodeTextField.setText(newValue.replaceAll("[^\\d]", ""));
        showScanCodePane(true);
        resetParams();
        searchCodeButton.setDisable(newValue.isEmpty());
    });
    editPackagesAmountSpinner.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL);
    editPackagesAmountSpinner.valueProperty().addListener((obs, oldValue, newValue) -> {
        if (newValue == null || newValue < 1)
            editPackagesAmountSpinner.getValueFactory().setValue(oldValue);
        enableRunTheOperationButton();
    });
    editPackagesAmountSpinner.focusedProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null && !newValue) {
            editPackagesAmountSpinner.increment(0);
            enableRunTheOperationButton();
        }
    });
    final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() {

        @Override
        public DateCell call(final DatePicker __) {
            return new DateCell() {

                @Override
                public void updateItem(LocalDate item, boolean empty) {
                    super.updateItem(item, empty);
                    if (!item.isBefore(LocalDate.now()))
                        return;
                    setDisable(true);
                    setStyle("-fx-background-color: #EEEEEE;");
                }
            };
        }
    };
    datePicker.setDayCellFactory(dayCellFactory);
    datePicker.setValue(LocalDate.now());
    VBox vbox = new VBox();
    vbox.setPadding(new Insets(10, 50, 50, 50));
    vbox.setSpacing(10);
    datePickerForSmartCode = new JFXDatePicker();
    Label lbl = new Label("Choose Date");
    vbox.getChildren().addAll(lbl, datePickerForSmartCode);
    JFXPopup popup = new JFXPopup(vbox);
    showDatePickerBtn.setOnMouseClicked(e -> popup.show(showDatePickerBtn, PopupVPosition.TOP, PopupHPosition.LEFT));
    radioButtonContainerSmarcodeOperations.addRadioButtons(Arrays.asList(new RadioButton[] { printSmartCodeRadioButton, addPackageToStoreRadioButton, removePackageFromStoreRadioButton, removePackageFromWarhouseRadioButton }));
    radioButtonContainerBarcodeOperations.addRadioButtons(Arrays.asList(new RadioButton[] { addPakageToWarhouseRadioButton }));
    resetParams();
    showScanCodePane(true);
}
Also used : JFXDatePicker(com.jfoenix.controls.JFXDatePicker) JFXPopup(com.jfoenix.controls.JFXPopup) Callback(javafx.util.Callback) Insets(javafx.geometry.Insets) Label(javafx.scene.control.Label) DatePicker(javafx.scene.control.DatePicker) JFXDatePicker(com.jfoenix.controls.JFXDatePicker) RadioButton(javafx.scene.control.RadioButton) JFXRadioButton(com.jfoenix.controls.JFXRadioButton) DateCell(javafx.scene.control.DateCell) LocalDate(java.time.LocalDate) VBox(javafx.scene.layout.VBox)

Example 17 with RadioButton

use of javafx.scene.control.RadioButton in project on-track by michaelplazek.

the class CentralTrafficControlController method connectOthers.

private void connectOthers() {
    TableView.TableViewSelectionModel<ScheduleRow> defaultModel = addScheduleTable.getSelectionModel();
    // connect the toggle buttons for mode of operation
    mode.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {

        public void changed(ObservableValue<? extends Toggle> ov, Toggle oldToggle, Toggle newToggle) {
            if (mode.getSelectedToggle() != null) {
                RadioButton btn = (RadioButton) newToggle.getToggleGroup().getSelectedToggle();
                changeMode(btn.getText(), defaultModel);
            }
        }
    });
    trainQueueTable.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
        if (trainQueueTable.getSelectionModel().getSelectedItem() != null) {
            TrainTracker selected = trainQueueTable.getSelectionModel().getSelectedItem();
            selectedScheduleTable.setItems(selected.getSchedule().getStops());
        }
    });
    trackSelect.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
        if (!newValue.equals("Select track")) {
            ctc.setLine(newValue);
            ctc.makeStationList();
            ctc.makeBlockList();
            stopColumn.setCellFactory(ComboBoxTableCell.forTableColumn(new DefaultStringConverter(), ctc.getStationList()));
            scheduleBlocks.setDisable(false);
            setAuthorityBlocks.setDisable(false);
            scheduleBlocks.setItems(ctc.getBlockList());
            setAuthorityBlocks.setItems(ctc.getBlockList());
            // only show trains that are on the selected line
            ctc.getTrainQueueTable().clear();
            ctc.getDispatchTable().clear();
            selectedScheduleTable.setItems(FXCollections.observableArrayList());
            TrainTracker item;
            ObservableList<TrainTracker> list = ctc.getTrainList();
            for (int i = 0; i < list.size(); i++) {
                item = list.get(i);
                if (item.getLine().equals(newValue)) {
                    // first, set the queue table
                    if (!item.isDispatched()) {
                        ctc.getTrainQueueTable().add(item);
                    } else {
                        // then get the dispatch table
                        ctc.getDispatchTable().add(item);
                    }
                }
            }
            // then set the user interface
            trainQueueTable.setItems(ctc.getTrainQueueTable());
            dispatchTable.setItems(ctc.getDispatchTable());
            if (ctc.getBlockList().size() > 0) {
                scheduleBlocks.setValue(ctc.getBlockList().get(0));
                setAuthorityBlocks.setValue(ctc.getBlockList().get(0));
            }
        } else {
            trackSelect.setValue(oldValue);
        }
    });
    maintenanceActions.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
        if (newValue.equals("Select action")) {
            maintenanceActions.setValue(oldValue);
        } else {
            String action = maintenanceActions.getSelectionModel().getSelectedItem();
            String line = maintenanceTracks.getSelectionModel().getSelectedItem();
            int blockId = extractBlock();
            Block block = Track.getListOfTracks().get(line).getBlock(blockId);
            if (action.equals("Toggle switch") && !block.isSwitch()) {
                submitMaintenance.setDisable(true);
            } else {
                submitMaintenance.setDisable(false);
            }
        }
    });
    maintenanceBlocks.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
        String action = maintenanceActions.getSelectionModel().getSelectedItem();
        String line = maintenanceTracks.getSelectionModel().getSelectedItem();
        int blockId = extractBlock();
        Block block = Track.getListOfTracks().get(line).getBlock(blockId);
        if (action.equals("Toggle switch") && !block.isSwitch()) {
            submitMaintenance.setDisable(true);
        } else {
            submitMaintenance.setDisable(false);
        }
    });
    maintenanceTracks.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
        if (!newValue.equals("Select track")) {
            trackMaintenance.setLine(newValue);
            trackMaintenance.makeBlockList();
            maintenanceBlocks.setItems(trackMaintenance.getBlockList());
            if (ctc.getBlockList().size() > 0) {
                maintenanceBlocks.setValue(trackMaintenance.getBlockList().get(0));
            }
        } else {
            maintenanceTracks.setValue(oldValue);
        }
        updateMaintenance();
    });
    trainStatus.setFill(Paint.valueOf("Grey"));
}
Also used : ScheduleRow(ctc.model.ScheduleRow) RadioButton(javafx.scene.control.RadioButton) Paint(javafx.scene.paint.Paint) TrainTracker(ctc.model.TrainTracker) DefaultStringConverter(javafx.util.converter.DefaultStringConverter) Toggle(javafx.scene.control.Toggle) Block(trackmodel.model.Block) TableView(javafx.scene.control.TableView)

Example 18 with RadioButton

use of javafx.scene.control.RadioButton in project org.csstudio.display.builder by kasemir.

the class RadioRepresentation method createRadioButton.

private RadioButton createRadioButton(final String text) {
    final RadioButton rb = new RadioButton(text);
    rb.setToggleGroup(toggle);
    rb.setMnemonicParsing(false);
    return rb;
}
Also used : RadioButton(javafx.scene.control.RadioButton)

Example 19 with RadioButton

use of javafx.scene.control.RadioButton in project org.csstudio.display.builder by kasemir.

the class RadioRepresentation method updateChanges.

@Override
public void updateChanges() {
    super.updateChanges();
    if (dirty_size.checkAndClear()) {
        // Size
        jfx_node.setPrefSize(model_widget.propWidth().getValue(), model_widget.propHeight().getValue());
        // Orientation seems more of a hint. JFX will chose based on width vs. height.
        jfx_node.setOrientation(model_widget.propHorizontal().getValue() ? Orientation.HORIZONTAL : Orientation.VERTICAL);
    }
    if (dirty_content.checkAndClear()) {
        active = true;
        try {
            // Copy volatile lists before iteration
            final List<String> save_items = new ArrayList<String>(items);
            final List<Node> save_buttons = new ArrayList<Node>(jfx_node.getChildren());
            // Set text of buttons, adding new ones as needed
            int i, save_index = index;
            for (i = 0; i < save_items.size(); i++) {
                if (i < save_buttons.size())
                    ((RadioButton) save_buttons.get(i)).setText(save_items.get(i));
                else
                    save_buttons.add(createRadioButton(save_items.get(i)));
            }
            while (i < save_buttons.size() && save_buttons.size() > 1) save_buttons.remove(save_buttons.size() - 1);
            // Select one of the radio buttons
            toggle.selectToggle(save_index < 0 || save_index >= save_buttons.size() ? null : (Toggle) save_buttons.get(save_index));
            jfx_node.getChildren().setAll(save_buttons);
        } finally {
            active = false;
        }
    }
    if (dirty_style.checkAndClear()) {
        final Color fg = JFXUtil.convert(model_widget.propForegroundColor().getValue());
        final Font font = JFXUtil.convert(model_widget.propFont().getValue());
        for (Node rb_node : jfx_node.getChildren()) {
            final RadioButton rb = (RadioButton) rb_node;
            rb.setTextFill(fg);
            rb.setFont(font);
        }
    }
}
Also used : Node(javafx.scene.Node) Toggle(javafx.scene.control.Toggle) Color(javafx.scene.paint.Color) ArrayList(java.util.ArrayList) RadioButton(javafx.scene.control.RadioButton) Font(javafx.scene.text.Font)

Example 20 with RadioButton

use of javafx.scene.control.RadioButton in project bisq-desktop by bisq-network.

the class FormBuilder method addLabelRadioButtonRadioButton.

// /////////////////////////////////////////////////////////////////////////////////////////
// Label  + RadioButton + RadioButton
// /////////////////////////////////////////////////////////////////////////////////////////
public static Tuple3<Label, RadioButton, RadioButton> addLabelRadioButtonRadioButton(GridPane gridPane, int rowIndex, ToggleGroup toggleGroup, String title, String radioButtonTitle1, String radioButtonTitle2) {
    Label label = addLabel(gridPane, rowIndex, title, 0);
    RadioButton radioButton1 = new AutoTooltipRadioButton(radioButtonTitle1);
    radioButton1.setToggleGroup(toggleGroup);
    radioButton1.setPadding(new Insets(6, 0, 0, 0));
    RadioButton radioButton2 = new AutoTooltipRadioButton(radioButtonTitle2);
    radioButton2.setToggleGroup(toggleGroup);
    radioButton2.setPadding(new Insets(6, 0, 0, 0));
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(radioButton1, radioButton2);
    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    gridPane.getChildren().add(hBox);
    return new Tuple3<>(label, radioButton1, radioButton2);
}
Also used : HBox(javafx.scene.layout.HBox) Insets(javafx.geometry.Insets) Tuple3(bisq.common.util.Tuple3) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) AutoTooltipRadioButton(bisq.desktop.components.AutoTooltipRadioButton) AutoTooltipRadioButton(bisq.desktop.components.AutoTooltipRadioButton) RadioButton(javafx.scene.control.RadioButton)

Aggregations

RadioButton (javafx.scene.control.RadioButton)29 Insets (javafx.geometry.Insets)9 ToggleGroup (javafx.scene.control.ToggleGroup)8 Label (javafx.scene.control.Label)7 Button (javafx.scene.control.Button)5 HBox (javafx.scene.layout.HBox)5 VBox (javafx.scene.layout.VBox)5 EasingInterpolator (com.almasb.fxgl.animation.EasingInterpolator)4 JFXRadioButton (com.jfoenix.controls.JFXRadioButton)4 AutoTooltipRadioButton (bisq.desktop.components.AutoTooltipRadioButton)3 ObservableValue (javafx.beans.value.ObservableValue)3 ActionEvent (javafx.event.ActionEvent)3 Node (javafx.scene.Node)3 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)2 RequiredFieldValidator (com.jfoenix.validation.RequiredFieldValidator)2 FontAwesomeIconView (de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView)2 ArrayList (java.util.ArrayList)2 Interpolator (javafx.animation.Interpolator)2 FXCollections (javafx.collections.FXCollections)2 ObservableList (javafx.collections.ObservableList)2