Example usage for javafx.scene.control SelectionMode SINGLE

List of usage examples for javafx.scene.control SelectionMode SINGLE

Introduction

In this page you can find the example usage for javafx.scene.control SelectionMode SINGLE.

Prototype

SelectionMode SINGLE

To view the source code for javafx.scene.control SelectionMode SINGLE.

Click Source Link

Document

Allows for only one item to be selected at a time.

Usage

From source file:net.rptools.gui.listeners.fxml.AbstractURLController.java

@Override
protected void init() {
    getURLList().getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    final List<AssetTableRow> urlRows = stateToGui();
    getURLList().setItems(FXCollections.observableList(urlRows));
    final String prefix = BOX + StringUtils.capitalize(getPrefix());
    LOGGER.debug("prefix={}", prefix);
    final TextInputControl name = ((TextInputControl) lookup(prefix + "Name"));
    final TextInputControl location = ((TextInputControl) lookup(prefix + "Location"));
    final BooleanBinding empty = name.textProperty().isEmpty().or(location.textProperty().isEmpty());
    lookup(prefix + "New").disableProperty().bind(empty);
}

From source file:dev.archiecortez.jfacelog.employeemanager.EmployeeManagerPresenter.java

/**
 * Initializes the controller class.//from w  ww .j av  a 2  s .  c  o m
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO
    employees = FXCollections.observableList(employeeDTO.listEmployees());
    employeesListView.setItems(employees);
    employeesListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    employeesListView.setCellFactory(value -> {
        return new DTREmployeeItemCell();
    });
}

From source file:ijfx.ui.activity.PerformanceActivity.java

public PerformanceActivity() throws IOException {
    FXUtilities.injectFXML(this);

    timerListView.setCellFactory(this::createListCell);
    timerListView.getSelectionModel().selectedItemProperty().addListener(this::onTimerChanged);
    timerListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    idColumn.setCellValueFactory(this::readOnly);
    meanColumn.setCellValueFactory(this::readOnly);
    stdDevColumn.setCellValueFactory(this::readOnly);
    minColumn.setCellValueFactory(this::readOnly);
    maxColumn.setCellValueFactory(this::readOnly);
    countColumn.setCellValueFactory(this::readOnly);

}

From source file:eu.ggnet.dwoss.redtape.document.DocumentUpdateView.java

private void initFxComponents() {
    final JFXPanel jfxp = new JFXPanel();
    positionPanelFx.add(jfxp, BorderLayout.CENTER);

    Platform.runLater(() -> {//from   ww w.j  a  va  2  s.  c o  m
        BorderPane pane = new BorderPane();
        Scene scene = new Scene(pane, Color.ALICEBLUE);

        positionsFxList = new ListView<>();
        positionsFxList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
        positionsFxList.setCellFactory(new PositionListCell.Factory());
        positionsFxList.setItems(positions);
        positionsFxList.setOnMouseClicked((mouseEvent) -> {
            if (mouseEvent.getButton().equals(MouseButton.PRIMARY) && mouseEvent.getClickCount() == 2) {
                if (isChangeAllowed()) {
                    controller.editPosition(positionsFxList.getSelectionModel().getSelectedItem());
                    positionsFxList.refresh();
                } else {
                    Alert.show("nderung an Positionen ist nicht erlaubt.");
                }
            }
        });

        pane.setCenter(positionsFxList);
        jfxp.setScene(scene);
    });
}

From source file:condorclient.MainFXMLController.java

void initialize2() {
    // TODO//from  w w  w . j av  a2  s.c  o m

    errorMessage = "";

    configureTable();

    if (create_button != null) {
        create_button.setDisable(true);
    }
    initConfigureButtons();
    //connectToService();

    connect_button.setDisable(false);

    int i = 0;
    while (i < 1000) {
        isSelected[i] = 0;
        i++;
    }
    if (statusListView != null) {
        statusListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
        //projectItemSelectedlistener
        //   displayedStatusNames.addListener(displayedStatusNamesListener);
    }
    // condoruser=handler.

}

From source file:be.makercafe.apps.makerbench.Main.java

/**
 * Creates the viewer control//from   w w  w  . ja v  a2  s . com
 *
 * @return
 */
