Example usage for javafx.scene.control ListView getItems

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

Introduction

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

Prototype

public final ObservableList<T> getItems() 

Source Link

Document

Returns an ObservableList that contains the items currently being shown to the user.

Usage

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;
    }/* www  .  j ava 2s . 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:com.saiton.ccs.validations.FormatAndValidate.java

public boolean validListView(ListView listView) {
    boolean valid = false;

    if (!listView.getItems().isEmpty()) {
        valid = true;/*from www.java2  s  .  c  o  m*/
    } else {

        valid = false;
    }
    return valid;

}

From source file:com.saiton.ccs.validations.FormatAndValidate.java

public boolean isListViewItemDuplicated(ListView listView, String value) {

    boolean valid = false;
    ObservableList<String> list = listView.getItems();

    if (list.size() != 0 && !value.isEmpty()) {
        for (int i = 0; i < list.size(); i++) {

            if (!list.get(i).equals(value)) {
                valid = true;//from  ww w.j a  v  a  2 s  . c  om

            }
        }

    } else if (list.size() == 0) {
        valid = true;
    }
    return valid;
}

From source file:com.saiton.ccs.validations.FormatAndValidate.java

public boolean isValidUniqueEmail(ListView listView, String email) {

    boolean valid = true;
    ObservableList<String> list = listView.getItems();
    boolean isEmail = org.apache.commons.validator.routines.EmailValidator.getInstance().isValid(email);

    if (isEmail == true) {
        if (list.size() != 0 && !email.isEmpty()) {
            for (int i = 0; i < list.size(); i++) {

                if (list.get(i).equals(email)) {
                    valid = false;//from www .j  av a 2  s .  c  o m
                }
                //                    else {
                //                        valid = false;
                //                    }

            }
        } else if (list.size() == 0) {
            valid = true;
        }
    }

    return valid;

}

From source file:com.saiton.ccs.validations.FormatAndValidate.java

public boolean isValidVehicleNo(ListView listView, String vehicleNo) {
    boolean valid = true;

    String vehicleNoTrimed = vehicleNo.trim();
    ObservableList<String> list = listView.getItems();

    if (vehicleNoTrimed.length() < 14 && vehicleNoTrimed.length() > 4) {

        if (list.size() != 0 && !vehicleNo.isEmpty()) {
            for (int i = 0; i < list.size(); i++) {

                if (list.get(i).equals(vehicleNo)) {
                    valid = false;//ww w  . j a  v a  2s.  co  m

                }
                //                    else {
                //
                //                        valid = false;
                //
                //                    }
            }
        } else if (list.size() == 0) {
            valid = true;
        }

    } else {

        valid = false;
    }

    return valid;

}

From source file:com.saiton.ccs.validations.FormatAndValidate.java

public boolean isValidUniqueTelephoneNumber(ListView listView, String telephone) {
    boolean valid = true;

    String telephoneNumber = telephone.trim();
    ObservableList<String> list = listView.getItems();

    String regex_Number = "([0-9])*"; //Regex pattern for Single Name with initials.

    Pattern pattern_Number = Pattern.compile(regex_Number); //    Pattern Compliler

    Matcher matcher_Number = pattern_Number.matcher(telephoneNumber); // Pattern Matcher where the Single Name argument is checked with the given pattern

    boolean matched_Number = matcher_Number.matches(); // Result of the matcher is returned as a boolean for Single Name

    if (matched_Number == true && telephoneNumber.length() < 14 && telephoneNumber.length() > 9) {

        if (list.size() != 0 && !telephone.isEmpty()) {
            for (int i = 0; i < list.size(); i++) {

                if (list.get(i).equals(telephone)) {
                    valid = false;/*from w  w  w . ja v a 2 s. co  m*/

                }
                //                    else {
                //
                //                        valid = false;
                //
                //                    }
            }
        } else if (list.size() == 0) {
            valid = true;
        }

    } else {

        valid = false;
    }

    return valid;

}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param mouseEvent/* w ww  .j  ava  2s  .  c  o m*/
 */
