Java 类javafx.scene.control.ListView 实例源码

项目:Learning-RxJava    文件:Ch6_15.java   
@Override
public void start(Stage stage) throws Exception {
    VBox root = new VBox();
    ListView<String> listView = new ListView<>();
    Button refreshButton = new Button("REFRESH");
    JavaFxObservable.actionEventsOf(refreshButton)
            .observeOn(Schedulers.io())
            .flatMapSingle(a ->
                    Observable.fromArray(getResponse("https://goo.gl/S0xuOi")
                            .split("\\r?\\n")
                    ).toList()
            ).observeOn(JavaFxScheduler.platform())
            .subscribe(list ->
                    listView.getItems().setAll(list));
    root.getChildren().addAll(listView, refreshButton);
    stage.setScene(new Scene(root));
    stage.show();
}
项目:CalendarFX    文件:SearchResultViewSkin.java   
public SearchResultViewSkin(SearchResultView view) {
    super(view);

    Label placeholderLabel = new Label();
    placeholderLabel.getStyleClass().add("placeholder-label"); //$NON-NLS-1$

    listView = new ListView<>();
    listView.setItems(view.getSearchResults());
    listView.setCellFactory(new SearchResultCellFactory());
    listView.setPlaceholder(placeholderLabel);
    listView.getSelectionModel().selectedItemProperty()
            .addListener(it -> view.getProperties().put(
                    "selected.search.result",   //$NON-NLS-1$
                    listView.getSelectionModel().getSelectedItem()));
    getChildren().add(listView);
}
项目:Matcher    文件:ListCellFactory.java   
@Override
public ListCell<T> call(ListView<T> list) {
    return new ListCell<T>() {
        @Override
        protected void updateItem(T item, boolean empty) {
            super.updateItem(item, empty);

            if (empty || item == null) {
                setText(null);
                setStyle("");
            } else {
                setText(ListCellFactory.this.getText(item));
                setStyle(ListCellFactory.this.getStyle(item));
            }
        }
    };
}
项目:marathonv5    文件:ListViewCellFactorySample.java   
public ListViewCellFactorySample() {
    final ListView<Number> listView = new ListView<Number>();
    listView.setItems(FXCollections.<Number>observableArrayList(
            100.00, -12.34, 33.01, 71.00, 23000.00, -6.00, 0, 42223.00, -12.05, 500.00,
            430000.00, 1.00, -4.00, 1922.01, -90.00, 11111.00, 3901349.00, 12.00, -1.00, -2.00,
            15.00, 47.50, 12.11

    ));

    listView.setCellFactory(new Callback<ListView<java.lang.Number>, ListCell<java.lang.Number>>() {
        @Override public ListCell<Number> call(ListView<java.lang.Number> list) {
            return new MoneyFormatCell();
        }
    });        

    listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    getChildren().add(listView);
}
项目:marathonv5    文件:MarathonFileChooser.java   
private void initListView() {
    if (!doesAllowChildren) {
        fillUpChildren(fileChooserInfo.getRoot());
    }
    childrenListView.setCellFactory(new Callback<ListView<File>, ListCell<File>>() {
        @Override public ListCell<File> call(ListView<File> param) {
            return new ChildrenFileCell();
        }
    });
    childrenListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (fileChooserInfo.isFileCreation()) {
            return;
        }
        File selectedItem = childrenListView.getSelectionModel().getSelectedItem();
        if (selectedItem == null) {
            fileNameBox.clear();
        }
    });
}
项目:marathonv5    文件:RunHistoryStage.java   
private void initComponents() {
    VBox.setVgrow(historyView, Priority.ALWAYS);
    historyView.setItems(FXCollections.observableArrayList(runHistoryInfo.getTests()));
    historyView.setCellFactory(new Callback<ListView<JSONObject>, ListCell<JSONObject>>() {
        @Override public ListCell<JSONObject> call(ListView<JSONObject> param) {
            return new HistoryStateCell();
        }
    });

    VBox historyBox = new VBox(5);
    HBox.setHgrow(historyBox, Priority.ALWAYS);

    countField.setText(getRemeberedCount());
    if (countNeeded) {
        form.addFormField("Max count of remembered runs: ", countField);
    }
    historyBox.getChildren().addAll(new Label("Select test", FXUIUtils.getIcon("params")), historyView, form);

    verticalButtonBar.setId("vertical-buttonbar");
    historyPane.setId("history-pane");
    historyPane.getChildren().addAll(historyBox, verticalButtonBar);

    doneButton.setOnAction((e) -> onOK());
    buttonBar.setButtonMinWidth(Region.USE_PREF_SIZE);
    buttonBar.getButtons().addAll(doneButton);
}
项目:marathonv5    文件:MarathonCheckListStage.java   
private void initCheckList() {
    ToolBar toolBar = new ToolBar();
    toolBar.getItems().add(new Text("Check Lists"));
    toolBar.setMinWidth(Region.USE_PREF_SIZE);
    leftPane.setTop(toolBar);
    checkListElements = checkListInfo.getCheckListElements();
    checkListView = new ListView<CheckListForm.CheckListElement>(checkListElements);
    checkListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        CheckListElement selectedItem = checkListView.getSelectionModel().getSelectedItem();
        if (selectedItem == null) {
            doneButton.setDisable(true);
            return;
        }
        Node checkListForm = getChecklistFormNode(selectedItem, Mode.DISPLAY);
        if (checkListForm == null) {
            doneButton.setDisable(true);
            return;
        }
        doneButton.setDisable(false);
        ScrollPane sp = new ScrollPane(checkListForm);
        sp.setFitToWidth(true);
        sp.setPadding(new Insets(0, 0, 0, 10));
        rightPane.setCenter(sp);
    });
    leftPane.setCenter(checkListView);
}
项目:CDN-FX-2.2    文件:TMTableFilter.java   
public static SortedList<Ticket> createTableFilter(TextField textSearch, ListView listView){

        if(isPrepared)
            return new SortedList<>(filteredTickets);

        textSearch.setOnKeyPressed((KeyEvent ke) ->{
            if(ke.getCode().equals(KeyCode.ENTER)){
                text = textSearch.getText();
                filterTickets();
            }
        });

        //Listview
        listView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
            @Override
            public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
                categoryText = newValue.split(" ")[0];
                if(categoryText.equals("DownloadPlayChild"))
                    categoryText = "DLP";
                filterTickets();
            }
        });

        isPrepared = true;
        return new SortedList<>(filteredTickets);
    }
