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

SpreadView.java 文件源码 项目:exchange 阅读 20 收藏 0 点赞 0 评论 0
@Override
protected void activate() {
    sortedList = new SortedList<>(model.spreadItems);
    sortedList.comparatorProperty().bind(tableView.comparatorProperty());
    tableView.setItems(sortedList);
    sortedList.addListener(itemListChangeListener);
    updateHeaders();
}
OfferBookViewModel.java 文件源码 项目:exchange 阅读 17 收藏 0 点赞 0 评论 0
@SuppressWarnings("WeakerAccess")
@Inject
public OfferBookViewModel(User user,
                          OpenOfferManager openOfferManager,
                          OfferBook offerBook,
                          Preferences preferences,
                          P2PService p2PService,
                          PriceFeedService priceFeedService,
                          ClosedTradableManager closedTradableManager,
                          FilterManager filterManager,
                          WalletsSetup walletsSetup,
                          AccountAgeWitnessService accountAgeWitnessService,
                          Navigation navigation,
                          BSFormatter formatter) {
    super();

    this.openOfferManager = openOfferManager;
    this.user = user;
    this.offerBook = offerBook;
    this.preferences = preferences;
    this.p2PService = p2PService;
    this.priceFeedService = priceFeedService;
    this.closedTradableManager = closedTradableManager;
    this.filterManager = filterManager;
    this.walletsSetup = walletsSetup;
    this.accountAgeWitnessService = accountAgeWitnessService;
    this.navigation = navigation;
    this.formatter = formatter;

    this.filteredItems = new FilteredList<>(offerBook.getOfferBookListItems());
    this.sortedItems = new SortedList<>(filteredItems);

    tradeCurrencyListChangeListener = c -> {
        fillAllTradeCurrencies();
    };
}
TwitchService.java 文件源码 项目:livestreamer_twitch_gui 阅读 19 收藏 0 点赞 0 评论 0
public TwitchService(final String name, final String url) {
    this.name = new SimpleStringProperty(name);
    this.url = new SimpleStringProperty(url);
    this.channelProperty = new SimpleObjectProperty<>(new SortedList<>(this.channelList));
    this.sortChannels = new SimpleBooleanProperty();
    this.sortChannels.bind(Settings.getInstance().sortTwitchProperty());
    this.sortChannels.addListener((observable, oldValue, newVale) -> this.changeComparator(newVale));
    this.channelProperty.get().addListener((ListChangeListener<IChannel>) change -> {
        change.next();
        this.changeComparator(this.sortChannels.get());
    });
}
Controller.java 文件源码 项目:sette-tool 阅读 23 收藏 0 点赞 0 评论 0
private void updateRunnerProjectList() {
    FilteredList<RunnerProject<Tool>> filteredList = availableRunnerProjects.filtered(rp -> {
        return snippetProjectFilter.getSelectionModel().getSelectedItems()
                .contains(rp.getSnippetProject())
                && toolFilter.getSelectionModel().getSelectedItems().contains(rp.getTool())
                && rp.getTag().toLowerCase()
                        .contains(runnerProjectTagFilter.getText().toLowerCase());
    });
    runnerProjectList.setItems(new SortedList<>(filteredList));

    updateSnippetList();
}
Controller.java 文件源码 项目:sette-tool 阅读 24 收藏 0 点赞 0 评论 0
private void updateSnippetList() {
    if (availableSnippets.isEmpty()) {
        snippetList.setItems(FXCollections.emptyObservableList());
    } else {
        FilteredList<Snippet> filteredList = availableSnippets.filtered(
                s -> s.getId().toLowerCase().contains(snippetFilter.getText().toLowerCase()));
        snippetList.setItems(new SortedList<>(filteredList));
    }

    updateInfoPane();
}
BeaconConfigsViewController.java 文件源码 项目:RaspberryPiBeaconParser 阅读 20 收藏 0 点赞 0 评论 0
@FXML
private void initialize() {
   // 0. Initialize the columns.
   idColumn.setCellValueFactory(cellData -> cellData.getValue().idProperty());
   nameColumn.setCellValueFactory(cellData -> cellData.getValue().nameProperty());
   uuidColumn.setCellValueFactory(cellData -> cellData.getValue().uuidProperty());
   txpowerColumn.setCellValueFactory(cellData -> cellData.getValue().txpowerProperty());
   minorIDColumn.setCellValueFactory(cellData -> cellData.getValue().minorIDProperty());
   majorIDColumn.setCellValueFactory(cellData -> cellData.getValue().majorIDProperty());
   // 1. Wrap the ObservableList in a FilteredList (initially display all data).
   FilteredList<ConfigModel> filteredData = new FilteredList<>(configModels, p -> true);
   // 2. Set the filter Predicate whenever the filter changes.
   filterField.textProperty().addListener((observable, oldValue, newValue) -> {
      filteredData.setPredicate(beacon -> {
         // If filter text is empty, display all persons.
         if (newValue == null || newValue.isEmpty()) {
            return true;
         }

         String lowerCaseFilter = newValue.toLowerCase();
         if (beacon.getName().toLowerCase().contains(lowerCaseFilter)) {
            return true;
         } else if (beacon.minorIDMatches(lowerCaseFilter)) {
            return true;
         } else if (beacon.idMatches(lowerCaseFilter)) {
            return true;
         }
         return false;
      });
   });

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

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

   // 5. Add sorted (and filtered) data to the table.
   configsTable.setItems(sortedData);
}
DbgView.java 文件源码 项目:erlyberly 阅读 17 收藏 0 点赞 0 评论 0
private void createModuleTreeItem(OtpErlangTuple tuple) {
    boolean isExported;
    OtpErlangAtom moduleNameAtom = (OtpErlangAtom) tuple.elementAt(0);
    OtpErlangList exportedFuncs = (OtpErlangList) tuple.elementAt(1);
    OtpErlangList localFuncs = (OtpErlangList) tuple.elementAt(2);

    TreeItem<ModFunc> moduleItem;

    ModFunc module = ModFunc.toModule(moduleNameAtom);
    moduleItem = new TreeItem<ModFunc>(module);
    moduleItem.setGraphic(treeIcon(AwesomeIcon.CUBE));

    ObservableList<TreeItem<ModFunc>> modFuncs = FXCollections.observableArrayList();

    SortedList<TreeItem<ModFunc>> sortedFuncs = new SortedList<TreeItem<ModFunc>>(modFuncs);

    FilteredList<TreeItem<ModFunc>> filteredFuncs = new FilteredList<TreeItem<ModFunc>>(sortedFuncs);

    sortedFuncs.setComparator(treeItemModFuncComparator());

    isExported = true;
    addTreeItems(toModFuncs(moduleNameAtom, exportedFuncs, isExported), modFuncs);

    isExported = false;
    addTreeItems(toModFuncs(moduleNameAtom, localFuncs, isExported), modFuncs);
    functionLists.put(module, filteredFuncs);

    Bindings.bindContentBidirectional(moduleItem.getChildren(), filteredFuncs);

    ArrayList<TreeItem<ModFunc>> treeModulesCopy = new ArrayList<>(treeModules);
    for (TreeItem<ModFunc> treeItem : treeModulesCopy) {
        if(treeItem.getValue().equals(module)) {
            treeModules.remove(treeItem);
        }
    }
    treeModules.add(moduleItem);
}
DbgTraceView.java 文件源码 项目:erlyberly 阅读 19 收藏 0 点赞 0 评论 0
public DbgTraceView(DbgController aDbgController) {
    dbgController = aDbgController;
    sortedTtraces = new SortedList<TraceLog>(dbgController.getTraceLogs());
    filteredTraces = new FilteredList<TraceLog>(sortedTtraces);

    setSpacing(5d);
    setStyle("-fx-background-insets: 5;");
    setMaxHeight(Double.MAX_VALUE);

    tracesBox = new TableView<TraceLog>();
    tracesBox.getStyleClass().add("trace-log-table");
    tracesBox.setOnMouseClicked(this::onTraceClicked);
    tracesBox.setMaxHeight(Double.MAX_VALUE);
    VBox.setVgrow(tracesBox, Priority.ALWAYS);

    putTableColumns();

    // #47 double wrapping the filtered list in another sorted list, otherwise
    // the table cannot be sorted on columns. Binding the items will throw exceptions
    // when sorting on columns.
    // see http://code.makery.ch/blog/javafx-8-tableview-sorting-filtering/
    SortedList<TraceLog> sortedData = new SortedList<>(filteredTraces);
    sortedData.comparatorProperty().bind(tracesBox.comparatorProperty());
    tracesBox.setItems(sortedData);

    putTraceContextMenu();

    Parent p = traceLogFloatySearchControl();

    getChildren().addAll(p, tracesBox);
}
MainWindow.java 文件源码 项目:skadi 阅读 23 收藏 0 点赞 0 评论 0
private void setupGrid() {
    grid = new ChannelGrid();
    grid.setBorder(Border.EMPTY);
    grid.setPadding(Insets.EMPTY);
    grid.setCellFactory(gridView -> new ChannelGridCell(grid, this));
    grid.cellHeightProperty().bind(scalingGridCellHeight);
    grid.cellWidthProperty().bind(scalingGridCellWidth);
    grid.setHorizontalCellSpacing(5);
    grid.setVerticalCellSpacing(5);

    filteredChannelListGrid = new FilteredList<>(channelStore.getChannels());
    final SortedList<Channel> sortedChannelListGrid = new SortedList<>(filteredChannelListGrid);
    sortedChannelListGrid.setComparator((channel1, channel2) -> Long.compare(channel2.getViewer(), channel1.getViewer()));
    grid.setItems(sortedChannelListGrid);
}
DebugSortedBug.java 文件源码 项目:skadi 阅读 20 收藏 0 点赞 0 评论 0
@Override
public void start(final Stage stage) throws Exception {

    for (int i = 0; i < NUM_ENTRIES; i++) {
        final TestEntry entry = new TestEntry("Entry" + i);
        entryList.add(entry);
        final EntryUpdateService updateService = new EntryUpdateService(entry);
        updateService.start();
    }

    final TableView<TestEntry> table = new TableView<>();
    table.setBorder(Border.EMPTY);
    table.setPadding(Insets.EMPTY);

    final TableColumn<TestEntry, TestEntry.EntryState> onlineColumn = new TableColumn<>("State");
    onlineColumn.setCellValueFactory(p -> p.getValue().onlineProperty());

    final TableColumn<TestEntry, String> nameColumn = new TableColumn<>("Name");
    nameColumn.setCellValueFactory(p -> p.getValue().nameProperty());

    table.getColumns().add(onlineColumn);
    table.getColumns().add(nameColumn);

    table.getSortOrder().add(onlineColumn);  // if commented out the bug disappears
    table.getSortOrder().add(nameColumn);

    final FilteredList<TestEntry> filteredList = entryList.filtered(c -> TestEntry.EntryState.ONLINE == c.getOnline());
    final SortedList<TestEntry> sortedList = new SortedList<>(filteredList);
    sortedList.comparatorProperty().bind(table.comparatorProperty());
    table.setItems(sortedList);

    final Scene scene = new Scene(table, 800, 600);
    stage.setScene(scene);
    stage.show();
}


问题


面经


文章

微信
公众号

扫码关注公众号