Example usage for javafx.scene.control ListView ListView

List of usage examples for javafx.scene.control ListView ListView

Introduction

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

Prototype

public ListView() 

Source Link

Document

Creates a default ListView which will display contents stacked vertically.

Usage

From source file:Main.java

@Override
public void start(final Stage stage) {
    stage.setTitle("HTML");
    stage.setWidth(500);/* w  ww .j ava 2 s .  com*/
    stage.setHeight(500);
    Scene scene = new Scene(new Group());

    VBox vbox = new VBox();
    ListView list = new ListView();
    VBox.setVgrow(list, Priority.ALWAYS);
    vbox.getChildren().addAll(new Label("Names:"), list);

    scene.setRoot(vbox);

    stage.setScene(scene);
    stage.show();
}

From source file:org.phoenicis.javafx.views.scriptui.StepRepresentationMenu.java

public StepRepresentationMenu(SetupUiJavaFXImplementation parent, Message<MenuItem> messageWaitingForResponse,
        String textToShow, List<String> menuItems, String defaultValue) {
    super(parent, messageWaitingForResponse, textToShow);
    this.messageWaitingForResponse = messageWaitingForResponse;

    this.menuItems = menuItems;
    this.listViewWidget = new ListView<>();
    this.defaultValue = defaultValue;
}

From source file:guipart.AddMessageUploadFile.java

private void setScene(Stage window) {
    fileNames = new ArrayList<File>();
    fileList = new ListView<String>();
    files = FXCollections.observableArrayList();
    fileList.setItems(files);// w  ww  .j a v  a  2  s .c o  m

    fileList.setTranslateY(-50);
    fileList.setMaxWidth(300);
    fileList.setMinHeight(150);

    Label addMessagesLabel = new Label("Add messages");
    Label loadedMessagesLabel = new Label("Loaded messages:");

    Label imageLabel2 = new Label();
    Image image2 = new Image(getClass().getResourceAsStream("/resources/gui/labelme_logo.png"));
    imageLabel2.setGraphic(new ImageView(image2));
    imageLabel2.setPrefSize(200, 200);
    HBox imageBox2 = new HBox();
    imageBox2.setAlignment(Pos.CENTER);
    imageBox2.setPadding(new Insets(20, 20, 20, 20));
    imageBox2.getChildren().add(imageLabel2);

    acceptButton = new Button("Accept All");
    browseButton = new Button("Browse");
    finishButton = new Button("Finish");
    previousButton = new Button("Previous");
    cancelButton = new Button("X");
    backButton = new Button("Back");
    pathField.setMinWidth(200);
    textCategory = new Label();

    addMessagesLabel.setFont(Font.font("Arial", FontWeight.BOLD, 28));

    HBox hBox = new HBox();
    hBox.setSpacing(20);
    hBox.getChildren().addAll(browseButton, pathField, acceptButton);
    hBox.setAlignment(Pos.CENTER);

    VBox layout = new VBox();
    layout.setSpacing(30);

    VBox filesPlaceholder = new VBox();
    filesPlaceholder.setSpacing(10);

    backButton.setTranslateY(-50);

    browseButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            //TODO: add more extensionFilters
            File currDir = new File(".");
            fileChooser.setInitialDirectory(currDir);
            fileChooser.getExtensionFilters().addAll((new FileChooser.ExtensionFilter("Text Files", "*.txt")));
            File file = fileChooser.showOpenDialog(window);

            if (file != null) {
                pathField.setText(file.getName());
                fileNames.add(file);
                files.add(file.getName());
            }
        }

    });

    fileList.setOnMouseClicked(e -> {
        //System.out.println(fileList.getSelectionModel().getSelectedItem());
        files.remove(fileList.getSelectionModel().getSelectedItem());
        for (File file : fileNames) {
            if (file.getName().equals(fileList.getSelectionModel().getSelectedItem())) {
                fileNames.remove(file);
                break;
            }
        }
    });

    acceptButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            if (!fileNames.isEmpty()) {
                Categorize categorize = new Categorize();
                categorize.trainModel();

                int size = files.size();

                for (int i = 0; i < size; i++) {
                    String fileName = files.get(i);
                    for (File file : fileNames) {
                        if (file.getName().equals(fileName)) {
                            try {
                                files.add(fileName + "      "
                                        + categorize.getCategory(FileUtils.readFileToString(file, "UTF-8")));
                            } catch (IOException ex) {
                                Logger.getLogger(AddMessageUploadFile.class.getName()).log(Level.SEVERE, null,
                                        ex);
                            }
                        }
                    }

                }

                int i = 0;
                while (i < size) {
                    files.remove(0);
                    i++;
                }
                /*
                try {
                textCategory.setText("The text category is: " + categorize.getCategory(FileUtils.readFileToString(fileNames.get(fileNames.size() - 1), "UTF-8")));
                } catch (IOException ex) {
                Logger.getLogger(AddMessageUploadFile.class.getName()).log(Level.SEVERE, null, ex);
                }*/
            }
            /*
            if (pathField.getText() != null) {
            int index = pathField.getText().lastIndexOf("\\");
                    
            Label messageLabel = new Label(pathField.getText().substring(index + 1));
            messageLabel.setMinWidth(200);
            messageLabel.setMinHeight(25);
            messageLabel.setStyle("-fx-fill: orange;\n"
                    + "-fx-border-color: blue;\n"
                    + "-fx-border-width: 3;\n");
            if (filesPlaceholder.getChildren().size() != 0) {
                layout.getChildren().remove(layout.getChildren().size() - 1);
            }
                    
            filesPlaceholder.getChildren().addAll(messageLabel);
            filesPlaceholder.setAlignment(Pos.CENTER);
            filesPlaceholder.setPadding(new Insets(0, 0, 0, 50));
                    
            layout.getChildren().add(filesPlaceholder);
            }*/
        }
    });

    backButton.setOnAction(e -> {
        window.setScene(mainPage.mainPageScene);

    });

    layout.getChildren().addAll(imageLabel2, addMessagesLabel, hBox, textCategory, fileList, backButton);
    layout.setStyle("-fx-background-color: white");
    layout.setAlignment(Pos.TOP_CENTER);
    layout.setStyle("-fx-background-color: #B8EDFF;");
    scene = new Scene(layout, 900, 600);
}