项目:marathonv5    文件:JavaFXElementPropertyAccessor.java   
public int getListItemIndex(ListView<?> listView, String string) {
    ObservableList<?> items = listView.getItems();
    for (int i = 0; i < items.size(); i++) {
        String text = getListSelectionText(listView, i);
        if (text.equals(string)) {
            return i;
        }
    }
    return -1;
}
项目:marathonv5    文件:JavaFXListViewElementTest.java   
@Test public void selectForDuplicateItems() {
    @SuppressWarnings("unchecked")
    ListView<String> listViewNode = (ListView<String>) getPrimaryStage().getScene().getRoot().lookup(".list-view");
    Platform.runLater(new Runnable() {

        @Override public void run() {
            listViewNode.getItems().add(2, "Row 2");
        }
    });
    Platform.runLater(() -> listView.marathon_select("[\"Row 2(1)\"]"));
    new Wait("Waiting for list item to be select") {
        @Override public boolean until() {
            return listViewNode.getSelectionModel().getSelectedIndex() == 2;
        }
    };
}
项目:marathonv5    文件:JavaFXListViewElementTest.java   
@Test public void selectForMultipleDuplicates() {
    @SuppressWarnings("unchecked")
    ListView<String> listViewNode = (ListView<String>) getPrimaryStage().getScene().getRoot().lookup(".list-view");
    Platform.runLater(new Runnable() {

        @Override public void run() {
            listViewNode.getItems().add(2, "Row 2");
            listViewNode.getItems().add(9, "Row 2");
            listViewNode.getItems().add(10, "Row 2");
        }
    });
    Platform.runLater(() -> listView.marathon_select("[\"Row 2(3)\"]"));
    new Wait("Waiting for list item to be select") {
        @Override public boolean until() {
            return listViewNode.getSelectionModel().getSelectedIndex() == 10;
        }
    };
}
项目:WholesomeChat    文件:MainController.java   
@FXML
public void onListClick(MouseEvent event) {
    Scene scene = stage.getScene();
    ListView<String> list = (ListView<String>) scene.lookup("#list");
    if (list.getSelectionModel() != null && list.getSelectionModel().getSelectedItem() != null) {
        JsonObject str = new JsonObject();
        str.addProperty("text", list.getSelectionModel().getSelectedItem().replaceAll("\\[.*?\\] @.*? > ", "").replaceAll("\"", "\\\"").trim());
        str.addProperty("intent", "precheck");
        chatAccess.send(gson.toJson(str));
    }
}
项目:ABC-List    文件:ExercisePresenter.java   
private void initializeComboBoxTimeChooser() {
    LoggerFacade.getDefault().info(this.getClass(), "Initialize [ComboBox] [TimeChooser]"); // NOI18N

    cbTimeChooser.setCellFactory((ListView<ETime> listview) -> new ListCell<ETime>() {
        @Override
        public void updateItem(ETime time, boolean empty) {
            super.updateItem(time, empty);
            this.setGraphic(null);
            this.setText(!empty ? time.toString() : null);
        }
    });

    final ObservableList<ETime> observableListTimes = FXCollections.observableArrayList();
    observableListTimes.addAll(ETime.values());
    cbTimeChooser.getItems().addAll(observableListTimes);
    cbTimeChooser.getSelectionModel().selectFirst();
}
项目:marathonv5    文件:ListViewCellFactorySample.java   
public ListViewCellFactorySample() {
    final ListView<Number> listView = new ListView<Number>();
    listView.setItems(FXCollections.<Number>observableArrayList(
            100.00, -12.34, 33.01, 71.00, 23000.00, -6.00, 0, 42223.00, -12.05, 500.00,
            430000.00, 1.00, -4.00, 1922.01, -90.00, 11111.00, 3901349.00, 12.00, -1.00, -2.00,
            15.00, 47.50, 12.11

    ));

    listView.setCellFactory(new Callback<ListView<java.lang.Number>, ListCell<java.lang.Number>>() {
        @Override public ListCell<Number> call(ListView<java.lang.Number> list) {
            return new MoneyFormatCell();
        }
    });        

    listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    getChildren().add(listView);
}
项目:Java-9-Programming-Blueprints    文件:TwitterPreferencesController.java   
private Node buildConfigurationUI() {
    VBox box = new VBox();
    box.setPadding(new Insets(10));

    CheckBox cb = new CheckBox(MessageBundle.getInstance().getString("homeTimelineCB"));
    cb.selectedProperty().addListener((ObservableValue<? extends Boolean> ov, Boolean oldVal, Boolean newVal) -> {
        showHomeTimeline = newVal;
    });

    Label label = new Label(MessageBundle.getInstance().getString("userListLabel") + ":");

    ListView<SelectableItem<UserList>> lv = new ListView<>();
    lv.setItems(itemList);
    lv.setCellFactory(CheckBoxListCell.forListView(item -> item.getSelected()));
    VBox.setVgrow(lv, Priority.ALWAYS);

    box.getChildren().addAll(cb, label, lv);
    showTwitterListSelection();

    return box;
}
项目:voogasalad-ltub    文件:PathSetter.java   
public PathSetter(ObservableList<Path> paths, String variableName){
    super(Path.class,variableName);
    this.myPaths=paths;     

    pathChoices= new ComboBox<>(myPaths);

    pathChoices.setCellFactory(new Callback<ListView<Path>, ListCell<Path>>(){
        @Override
        public ListCell<Path> call(ListView<Path> list){
            return new PathCell();
        }
    });
    pathChoices.setButtonCell(new PathButtonCell());

    this.getChildren().add(pathChoices);

}
项目:marathonv5    文件:RFXListViewTest.java   
@Test public void getTextForMultipleSelection() {
    ListView<?> listView = (ListView<?>) getPrimaryStage().getScene().getRoot().lookup(".list-view");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            MultipleSelectionModel<?> selectionModel = listView.getSelectionModel();
            selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
            selectionModel.selectIndices(2, 8);
            RFXListView rfxListView = new RFXListView(listView, null, null, lr);
            rfxListView.focusLost(new RFXListView(null, null, null, lr));
            text.add(rfxListView.getAttribute("text"));
        }
    });
    new Wait("Waiting for list text.") {
        @Override public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("[\"Long Row 3\",\"Row 9\"]", text.get(0));
}
项目:marathonv5    文件:RFXListViewTest.java   
@Test public void selectSpecialItemSelection() {
    @SuppressWarnings("unchecked")
    ListView<String> listView = (ListView<String>) getPrimaryStage().getScene().getRoot().lookup(".list-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(new Runnable() {
        @Override public void run() {
            listView.getItems().add(7, " Special Characters ([],)");
            listView.getSelectionModel().select(7);
            RFXListView rfxListView = new RFXListView(listView, null, null, lr);
            rfxListView.focusLost(new RFXListView(null, null, null, lr));
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("[\" Special Characters ([],)\"]", recording.getParameters()[0]);
}
项目:marathonv5    文件:RFXListViewChoiceBoxListCell.java   
@Test public void select() {
    @SuppressWarnings("unchecked")
    ListView<String> listView = (ListView<String>) getPrimaryStage().getScene().getRoot().lookup(".list-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        @SuppressWarnings("unchecked")
        ChoiceBoxListCell<String> cell = (ChoiceBoxListCell<String>) getCellAt(listView, 3);
        Point2D point = getPoint(listView, 3);
        RFXListView rfxListView = new RFXListView(listView, null, point, lr);
        rfxListView.focusGained(rfxListView);
        cell.startEdit();
        cell.updateItem("Option 3", false);
        cell.commitEdit("Option 3");
        rfxListView.focusLost(rfxListView);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("Option 3", recording.getParameters()[0]);
}
项目:Goliath-Overclocking-Utility-FX    文件:ConsolePane.java   
public ConsolePane()
{
    super();
    super.setPrefHeight(AppTabPane.CONTENT_HEIGHT);
    super.setPrefWidth(AppTabPane.CONTENT_WIDTH);

    OUTPUT.add("Goliath Overclocking Utility V1 Alpha");
    OUTPUT.add("Theme: " + AppSettings.getTheme());
    OUTPUT.add("Show Extra Attribute Information: " + AppSettings.getShowExtraAttributeInfo());

    list = new ListView<>(FXCollections.observableArrayList(OUTPUT));
    list.setEditable(false);
    list.setPrefHeight(283);
    list.setPrefWidth(750);
    list.setPlaceholder(new Label("No Output"));
    list.setItems(FXCollections.observableArrayList(OUTPUT));

    super.getChildren().add(list);
}
项目:Lernkartei_2017    文件:GroupMemberView.java   
@Override
public Parent constructContainer()
{
    bp.setId("loginviewbg");

    list = new ListView<String>();
    items = FXCollections.observableArrayList("Philippe Kr�ttli","Irina Deck","Javier Martinez Alvarez","Frithjof Hoppe");
    list.setItems(items);       

    AllFields = new VBox(50);
    AllFields.setAlignment(Pos.CENTER);
    AllFields.setMaxWidth(300);
    AllFields.setPadding(new Insets(20));

    GroupName = new HBox(50);
    Option = new HBox(50);

    name = new Label("Name:");
    groupname = new Label("{Gruppenname}");

    btnAdd = new AppButton("Hinzuf�gen");
    btnRemove = new AppButton("Entfernen");
    back = new BackButton(getFXController(),"Zur�ck");



    GroupName.getChildren().addAll(name,groupname);
    Option.getChildren().addAll(back,btnAdd,btnRemove);

    AllFields.getChildren().addAll(GroupName,Option,list);


    bp.setCenter(AllFields);

    back.setOnAction(e -> getFXController().showView("groupview"));
    btnAdd.setOnAction(e -> getFXController().showView("userlistview"));

    btnRemove.setOnAction(e -> {
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Mitglied l�schen");
    alert.setHeaderText("Sie sind gerade dabei ein Mitglied aus der Gruppe zu entfernen.");
    alert.setContentText("Sind Sie sich sicher, dass sie das tun wollen?");
    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK){
        // ... user chose OK
    } else {
        Alert noDeletion = new Alert(AlertType.INFORMATION);
        noDeletion.setTitle("L�schvorgang abgebrochen");
        noDeletion.setHeaderText("Mitglied nicht gel�scht");
        noDeletion.setContentText("Der L�schvorgang wurde abgebrochen.");
        noDeletion.showAndWait();
        alert.close();
    }});

    return bp;
}
项目:stvs    文件:IoVariableChooserDialog.java   
private ListCell<CodeIoVariable> createCellForListView(
    ListView<CodeIoVariable> codeIoVariableListView) {
  return new ListCell<CodeIoVariable>() {
    @Override
    protected void updateItem(CodeIoVariable item, boolean empty) {
      super.updateItem(item, empty);
      if (empty) {
        setText(null);
      } else {
        setText(item.getCategory() + " " + item.getName() + " : " + item.getType());
      }
    }
  };
}
项目:GameAuthoringEnvironment    文件:BasicUIFactory.java   
public void modifyListView (ListView<?> listView,
                            double width,
                            double height,
                            String cssClass) {
    listView.setPrefSize(width, height);
    listView.getStyleClass().add(cssClass);
}
项目:cassandra-client    文件:TableListView.java   
private ListView<String> list() {
    ListView<String> tables = new ListView<>(FXCollections.observableArrayList());
    tables.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    tables.setPrefHeight(480);
    tables.setPrefWidth(256);
    return tables;
}
项目:Squid    文件:ExpressionBuilderController.java   
@Override
public ListCell<Expression> call(ListView<Expression> param) {
    ListCell<Expression> cell = new ListCell<Expression>() {
        @Override
        public void updateItem(Expression expression, boolean empty) {
            super.updateItem(expression, empty);
            if (empty) {
                setText(null);
                setGraphic(null);
            } else {
                setText(expression.getName());
            }
        }
    };

    cell.setOnDragDetected(event -> {
        if (!cell.isEmpty()) {
            Dragboard db = cell.startDragAndDrop(TransferMode.COPY);
            db.setDragView(new Image(SQUID_LOGO_SANS_TEXT_URL, 32, 32, true, true));
            ClipboardContent cc = new ClipboardContent();
            cc.putString("[\"" + cell.getItem().getName() + "\"]");
            db.setContent(cc);
            dragExpressionSource.set(cell);
        }
    });

    cell.setCursor(Cursor.CLOSED_HAND);
    return cell;
}
项目:Squid    文件:ExpressionBuilderController.java   
@Override
public ListCell<SquidRatiosModel> call(ListView<SquidRatiosModel> param) {
    ListCell<SquidRatiosModel> cell = new ListCell<SquidRatiosModel>() {
        @Override
        public void updateItem(SquidRatiosModel expression, boolean empty) {
            super.updateItem(expression, empty);
            if (empty) {
                setText(null);
                setGraphic(null);
            } else {
                setText(expression.getRatioName());
            }
        }
    };

    cell.setOnDragDetected(event -> {
        if (!cell.isEmpty()) {
            Dragboard db = cell.startDragAndDrop(TransferMode.COPY);
            db.setDragView(new Image(SQUID_LOGO_SANS_TEXT_URL, 32, 32, true, true));
            ClipboardContent cc = new ClipboardContent();
            cc.putString("[\"" + cell.getItem().getRatioName() + "\"]");
            db.setContent(cc);
            dragSquidRatioModelSource.set(cell.getItem());
        }
    });

    cell.setCursor(Cursor.CLOSED_HAND);
    return cell;
}
项目:Squid    文件:ExpressionBuilderController.java   
@Override
public ListCell<String> call(ListView<String> param) {
    ListCell<String> cell = new ListCell<String>() {
        @Override
        public void updateItem(String operationOrFunction, boolean empty) {
            super.updateItem(operationOrFunction, empty);
            if (empty) {
                setText(null);
                setGraphic(null);
            } else {
                setText(operationOrFunction);
            }
        }
    };

    cell.setOnDragDetected(event -> {
        if (!cell.isEmpty()) {
            Dragboard db = cell.startDragAndDrop(TransferMode.COPY);
            db.setDragView(new Image(SQUID_LOGO_SANS_TEXT_URL, 32, 32, true, true));
            ClipboardContent cc = new ClipboardContent();
            cc.putString(cell.getItem());
            db.setContent(cc);
            dragSource.set(cell.getItem());
        }
    });

    cell.setCursor(Cursor.CLOSED_HAND);
    return cell;
}
项目:icewolf    文件:IWEditBookmarkDialog.java   
public IWEditBookmarkDialog(ListView lv, ListView lv1, HashMap<Integer, String> hm, HashMap<Integer, String> hm1, String id, String name, String url, int catindex) {
    this.listView = lv;
    this.bookmarkListView = lv1;
    this.hm = hm;
    this.hm1 = hm1;
    this.name = name;
    this.url = url;
    this.id = id;
    this.catindex = catindex;
}
项目:marathonv5    文件:HorizontalListViewSample.java   
public HorizontalListViewSample() {
    ListView horizontalListView = new ListView();
    horizontalListView.setOrientation(Orientation.HORIZONTAL);
    horizontalListView.setItems(FXCollections.observableArrayList(
            "Row 1", "Row 2", "Long Row 3", "Row 4", "Row 5", "Row 6",
            "Row 7", "Row 8", "Row 9", "Row 10", "Row 11", "Row 12", "Row 13",
            "Row 14", "Row 15", "Row 16", "Row 17", "Row 18", "Row 19", "Row 20"
    ));
    getChildren().add(horizontalListView);
}
项目:marathonv5    文件:ListLayout.java   
private VBox createListView() {
    listViewBox = new VBox(5);
    classPathListView = new ListView<ClassPathElement>(classPathListItems);
    classPathListView.setPrefHeight(Node.BASELINE_OFFSET_SAME_AS_HEIGHT);
    classPathListView.setId("ClassPathList");
    classPathListView.setCellFactory((e) -> {
        ClassPathCell classPathCell = new ClassPathCell();
        classPathCell.setId("ClassPathCell");
        return classPathCell;
    });

    if (!isSingleSelection()) {
        classPathListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    }
    classPathListView.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
        MultipleSelectionModel<ClassPathElement> selectionModel = classPathListView.getSelectionModel();
        int itemCount = classPathListItems.size();
        int selectedIndex = selectionModel.getSelectedIndex();
        setButtonState(deleteButton, selectedIndex != -1);
        boolean enable = selectedIndex != 0 && selectedIndex != -1 && itemCount > 1;
        setButtonState(upButton, enable);
        enable = selectedIndex != itemCount - 1 && selectedIndex != -1 && itemCount > 1;
        setButtonState(downButton, enable);
    });
    listViewBox.getChildren().add(classPathListView);
    HBox.setHgrow(listViewBox, Priority.ALWAYS);
    VBox.setVgrow(classPathListView, Priority.ALWAYS);
    return listViewBox;
}
项目:marathonv5    文件:JavaFXElementPropertyAccessor.java   
public String getListSelectionText(ListView<?> listView, Integer index) {
    String original = getListItemText(listView, index);
    String itemText = original;
    int suffixIndex = 0;
    for (int i = 0; i < index; i++) {
        String current = getListItemText(listView, i);
        if (current.equals(original)) {
            itemText = String.format("%s(%d)", original, ++suffixIndex);
        }
    }
    return itemText;
}
项目:drd    文件:DiceController.java   
@Override
public void initialize(URL location, ResourceBundle resources) {
    title = resources.getString(R.Translate.DICE_TITLE);

    lvDices.setItems(FXCollections.observableArrayList(DiceHelper.DiceType.values()));
    lvDices.setCellFactory(new Callback<ListView<DiceType>, ListCell<DiceType>>() {
        @Override
        public ListCell<DiceType> call(ListView<DiceType> param) {
            ListCell<DiceType> cell = new ListCell<DiceType>() {
                @Override
                protected void updateItem(DiceType item, boolean empty) {
                    super.updateItem(item, empty);
                    if (empty) {
                        setText(null);
                    } else {
                        if (item == DiceType.CUSTOM) {
                            setText("Vlastní");
                        } else {
                            setText(item.toString());
                        }
                    }
                }
            };
            return cell;
        }
    });
    spinnerDiceSideCount.disableProperty().bind(
        lvDices.getFocusModel().focusedIndexProperty().isEqualTo(0).not());
    // TODO vymyslet lepší způsob
    spinnerDiceSideCount.valueProperty().addListener((observable, oldValue, newValue) -> {
        diceSideCount.setValue(newValue);
    });
    lvDices.getFocusModel().focusedItemProperty()
        .addListener((observable, oldValue, newValue) -> {
            diceSideCount.setValue(newValue.getSideCount());
        });
    diceRollCount.bind(spinnerRollCount.valueProperty());

    initTable();
}
项目:uPMT    文件:LaunchingScreenController.java   
@Override
public void initialize(URL location, ResourceBundle resources) {

    //TODO: in this part, we prompt a lauchingScreen Dialog for open or create new project
    ObservableList<Projet> items = FXCollections.observableArrayList (m_main.getProjects());
    tousLesProjets.setItems(items);
    tousLesProjets.getFocusModel().focus(0);
    tousLesProjets.setCellFactory(new Callback<ListView<Projet>, ListCell<Projet>>() {
        @Override
        public ListCell<Projet> call(ListView<Projet> param) {

            ListCell<Projet> cell = new ListCell<Projet>() {

                @Override
                protected void updateItem(Projet item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null) {
                        setText(item.getName());
                    } else {
                        setText(""); 
                    }
                }
            };
            return cell;
        }
    });
}
项目:ABC-List    文件:TestdataExerciseTermPresenter.java   
private void initializeComboBoxes() {
        LoggerFacade.getDefault().info(this.getClass(), "Initialize ComboBoxes"); // NOI18N

        cbQuantityEntities.getItems().addAll(EntityHelper.getDefault().getQuantityEntities());
//        cbQuantityEntities.getItems().remove(cbQuantityEntities.getItems().size() - 1);
//        cbQuantityEntities.getItems().remove(cbQuantityEntities.getItems().size() - 1);
        cbQuantityEntities.setCellFactory(new Callback<ListView<Integer>, ListCell<Integer>>() {

            @Override
            public ListCell<Integer> call(ListView<Integer> param) {
                return new ListCell<Integer>() {

                        @Override
                        protected void updateItem(Integer item, boolean empty) {
                            super.updateItem(item, empty);

                            if (item == null) {
                                super.setText(null);
                                return;
                            }

                            super.setText("" + item); // NOI18N
                        }
                    };
            }
        });

        final Integer quantityEntities = PreferencesFacade.getDefault().getInt(
                PREF__TESTDATA__QUANTITY_ENTITIES__EXERCISE_TERM,
                PREF__TESTDATA__QUANTITY_ENTITIES__EXERCISE_TERM_DEFAULT_VALUE);
        cbQuantityEntities.getSelectionModel().select(quantityEntities);
    }
