java类javafx.collections.transformation.SortedList的实例源码

FxMediaTags.java 文件源码 项目:fx-media-tags 阅读 27 收藏 0 点赞 0 评论 0
public FxMediaTags() {
    getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
    getDialogPane().setContent(createForm());
    getDialogPane().setPrefWidth(RESOLUTION.getWidth() / 4);
    getDialogPane().setPrefHeight(RESOLUTION.getHeight());
    setResultConverter(createResultConverter());
    //
    titleProperty().bind(MODEL.dialogTitleProperty());
    //
    TAGS_TABLE.setItems(new SortedList<>(MODEL.tagsProperty(), (a,b) -> a.compareTo(b)));
    TAGS_TABLE.setContextMenu(createContextMenu());
    TAGS_TABLE.setOnMousePressed(event -> {
        if (event.isPrimaryButtonDown() && event.getClickCount() == 2) {
            final Button okButton = ((Button)getDialogPane().lookupButton(ButtonType.OK));
            if (null != okButton) {
                okButton.fire();
            }
        }
    });
}
CollatedTreeItem.java 文件源码 项目:marathonv5 阅读 20 收藏 0 点赞 0 评论 0
public CollatedTreeItem() {
    children = FXCollections.observableArrayList();
    filteredChildren = new FilteredList<>(children, new Predicate<TreeItem<T>>() {
        @Override public boolean test(TreeItem<T> t) {
            return filter.test(t.getValue());
        }
    });
    sortedChildren = new SortedList<>(filteredChildren);
    ObservableList<TreeItem<T>> original = super.getChildren();
    sortedChildren.addListener(new ListChangeListener<TreeItem<T>>() {
        @Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends TreeItem<T>> c) {
            while (c.next()) {
                original.removeAll(c.getRemoved());
                original.addAll(c.getFrom(), c.getAddedSubList());
            }
        }
    });
}
TDATableFilter.java 文件源码 项目:CDN-FX-2.2 阅读 16 收藏 0 点赞 0 评论 0
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().toLowerCase();
                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);
    }
TMTableFilter.java 文件源码 项目:CDN-FX-2.2 阅读 23 收藏 0 点赞 0 评论 0
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);
    }
