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:org.sleuthkit.autopsy.imagegallery.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);// w  w  w  .  j  av  a 2s  . c  o 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) -> {
                boolean wasPermuted = false;
                while (change.next()) {
                    for (DrawableGroup g : change.getAddedSubList()) {
                        insertIntoNavTree(g);
                        if (g.getHashSetHitsCount() > 0) {
                            insertIntoHashTree(g);
                        }
                    }
                    for (DrawableGroup g : change.getRemoved()) {
                        removeFromNavTree(g);
                        removeFromHashTree(g);
                    }
                    if (change.wasPermutated()) {
                        // Handle this afterward
                        wasPermuted = true;
                    }
                }

                if (wasPermuted) {
                    rebuildTrees();

                }
            });

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

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

From source file:se.trixon.filebydate.ui.ProfilePanel.java

private void createUI() {
    //setGridLinesVisible(true);

    Label nameLabel = new Label(Dict.NAME.toString());
    Label descLabel = new Label(Dict.DESCRIPTION.toString());
    Label filePatternLabel = new Label(Dict.FILE_PATTERN.toString());
    Label dateSourceLabel = new Label(Dict.DATE_SOURCE.toString());
    mDatePatternLabel = new Label(Dict.DATE_PATTERN.toString());
    Label operationLabel = new Label(Dict.OPERATION.toString());
    Label caseBaseLabel = new Label(Dict.BASENAME.toString());
    Label caseExtLabel = new Label(Dict.EXTENSION.toString());

    mLinksCheckBox = new CheckBox(Dict.FOLLOW_LINKS.toString());
    mRecursiveCheckBox = new CheckBox(Dict.RECURSIVE.toString());
    mReplaceCheckBox = new CheckBox(Dict.REPLACE.toString());

    mCaseBaseComboBox = new ComboBox<>();
    mDatePatternComboBox = new ComboBox<>();
    mDateSourceComboBox = new ComboBox<>();
    mFilePatternComboBox = new ComboBox<>();
    mOperationComboBox = new ComboBox<>();
    mCaseExtComboBox = new ComboBox<>();

    mNameTextField = new TextField();
    mDescTextField = new TextField();

    mSourceChooserPane = new FileChooserPane(Dict.OPEN.toString(), Dict.SOURCE.toString(), ObjectMode.DIRECTORY,
            SelectionMode.SINGLE);
    mDestChooserPane = new FileChooserPane(Dict.OPEN.toString(), Dict.DESTINATION.toString(),
            ObjectMode.DIRECTORY, SelectionMode.SINGLE);

    mFilePatternComboBox.setEditable(true);
    mDatePatternComboBox.setEditable(true);
    //mDatePatternLabel.setPrefWidth(300);

    int col = 0;/*ww w.j av a  2 s.  c o m*/
    int row = 0;

    add(nameLabel, col, row, REMAINING, 1);
    add(mNameTextField, col, ++row, REMAINING, 1);
    add(descLabel, col, ++row, REMAINING, 1);
    add(mDescTextField, col, ++row, REMAINING, 1);
    add(mSourceChooserPane, col, ++row, REMAINING, 1);
    add(mDestChooserPane, col, ++row, REMAINING, 1);

    GridPane patternPane = new GridPane();
    patternPane.addRow(0, filePatternLabel, dateSourceLabel, mDatePatternLabel);
    patternPane.addRow(1, mFilePatternComboBox, mDateSourceComboBox, mDatePatternComboBox);
    patternPane.setHgap(8);
    addRow(++row, patternPane);

    GridPane.setHgrow(mFilePatternComboBox, Priority.ALWAYS);
    GridPane.setHgrow(mDateSourceComboBox, Priority.ALWAYS);
    GridPane.setHgrow(mDatePatternComboBox, Priority.ALWAYS);

    GridPane.setFillWidth(mFilePatternComboBox, true);
    GridPane.setFillWidth(mDateSourceComboBox, true);
    GridPane.setFillWidth(mDatePatternComboBox, true);

    double width = 100.0 / 3.0;
    ColumnConstraints col1 = new ColumnConstraints();
    col1.setPercentWidth(width);
    ColumnConstraints col2 = new ColumnConstraints();
    col2.setPercentWidth(width);
    ColumnConstraints col3 = new ColumnConstraints();
    col3.setPercentWidth(width);
    patternPane.getColumnConstraints().addAll(col1, col2, col3);

    mFilePatternComboBox.setMaxWidth(Double.MAX_VALUE);
    mDateSourceComboBox.setMaxWidth(Double.MAX_VALUE);
    mDatePatternComboBox.setMaxWidth(Double.MAX_VALUE);
    GridPane subPane = new GridPane();
    //subPane.setGridLinesVisible(true);
    subPane.addRow(0, operationLabel, new Label(), new Label(), new Label(), caseBaseLabel, caseExtLabel);
    subPane.addRow(1, mOperationComboBox, mLinksCheckBox, mRecursiveCheckBox, mReplaceCheckBox,
            mCaseBaseComboBox, mCaseExtComboBox);
    subPane.setHgap(8);
    add(subPane, col, ++row, REMAINING, 1);

    final Insets rowInsets = new Insets(0, 0, 8, 0);

    GridPane.setMargin(mNameTextField, rowInsets);
    GridPane.setMargin(mDescTextField, rowInsets);
    GridPane.setMargin(mSourceChooserPane, rowInsets);
    GridPane.setMargin(mDestChooserPane, rowInsets);
    GridPane.setMargin(patternPane, rowInsets);

    mFilePatternComboBox.setItems(FXCollections.observableArrayList("*", "{*.jpg,*.JPG}", "{*.mp4,*.MP4}"));

    mDatePatternComboBox.setItems(FXCollections.observableArrayList("yyyy/MM/yyyy-MM-dd",
            "yyyy/MM/yyyy-MM-dd/HH", "yyyy/MM/dd", "yyyy/ww", "yyyy/ww/u"));

    mCaseBaseComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(NameCase.values())));
    mCaseExtComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(NameCase.values())));
    mDateSourceComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(DateSource.values())));
    mOperationComboBox.setItems(FXCollections.observableArrayList(Arrays.asList(Command.COPY, Command.MOVE)));
}