项目:boomer-tuner    文件:RootController.java   
public void createPlaylist(final RootView rootView, final ListView<CategoryType> menu, final Playlist playlist) {
    menu.getSelectionModel().selectedItemProperty().removeListener(getMenuListener());
    menu.getSelectionModel().select(CategoryType.Playlists);
    menu.getSelectionModel().selectedItemProperty().addListener(getMenuListener());

    PlaylistModel playlistModel = new PlaylistModel();
    playlistModel.setDirectorySelected(rootModel.isDirectorySelected());
    playlistModel.setSelectedPlaylist(playlist);
    CategoryView newView = new PlaylistView(playlistModel, new PlaylistController(playlistModel));
    newView.setListeners(rootModel);
    rootView.setCenter((Node) newView);
}
项目:marathonv5    文件:JavaFXElementFactory.java   
public static void reset() {
    add(Node.class, JavaFXElement.class);
    add(TextInputControl.class, JavaFXTextInputControlElement.class);
    add(HTMLEditor.class, JavaFXHTMLEditor.class);
    add(CheckBox.class, JavaFXCheckBoxElement.class);
    add(ToggleButton.class, JavaFXToggleButtonElement.class);
    add(Slider.class, JavaFXSliderElement.class);
    add(Spinner.class, JavaFXSpinnerElement.class);
    add(SplitPane.class, JavaFXSplitPaneElement.class);
    add(ProgressBar.class, JavaFXProgressBarElement.class);
    add(ChoiceBox.class, JavaFXChoiceBoxElement.class);
    add(ColorPicker.class, JavaFXColorPickerElement.class);
    add(ComboBox.class, JavaFXComboBoxElement.class);
    add(DatePicker.class, JavaFXDatePickerElement.class);
    add(TabPane.class, JavaFXTabPaneElement.class);
    add(ListView.class, JavaFXListViewElement.class);
    add(TreeView.class, JavaFXTreeViewElement.class);
    add(TableView.class, JavaFXTableViewElement.class);
    add(TreeTableView.class, JavaFXTreeTableViewElement.class);
    add(CheckBoxListCell.class, JavaFXCheckBoxListCellElement.class);
    add(ChoiceBoxListCell.class, JavaFXChoiceBoxListCellElement.class);
    add(ComboBoxListCell.class, JavaFXComboBoxListCellElemnt.class);
    add(CheckBoxTreeCell.class, JavaFXCheckBoxTreeCellElement.class);
    add(ChoiceBoxTreeCell.class, JavaFXChoiceBoxTreeCellElement.class);
    add(ComboBoxTreeCell.class, JavaFXComboBoxTreeCellElement.class);
    add(TableCell.class, JavaFXTableViewCellElement.class);
    add(CheckBoxTableCell.class, JavaFXCheckBoxTableCellElement.class);
    add(ChoiceBoxTableCell.class, JavaFXChoiceBoxTableCellElement.class);
    add(ComboBoxTableCell.class, JavaFXComboBoxTableCellElemnt.class);
    add(TreeTableCell.class, JavaFXTreeTableCellElement.class);
    add(CheckBoxTreeTableCell.class, JavaFXCheckBoxTreeTableCell.class);
    add(ChoiceBoxTreeTableCell.class, JavaFXChoiceBoxTreeTableCell.class);
    add(ComboBoxTreeTableCell.class, JavaFXComboBoxTreeTableCell.class);
}
项目:boomer-tuner    文件:PlaylistView.java   
private void initializeViews() {
    setPrefHeight(575);
    setPrefWidth(668);
    playlists = new ListView<>();
    detail = new SongsView(new SongsController());
    getItems().addAll(playlists, detail);
    setDividerPositions(0.28f);
}
项目:waterrower-workout    文件:SelectUserAction.java   
/**
 * An action which shows the popup to select or add a user.
 *
 * @param bundle  The resource bundle, must not be null.
 * @param context The application context, must not be null.
 * @param window  The main window of the application, must not be null.
 */