ItemSelectorController.java 文件源码 项目:osrs-equipment-builder 阅读 20 收藏 0 点赞 0 评论 0
private void setupSorting() {
    FilteredList<Item> filteredData = new FilteredList<>(itemList, p -> true);

    filterField.textProperty().addListener((observable, oldValue, newValue) -> {
        filteredData.setPredicate(item -> {
            if(newValue == null || newValue.isEmpty() )
                return true;

            if(item.getName().toLowerCase().contains(newValue.toLowerCase())){
                return true;
            } else {
                return false;
            }

        });
    });

    SortedList<Item> sortedData = new SortedList<>(filteredData);

    sortedData.comparatorProperty().bind(itemTable.comparatorProperty());

    itemTable.setItems(sortedData);

}
AlbumsViewSpecificController.java 文件源码 项目:MusicHub 阅读 16 收藏 0 点赞 0 评论 0
@Override
public void buildUI() {
    albumSongsList = FXCollections.observableArrayList();
    songDataSortedList = new SortedList<>(albumSongsList, new SongDataComparator());
    songListTable.getStylesheets().clear();
    songListTable.getStylesheets().add(Constants.getCssMainFilePath());

    songListTableTitle.setCellValueFactory(cellData -> cellData.getValue().titleProperty());
    songListTableArtist.setCellValueFactory(cellData -> cellData.getValue().artistProperty());
    songListTableAlbum.setCellValueFactory(cellData -> cellData.getValue().albumTitleProperty());
    songListTableYear.setCellValueFactory(cellData -> cellData.getValue().yearProperty());
    songListTableGenre.setCellValueFactory(cellData -> cellData.getValue().gerneProperty());
    songListTableLength.setCellValueFactory(cellData -> cellData.getValue().lengthStrProperty());
    songListTableLength.setStyle("-fx-alignment: CENTER-RIGHT;");
    songListTable.setItems(songDataSortedList);
    songListTable.setOnMouseClicked(event -> {
        if (event.getClickCount() == 2) {
            mainPlayerController.playSong(songListTable.getSelectionModel().getSelectedItem());
            mainPlayerController.setViewId(Constants.VIEWS_ID.ALBUMS);
            buildPlaylist();
        }
    });

    songListTable.setFixedCellSize(48.0);
}
CommandFinderTools.java 文件源码 项目:qupath 阅读 22 收藏 0 点赞 0 评论 0
static TableView<CommandEntry> createCommandTable(final ObservableList<CommandEntry> commands) {
    TableView<CommandEntry> table = new TableView<>();
    SortedList<CommandEntry> items = new SortedList<>(commands);
    items.comparatorProperty().bind(table.comparatorProperty());
    table.setItems(items);

    TableColumn<CommandEntry, String> col1 = new TableColumn<>("Command");
    col1.setCellValueFactory(new PropertyValueFactory<>("text"));
    TableColumn<CommandEntry, String> col2 = new TableColumn<>("Menu Path");
    col2.setCellValueFactory(new PropertyValueFactory<>("menuPath"));
    table.getColumns().add(col1);
    table.getColumns().add(col2);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    table.setFocusTraversable(false);
    return table;
}
AdhocListTest.java 文件源码 项目:POL-POM-5 阅读 18 收藏 0 点赞 0 评论 0
@Test
public void testListPermutation() {
    SortedList<String> sortedList = FXCollections.observableArrayList(Arrays.asList("3", "7", "1", "5"))
            .sorted(Comparator.naturalOrder());
    AdhocList<String> mappedList = new AdhocList<>(sortedList, "0");

    assertEquals(5, mappedList.size());
    assertEquals("0", mappedList.get(0));
    assertEquals("1", mappedList.get(1));
    assertEquals("3", mappedList.get(2));
    assertEquals("5", mappedList.get(3));
    assertEquals("7", mappedList.get(4));

    sortedList.comparatorProperty().set(Comparator.comparing(String::valueOf).reversed());

    assertEquals(5, mappedList.size());
    assertEquals("0", mappedList.get(0));
    assertEquals("7", mappedList.get(1));
    assertEquals("5", mappedList.get(2));
    assertEquals("3", mappedList.get(3));
    assertEquals("1", mappedList.get(4));
}
PhoenicisFilteredListTest.java 文件源码 项目:POL-POM-5 阅读 13 收藏 0 点赞 0 评论 0
@Test
public void testListPermutation() {
    SortedList<Integer> sortedList = FXCollections.observableList(Arrays.asList(1, 2, 4, 3))
            .sorted(Comparator.naturalOrder());
    PhoenicisFilteredList<Integer> filteredList = new PhoenicisFilteredList<>(sortedList, i -> i % 2 == 0);

    assertEquals(2, filteredList.size());
    assertEquals(2, (int) filteredList.get(0));
    assertEquals(4, (int) filteredList.get(1));

    sortedList.comparatorProperty().set(Comparator.comparing(String::valueOf).reversed());

    assertEquals(2, filteredList.size());
    assertEquals(4, (int) filteredList.get(0));
    assertEquals(2, (int) filteredList.get(1));
}
MappedListTest.java 文件源码 项目:POL-POM-5 阅读 17 收藏 0 点赞 0 评论 0
@Test
public void testListPermutation() {
    SortedList<Integer> sortedList = FXCollections.observableList(Arrays.asList(3, 7, 1, 5))
            .sorted(Comparator.naturalOrder());
    MappedList<String, Integer> mappedList = new MappedList<>(sortedList, i -> String.valueOf(i));

    assertEquals(4, mappedList.size());
    assertEquals("1", mappedList.get(0));
    assertEquals("3", mappedList.get(1));
    assertEquals("5", mappedList.get(2));
    assertEquals("7", mappedList.get(3));

    sortedList.comparatorProperty().set(Comparator.comparing(String::valueOf).reversed());

    assertEquals(4, mappedList.size());
    assertEquals("7", mappedList.get(0));
    assertEquals("5", mappedList.get(1));
    assertEquals("3", mappedList.get(2));
    assertEquals("1", mappedList.get(3));
}
ActivityController.java 文件源码 项目:PeerWasp 阅读 34 收藏 0 点赞 0 评论 0
/**
 * Wires the list view with the items source and configures filtering and sorting of the items.
 */