From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java

private void openAccountManager() {
    //Window Crap
    Stage accountManagerStage = new Stage();
    accountManagerStage.setTitle("Starbound Server Account Manager");

    GridPane gp = new GridPane();
    gp.setAlignment(Pos.CENTER);/*from ww w. j  a va 2 s.  c om*/
    gp.setVgap(10);
    gp.setHgap(10);
    gp.setPadding(new Insets(25, 25, 25, 25));

    Text title = new Text("Starbound Account Manager");
    title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20));
    gp.add(title, 0, 0, 2, 1);

    ListView<String> user_list = new ListView<String>();
    ObservableList<String> user_list_o = FXCollections.observableArrayList(users);
    user_list.setItems(user_list_o);
    user_list.setPrefHeight(50);

    ListView<String> banned_users_list = new ListView<String>();
    ObservableList<String> banned_users_list_o = FXCollections.observableArrayList(banned_usernames);
    banned_users_list.setItems(banned_users_list_o);
    banned_users_list.setPrefHeight(50);

    ListView<String> banned_ips_list = new ListView<String>();
    ObservableList<String> banned_ips_list_o = FXCollections.observableArrayList(banned_ips);
    banned_ips_list.setItems(banned_ips_list_o);
    banned_ips_list.setPrefHeight(50);

    ListView<String> banned_playernames_list = new ListView<String>();
    ObservableList<String> banned_playernames_list_o = FXCollections.observableArrayList(banned_playernames);
    banned_playernames_list.setItems(banned_playernames_list_o);
    banned_playernames_list.setPrefHeight(50);

    Label user_list_l = new Label("Current Users");
    Label banned_users_list_l = new Label("Banned Users");
    Label banned_ips_list_l = new Label("Banned IP's");
    Label banned_playernames_list_l = new Label("Banned Player Names");

    Button add_user = new Button("Add User");
    Button add_banned_user = new Button("Add Banned User");
    Button add_banned_ip = new Button("Add Banned IP");
    Button add_banned_playername = new Button("Add Banner Playername");

    Button remove_user = new Button("Remove User");
    Button remove_banned_user = new Button("Remove Banned User");
    Button remove_banned_ip = new Button("Remove Banned IP");
    Button remove_banned_playername = new Button("Remove Banner Playername");

    HBox userbox = new HBox();
    userbox.setAlignment(Pos.BOTTOM_LEFT);
    userbox.getChildren().addAll(add_user, remove_user);
    userbox.setSpacing(5);

    HBox b_userbox = new HBox();
    b_userbox.setAlignment(Pos.BOTTOM_LEFT);
    b_userbox.getChildren().addAll(add_banned_user, remove_banned_user);
    b_userbox.setSpacing(5);

    HBox b_ipbox = new HBox();
    b_ipbox.setAlignment(Pos.BOTTOM_LEFT);
    b_ipbox.getChildren().addAll(add_banned_ip, remove_banned_ip);
    b_ipbox.setSpacing(5);

    HBox b_playerbox = new HBox();
    b_playerbox.setAlignment(Pos.BOTTOM_LEFT);
    b_playerbox.getChildren().addAll(add_banned_playername, remove_banned_playername);
    b_playerbox.setSpacing(5);

    Button save = new Button("Save Config");
    save.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            save();
        }

    });

    add_user.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            createAccount(user_list);
        }

    });
    add_banned_user.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            createBannedUser(banned_users_list);
        }

    });
    add_banned_ip.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            createBannedIP(banned_ips_list);
        }

    });
    add_banned_playername.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            createBannedPlayername(banned_playernames_list);
        }

    });

    remove_user.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            users.remove(user_list.getSelectionModel().getSelectedItem());
            user_list.setItems(FXCollections.observableArrayList(users));
        }

    });
    remove_banned_user.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            banned_usernames.remove(banned_users_list.getSelectionModel().getSelectedItem());
            banned_users_list.setItems(FXCollections.observableArrayList(banned_usernames));
        }

    });
    remove_banned_ip.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            banned_ips.remove(banned_ips_list.getSelectionModel().getSelectedItem());
            banned_ips_list.setItems(FXCollections.observableArrayList(banned_ips));
        }

    });
    remove_banned_playername.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            banned_playernames.remove(banned_playernames_list.getSelectionModel().getSelectedItem());
            banned_playernames_list.setItems(FXCollections.observableArrayList(banned_playernames));
        }

    });

    gp.add(user_list_l, 0, 1);
    gp.add(user_list, 0, 2);
    gp.add(userbox, 0, 3);
    gp.add(banned_users_list_l, 0, 4);
    gp.add(banned_users_list, 0, 5);
    gp.add(b_userbox, 0, 6);
    gp.add(banned_ips_list_l, 0, 7);
    gp.add(banned_ips_list, 0, 8);
    gp.add(b_ipbox, 0, 9);
    gp.add(banned_playernames_list_l, 0, 10);
    gp.add(banned_playernames_list, 0, 11);
    gp.add(b_playerbox, 0, 12);
    gp.add(save, 0, 13);

    Scene sc = new Scene(gp, 800 / 2, 600);
    accountManagerStage.setScene(sc);
    accountManagerStage.show();

}