public SelectUserAction(ResourceBundle bundle, ApplicationContext context, Window window) {
    super(bundle, context, window);

    CreateUserAction createUserAction = new CreateUserAction(getBundle(), getApplicationContext(), getWindow());

    selectUserPopOver = new SelectionPopOver<User>() {

        @Override
        protected void onSelected(User user) {
            Log.debug(APPLICATION, "Change active user to '" + user + "'.");
            getApplicationContext().changeActiveUser(user);
        }

        @Override
        protected void onAddClicked(ActionEvent event) {
            Log.debug(APPLICATION, "User wants to add a new user!");
            createUserAction.handle(event);
        }

        @Override
        protected ListCell<User> createListCell(ListView<User> listView) {
            return new UserListCell(listView);
        }

    };
    selectUserPopOver.setPlaceholderText(bundle.getString("popup_select_user_list_no_users"));
    selectUserPopOver.setButtonText(bundle.getString("popup_select_user_btn_add_user"));
}
项目:marathonv5    文件:JavaFXListViewItemElement.java   
@Override public List<IJavaFXElement> getByPseudoElement(String selector, Object[] params) {
    ListView<?> listView = (ListView<?>) getComponent();
    if (getVisibleCellAt(listView, itemIndex) == null) {
        EventQueueWait.exec(() -> listView.scrollTo(itemIndex));
        return Arrays.asList();
    }
    if (selector.equals("editor")) {
        return Arrays.asList(JavaFXElementFactory.createElement(getEditor(), driver, window));
    }
    return super.getByPseudoElement(selector, params);
}
项目:marathonv5    文件:JavaFXListViewItemElement.java   
@Override public Object _makeVisible() {
    ListView<?> listView = (ListView<?>) getComponent();
    Node cell = getVisibleCellAt(listView, itemIndex);
    if (cell == null) {
        EventQueueWait.exec(() -> listView.scrollTo(itemIndex));
        return false;
    }
    return true;
}