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(); } } }); }
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()); } } }); }
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); }
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); }
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); }
@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); }
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; }
@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)); }
@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)); }
@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)); }
/** * 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(); } }); }
/** * 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); }
private void updateFilters() { LOG.trace("updateFilters()"); if (tableViewData == null) return; SortedList<DesignVariable> sortedList = getSortedFilteredDesignVariables(tableViewData); tableView.setItems(sortedList); sortedList.comparatorProperty().bind(tableView.comparatorProperty()); updateLabel(); }
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; })); }
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; }); }
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); }
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); }
@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(); }
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); } }
@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); } }
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())) ); }
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; }
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; }
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); }
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(); }
/** * 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); }
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); }
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(); }
@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(); }
@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)); }
@Override protected void activate() { sortedList = new SortedList<>(model.spreadItems); sortedList.comparatorProperty().bind(tableView.comparatorProperty()); tableView.setItems(sortedList); sortedList.addListener(itemListChangeListener); updateHeaders(); }
@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(); }; }
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()); }); }
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(); }
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(); }
@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); }
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); }
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); }
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); }
@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(); }