From source file:tachyon.view.ProjectProperties.java

public ProjectProperties(JavaProject project, Window w) {
    this.project = project;
    stage = new Stage();
    stage.initOwner(w);/*from w w w .j a va 2s .  c  o  m*/
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setWidth(600);
    stage.setTitle("Project Properties - " + project.getProjectName());
    stage.getIcons().add(tachyon.Tachyon.icon);
    stage.setResizable(false);
    HBox mai, libs, one, two, thr, fou;
    ListView<String> compileList, runtimeList;
    Button compileAdd, compileRemove, preview, selectIm, runtimeAdd, runtimeRemove;
    TextField iconField;
    stage.setScene(new Scene(new VBox(5, pane = new TabPane(
            new Tab("Library Settings",
                    box1 = new VBox(15,
                            libs = new HBox(10, new Label("External Libraries"), libsView = new ListView<>(),
                                    new VBox(5, addJar = new Button("Add Jar"),
                                            removeJar = new Button("Remove Jar"))))),
            new Tab("Program Settings",
                    new ScrollPane(box2 = new VBox(15, one = new HBox(10, new Label("Main-Class"),
                            mainClass = new TextField(project.getMainClassName()),
                            select = new Button("Select")),
                            two = new HBox(10, new Label("Compile-Time Arguments"),
                                    compileList = new ListView<>(),
                                    new VBox(5, compileAdd = new Button("Add Argument"),
                                            compileRemove = new Button("Remove Argument")))))),
            new Tab("Deployment Settings",
                    box3 = new VBox(15, thr = new HBox(10, new Label("Icon File"),
                            iconField = new TextField(project.getFileIconPath()),
                            preview = new Button("Preview Image"), selectIm = new Button("Select Icon")),
                            fou = new HBox(10, new Label("Runtime Arguments"), runtimeList = new ListView<>(),
                                    new VBox(5, runtimeAdd = new Button("Add Argument"),
                                            runtimeRemove = new Button("Remove Argument")))))),
            new VBox(15, mai = new HBox(10, cancel = new Button("Cancel"), confirm = new Button("Confirm"))))));
    if (applyCss.get()) {
        stage.getScene().getStylesheets().add(css);
    }
    for (Tab b : pane.getTabs()) {
        b.setClosable(false);
    }
    mainClass.setPromptText("Main-Class");
    box1.setPadding(new Insets(5, 10, 5, 10));
    mai.setAlignment(Pos.CENTER_RIGHT);
    mai.setPadding(box1.getPadding());
    libs.setAlignment(Pos.CENTER);
    one.setAlignment(Pos.CENTER);
    two.setAlignment(Pos.CENTER);
    thr.setAlignment(Pos.CENTER);
    fou.setAlignment(Pos.CENTER);
    box1.setAlignment(Pos.CENTER);
    box2.setPadding(box1.getPadding());
    box2.setAlignment(Pos.CENTER);
    box3.setPadding(box1.getPadding());
    box3.setAlignment(Pos.CENTER);
    mainClass.setEditable(false);
    mainClass.setPrefWidth(200);
    for (JavaLibrary lib : project.getAllLibs()) {
        libsView.getItems().add(lib.getBinaryAbsolutePath());
    }
    for (String sa : project.getCompileTimeArguments().keySet()) {
        compileList.getItems().add(sa + ":" + project.getCompileTimeArguments().get(sa));
    }
    for (String sa : project.getRuntimeArguments()) {
        runtimeList.getItems().add(sa);
    }
    compileAdd.setOnAction((e) -> {
        Dialog<Pair<String, String>> dialog = new Dialog<>();
        dialog.setTitle("Compiler Argument");
        dialog.initOwner(stage);
        dialog.setHeaderText("Entry the argument");

        ButtonType loginButtonType = new ButtonType("Done", ButtonData.OK_DONE);
        dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);

        GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(20, 150, 10, 10));

        TextField username = new TextField();
        username.setPromptText("Key");
        TextField password = new TextField();
        password.setPromptText("Value");

        grid.add(new Label("Key:"), 0, 0);
        grid.add(username, 1, 0);
        grid.add(new Label("Value:"), 0, 1);
        grid.add(password, 1, 1);

        Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
        loginButton.setDisable(true);

        username.textProperty().addListener((observable, oldValue, newValue) -> {
            loginButton.setDisable(newValue.trim().isEmpty());
        });

        dialog.getDialogPane().setContent(grid);

        Platform.runLater(() -> username.requestFocus());

        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == loginButtonType) {
                return new Pair<>(username.getText(), password.getText());
            }
            return null;
        });

        Optional<Pair<String, String>> result = dialog.showAndWait();
        if (result.isPresent()) {
            compileList.getItems().add(result.get().getKey() + ":" + result.get().getValue());
        }
    });
    compileRemove.setOnAction((e) -> {
        if (compileList.getSelectionModel().getSelectedItem() != null) {
            compileList.getItems().remove(compileList.getSelectionModel().getSelectedItem());
        }
    });
    runtimeAdd.setOnAction((e) -> {
        TextInputDialog dia = new TextInputDialog();
        dia.setTitle("Add Runtime Argument");
        dia.setHeaderText("Enter an argument");
        dia.initOwner(stage);
        Optional<String> res = dia.showAndWait();
        if (res.isPresent()) {
            runtimeList.getItems().add(res.get());
        }
    });
    runtimeRemove.setOnAction((e) -> {
        if (runtimeList.getSelectionModel().getSelectedItem() != null) {
            runtimeList.getItems().remove(runtimeList.getSelectionModel().getSelectedItem());
        }
    });
    preview.setOnAction((e) -> {
        if (!iconField.getText().isEmpty()) {
            if (iconField.getText().endsWith(".ico")) {
                List<BufferedImage> read = new ArrayList<>();
                try {
                    read.addAll(ICODecoder.read(new File(iconField.getText())));
                } catch (IOException ex) {
                }
                if (read.size() >= 1) {
                    Image im = SwingFXUtils.toFXImage(read.get(0), null);
                    Stage st = new Stage();
                    st.initOwner(stage);
                    st.initModality(Modality.APPLICATION_MODAL);
                    st.setTitle("Icon Preview");
                    st.getIcons().add(Tachyon.icon);
                    st.setScene(new Scene(new BorderPane(new ImageView(im))));
                    if (applyCss.get()) {
                        st.getScene().getStylesheets().add(css);
                    }
                    st.showAndWait();
                }
            } else if (iconField.getText().endsWith(".icns")) {
                try {
                    BufferedImage ima = Imaging.getBufferedImage(new File(iconField.getText()));
                    if (ima != null) {
                        Image im = SwingFXUtils.toFXImage(ima, null);
                        Stage st = new Stage();
                        st.initOwner(stage);
                        st.initModality(Modality.APPLICATION_MODAL);
                        st.setTitle("Icon Preview");
                        st.getIcons().add(Tachyon.icon);
                        st.setScene(new Scene(new BorderPane(new ImageView(im))));
                        if (applyCss.get()) {
                            st.getScene().getStylesheets().add(css);
                        }
                        st.showAndWait();
                    }
                } catch (ImageReadException | IOException ex) {
                }
            } else {
                Image im = new Image(new File(iconField.getText()).toURI().toString());
                Stage st = new Stage();
                st.initOwner(stage);
                st.initModality(Modality.APPLICATION_MODAL);
                st.setTitle("Icon Preview");
                st.getIcons().add(Tachyon.icon);
                st.setScene(new Scene(new BorderPane(new ImageView(im))));
                if (applyCss.get()) {
                    st.getScene().getStylesheets().add(css);
                }
                st.showAndWait();
            }
        }
    });
    selectIm.setOnAction((e) -> {
        FileChooser fc = new FileChooser();
        fc.setTitle("Icon File");
        String OS = System.getProperty("os.name").toLowerCase();
        fc.getExtensionFilters().add(new ExtensionFilter("Icon File",
                OS.contains("win") ? getWindowsImageExtensions() : getMacImageExtensions()));
        fc.setSelectedExtensionFilter(fc.getExtensionFilters().get(0));
        File lf = fc.showOpenDialog(stage);
        if (lf != null) {
            iconField.setText(lf.getAbsolutePath());
        }
    });

    addJar.setOnAction((e) -> {
        FileChooser f = new FileChooser();
        f.setTitle("External Libraries");
        f.setSelectedExtensionFilter(new ExtensionFilter("Jar Files", "*.jar"));
        List<File> showOpenMultipleDialog = f.showOpenMultipleDialog(stage);
        if (showOpenMultipleDialog != null) {
            for (File fi : showOpenMultipleDialog) {
                if (!libsView.getItems().contains(fi.getAbsolutePath())) {
                    libsView.getItems().add(fi.getAbsolutePath());
                }
            }
        }
    });

    removeJar.setOnAction((e) -> {
        String selected = libsView.getSelectionModel().getSelectedItem();
        if (selected != null) {
            libsView.getItems().remove(selected);
        }
    });

    select.setOnAction((e) -> {
        List<String> all = getAll();
        ChoiceDialog<String> di = new ChoiceDialog<>(project.getMainClassName(), all);
        di.setTitle("Select Main Class");
        di.initOwner(stage);
        di.setHeaderText("Select A Main Class");
        Optional<String> show = di.showAndWait();
        if (show.isPresent()) {
            mainClass.setText(show.get());
        }
    });
    cancel.setOnAction((e) -> {
        stage.close();
    });
    confirm.setOnAction((e) -> {
        project.setMainClassName(mainClass.getText());
        project.setFileIconPath(iconField.getText());
        project.setRuntimeArguments(runtimeList.getItems());
        HashMap<String, String> al = new HashMap<>();
        for (String s : compileList.getItems()) {
            String[] spl = s.split(":");
            al.put(spl[0], spl[1]);
        }
        project.setCompileTimeArguments(al);
        project.setAllLibs(libsView.getItems());
        stage.close();
    });
}