private TreeView<String> createViewer() {
    TreeView<String> viewer = new TreeView<String>(setRootFolder(new File(this.pathMakerbenchHome)));
    viewer.setMinWidth(200.0);
    viewer.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    viewer.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent mouseEvent) {

            if (mouseEvent.getClickCount() == 2) {
                ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel()
                        .getSelectedItem();
                //               System.out.println("Selected Text : " + item.getValue());

                createEditor(item.getValue(), item.getPath(), null);
            } else if (mouseEvent.getButton() == MouseButton.SECONDARY) {
                ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel()
                        .getSelectedItem();
                if (item.getPath().toFile().isFile()) {
                    viewer.getContextMenu().getItems().get(0).setDisable(true);
                    viewer.getContextMenu().getItems().get(1).setDisable(true);
                    viewer.getContextMenu().getItems().get(2).setDisable(true);
                } else {
                    viewer.getContextMenu().getItems().get(0).setDisable(false);
                    viewer.getContextMenu().getItems().get(1).setDisable(false);
                    viewer.getContextMenu().getItems().get(2).setDisable(false);
                }
            }

        }
    });
    viewer.setContextMenu(rootContextMenu);
    viewer.setEditable(false);
    viewer.setShowRoot(false);

    return viewer;
}

From source file:Main.java

@SuppressWarnings("unchecked")
private void initializeBoundsTableView() {
    boundsTableView.setPrefSize(200, 100);
    boundsTableView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    boundsTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    TableColumn<BoundsRecord, String> boundsTypeCol = new TableColumn<>("Bounds Type");
    boundsTypeCol.setCellValueFactory(new PropertyValueFactory<>("boundsType"));

    TableColumn<BoundsRecord, Double> xCol = new TableColumn<>("MinX");
    xCol.setCellValueFactory(new PropertyValueFactory<>("x"));

    TableColumn<BoundsRecord, Double> yCol = new TableColumn<>("MinY");
    yCol.setCellValueFactory(new PropertyValueFactory<>("y"));

    TableColumn<BoundsRecord, Double> wCol = new TableColumn<>("Width");
    wCol.setCellValueFactory(new PropertyValueFactory<>("w"));

    TableColumn<BoundsRecord, Double> hCol = new TableColumn<>("Height");
    hCol.setCellValueFactory(new PropertyValueFactory<>("h"));

    boundsTableView.getColumns().setAll(boundsTypeCol, xCol, yCol, wCol, hCol);
}

From source file:com.ggvaidya.scinames.dataset.DatasetSceneController.java

@SuppressWarnings("unchecked")
private void initAdditionalData() {
    // Resize to fit columns, as per https://stackoverflow.com/a/22488513/27310
    additionalDataTableView.setColumnResizePolicy((param) -> true);

    // Set up additional data objects.
    additionalDataTableView.setRowFactory(table -> {
        @SuppressWarnings("rawtypes")
        TableRow row = new TableRow<>();

        row.setOnMouseClicked(event -> {
            if (row.isEmpty())
                return;
            Object item = row.getItem();

            if (event.getClickCount() == 2) {
                // Try opening the detailed view on this item -- if we can.
                datasetView.getProjectView().openDetailedView(item);
            }/*from  w  w w  .  ja va  2 s .c  o m*/
        });

        return row;
    });
    additionalDataTableView.setItems(new SortedList<>(tableItems));

    // Set up events.
    additionalDataCombobox.getSelectionModel().selectedItemProperty()
            .addListener((Observable o) -> additionalDataUpdateList());
    additionalListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    additionalListView.getSelectionModel().selectedItemProperty()
            .addListener((Observable o) -> additionalDataUpdateTable());

    additionalDataCombobox.getSelectionModel().select(0);

    // When the change is changed, select an item.
    changesTableView.getSelectionModel().getSelectedItems()
            .addListener((ListChangeListener<Change>) c -> additionalDataUpdateList());
}

From source file:com.ggvaidya.scinames.dataset.BinomialChangesSceneController.java