private static void gereSourisPanoramique(MouseEvent mouseEvent) {
    if (mouseEvent.getButton() == MouseButton.SECONDARY) {
        if (mouseEvent.isShiftDown()) {
            panoChoixNord(mouseEvent.getSceneX() - ivImagePanoramique.getLayoutX());
            mouseEvent.consume();
        } else if (mouseEvent.isControlDown()) {
        } else {
            panoChoixRegard(mouseEvent.getSceneX() - ivImagePanoramique.getLayoutX(),
                    mouseEvent.getSceneY() - getiDecalageMac());
            mouseEvent.consume();
        }
    }
    if (mouseEvent.getButton() == MouseButton.PRIMARY) {
        if (!(mouseEvent.isControlDown()) && bEstCharge) {
            if (!bDragDrop) {
                panePanoramique.setCursor(Cursor.DEFAULT);
                panePanoramique.setOnMouseClicked((me) -> {
                });
                Circle c1 = new Circle(mouseEvent.getSceneX(),
                        mouseEvent.getSceneY() - panePanoramique.getLayoutY() - 130 - getiDecalageMac(), 3);
                panePanoramique.getChildren().add(c1);
                ListView<String> lvMenuChoixTypeHotspot = new ListView<>();
                double tailleFenetre = 70;
                if (getiNombrePanoramiques() > 1) {
                    lvMenuChoixTypeHotspot.getItems().add("Panoramique");
                    tailleFenetre += 20;
                }
                lvMenuChoixTypeHotspot.getItems().add("Image");
                if (getiNombreDiapo() > 0) {
                    lvMenuChoixTypeHotspot.getItems().add("Diaporama");
                    tailleFenetre += 20;
                }
                lvMenuChoixTypeHotspot.getItems().add("HTML");
                lvMenuChoixTypeHotspot.getItems().add("Annuler");
                lvMenuChoixTypeHotspot.setMaxHeight(tailleFenetre);
                lvMenuChoixTypeHotspot.setPrefHeight(tailleFenetre);
                lvMenuChoixTypeHotspot.setMinHeight(tailleFenetre);
                lvMenuChoixTypeHotspot.setPrefWidth(120);
                lvMenuChoixTypeHotspot.setCursor(Cursor.DEFAULT);
                lvMenuChoixTypeHotspot.setLayoutX(mouseEvent.getSceneX());
                lvMenuChoixTypeHotspot.setLayoutY(
                        mouseEvent.getSceneY() - panePanoramique.getLayoutY() - 104 - getiDecalageMac());
                panePanoramique.getChildren().add(lvMenuChoixTypeHotspot);
                lvMenuChoixTypeHotspot.getSelectionModel().selectedItemProperty()
                        .addListener((ov, ancValeur, nouvValeur) -> {
                            panePanoramique.getChildren().remove(lvMenuChoixTypeHotspot);
                            panePanoramique.getChildren().remove(c1);

                            switch (nouvValeur) {
                            case "Panoramique":
                                panoMouseClic(mouseEvent.getSceneX() - ivImagePanoramique.getLayoutX(),
                                        mouseEvent.getSceneY());
                                break;
                            case "Image":
                                panoAjouteImage(mouseEvent.getSceneX() - ivImagePanoramique.getLayoutX(),
                                        mouseEvent.getSceneY());
                                break;
                            case "HTML":
                                panoAjouteHTML(mouseEvent.getSceneX() - ivImagePanoramique.getLayoutX(),
                                        mouseEvent.getSceneY());
                                break;
                            case "Diaporama":
                                panoAjouteDiaporama(mouseEvent.getSceneX() - ivImagePanoramique.getLayoutX(),
                                        mouseEvent.getSceneY());
                                break;
                            case "Annuler":
                                break;

                            }
                            panePanoramique.setCursor(Cursor.CROSSHAIR);
                            panePanoramique.setOnMouseClicked((me) -> {
                                gereSourisPanoramique(me);
                            });

                        });

            } else {
                bDragDrop = false;
            }
        }
    }
}

From source file:org.craftercms.social.migration.controllers.MainController.java