From source file:cz.lbenda.gui.tableView.FilterMenuItem.java

private FilterMenuItem(VBox panel, FilterableTableView filterableTableView,
        FilterableTableColumn filterableTableColumn) {
    super(null, panel);
    this.filterableTableView = filterableTableView;
    okCancelBar.setAlignment(Pos.BOTTOM_RIGHT);
    this.tableColumn = filterableTableColumn;
    this.getStyleClass().add("listview-menu-item");

    SortedList<Item> sortedList = new SortedList<>(filteredList, Item::compareTo);
    ListView<Item> listView = new ListView<>();
    listView.setItems(sortedList);/*from   ww  w  . j a v  a 2  s . co m*/
    listView.setCellFactory(CheckBoxListCell.forListView(Item::onProperty));

    TextField textField = new TextField();
    textField.textProperty().addListener((observable, oldValue, newValue) -> {
        filteredList.setPredicate(item -> StringUtils.isEmpty(newValue) || !StringUtils.isEmpty(item.getName())
                && item.getName().toLowerCase().contains(newValue.toLowerCase()));
    });

    prepareBars();
    prepareQuickFilter();
    prepareOkCancelBar();
    panel.getChildren().add(buttonBar);
    panel.getChildren().add(textField);
    panel.getChildren().add(listView);
    panel.getChildren().add(quickFilter);
    panel.getChildren().add(okCancelBar);

    //noinspection unchecked
    filterableTableView.sortProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue == null || (newValue != comparatorAsc && newValue != comparatorDsc)) {
            filterableTableColumn.removeRightIndicator(sortIndicator);
            sortToggleGroup.selectToggle(null);
        } else {
            filterableTableColumn.removeRightIndicator(sortIndicator);
            filterableTableColumn.addRightIndicator(sortIndicator);
            if (newValue == comparatorAsc) {
                sortIndicator.setImage(IconFactory.getInstance().image(this, ICON_SORT_ASC,
                        IconFactory.IconLocation.INDICATOR));
            } else {
                sortIndicator.setImage(IconFactory.getInstance().image(this, ICON_SORT_DSC,
                        IconFactory.IconLocation.INDICATOR));
            }
        }
    });
}