@SuppressWarnings("unchecked")
private void initAdditionalData() {
    // Resize to fit columns, as per https://stackoverflow.com/a/22488513/27310
    additionalDataTableView.setColumnResizePolicy((param) -> true);

    // Set up additional data objects.
    additionalDataTableView.setRowFactory(table -> {
        @SuppressWarnings("rawtypes")
        TableRow row = new TableRow<>();

        row.setOnMouseClicked(event -> {
            if (row.isEmpty())
                return;
            Object item = row.getItem();

            if (event.getClickCount() == 2) {
                // Try opening the detailed view on this item -- if we can.
                binomialChangesView.getProjectView().openDetailedView(item);
            }/*ww w.  j av  a2  s .  c o m*/
        });

        return row;
    });
    additionalDataTableView.setItems(new SortedList<>(tableItems));

    // Set up events.
    additionalDataCombobox.getSelectionModel().selectedItemProperty()
            .addListener((Observable o) -> additionalDataUpdateList());
    additionalListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    additionalListView.getSelectionModel().selectedItemProperty()
            .addListener((Observable o) -> additionalDataUpdateTable());

    additionalDataCombobox.getSelectionModel().select(0);

    // When the change is changed, select an item.
    changesTableView.getSelectionModel().getSelectedItems()
            .addListener((ListChangeListener<Change>) c -> additionalDataUpdateList());
}

From source file:org.sleuthkit.autopsy.imageanalyzer.gui.navpanel.NavPanel.java

@FXML
void initialize() {
    assert hashTab != null : "fx:id=\"hashTab\" was not injected: check your FXML file 'NavPanel.fxml'.";
    assert hashTree != null : "fx:id=\"hashTree\" was not injected: check your FXML file 'NavPanel.fxml'.";
    assert navTab != null : "fx:id=\"navTab\" was not injected: check your FXML file 'NavPanel.fxml'.";
    assert navTabPane != null : "fx:id=\"navTabPane\" was not injected: check your FXML file 'NavPanel.fxml'.";
    assert navTree != null : "fx:id=\"navTree\" was not injected: check your FXML file 'NavPanel.fxml'.";
    assert sortByBox != null : "fx:id=\"sortByBox\" was not injected: check your FXML file 'NavPanel.fxml'.";

    VBox.setVgrow(this, Priority.ALWAYS);

    navTree.setShowRoot(false);//from w  ww . ja  va 2s  . co  m
    hashTree.setShowRoot(false);

    navTree.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    hashTree.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

    sortByBox.setCellFactory((ListView<TreeNodeComparators> p) -> new TreeNodeComparators.ComparatorListCell());

    sortByBox.setButtonCell(new TreeNodeComparators.ComparatorListCell());
    sortByBox.setItems(
            FXCollections.observableArrayList(FXCollections.observableArrayList(TreeNodeComparators.values())));
    sortByBox.getSelectionModel().select(TreeNodeComparators.HIT_COUNT);
    sortByBox.getSelectionModel().selectedItemProperty().addListener((Observable o) -> {
        resortHashTree();
    });

    navTree.setCellFactory((TreeView<TreeNode> p) -> new GroupTreeCell());

    hashTree.setCellFactory((TreeView<TreeNode> p) -> new GroupTreeCell());

    activeTreeProperty.addListener((Observable o) -> {
        updateControllersGroup();
        activeTreeProperty.get().getSelectionModel().selectedItemProperty().addListener((Observable o1) -> {
            updateControllersGroup();
        });
    });

    this.activeTreeProperty.set(navTree);

    navTabPane.getSelectionModel().selectedItemProperty()
            .addListener((ObservableValue<? extends Tab> ov, Tab t, Tab t1) -> {
                if (t1 == hashTab) {
                    activeTreeProperty.set(hashTree);
                } else if (t1 == navTab) {
                    activeTreeProperty.set(navTree);
                }
            });

    initHashTree();
    initNavTree();

    controller.getGroupManager().getAnalyzedGroups()
            .addListener((ListChangeListener.Change<? extends DrawableGroup> change) -> {
                while (change.next()) {
                    for (DrawableGroup g : change.getAddedSubList()) {
                        insertIntoNavTree(g);
                        if (g.getFilesWithHashSetHitsCount() > 0) {
                            insertIntoHashTree(g);
                        }
                    }
                    for (DrawableGroup g : change.getRemoved()) {
                        removeFromNavTree(g);
                        removeFromHashTree(g);
                    }
                }
            });

    for (DrawableGroup g : controller.getGroupManager().getAnalyzedGroups()) {
        insertIntoNavTree(g);
        if (g.getFilesWithHashSetHitsCount() > 0) {
            insertIntoHashTree(g);
        }
    }

    controller.viewState().addListener((ObservableValue<? extends GroupViewState> observable,
            GroupViewState oldValue, GroupViewState newValue) -> {
        if (newValue != null && newValue.getGroup() != null) {
            setFocusedGroup(newValue.getGroup());
        }
    });
}