private void loadItems() {
    // filtering -- default show all
    FilteredList<ActivityItem> filteredItems = new FilteredList<>(activityLogger.getActivityItems(), p -> true);
    txtFilter.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            // filter on predicate
            filteredItems.setPredicate(new ActivityItemFilterPredicate(newValue));
        }
    });

    // sorting
    SortedList<ActivityItem> sortedItems = new SortedList<>(filteredItems, new ActivityItemTimeComparator());

    // set item source
    lstActivityLog.setItems(sortedItems);
    lstActivityLog
            .setCellFactory(new Callback<ListView<ActivityItem>, ListCell<ActivityItem>>() {
                @Override
                public ListCell<ActivityItem> call(ListView<ActivityItem> param) {
                    return new ActivityItemCell();
                }
            });
}
NewLogEntryTabController.java 文件源码 项目:Recordian 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Sets the items for all combo boxes in newLogEntryTab view
 */
private void setAllComboBoxItems(){

    Consumer<ComboBox<String>> disableComboBoxIfEmpty = (comboBox) -> {
        if (comboBox.getItems().isEmpty()) {
            comboBox.setDisable(true);
        } else {comboBox.setDisable(false);}
    };

    // Establish process for populating a combo box
    BiConsumer<ComboBox<String>, ObservableList<String>> setComboBoxItems = (comboBox, observableList) -> {
        observableList.addListener((ListChangeListener<String>) c -> {
            comboBox.setItems(observableList);
            disableComboBoxIfEmpty.accept(comboBox);
        });
        comboBox.setItems(observableList);
        disableComboBoxIfEmpty.accept(comboBox);
    };

    // Set company combo box items
    sortedCompanyNames = new SortedList<>(companyNames, String.CASE_INSENSITIVE_ORDER);
    setComboBoxItems.accept(companyComboBox, sortedCompanyNames);

    // Set location combo box items
    sortedLocationNames = new SortedList<>(locationNames, String.CASE_INSENSITIVE_ORDER);
    setComboBoxItems.accept(locationComboBox, sortedLocationNames);

    // Set supervisor combo box items
    sortedSupervisorDisplayNames = new SortedList<>(supervisorDisplayNames, String.CASE_INSENSITIVE_ORDER);
    setComboBoxItems.accept(supervisorComboBox, sortedSupervisorDisplayNames);
}
JavaFXUI.java 文件源码 项目:OpenVSP3Plugin 阅读 19 收藏 0 点赞 0 评论 0
private void updateFilters() {
    LOG.trace("updateFilters()");
    if (tableViewData == null) return;
    SortedList<DesignVariable> sortedList = getSortedFilteredDesignVariables(tableViewData);
    tableView.setItems(sortedList);
    sortedList.comparatorProperty().bind(tableView.comparatorProperty());
    updateLabel();
}
JavaFXUI.java 文件源码 项目:OpenVSP3Plugin 阅读 18 收藏 0 点赞 0 评论 0
private SortedList<DesignVariable> getSortedFilteredDesignVariables(ObservableList<DesignVariable> designVariables) {
    LOG.trace("getSortedFilteredDesignVariables(designVariables)");
    Pattern pattern;
    try {
        pattern = Pattern.compile(filterTextField.getText());
    } catch(Exception ex) {
        pattern = emptyPattern;
    }
    Pattern finalPattern = pattern; // make lambda happy
    return new SortedList<>(designVariables.filtered((DesignVariable dv) -> {
        boolean filter = ((selectedOnlyButton.isSelected() && !dv.isChecked()) ||
                (!filterTextField.getText().isEmpty() && !finalPattern.matcher(dv.getFullName()).find()));
        return !filter;
    }));
}
PluginState.java 文件源码 项目:OpenVSP3Plugin 阅读 17 收藏 0 点赞 0 评论 0
private SortedList<DesignVariable> desFileSort(ObservableList<DesignVariable> list) {
    return list.sorted((DesignVariable dv1, DesignVariable dv2) -> {
        int value;
        if (dv1.getContainer().equals(dv2.getContainer())) {
            if (dv1.getGroup().equals(dv2.getGroup())) {
                value = dv1.getName().compareTo(dv2.getName());
            } else {
                value = dv2.getGroup().replace("_", " ").compareTo(dv1.getGroup().replace("_", " "));
            }
        } else {
            value = dv1.getContainer().compareTo(dv2.getContainer());
        }
        return value;
    });
}
LogPane.java 文件源码 项目:CalendarFX 阅读 17 收藏 0 点赞 0 评论 0
public LogPane() {
    super();
    table = new TableView<>();

    TableColumn<LogItem, StatusType> statusColumn = new TableColumn<>("Status");
    statusColumn.setCellValueFactory(new PropertyValueFactory<>("status"));
    statusColumn.prefWidthProperty().bind(Bindings.multiply(0.1, table.widthProperty()));
    statusColumn.setCellFactory(col -> new StatusTypeCell());

    TableColumn<LogItem, ActionType> actionColumn = new TableColumn<>("Action");
    actionColumn.setCellValueFactory(new PropertyValueFactory<>("action"));
    actionColumn.prefWidthProperty().bind(Bindings.multiply(0.1, table.widthProperty()));
    actionColumn.setCellFactory(col -> new ActionTypeCell());

    TableColumn<LogItem, LocalDateTime> timeColumn = new TableColumn<>("Time");
    timeColumn.setCellValueFactory(new PropertyValueFactory<>("time"));
    timeColumn.prefWidthProperty().bind(Bindings.multiply(0.2, table.widthProperty()));
    timeColumn.setCellFactory(col -> new TimeCell());

    TableColumn<LogItem, String> calendarColumn = new TableColumn<>("Calendar");
    calendarColumn.setCellValueFactory(new PropertyValueFactory<>("calendar"));
    calendarColumn.prefWidthProperty().bind(Bindings.multiply(0.2, table.widthProperty()));

    TableColumn<LogItem, String> descriptionColumn = new TableColumn<>("Description");
    descriptionColumn.setCellValueFactory(new PropertyValueFactory<>("description"));
    descriptionColumn.prefWidthProperty().bind(Bindings.multiply(0.4, table.widthProperty()));

    filteredData = new FilteredList<>(items);
    SortedList<LogItem> sortedData = new SortedList<>(filteredData);
    sortedData.comparatorProperty().bind(table.comparatorProperty());

    table.getColumns().add(statusColumn);
    table.getColumns().add(actionColumn);
    table.getColumns().add(timeColumn);
    table.getColumns().add(calendarColumn);
    table.getColumns().add(descriptionColumn);
    table.setTableMenuButtonVisible(true);
    table.setItems(sortedData);
    table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
ParsedFilesController.java 文件源码 项目:recruitervision 阅读 18 收藏 0 点赞 0 评论 0
private void initTable() {
    fileName.setCellValueFactory(param -> new SimpleStringProperty(FilenameUtils.getBaseName(param.getValue().getFile().getPath())));
    fileLocation.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getFile().getPath()));
    fileExtension.setCellValueFactory(param -> new SimpleStringProperty(FilenameUtils.getExtension(param.getValue().getFile().getPath())));
    language.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getLanguage()));

    fileStatus_parsed.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getParsedStatus()));
    fileStatus_extracted.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getExtractedStatus()));

    // Searchable
    FilteredList<Filed> filteredData = new FilteredList<>(observableFiles, f -> true);
    searcheableField.textProperty().addListener((observable, oldValue, newValue) -> filteredData.setPredicate(filed -> {
        if (newValue == null || newValue.isEmpty()) {
            return true;
        }
        String lowerCaseFilter = newValue.toLowerCase();

        if (FilenameUtils.getBaseName(filed.getFile().getPath()).toLowerCase().contains(lowerCaseFilter)) {
            return true;
        } else if (filed.getFile().getPath().toLowerCase().contains(lowerCaseFilter)) {
            return true;
        } else if (filed.getLanguage().toLowerCase().contains(lowerCaseFilter)) {
            return true;
        }
        return false;
    }));
    SortedList<Filed> sortedList = new SortedList<>(filteredData);
    sortedList.comparatorProperty().bind(millingTable.comparatorProperty());

    millingTable.getColumns().setAll(fileName, fileLocation, fileExtension, language, fileStatus);
    millingTable.setItems(sortedList);
}
CloudLinkService.java 文件源码 项目:javaone2016 阅读 23 收藏 0 点赞 0 评论 0
@Override
public ReadOnlyListProperty<News> retrieveNews() {
    if (news == null) {
        GluonObservableList<News> gluonNews = DataProvider.retrieveList(cloudGluonClient.createListDataReader("activityFeed", News.class, SyncFlag.LIST_READ_THROUGH));
        SortedList<News> sortedNews = new SortedList<>(gluonNews);
        sortedNews.setComparator((n1, n2) -> n1.getCreationDate() == n2.getCreationDate() ? n1.getUuid().compareTo(n2.getUuid()) : Long.compare(n1.getCreationDate(), n2.getCreationDate()) * -1);
        news = new ReadOnlyListWrapper<>(sortedNews);
    }
    return news.getReadOnlyProperty();
}
GoodsReceiptForm.java 文件源码 项目:myWMS 阅读 15 收藏 0 点赞 0 评论 0
public ObservableValue<?> getValueProperty(String id) {
    if (Strings.equals(id, "positionList")) {
        Comparator<LOSGoodsReceiptPosition> comparator = Comparator.comparing(
                LOSGoodsReceiptPosition::getPositionNumber,  
                new PositionComparator());

        return MBindings.get(dataProperty(), d -> new SortedList<LOSGoodsReceiptPosition>(
                FXCollections.observableList(d.getPositionList()), comparator)); 
    }
    else {
        return super.getValueProperty(id);
    }
}
IngAusOfxFixController.java 文件源码 项目:IngAusOfxFixLinux 阅读 16 收藏 0 点赞 0 评论 0
@FXML
    public void handleBtnActionSaveSettings(Event e) throws IOException {

        int i = 0;
        String suffix;
        String tmpBook;

        defaultProps.setProperty(DEFAULT_PROP, BankAcct.getDefaultBankAcct());

        // Until problem in Java 8u92 with adding items to ComboBox which uses SortedList is fixed,
        //  sort the bankAccts before saving

//      Set bankAcctSet = bankAcctMap.keySet();
//      Iterator itr = bankAcctSet.iterator();

        SortedList sortedBookList = new SortedList<>(bankAcctComboBoxData, Collator.getInstance());
        Iterator itr = sortedBookList.iterator();

        while (itr.hasNext()) {
            tmpBook = (String) itr.next();
            BankAcct refBook = (BankAcct) bankAcctMap.get(tmpBook);
            suffix = String.valueOf(i++);
            defaultProps.setProperty(ACCTNAME_PROP + suffix, refBook.getBankAcctName());
            defaultProps.setProperty(BANKID_PROP + suffix, refBook.getBankAcctBankId());
            defaultProps.setProperty(ACCTNO_PROP + suffix, refBook.getBankAcctNo());
            defaultProps.setProperty(ACCTTYPE_PROP + suffix, refBook.getBankAcctType());
            defaultProps.setProperty(OFXDIR_PROP + suffix, refBook.getBankAcctOfxDir());
        }

        try (FileOutputStream out = new FileOutputStream(DEF_PROP)) {
            defaultProps.store(out, "---Backup GnuCash Settings---");
            taLog.setText("Settings successfully saved to " + DEF_PROP);
        } catch (IOException ex) {
            //System.out.println("My Exception Message " + ex.getMessage());
            //System.out.println("My Exception Class " + ex.getClass());
            Logger.getLogger(IngAusOfxFixController.class.getName()).log(Level.SEVERE, null, ex);
            taLog.setText("Error: Cannot Save Settings to : " + DEF_PROP);
        }
    }
