Example usage for javafx.scene.control SingleSelectionModel select

List of usage examples for javafx.scene.control SingleSelectionModel select

Introduction

In this page you can find the example usage for javafx.scene.control SingleSelectionModel select.

Prototype

@Override
public void select(int index) 

Source Link

Document

Selects the given index.

Usage

From source file:eu.ggnet.dwoss.receipt.shipment.ShipmentUpdateStage.java

private void init(Shipment s) {

    okButton.setOnAction((ActionEvent event) -> {
        shipment = getShipment();/* w  w  w  .  ja  v a2  s.c  o m*/
        if (isValid())
            close();
    });

    cancelButton.setOnAction((ActionEvent event) -> {
        close();
    });

    idField = new TextField(Long.toString(s.getId()));
    idField.setDisable(true);
    shipIdField = new TextField(s.getShipmentId());

    Callback<ListView<TradeName>, ListCell<TradeName>> cb = new Callback<ListView<TradeName>, ListCell<TradeName>>() {
        @Override
        public ListCell<TradeName> call(ListView<TradeName> param) {
            return new ListCell<TradeName>() {
                @Override
                protected void updateItem(TradeName item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item == null || empty)
                        setText("Hersteller whlen...");
                    else
                        setText(item.getName());
                }
            };
        }
    };

    Set<TradeName> contractors = Client.lookup(MandatorSupporter.class).loadContractors().all();
    ownerBox = new ComboBox<>(FXCollections.observableArrayList(contractors));
    ownerBox.setMaxWidth(MAX_VALUE);
    ownerBox.setCellFactory(cb);
    ownerBox.getSelectionModel().selectedItemProperty().addListener(
            (ObservableValue<? extends TradeName> observable, TradeName oldValue, TradeName newValue) -> {
                if (newValue == null)
                    return;
                shipment.setContractor(newValue);
                manufacturerBox.getSelectionModel().select(newValue.getManufacturer());
            });

    ObservableList<TradeName> manufacturers = FXCollections.observableArrayList(TradeName.getManufacturers());
    manufacturerBox = new ComboBox<>(manufacturers);
    manufacturerBox.setMaxWidth(MAX_VALUE);
    manufacturerBox.setCellFactory(cb);
    SingleSelectionModel<TradeName> sm = ownerBox.getSelectionModel();
    if (s.getContractor() == null)
        sm.selectFirst();
    else
        sm.select(s.getContractor());
    if (shipment.getDefaultManufacturer() != null)
        manufacturerBox.getSelectionModel().select(shipment.getDefaultManufacturer());

    statusBox = new ComboBox<>(FXCollections.observableArrayList(Shipment.Status.values()));
    statusBox.setMaxWidth(MAX_VALUE);
    statusBox.getSelectionModel().select(s.getStatus() == null ? OPENED : s.getStatus());

    GridPane grid = new GridPane();
    grid.addRow(1, new Label("ID:"), idField);
    grid.addRow(2, new Label("Shipment ID:"), shipIdField);
    grid.addRow(3, new Label("Besitzer:"), ownerBox);
    grid.addRow(4, new Label("Hersteller:"), manufacturerBox);
    grid.addRow(5, new Label("Status"), statusBox);
    grid.setMaxWidth(MAX_VALUE);
    grid.vgapProperty().set(2.);
    grid.getColumnConstraints().add(0,
            new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.SOMETIMES, HPos.LEFT, false));
    grid.getColumnConstraints().add(1,
            new ColumnConstraints(100, 150, Double.MAX_VALUE, Priority.ALWAYS, HPos.LEFT, true));

    HBox hButtonBox = new HBox(okButton, cancelButton);
    hButtonBox.alignmentProperty().set(Pos.TOP_RIGHT);

    errorLabel.setWrapText(true);
    BorderPane rootPane = new BorderPane(grid, errorLabel, null, hButtonBox, null);

    this.setTitle(s.getId() > 0 ? "Shipment bearbeiten" : "Shipment anlegen");
    this.setScene(new Scene(rootPane));
    this.setResizable(false);
}

From source file:frontend.GUIController.java

@FXML
private void save(ActionEvent event) throws Exception {
    //ADD the existing file to the output folder
    SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel();
    selectionModel.select(tab5);
}

From source file:frontend.GUIController.java

@FXML
private void retrain(ActionEvent event) throws Exception {
    //ADD retrain the model
    System.out.println("Retraining the model");
    SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel();
    selectionModel.select(tab2);
}

From source file:frontend.GUIController.java

@FXML
private void processSave(ActionEvent event) {
    System.out.println("Steping to next step saving file...");
    String path = outFolder.textProperty().getValue().toString();
    at.saveChanges(path, personData, predicted.isSelected());

    SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel();
    selectionModel.select(tab5);
}

From source file:frontend.GUIController.java

@FXML
private void processLogin(ActionEvent event) throws Exception {
    processInput(new Runnable() {
        @Override/*from  w  ww .ja  va  2  s  . c  o  m*/
        public void run() {
            SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel();
            selectionModel.select(tab3);
            outFiles.getItems().clear();
            outFiles.getItems().addAll(at.files);
            System.out.println("Added files to drop down: " + at.files);
            outFiles.getSelectionModel().selectFirst();

            next1.setDisable(false);
            featureTable.setEditable(true);
            tweetLabel.setEditable(true);
            tweetText.setEditable(true);
            tweetFeature.setVisible(true);
            tweetProb.setVisible(true);
        }
    }, new Runnable() {
        @Override
        public void run() {
            System.err.println("Task Failed");
        }
    });
}