protected void loadScripts(final String path, final ListView whereToAdd) {

    log.info("Loading migration Scripts from {}", path);
    if (path != null) {
        File profileScriptPath = new File(path);
        if (!profileScriptPath.isDirectory()) {
            log.error("Profile Loading Path {} is not a directory");
            return;
        }/*from  w w  w  .ja  v  a2  s. c o  m*/
        final File[] scripts = profileScriptPath.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(final File dir, final String name) {
                return name.endsWith(".js");
            }
        });
        whereToAdd.getItems().addAll(scripts);
    } else {
        log.info("Property is not set using Default Scripts");
        return;
    }
}

From source file:org.nmrfx.processor.gui.PropertyManager.java

PropertyManager(ProcessorController processorController, final ListView scriptView, PropertySheet propertySheet,
        ObservableList<String> listItems, TextField opTextField, PopOver popOver) {
    this.processorController = processorController;
    this.scriptView = scriptView;
    this.listItems = listItems;
    this.opTextField = opTextField;
    this.propertySheet = propertySheet;
    this.popOver = popOver;
    doubleListener = new ChangeListener<Number>() {
        @Override/*from ww w  .  java  2 s .com*/
        public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) {
            updateOp((PropertySheet.Item) observableValue);
        }
    };
    intListener = new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) {
            updateOp((PropertySheet.Item) observableValue);
        }
    };
    boolListener = new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observableValue, Boolean bool, Boolean bool2) {
            updateOp((PropertySheet.Item) observableValue);
        }
    };
    stringListener = new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observableValue, String string, String string2) {
            updateOp((PropertySheet.Item) observableValue);
        }
    };
    complexListener = new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observableValue, String c1, String c2) {
            updateOp((PropertySheet.Item) observableValue);
        }
    };
    listListener = new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observableValue, String c1, String c2) {
            updateOp((PropertySheet.Item) observableValue);
        }
    };

    ChangeListener<Number> scriptOpListener = new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) {
            int scriptIndex = (Integer) number2;
            try {
                if ((listItems.size() == 1) && (scriptIndex == -1)) {
                    //there is a single item in the Cells -- Don't unselect
                    scriptIndex = 0;
                } else if (scriptIndex != -1) {
                    String selOp = (String) scriptView.getItems().get(scriptIndex);
                    setPropSheet(scriptIndex, selOp);
                } else {
                    setPropSheet(scriptIndex, "");
                }
            } catch (Exception e) {
                System.out.println(e.getMessage());
            } finally {
                currentIndex = scriptIndex;
            }
        }
    };
    scriptView.getSelectionModel().selectedIndexProperty().addListener(scriptOpListener);

    propertySheet.setPropertyEditorFactory(new NvFxPropertyEditorFactory(processorController));
    propertySheet.setMode(PropertySheet.Mode.NAME);
    propertySheet.setModeSwitcherVisible(false);
    propertySheet.setSearchBoxVisible(false);

}

From source file:qupath.lib.gui.tma.TMASummaryViewer.java

