javafx.collections.transformation.SortedList Java Examples
The following examples show how to use
javafx.collections.transformation.SortedList.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventLogController.java From pmd-designer with BSD 2-Clause "Simplified" License | 6 votes |
/** * Binds the popup to the rest of the app. Necessarily performed after the initialization * of the controller (ie @FXML fields are non-null). All bindings must be revocable * with the returned subscription, that way no processing is done when the popup is not * shown. */ private Subscription bindPopupToThisController() { Subscription binding = valuesOf(eventLogTableView.getSelectionModel().selectedItemProperty()) .distinct() .subscribe(this::onExceptionSelectionChanges); // reset error nodes on closing binding = binding.and(() -> selectedErrorNodes.setValue(Collections.emptyList())); SortedList<LogEntry> logEntries = new SortedList<>(getLogger().getLog(), Comparator.reverseOrder()); eventLogTableView.itemsProperty().setValue(logEntries); binding = binding.and( () -> eventLogTableView.itemsProperty().setValue(FXCollections.emptyObservableList()) ); myPopupStage.titleProperty().bind(this.titleProperty()); binding = binding.and( () -> myPopupStage.titleProperty().unbind() ); return binding; }
Example #2
Source File: ActivityController.java From PeerWasp with MIT License | 6 votes |
/** * 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(); } }); }
Example #3
Source File: CollatedTreeItem.java From marathonv5 with Apache License 2.0 | 6 votes |
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()); } } }); }
Example #4
Source File: TableVisualisation.java From constellation with Apache License 2.0 | 6 votes |
public void populateTable(final List<C> items) { final ObservableList<C> tableData = FXCollections.observableArrayList(items); final FilteredList<C> filteredData = new FilteredList<>(tableData, predicate -> true); filteredData.addListener((Change<? extends C> change) -> table.refresh()); tableFilter.textProperty().addListener((observable, oldValue, newValue) -> { filteredData.setPredicate(item -> { if (newValue == null || newValue.isEmpty()) { return true; } final String lowerCaseFilter = newValue.toLowerCase(); return item.getIdentifier().toLowerCase().contains(lowerCaseFilter); }); }); final SortedList<C> sortedData = new SortedList<>(filteredData); sortedData.comparatorProperty().bind(table.comparatorProperty()); table.setItems(sortedData); }
Example #5
Source File: BoardPresenter.java From Game2048FX with GNU General Public License v3.0 | 5 votes |
private void updateList() { AppBar appBar = getApp().getAppBar(); appBar.setProgress(-1); appBar.setProgressBarVisible(true); scores = cloud.updateLeaderboard(); scores.addListener((ListChangeListener.Change<? extends Score> c) -> { while (c.next()) { if (c.wasAdded() && ! c.getAddedSubList().isEmpty()) { Platform.runLater(() -> scoreBoardDay.getSelectionModel().select(c.getAddedSubList().get(0))); } } }); if (scores.isInitialized()) { scoreBoardDay.setItems(new SortedList<>(scores, COMPARATOR)); appBar.setProgress(1); appBar.setProgressBarVisible(false); } else { scores.initializedProperty().addListener(new InvalidationListener() { @Override public void invalidated(Observable observable) { if (scores.isInitialized()) { scoreBoardDay.setItems(new SortedList<>(scores, COMPARATOR)); appBar.setProgress(1); appBar.setProgressBarVisible(false); scores.initializedProperty().removeListener(this); } } }); } }
Example #6
Source File: DbgTraceView.java From erlyberly with GNU General Public License v3.0 | 5 votes |
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); }
Example #7
Source File: DbgView.java From erlyberly with GNU General Public License v3.0 | 5 votes |
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); }
Example #8
Source File: SpreadView.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void activate() { sortedList = new SortedList<>(model.spreadItems); sortedList.comparatorProperty().bind(tableView.comparatorProperty()); tableView.setItems(sortedList); sortedList.addListener(itemListChangeListener); updateHeaders(); }
Example #9
Source File: ProposalResultsWindow.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
public void show(EvaluatedProposal evaluatedProposal, Ballot ballot, boolean isVoteIncludedInResult, SortedList<VoteListItem> sortedVotes) { this.isVoteIncludedInResult = isVoteIncludedInResult; this.sortedVotes = sortedVotes; rowIndex = 0; width = 1000; createTabPane(); createGridPane(); addContent(evaluatedProposal, ballot); display(); }
Example #10
Source File: FailedTradesView.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void activate() { scene = root.getScene(); if (scene != null) { scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEventEventHandler); } sortedList = new SortedList<>(model.getList()); sortedList.comparatorProperty().bind(tableView.comparatorProperty()); tableView.setItems(sortedList); }
Example #11
Source File: LibraryFeaturePanelSkin.java From phoenicis with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override public ObjectExpression<SidebarBase<?, ?, ?>> createSidebar() { final SortedList<ShortcutCategoryDTO> sortedCategories = getControl().getCategories() .sorted(Comparator.comparing(ShortcutCategoryDTO::getName)); final LibrarySidebar sidebar = new LibrarySidebar(getControl().getFilter(), sortedCategories, this.selectedListWidget); sidebar.applicationNameProperty().bind(getControl().applicationNameProperty()); sidebar.setOnCreateShortcut(() -> { // deselect the currently selected shortcut getControl().setSelectedShortcut(null); // open the shortcut creation details panel getControl().setOpenedDetailsPanel(new ShortcutCreation()); }); sidebar.setOnOpenConsole(getControl()::openConsole); // set the default selection sidebar.setSelectedListWidget(Optional .ofNullable(getControl().getJavaFxSettingsManager()) .map(JavaFxSettingsManager::getLibraryListType) .orElse(ListWidgetType.ICONS_LIST)); // save changes to the list widget selection to the hard drive sidebar.selectedListWidgetProperty().addListener((observable, oldValue, newValue) -> { final JavaFxSettingsManager javaFxSettingsManager = getControl().getJavaFxSettingsManager(); if (newValue != null) { javaFxSettingsManager.setLibraryListType(newValue); javaFxSettingsManager.save(); } }); return new SimpleObjectProperty<>(sidebar); }
Example #12
Source File: ContainersFeaturePanelSkin.java From phoenicis with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override public ObjectExpression<SidebarBase<?, ?, ?>> createSidebar() { /* * initialize the container categories by sorting them */ final SortedList<ContainerCategoryDTO> sortedCategories = getControl().getCategories() .sorted(Comparator.comparing(ContainerCategoryDTO::getName)); final ContainerSidebar sidebar = new ContainerSidebar(getControl().getFilter(), sortedCategories, this.selectedListWidget); // set the default selection sidebar.setSelectedListWidget(Optional .ofNullable(getControl().getJavaFxSettingsManager()) .map(JavaFxSettingsManager::getContainersListType) .orElse(ListWidgetType.ICONS_LIST)); // save changes to the list widget selection to the hard drive sidebar.selectedListWidgetProperty().addListener((observable, oldValue, newValue) -> { final JavaFxSettingsManager javaFxSettingsManager = getControl().getJavaFxSettingsManager(); if (newValue != null) { javaFxSettingsManager.setContainersListType(newValue); javaFxSettingsManager.save(); } }); return new SimpleObjectProperty<>(sidebar); }
Example #13
Source File: InstallationsFeaturePanelSkin.java From phoenicis with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override public ObjectExpression<SidebarBase<?, ?, ?>> createSidebar() { final SortedList<InstallationCategoryDTO> sortedCategories = getControl().getInstallationCategories() .sorted(Comparator.comparing(InstallationCategoryDTO::getName)); final InstallationSidebar sidebar = new InstallationSidebar(getControl().getFilter(), sortedCategories, this.selectedListWidget); // set the default selection sidebar.setSelectedListWidget(Optional .ofNullable(getControl().getJavaFxSettingsManager()) .map(JavaFxSettingsManager::getInstallationsListType) .orElse(ListWidgetType.ICONS_LIST)); // save changes to the list widget selection to the hard drive sidebar.selectedListWidgetProperty().addListener((observable, oldValue, newValue) -> { final JavaFxSettingsManager javaFxSettingsManager = getControl().getJavaFxSettingsManager(); if (newValue != null) { javaFxSettingsManager.setInstallationsListType(newValue); javaFxSettingsManager.save(); } }); return new SimpleObjectProperty<>(sidebar); }
Example #14
Source File: ToolsController.java From Noexes with GNU General Public License v3.0 | 5 votes |
@FXML public void initialize() { memoryInfoList = FXCollections.observableArrayList(); for (TableColumn c : memInfoTable.getColumns()) { c.setReorderable(false); } memInfoTable.setItems(new SortedList<>(memoryInfoList, (info1, info2) -> { long addr1 = info1.getAddr(); long addr2 = info2.getAddr(); if (addr1 < addr2) { return -1; } if (addr1 > addr2) { return 1; } return 0; })); memInfoName.setCellValueFactory(param -> param.getValue().nameProperty()); memInfoAddr.setCellValueFactory(param -> param.getValue().addrProperty()); memInfoSize.setCellValueFactory(param -> param.getValue().sizeProperty()); memInfoType.setCellValueFactory(param -> param.getValue().typeProperty()); memInfoPerm.setCellValueFactory(param -> param.getValue().accessProperty()); memInfoAddr.setCellFactory(param -> new FormattedTableCell<>(addr -> HexUtils.formatAddress(addr.longValue()))); memInfoSize.setCellFactory(param -> new FormattedTableCell<>(size -> HexUtils.formatSize(size.longValue()))); memInfoPerm.setCellFactory(param -> new FormattedTableCell<>(access -> HexUtils.formatAccess(access.intValue()))); pidList.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { if (newValue == null) { return; } displayTitleId(mc.getDebugger().getTitleId(newValue)); }); MemoryInfoContextMenu cm = new MemoryInfoContextMenu(() -> mc, memInfoTable); memInfoTable.contextMenuProperty().setValue(cm); }
Example #15
Source File: PersonsController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
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); }
Example #16
Source File: OpenOffersView.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
@Override protected void activate() { sortedList = new SortedList<>(model.getList()); sortedList.comparatorProperty().bind(tableView.comparatorProperty()); tableView.setItems(sortedList); }
Example #17
Source File: LibraryController.java From houdoku with MIT License | 4 votes |
/** * Populates the tableView and treeView with series from the library. * * <p>This function should be run whenever there is a possibility that a series has been added * or removed from the library. It does not need to be run whenever the properties of a series * changes, since the cell factories will handle that properly with just tableView.refresh(). */ public void updateContent() { // Use filterTextField to filter series in table by title // Filter code/method derived from // http://code.makery.ch/blog/javafx-8-tableview-sorting-filtering // with minor changes. // 1. Wrap the ObservableList in a FilteredList (initially display all data). // 2. Set the filter Predicate whenever the filter changes. // 3. Wrap the FilteredList in a SortedList. // 4. Bind the SortedList comparator to the TableView comparator. // 5. Add sorted (and filtered) data to the table. ObservableList<Series> master_data = FXCollections.observableArrayList(library.getSerieses()); FilteredList<Series> filtered_data = new FilteredList<>(master_data, p -> true); setCombinedPredicate(filtered_data); SortedList<Series> sorted_data = new SortedList<>(filtered_data); sorted_data.setComparator((s1, s2) -> s1.getTitle().compareToIgnoreCase(s2.getTitle())); tableView.setItems(sorted_data); int num_columns = (int) columnNumSlider.getValue(); // update gridPane when FX app thread is available Platform.runLater(() -> { flowPane.getChildren().clear(); for (Series series : sorted_data) { ImageView cover = new ImageView(); cover.setImage(series.getCover()); // determine the number of unread chapters for displaying badge on cover Config config = sceneManager.getConfig(); boolean lang_filter_enabled = (boolean) config.getValue(Config.Field.LANGUAGE_FILTER_ENABLED); int unread_chapters = lang_filter_enabled ? series.getNumUnreadChapters(Languages.get( (String) config.getValue(Config.Field.LANGUAGE_FILTER_LANGUAGE))) : series.getNumUnreadChapters(); // create the result container StackPane result_pane = LayoutHelpers.createCoverContainer(flowPane, series.getTitle(), cover, unread_chapters); result_pane.prefWidthProperty().bind( flowPane.widthProperty().divide(num_columns).subtract(flowPane.getHgap())); // create buttons shown on hover VBox button_container = new VBox(); button_container.setAlignment(Pos.CENTER); button_container.setSpacing(3); Button view_button = new Button("View series"); Button edit_button = new Button("Edit categories"); Button remove_button = new Button("Remove series"); StackPane.setAlignment(button_container, Pos.CENTER); view_button.setOnAction(event -> goToSeries(series)); edit_button.setOnAction(event -> promptEditCategories(series)); remove_button.setOnAction(event -> promptRemoveSeries(series)); button_container.getChildren().addAll(view_button, edit_button, remove_button); result_pane.getChildren().add(button_container); result_pane.setOnMouseClicked(newCoverClickHandler(series)); // hide all buttons by default LayoutHelpers.setChildButtonVisible(result_pane, false); flowPane.getChildren().add(result_pane); } }); // update occurrence listings in category tree library.calculateCategoryOccurrences(); treeView.refresh(); }
Example #18
Source File: AlarmTableUI.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private TableView<AlarmInfoRow> createTable(final ObservableList<AlarmInfoRow> rows, final boolean active) { final SortedList<AlarmInfoRow> sorted = new SortedList<>(rows); final TableView<AlarmInfoRow> table = new TableView<>(sorted); // Ensure that the sorted rows are always updated as the column sorting // of the TableView is changed by the user clicking on table headers. sorted.comparatorProperty().bind(table.comparatorProperty()); TableColumn<AlarmInfoRow, SeverityLevel> sevcol = new TableColumn<>(/* Icon */); sevcol.setPrefWidth(25); sevcol.setReorderable(false); sevcol.setResizable(false); sevcol.setCellValueFactory(cell -> cell.getValue().severity); sevcol.setCellFactory(c -> new SeverityIconCell()); table.getColumns().add(sevcol); final TableColumn<AlarmInfoRow, String> pv_col = new TableColumn<>("PV"); pv_col.setPrefWidth(240); pv_col.setReorderable(false); pv_col.setCellValueFactory(cell -> cell.getValue().pv); pv_col.setCellFactory(c -> new DragPVCell()); pv_col.setComparator(CompareNatural.INSTANCE); table.getColumns().add(pv_col); TableColumn<AlarmInfoRow, String> col = new TableColumn<>("Description"); col.setPrefWidth(400); col.setReorderable(false); col.setCellValueFactory(cell -> cell.getValue().description); col.setCellFactory(c -> new DragPVCell()); col.setComparator(CompareNatural.INSTANCE); table.getColumns().add(col); sevcol = new TableColumn<>("Alarm Severity"); sevcol.setPrefWidth(130); sevcol.setReorderable(false); sevcol.setCellValueFactory(cell -> cell.getValue().severity); sevcol.setCellFactory(c -> new SeverityLevelCell()); table.getColumns().add(sevcol); col = new TableColumn<>("Alarm Status"); col.setPrefWidth(130); col.setReorderable(false); col.setCellValueFactory(cell -> cell.getValue().status); col.setCellFactory(c -> new DragPVCell()); table.getColumns().add(col); TableColumn<AlarmInfoRow, Instant> timecol = new TableColumn<>("Alarm Time"); timecol.setPrefWidth(200); timecol.setReorderable(false); timecol.setCellValueFactory(cell -> cell.getValue().time); timecol.setCellFactory(c -> new TimeCell()); table.getColumns().add(timecol); col = new TableColumn<>("Alarm Value"); col.setPrefWidth(100); col.setReorderable(false); col.setCellValueFactory(cell -> cell.getValue().value); col.setCellFactory(c -> new DragPVCell()); table.getColumns().add(col); sevcol = new TableColumn<>("PV Severity"); sevcol.setPrefWidth(130); sevcol.setReorderable(false); sevcol.setCellValueFactory(cell -> cell.getValue().pv_severity); sevcol.setCellFactory(c -> new SeverityLevelCell()); table.getColumns().add(sevcol); col = new TableColumn<>("PV Status"); col.setPrefWidth(130); col.setReorderable(false); col.setCellValueFactory(cell -> cell.getValue().pv_status); col.setCellFactory(c -> new DragPVCell()); table.getColumns().add(col); // Initially, sort on PV name // - restore(Memento) might change that table.getSortOrder().setAll(List.of(pv_col)); pv_col.setSortType(SortType.ASCENDING); table.setPlaceholder(new Label(active ? "No active alarms" : "No acknowledged alarms")); table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); createContextMenu(table, active); // Double-click to acknowledge or un-acknowledge table.setRowFactory(tv -> { final TableRow<AlarmInfoRow> row = new TableRow<>(); row.setOnMouseClicked(event -> { if (event.getClickCount() == 2 && !row.isEmpty()) JobManager.schedule("ack", monitor -> client.acknowledge(row.getItem().item, active)); }); return row; }); return table; }
Example #19
Source File: OfferBookViewModel.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
SortedList<OfferBookListItem> getOfferList() { return sortedItems; }
Example #20
Source File: OfferBookViewModel.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
@Inject public OfferBookViewModel(User user, OpenOfferManager openOfferManager, OfferBook offerBook, Preferences preferences, P2PService p2PService, PriceFeedService priceFeedService, ClosedTradableManager closedTradableManager, FilterManager filterManager, AccountAgeWitnessService accountAgeWitnessService, Navigation navigation, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter, BsqFormatter bsqFormatter) { 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.accountAgeWitnessService = accountAgeWitnessService; this.navigation = navigation; this.btcFormatter = btcFormatter; this.bsqFormatter = bsqFormatter; this.filteredItems = new FilteredList<>(offerBook.getOfferBookListItems()); this.sortedItems = new SortedList<>(filteredItems); tradeCurrencyListChangeListener = c -> { fillAllTradeCurrencies(); }; filterItemsListener = c -> { final Optional<OfferBookListItem> highestAmountOffer = filteredItems.stream() .max(Comparator.comparingLong(o -> o.getOffer().getAmount().getValue())); final boolean containsRangeAmount = filteredItems.stream().anyMatch(o -> o.getOffer().isRange()); if (highestAmountOffer.isPresent()) { final OfferBookListItem item = highestAmountOffer.get(); if (!item.getOffer().isRange() && containsRangeAmount) { maxPlacesForAmount.set(formatAmount(item.getOffer(), false) .length() * 2 + FormattingUtils.RANGE_SEPARATOR.length()); maxPlacesForVolume.set(formatVolume(item.getOffer(), false) .length() * 2 + FormattingUtils.RANGE_SEPARATOR.length()); } else { maxPlacesForAmount.set(formatAmount(item.getOffer(), false).length()); maxPlacesForVolume.set(formatVolume(item.getOffer(), false).length()); } } final Optional<OfferBookListItem> highestPriceOffer = filteredItems.stream() .filter(o -> o.getOffer().getPrice() != null) .max(Comparator.comparingLong(o -> o.getOffer().getPrice() != null ? o.getOffer().getPrice().getValue() : 0)); highestPriceOffer.ifPresent(offerBookListItem -> maxPlacesForPrice.set(formatPrice(offerBookListItem.getOffer(), false).length())); final Optional<OfferBookListItem> highestMarketPriceMarginOffer = filteredItems.stream() .filter(o -> o.getOffer().isUseMarketBasedPrice()) .max(Comparator.comparing(o -> new DecimalFormat("#0.00").format(o.getOffer().getMarketPriceMargin() * 100).length())); highestMarketPriceMarginOffer.ifPresent(offerBookListItem -> maxPlacesForMarketPriceMargin.set(formatMarketPriceMargin(offerBookListItem.getOffer(), false).length())); }; }
Example #21
Source File: ReplayStage.java From xframium-java with GNU General Public License v3.0 | 4 votes |
public ReplayStage (Session session, Path path, Preferences prefs, Screen screen) { this.prefs = prefs; final Label label = session.getHeaderLabel (); label.setFont (new Font ("Arial", 20)); label.setPadding (new Insets (10, 10, 10, 10)); // trbl boolean showTelnet = prefs.getBoolean ("ShowTelnet", false); boolean showExtended = prefs.getBoolean ("ShowExtended", false); final HBox checkBoxes = new HBox (); checkBoxes.setSpacing (15); checkBoxes.setPadding (new Insets (10, 10, 10, 10)); // trbl checkBoxes.getChildren ().addAll (showTelnetCB, show3270ECB); SessionTable sessionTable = new SessionTable (); CommandPane commandPane = new CommandPane (sessionTable, CommandPane.ProcessInstruction.DoProcess); // commandPane.setScreen (session.getScreen ()); commandPane.setScreen (screen); setTitle ("Replay Commands - " + path.getFileName ()); ObservableList<SessionRecord> masterData = session.getDataRecords (); FilteredList<SessionRecord> filteredData = new FilteredList<> (masterData, p -> true); ChangeListener<? super Boolean> changeListener = (observable, oldValue, newValue) -> change (sessionTable, filteredData); showTelnetCB.selectedProperty ().addListener (changeListener); show3270ECB.selectedProperty ().addListener (changeListener); if (true) // this sucks - remove it when java works properly { showTelnetCB.setSelected (true); // must be a bug show3270ECB.setSelected (true); } showTelnetCB.setSelected (showTelnet); show3270ECB.setSelected (showExtended); SortedList<SessionRecord> sortedData = new SortedList<> (filteredData); sortedData.comparatorProperty ().bind (sessionTable.comparatorProperty ()); sessionTable.setItems (sortedData); displayFirstScreen (session, sessionTable); setOnCloseRequest (e -> Platform.exit ()); windowSaver = new WindowSaver (prefs, this, "Replay"); if (!windowSaver.restoreWindow ()) { primaryScreenBounds = javafx.stage.Screen.getPrimary ().getVisualBounds (); setX (800); setY (primaryScreenBounds.getMinY ()); double height = primaryScreenBounds.getHeight (); setHeight (Math.min (height, 1200)); } BorderPane borderPane = new BorderPane (); borderPane.setLeft (sessionTable); // fixed size borderPane.setCenter (commandPane); // expands to fill window borderPane.setTop (label); borderPane.setBottom (checkBoxes); Scene scene = new Scene (borderPane); setScene (scene); }
Example #22
Source File: TradesChartsView.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
@Override protected void activate() { // root.getParent() is null at initialize tabPaneSelectionModel = GUIUtil.getParentOfType(root, JFXTabPane.class).getSelectionModel(); selectedTabIndexListener = (observable, oldValue, newValue) -> model.setSelectedTabIndex((int) newValue); model.setSelectedTabIndex(tabPaneSelectionModel.getSelectedIndex()); tabPaneSelectionModel.selectedIndexProperty().addListener(selectedTabIndexListener); currencyComboBox.setConverter(new CurrencyStringConverter(currencyComboBox)); currencyComboBox.getEditor().getStyleClass().add("combo-box-editor-bold"); currencyComboBox.setAutocompleteItems(model.getCurrencyListItems()); currencyComboBox.setVisibleRowCount(10); if (model.showAllTradeCurrenciesProperty.get()) currencyComboBox.getSelectionModel().select(SHOW_ALL); else if (model.getSelectedCurrencyListItem().isPresent()) currencyComboBox.getSelectionModel().select(model.getSelectedCurrencyListItem().get()); currencyComboBox.getEditor().setText(new CurrencyStringConverter(currencyComboBox).toString(currencyComboBox.getSelectionModel().getSelectedItem())); currencyComboBox.setOnChangeConfirmed(e -> { if (currencyComboBox.getEditor().getText().isEmpty()) currencyComboBox.getSelectionModel().select(SHOW_ALL); CurrencyListItem selectedItem = currencyComboBox.getSelectionModel().getSelectedItem(); if (selectedItem != null) model.onSetTradeCurrency(selectedItem.tradeCurrency); }); toggleGroup.getToggles().get(model.tickUnit.ordinal()).setSelected(true); model.priceItems.addListener(itemsChangeListener); toggleGroup.selectedToggleProperty().addListener(timeUnitChangeListener); priceAxisY.widthProperty().addListener(priceAxisYWidthListener); volumeAxisY.widthProperty().addListener(volumeAxisYWidthListener); model.tradeStatisticsByCurrency.addListener(tradeStatisticsByCurrencyListener); priceAxisY.labelProperty().bind(priceColumnLabel); priceColumnLabel.addListener(priceColumnLabelListener); currencySelectionBinding = EasyBind.combine( model.showAllTradeCurrenciesProperty, model.selectedTradeCurrencyProperty, (showAll, selectedTradeCurrency) -> { priceChart.setVisible(!showAll); priceChart.setManaged(!showAll); priceColumn.setSortable(!showAll); if (showAll) { volumeColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.amount"))); priceColumnLabel.set(Res.get("shared.price")); if (!tableView.getColumns().contains(marketColumn)) tableView.getColumns().add(1, marketColumn); volumeChart.setPrefHeight(volumeChart.getMaxHeight()); } else { volumeChart.setPrefHeight(volumeChart.getMinHeight()); priceSeries.setName(selectedTradeCurrency.getName()); String code = selectedTradeCurrency.getCode(); volumeColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.amountWithCur", code))); priceColumnLabel.set(CurrencyUtil.getPriceWithCurrencyCode(code)); tableView.getColumns().remove(marketColumn); } layout(); return null; }); currencySelectionSubscriber = currencySelectionBinding.subscribe((observable, oldValue, newValue) -> {}); sortedList = new SortedList<>(model.tradeStatisticsByCurrency); sortedList.comparatorProperty().bind(tableView.comparatorProperty()); tableView.setItems(sortedList); priceChart.setAnimated(model.preferences.isUseAnimations()); volumeChart.setAnimated(model.preferences.isUseAnimations()); priceAxisX.setTickLabelFormatter(getTimeAxisStringConverter()); volumeAxisX.setTickLabelFormatter(getTimeAxisStringConverter()); nrOfTradeStatisticsLabel.setText(Res.get("market.trades.nrOfTrades", model.tradeStatisticsByCurrency.size())); UserThread.runAfter(this::updateChartData, 100, TimeUnit.MILLISECONDS); if (root.getParent() instanceof Pane) { rootParent = (Pane) root.getParent(); rootParent.heightProperty().addListener(parentHeightListener); } layout(); }
Example #23
Source File: ObservableListDecorator.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
SortedList<T> asSortedList() { return new SortedList<>(delegate); }
Example #24
Source File: ConsoleMessageTab.java From xframium-java with GNU General Public License v3.0 | 4 votes |
public ConsoleMessageTab () { super ("Filters"); setClosable (false); consoleMessageTable.getSelectionModel ().selectedItemProperty () .addListener ( (obs, oldSelection, newSelection) -> select (newSelection)); HBox box = new HBox (10); // spacing box.setPadding (new Insets (10, 10, 10, 10)); // trbl box.setAlignment (Pos.CENTER_LEFT); Label lblTime = new Label ("Time"); Label lblSubsytem = new Label ("Task"); Label lblMessageCode = new Label ("Code"); Label lblMessageText = new Label ("Text"); box.getChildren ().addAll (lblTime, txtTime, lblSubsytem, txtTask, lblMessageCode, txtMessageCode, lblMessageText, txtMessageText); BorderPane borderPane = new BorderPane (); borderPane.setTop (box); borderPane.setCenter (consoleMessageTable); setContent (borderPane); FilteredList<ConsoleMessage> filteredData = new FilteredList<> (consoleMessageTable.messages, m -> true); SortedList<ConsoleMessage> sortedData = new SortedList<> (filteredData); sortedData.comparatorProperty ().bind (consoleMessageTable.comparatorProperty ()); consoleMessageTable.setItems (sortedData); txtTime.textProperty () .addListener ( (observable, oldValue, newValue) -> setFilter (filteredData)); txtTask.textProperty () .addListener ( (observable, oldValue, newValue) -> setFilter (filteredData)); txtMessageCode.textProperty () .addListener ( (observable, oldValue, newValue) -> setFilter (filteredData)); txtMessageText.textProperty () .addListener ( (observable, oldValue, newValue) -> setFilter (filteredData)); }
Example #25
Source File: VoteResultView.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
private void showProposalResultWindow(EvaluatedProposal evaluatedProposal, Ballot ballot, boolean isVoteIncludedInResult, SortedList<VoteListItem> sortedVoteListItemList) { proposalResultsWindow.show(evaluatedProposal, ballot, isVoteIncludedInResult, sortedVoteListItemList); }
Example #26
Source File: ObservableMapValues.java From SmartModInserter with GNU Lesser General Public License v3.0 | 4 votes |
@Override public SortedList<T> sorted(Comparator<T> comparator) { return internalStore.sorted(comparator); }
Example #27
Source File: ConsoleMessageTab.java From dm3270 with Apache License 2.0 | 4 votes |
public ConsoleMessageTab () { super ("Filters"); setClosable (false); consoleMessageTable.getSelectionModel ().selectedItemProperty () .addListener ( (obs, oldSelection, newSelection) -> select (newSelection)); HBox box = new HBox (10); // spacing box.setPadding (new Insets (10, 10, 10, 10)); // trbl box.setAlignment (Pos.CENTER_LEFT); Label lblTime = new Label ("Time"); Label lblSubsytem = new Label ("Task"); Label lblMessageCode = new Label ("Code"); Label lblMessageText = new Label ("Text"); box.getChildren ().addAll (lblTime, txtTime, lblSubsytem, txtTask, lblMessageCode, txtMessageCode, lblMessageText, txtMessageText); BorderPane borderPane = new BorderPane (); borderPane.setTop (box); borderPane.setCenter (consoleMessageTable); setContent (borderPane); FilteredList<ConsoleMessage> filteredData = new FilteredList<> (consoleMessageTable.messages, m -> true); SortedList<ConsoleMessage> sortedData = new SortedList<> (filteredData); sortedData.comparatorProperty ().bind (consoleMessageTable.comparatorProperty ()); consoleMessageTable.setItems (sortedData); txtTime.textProperty () .addListener ( (observable, oldValue, newValue) -> setFilter (filteredData)); txtTask.textProperty () .addListener ( (observable, oldValue, newValue) -> setFilter (filteredData)); txtMessageCode.textProperty () .addListener ( (observable, oldValue, newValue) -> setFilter (filteredData)); txtMessageText.textProperty () .addListener ( (observable, oldValue, newValue) -> setFilter (filteredData)); }
Example #28
Source File: PendingTradesView.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
@Override protected void activate() { sortedList = new SortedList<>(model.dataModel.list); sortedList.comparatorProperty().bind(tableView.comparatorProperty()); tableView.setItems(sortedList); scene = root.getScene(); if (scene != null) { scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEventEventHandler); //TODO: in what cases is it necessary to request focus? /*appFocusSubscription = EasyBind.subscribe(scene.getWindow().focusedProperty(), isFocused -> { if (isFocused && model.dataModel.selectedItemProperty.get() != null) { // Focus selectedItem from model int index = table.getItems().indexOf(model.dataModel.selectedItemProperty.get()); UserThread.execute(() -> { //TODO app wide focus //table.requestFocus(); //UserThread.execute(() -> table.getFocusModel().focus(index)); }); } });*/ } selectedItemSubscription = EasyBind.subscribe(model.dataModel.selectedItemProperty, selectedItem -> { if (selectedItem != null) { if (selectedSubView != null) selectedSubView.deactivate(); if (selectedItem.getTrade() != null) { selectedSubView = model.dataModel.tradeManager.isBuyer(model.dataModel.getOffer()) ? new BuyerSubView(model) : new SellerSubView(model); selectedSubView.setMinHeight(440); VBox.setVgrow(selectedSubView, Priority.ALWAYS); if (root.getChildren().size() == 1) root.getChildren().add(selectedSubView); else if (root.getChildren().size() == 2) root.getChildren().set(1, selectedSubView); // create and register a callback so we can be notified when the subview // wants to open the chat window ChatCallback chatCallback = this::openChat; selectedSubView.setChatCallback(chatCallback); } updateTableSelection(); } else { removeSelectedSubView(); } model.onSelectedItemChanged(selectedItem); if (selectedSubView != null && selectedItem != null) selectedSubView.activate(); }); selectedTableItemSubscription = EasyBind.subscribe(tableView.getSelectionModel().selectedItemProperty(), selectedItem -> { if (selectedItem != null && !selectedItem.equals(model.dataModel.selectedItemProperty.get())) model.dataModel.onSelectItem(selectedItem); }); updateTableSelection(); model.dataModel.list.addListener(tradesListChangeListener); updateNewChatMessagesByTradeMap(); }
Example #29
Source File: RequireNdockController.java From logbook-kai with MIT License | 4 votes |
@FXML void initialize() { TableTool.setVisible(this.table, this.getClass().toString() + "#" + "table"); // カラムとオブジェクトのバインド this.row.setCellFactory(e -> { TableCell<RequireNdock, Integer> cell = new TableCell<RequireNdock, Integer>() { @Override protected void updateItem(Integer item, boolean empty) { super.updateItem(item, empty); if (!empty) { TableRow<?> currentRow = this.getTableRow(); this.setText(Integer.toString(currentRow.getIndex() + 1)); } else { this.setText(null); } } }; return cell; }); this.deck.setCellValueFactory(new PropertyValueFactory<>("deck")); this.ship.setCellValueFactory(new PropertyValueFactory<>("ship")); this.ship.setCellFactory(p -> new ShipImageCell()); this.lv.setCellValueFactory(new PropertyValueFactory<>("lv")); this.time.setCellValueFactory(new PropertyValueFactory<>("time")); this.time.setCellFactory(p -> new TimeCell()); this.end.setCellValueFactory(new PropertyValueFactory<>("end")); this.fuel.setCellValueFactory(new PropertyValueFactory<>("fuel")); this.metal.setCellValueFactory(new PropertyValueFactory<>("metal")); SortedList<RequireNdock> sortedList = new SortedList<>(this.ndocks); this.table.setItems(sortedList); sortedList.comparatorProperty().bind(this.table.comparatorProperty()); this.table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); this.table.setOnKeyPressed(TableTool::defaultOnKeyPressedHandler); this.timeline = new Timeline(); this.timeline.setCycleCount(Timeline.INDEFINITE); this.timeline.getKeyFrames().add(new KeyFrame( javafx.util.Duration.seconds(1), this::update)); this.timeline.play(); this.update(null); }
Example #30
Source File: MissionLogController.java From logbook-kai with MIT License | 4 votes |
@FXML void initialize() { TableTool.setVisible(this.detail, this.getClass() + "#" + "detail"); TableTool.setVisible(this.aggregate, this.getClass() + "#" + "aggregate"); // SplitPaneの分割サイズ Timeline x = new Timeline(); x.getKeyFrames().add(new KeyFrame(Duration.millis(1), (e) -> { Tools.Conrtols.setSplitWidth(this.splitPane1, this.getClass() + "#" + "splitPane1"); Tools.Conrtols.setSplitWidth(this.splitPane2, this.getClass() + "#" + "splitPane2"); Tools.Conrtols.setSplitWidth(this.splitPane3, this.getClass() + "#" + "splitPane3"); })); x.play(); // 集計 this.collect.setShowRoot(false); this.collect.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); this.unit.setCellValueFactory(new TreeItemPropertyValueFactory<>("unit")); this.successGood.setCellValueFactory(new TreeItemPropertyValueFactory<>("successGood")); this.success.setCellValueFactory(new TreeItemPropertyValueFactory<>("success")); this.fail.setCellValueFactory(new TreeItemPropertyValueFactory<>("fail")); // 詳細 SortedList<MissionLogDetail> sortedList = new SortedList<>(this.details); this.detail.setItems(this.details); sortedList.comparatorProperty().bind(this.detail.comparatorProperty()); this.detail.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); this.detail.setOnKeyPressed(TableTool::defaultOnKeyPressedHandler); this.date.setCellValueFactory(new PropertyValueFactory<>("date")); this.name.setCellValueFactory(new PropertyValueFactory<>("name")); this.result.setCellValueFactory(new PropertyValueFactory<>("result")); this.fuel.setCellValueFactory(new PropertyValueFactory<>("fuel")); this.ammo.setCellValueFactory(new PropertyValueFactory<>("ammo")); this.metal.setCellValueFactory(new PropertyValueFactory<>("metal")); this.bauxite.setCellValueFactory(new PropertyValueFactory<>("bauxite")); this.item1name.setCellValueFactory(new PropertyValueFactory<>("item1name")); this.item1count.setCellValueFactory(new PropertyValueFactory<>("item1count")); this.item2name.setCellValueFactory(new PropertyValueFactory<>("item2name")); this.item2count.setCellValueFactory(new PropertyValueFactory<>("item2count")); // 集計 SortedList<MissionAggregate> sortedList2 = new SortedList<>(this.aggregates); this.aggregate.setItems(this.aggregates); sortedList2.comparatorProperty().bind(this.aggregate.comparatorProperty()); this.aggregate.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); this.aggregate.setOnKeyPressed(TableTool::defaultOnKeyPressedHandler); this.resource.setCellValueFactory(new PropertyValueFactory<>("resource")); this.count.setCellValueFactory(new PropertyValueFactory<>("count")); this.average.setCellValueFactory(new PropertyValueFactory<>("average")); this.readLog(); this.setCollect(); // 選択された時のリスナーを設定 this.collect.getSelectionModel() .selectedItemProperty() .addListener(this::detail); this.aggregate.getSelectionModel() .selectedItemProperty() .addListener(this::chart); }