AlbumsViewOverviewController.java 文件源码 项目:MusicHub 阅读 18 收藏 0 点赞 0 评论 0
public void setDB() {
    albumsListView.setCellFactory(gridView -> {
        AlbumTileCell albumTileCell = new AlbumTileCell(this);
        monitoringCells.add(albumTileCell);
        return albumTileCell;
    });
    Platform.runLater(() -> albumsListView.setItems(
            new SortedList<>(mainPlayerController.getAlbumTileObservableList(), new AlbumTileComparator()))
    );
}
EloModel.java 文件源码 项目:polTool 阅读 19 收藏 0 点赞 0 评论 0
private ObservableList<MatchSet> sortMatchSets(ObservableList<MatchSet> sets) {
    ObservableList<MatchSet> sortedResult = new SortedList<MatchSet>(sets,
            (set1, set2) -> {
                return ComparisonChain.start()
                        .compare(set1.getDate(), set2.getDate())
                        .compare(set1.getSetNr(), set1.getSetNr())
                        .compare(set1.getHomeTeam(), set2.getHomeTeam())
                        .result();
            });
    return sortedResult;
}
AbstractEloTable.java 文件源码 项目:polTool 阅读 14 收藏 0 点赞 0 评论 0
protected ObservableList<MatchSet> sortMatchSets(
        ObservableList<MatchSet> sets) {
    ObservableList<MatchSet> sortedResult = new SortedList<MatchSet>(sets,
            (set1, set2) -> {
                return ComparisonChain.start()
                        .compare(set1.getDate(), set2.getDate())
                        .compare(set1.getSetNr(), set1.getSetNr())
                        .compare(set1.getHomeTeam(), set2.getHomeTeam())
                        .result();
            });
    return sortedResult;
}
MatchSetTable.java 文件源码 项目:polTool 阅读 17 收藏 0 点赞 0 评论 0
protected void createTable() {
    TableColumn<MatchSet, LocalDateTime> date = createColumn("Spieldatum",
            "date", LocalDateTime.class, 100d);
    createColumn("HeimTeam", "homeTeam", String.class, 120d);
    createColumn("Gäste", "guestTeam", String.class, 120d);
    createColumn("Satz", "setNr", Integer.class, 45d);
    createColumn("Heimspieler 1", "homePlayer1", String.class, 140d);
    createColumn("Heimspieler 2", "homePlayer2", String.class, 140d);
    createColumn("Gastspieler 1", "guestPlayer1", String.class, 140d);
    createColumn("Gastspieler 2", "guestPlayer2", String.class, 140d);
    createColumn("Punkte Heim", "homeResult", Integer.class, 70d);
    createColumn("Punkte Gast", "guestResult", Integer.class, 70d);

    date.setCellFactory(column -> {
        return new TableCell<MatchSet, LocalDateTime>() {

            @Override
            protected void updateItem(LocalDateTime item, boolean empty) {
                super.updateItem(item, empty);
                if (item == null || empty) {
                    setText(null);
                    setStyle("");
                } else {
                    setText(item.format(DateTimeFormatter
                            .ofPattern("dd.MM.yyyy HH:mm")));
                }
            }

        };
    });

    setList = new FilteredList<MatchSet>(model.getSets(), set -> true);
    SortedList<MatchSet> sortedSets = new SortedList<MatchSet>(setList);
    sortedSets.comparatorProperty().bind(comparatorProperty());
    setItems(sortedSets);
}
DashBoard.java 文件源码 项目:HitBoard 阅读 31 收藏 0 点赞 0 评论 0
private void setupGamesList() {
    new Thread(() -> {
        try {
            cbGames.setDisable(true);
            List<String> games = RequestHandler.instance().getGames()
                    .getGamesListNames(2900, false);
            SortedList<String> gamesS = FXCollections
                    .observableArrayList(games).sorted();
            Platform.runLater(() -> cbGames.setItems(gamesS));
        } catch (Exception e) {
            e.printStackTrace();
        }
        cbGames.setDisable(false);
    }).start();
}
TableViewPlus.java 文件源码 项目:blackmarket 阅读 18 收藏 0 点赞 0 评论 0
/**
 * Just add some sample data in the constructor.
 */