private Pane createSidePane() {
    BorderPane pane = new BorderPane();

    TabPane tabPane = new TabPane();

    kmDisplay = new KaplanMeierDisplay(null, null, null, null);
    BorderPane paneKaplanMeier = new BorderPane();
    paneKaplanMeier.setCenter(kmDisplay.getView());
    paneKaplanMeier.setPadding(new Insets(10, 10, 10, 10));
    //      comboMainMeasurement.prefWidthProperty().bind(paneKaplanMeier.widthProperty());
    comboMainMeasurement.setMaxWidth(Double.MAX_VALUE);
    comboMainMeasurement.setTooltip(new Tooltip("Measurement thresholded to create survival curves etc."));

    GridPane kmTop = new GridPane();
    kmTop.add(new Label("Score"), 0, 0);
    kmTop.add(comboMainMeasurement, 1, 0);
    kmTop.add(new Label("Survival type"), 0, 1);
    kmTop.add(comboSurvival, 1, 1);//  w ww . j a v a  2 s .c  o  m
    comboSurvival.setTooltip(new Tooltip("Specify overall or recurrence-free survival (if applicable)"));
    comboSurvival.setMaxWidth(Double.MAX_VALUE);
    GridPane.setHgrow(comboMainMeasurement, Priority.ALWAYS);
    GridPane.setHgrow(comboSurvival, Priority.ALWAYS);
    kmTop.setHgap(5);
    paneKaplanMeier.setTop(kmTop);
    //      kmDisplay.setOrientation(Orientation.VERTICAL);

    histogramDisplay = new HistogramDisplay(model, false);

    comboMainMeasurement.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> {
        histogramDisplay.refreshCombo();
        histogramDisplay.showHistogram(n);
        updateSurvivalCurves();
    });
    comboMeasurementMethod.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> {
        histogramDisplay.refreshHistogram();
        scatterPane.updateChart();
        updateSurvivalCurves();
    });
    comboSurvival.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> {
        updateSurvivalCurves();
    });

    // Create a Tab for showing images
    BorderPane paneImages = new BorderPane();
    CheckBox cbShowOverlay = new CheckBox("Show overlay");
    imageAvailability.addListener((c, v, n) -> {
        if (n == ImageAvailability.OVERLAY_ONLY)
            cbShowOverlay.setSelected(true);
        else if (n == ImageAvailability.IMAGE_ONLY)
            cbShowOverlay.setSelected(false);
        cbShowOverlay.setDisable(n != ImageAvailability.BOTH);
    });
    ListView<TMAEntry> listImages = new ListView<>();
    listImages.setCellFactory(v -> new ImageListCell(cbShowOverlay.selectedProperty(), imageCache));
    listImages.widthProperty().addListener((v, o, n) -> listImages.refresh());
    listImages.setStyle("-fx-control-inner-background-alt: -fx-control-inner-background ;");
    table.getSelectionModel().getSelectedItems().addListener((Change<? extends TreeItem<TMAEntry>> e) -> {
        List<TMAEntry> entries = new ArrayList<>();
        for (TreeItem<TMAEntry> item : e.getList()) {
            if (item.getChildren().isEmpty()) {
                if (item.getValue().hasImage() || item.getValue().hasOverlay())
                    entries.add(item.getValue());
            } else {
                for (TreeItem<TMAEntry> item2 : item.getChildren()) {
                    if (item2.getValue().hasImage() || item2.getValue().hasOverlay())
                        entries.add(item2.getValue());
                }
            }
            listImages.getItems().setAll(entries);
        }
    });
    cbShowOverlay.setAlignment(Pos.CENTER);
    cbShowOverlay.setMaxWidth(Double.MAX_VALUE);
    cbShowOverlay.setPadding(new Insets(5, 5, 5, 5));
    cbShowOverlay.selectedProperty().addListener((v, o, n) -> listImages.refresh());
    paneImages.setCenter(listImages);
    paneImages.setTop(cbShowOverlay);

    // Determine visibility based upon whether there are any images to show
    //      Tab tabImages = new Tab("Images", paneImages);

    ScrollPane scrollPane = new ScrollPane(paneKaplanMeier);
    scrollPane.setFitToWidth(true);
    scrollPane.setFitToHeight(true);
    scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
    scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
    Tab tabSurvival = new Tab("Survival", scrollPane);
    tabPane.getTabs().addAll(new Tab("Table", getCustomizeTablePane()),
            //            tabImages,
            new Tab("Histogram", histogramDisplay.getPane()), new Tab("Scatterplot", scatterPane.getPane()),
            tabSurvival);
    tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);

    //      if (imageAvailability.get() != ImageAvailability.NONE)
    //         tabPane.getTabs().add(1, tabImages);
    //      
    //      imageAvailability.addListener((c, v, n) -> {
    //         if (n == ImageAvailability.NONE)
    //            tabPane.getTabs().remove(tabImages);
    //         else if (!tabPane.getTabs().contains(tabImages))
    //            tabPane.getTabs().add(1, tabImages);
    //      });

    //      tabSurvival.visibleProperty().bind(
    //            Bindings.createBooleanBinding(() -> !survivalColumns.isEmpty(), survivalColumns)
    //            );

    pane.setCenter(tabPane);

    pane.setMinWidth(350);

    return pane;
}