Example usage for javafx.scene.control MultipleSelectionModel setSelectionMode

List of usage examples for javafx.scene.control MultipleSelectionModel setSelectionMode

Introduction

In this page you can find the example usage for javafx.scene.control MultipleSelectionModel setSelectionMode.

Prototype

public final void setSelectionMode(SelectionMode value) 

Source Link

Usage

From source file:de.ks.file.FileViewController.java

@Override
public void initialize(URL location, ResourceBundle resources) {
    fileList.setItems(files);/*from   w w  w  . j  a  va  2s . c  om*/

    MultipleSelectionModel<File> selectionModel = fileList.getSelectionModel();
    selectionModel.setSelectionMode(SelectionMode.MULTIPLE);

    ReadOnlyObjectProperty<File> selection = selectionModel.selectedItemProperty();
    selection.addListener((p, o, n) -> {
        folderName.setText(n == null ? "" : n.getParentFile().getAbsolutePath());
        fileNameLabel.setText(n == null ? "" : n.getName());
    });

    BooleanBinding isDirectory = Bindings
            .createBooleanBinding(() -> selection.get() != null && selection.get().isDirectory(), selection);
    edit.disableProperty().bind(isDirectory);

    files.addListener((ListChangeListener<File>) change -> {
        files.forEach(file -> {
            if (!fileReferences.containsKey(file) && file.exists() && !file.isDirectory()) {
                fileReferences.put(file, fileStore.getReference(file));
            }
        });
    });
    BooleanBinding disable = fileList.getSelectionModel().selectedItemProperty().isNull();
    open.disableProperty().bind(disable);
    edit.disableProperty().bind(disable);
    openFolder.disableProperty().bind(disable);
    removeFile.disableProperty().bind(disable);
}