public TableViewPlus(Map<String, String> columnNameFieldMapping, 
        double[] minWidths, 
        ObservableList<S> masterData) {

    // remove focus
    setStyle(
            "-fx-background-color: -fx-outer-border, -fx-inner-border, -fx-body-color; -fx-background-insets: 0, 1, 2; -fx-background-radius: 5, 4, 3;");

    // 0. Initialize the columns.
    columnNameFieldMapping.entrySet().stream().forEachOrdered(entry -> {
        TableColumn<S, String> column = new TableColumn<>(entry.getKey());
        column.setCellValueFactory(new PropertyValueFactory<S, String>(entry.getValue()));
        column.impl_setReorderable(false);
        getColumns().add(column);
    });

    IntStream.range(0, getColumns().size())
        .forEach(i -> getColumns().get(i).setMinWidth(minWidths[i]));

    // 1. Wrap the ObservableList in a FilteredList (initially display all data).
    filteredData = new FilteredList<>(masterData, p -> true);

    // 3. Wrap the FilteredList in a SortedList. 
    SortedList<S> sortedData = new SortedList<>(filteredData);

    // 4. Bind the SortedList comparator to the TableView comparator.
    sortedData.comparatorProperty().bind(comparatorProperty());

    // 5. Add sorted (and filtered) data to the table.
    setItems(sortedData);
}
PersonsController.java 文件源码 项目:examples-javafx-repos1 阅读 17 收藏 0 点赞 0 评论 0
protected void doFilterTable(TextField tf) {
    String criteria = tf.getText();

    if( logger.isLoggable(Level.FINE) ) {
        logger.fine( "[FILTER] filtering on=" + criteria );
    }

    if( criteria == null || criteria.isEmpty() ) {
        tblPersons.setItems( personsActiveRecord );
        return;
    }

    FilteredList<Person> fl = new FilteredList<>(personsActiveRecord, p -> true);

    fl.setPredicate(person -> {

        if (criteria == null || criteria.isEmpty()) {
             return true;
         }

         String lcCriteria = criteria.toLowerCase();

         if (person.getFirstName().toLowerCase().contains(lcCriteria)) {
             return true; // Filter matches first name.
         } else if (person.getLastName().toLowerCase().contains(lcCriteria)) {
             return true; // Filter matches last name.
         } else if (person.getEmail().toLowerCase().contains(lcCriteria)) {
             return true;  //   matches email
         }

         return false; // Does not match.
     });

     SortedList<Person> sortedData = new SortedList<>(fl);
     sortedData.comparatorProperty().bind(tblPersons.comparatorProperty());  // ?       
     tblPersons.setItems(sortedData);
}
TorrentViewTable.java 文件源码 项目:jfx-torrent 阅读 21 收藏 0 点赞 0 评论 0
private void initComponents() {
       torrentViews.addListener((ListChangeListener<TorrentView>) l -> {
           if(l.next()) {
               totalTorrents.set(torrentViews.size());
           }
       });

       final SortedList<TorrentView> sortedTorrents = new SortedList<>(filteredTorrents);
       sortedTorrents.comparatorProperty().bind(torrentTable.comparatorProperty());

       torrentTable.setItems(sortedTorrents);
       torrentTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
       torrentTable.setTableMenuButtonVisible(false);
       torrentTable.setRowFactory(t -> new TorrentViewTableRow<>());

       final String emptyTorrentListMessage = "Go to 'File->Add Torrent...' to add torrents.";
       final Text emptyTorrentListPlaceholder = new Text(emptyTorrentListMessage);
       emptyTorrentListPlaceholder.getStyleClass().add(CssProperties.TORRENT_LIST_EMPTY_TEXT);

       filteredTorrents.predicateProperty().addListener((obs, oldV, newV) -> {
           emptyTorrentListPlaceholder.setText(filteredTorrents.isEmpty() && torrentViews.isEmpty()?
               emptyTorrentListMessage : "No torrents to display.");
       });

       final BorderPane placeholderPane = new BorderPane();
       placeholderPane.getStyleClass().add(CssProperties.PLACEHOLDER_EMPTY);
       placeholderPane.setPadding(new Insets(15, 0, 0, 40));
       placeholderPane.setLeft(emptyTorrentListPlaceholder);
       torrentTable.setPlaceholder(placeholderPane);
       createColumns();
}
OwnNoteEditor.java 文件源码 项目:ownNoteEditor 阅读 15 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
public void initFromDirectory(final boolean updateOnly) {
    checkChangedNote();

    // scan directory
    myFileManager.initOwnNotePath(ownCloudPath.textProperty().getValue());

    // add new table entries & disable & enable accordingly
    notesList = myFileManager.getNotesList();
    // http://code.makery.ch/blog/javafx-8-tableview-sorting-filtering/

    // 1. Wrap the ObservableList in a FilteredList (initially display all data).
    filteredData = new FilteredList<>(notesList, p -> true);
    // re-apply filter predicate when already set
    final String curGroupName = (String) notesTable.getTableView().getUserData();
    if (curGroupName != null) {
        setFilterPredicate(curGroupName);
    }

    // 2. Set the filter Predicate whenever the filter changes.
    // done in TabPane and TableView controls

    // 3. Wrap the FilteredList in a SortedList. 
    SortedList<Map<String, String>> sortedData = new SortedList<Map<String, String>>(filteredData);

    // 4. Bind the SortedList comparator to the TableView comparator.
    sortedData.comparatorProperty().bind(notesTable.comparatorProperty());

    // 5. Add sorted (and filtered) data to the table.        
    notesTable.setNotes(sortedData);

    ObservableList<Map<String, String>> groupsList = myFileManager.getGroupsList();
    myGroupList.setGroups(groupsList, updateOnly);

    // and now store group names (real ones!) for later use
    initGroupNames();
}
ExpandedListTest.java 文件源码 项目:POL-POM-5 阅读 15 收藏 0 点赞 0 评论 0
@Test
public void testListPermutation() {
    SortedList<List<String>> observableList = FXCollections
            .<List<String>> observableArrayList(Arrays.asList("11"), Arrays.asList("21", "22"), Arrays.asList())
            .sorted(Comparator.comparing(List::size));
    ExpandedList<String, List<String>> expandedList = new ExpandedList<>(observableList, Function.identity());
    List<String> actual = new ArrayList<>();

    Bindings.bindContent(actual, expandedList);

    assertEquals(3, expandedList.size());
    assertEquals("11", expandedList.get(0));
    assertEquals("21", expandedList.get(1));
    assertEquals("22", expandedList.get(2));

    assertEquals(3, actual.size());
    assertEquals("11", actual.get(0));
    assertEquals("21", actual.get(1));
    assertEquals("22", actual.get(2));

    observableList.comparatorProperty().set(Comparator.comparing(o -> ((List<String>) o).size()).reversed());

    assertEquals(3, expandedList.size());
    assertEquals("21", expandedList.get(0));
    assertEquals("22", expandedList.get(1));
    assertEquals("11", expandedList.get(2));

    assertEquals(3, actual.size());
    assertEquals("21", actual.get(0));
    assertEquals("22", actual.get(1));
    assertEquals("11", actual.get(2));
}


问题


面经


文章

微信
公众号

扫码关注公众号