From source file:net.thirdy.blackmarket.controls.ModSelectionPane.java

private void setupModListView() {
    modsListView = new ListView<>();
    modsListView.setEditable(true);//from   ww w.  j  a v a2s. c o  m
    modsListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    modsListView.setMaxHeight(Double.MAX_VALUE);
    // remove focus
    modsListView.setStyle("-fx-background-color: transparent, -fx-inner-border,"
            + " -fx-body-color; -fx-background-insets: 0, 1, 2; -fx-background-radius: 5, 4, 3;");

    modsListView.setCellFactory((listView) -> new ModListCell(listView));
    modsListView.setId("modsListView");
}

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(() -> {/* w  w w.ja  v  a  2  s  .  c  om*/
        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:cz.lbenda.rcp.DialogHelper.java

/** Show unsaved object if aren't saved. if user want cancel the closing then return false, elserwhere return true
 * @param savableRegistry register which hold unsaved data
 * @return true if window/object can be closed */
public boolean showUnsavedObjectDialog(SavableRegistry savableRegistry) {
    Set<Savable> savables = savableRegistry.dirtySavables();
    if (savables.size() == 0) {
        return true;
    }/*from  w w w.  j a  va  2  s.  co  m*/
    Dialog<?> dialog = new Dialog<>();
    dialog.setResizable(false);
    dialog.setTitle(msgNotSavedObjectsTitle);
    dialog.setHeaderText(msgNotSavedObjectsHeader);

    BorderPane pane = new BorderPane();
    pane.setPrefHeight(400);
    pane.setPrefWidth(300);
    ListView<DialogHelper.Item> listView = new ListView<>();
    listView.getItems()
            .addAll(savables.stream().map(savable -> new Item(savable, true)).collect(Collectors.toList()));
    listView.setCellFactory(CheckBoxListCell.forListView(DialogHelper.Item::onProperty));
    pane.setCenter(listView);

    dialog.getDialogPane().setContent(pane);

    ButtonType btCancel = new ButtonType(button_cancel, ButtonBar.ButtonData.CANCEL_CLOSE);
    ButtonType btSaveClose = new ButtonType(button_saveAndClose, ButtonBar.ButtonData.OK_DONE);
    ButtonType btClose = new ButtonType(button_closeWithoutSave);

    dialog.getDialogPane().getButtonTypes().addAll(btClose, btSaveClose, btCancel);

    Optional<?> result = dialog.showAndWait();
    if (result.isPresent()) {
        if (btCancel == result.get()) {
            return false;
        }
        if (btSaveClose == result.get()) {
            listView.getItems().stream().filter(Item::isOn).forEach(item -> item.getSavable().save());
        }
    } else {
        return false;
    }
    return true;
}

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

private void createUI() {
    mRoot = new BorderPane();
    Scene scene = new Scene(mRoot);
    //scene.getStylesheets().add("css/modena_dark.css");

    mDefaultFont = Font.getDefault();
    initActions();/* w w  w.  j a va2s  .co  m*/

    mListView = new ListView<>();
    mListView.setItems(mItems);
    mListView.setCellFactory((ListView<Profile> param) -> new ProfileListCell());
    Label welcomeLabel = new Label(mBundle.getString("welcome"));
    welcomeLabel.setFont(Font.font(mDefaultFont.getName(), FontPosture.ITALIC, 18));

    mListView.setPlaceholder(welcomeLabel);

    mPreviewPanel = new PreviewPanel();

    mRoot.setCenter(mListView);
    mRoot.setBottom(mPreviewPanel);

    mStage.setScene(scene);
    setRunningState(RunState.STARTABLE);
}