List of usage examples for javafx.util StringConverter toString
public abstract String toString(T object);
From source file:cz.lbenda.gui.tableView.FilterMenuItem.java
/** Init menu item before is showed to user */ @SuppressWarnings("unchecked") public void beforeOpenInit() { StringConverter converter = filterableTableView.stringConverter(tableColumn); items.clear();//from w ww . j a v a 2 s. c om existingItemNames.clear(); filterableTableView.valuesForColumn(tableColumn).filter(value -> { if (value == null) { return existingItemNames.add(""); } return existingItemNames.add(converter.toString(value)); }).forEach(value -> { Item item = itemsMap.get(value); if (item != null) { items.add(item); } else { if (value == null) { item = new Item(null, true); } else { item = new Item(converter.toString(value), true); } items.add(item); itemsMap.put(value, item); } }); }
From source file:cz.lbenda.gui.tableView.FilterMenuItem.java
private void prepareOkCancelBar() { Button okButton = new Button(msgOK); okButton.setDefaultButton(true);/*from ww w .j a v a 2s . c om*/ Button cancelButton = new Button(msgCancel); cancelButton.setCancelButton(true); okCancelBar.getChildren().addAll(okButton, cancelButton); //noinspection unchecked final StringConverter converter = filterableTableView.stringConverter(tableColumn); okButton.setOnAction(event -> { if (filter != null) { filterableTableView.filters().remove(filter); } if (!isFilter()) { tableColumn.removeLeftIndicator(filterIndicator); } else { tableColumn.addLeftIndicator(filterIndicator); //noinspection unchecked filter = row -> { //noinspection unchecked Object value = filterableTableView.valueForColumn(row, tableColumn); String text; if (value == null) { text = ""; } else { //noinspection unchecked text = converter.toString(value); } return chosenItemNames.contains(text); }; //noinspection unchecked filterableTableView.filters().add(filter); } }); }
From source file:cz.lbenda.gui.tableView.FilterMenuItem.java
/** Prepare buttons to button bar */ private void prepareBars() { ToggleButton sortAsc = new ToggleButton(msgSortAsc, IconFactory.getInstance().imageView(this, ICON_SORT_ASC, IconFactory.IconLocation.LOCAL_TOOLBAR)); ToggleButton sortDsc = new ToggleButton(msgSortDsc, IconFactory.getInstance().imageView(this, ICON_SORT_DSC, IconFactory.IconLocation.LOCAL_TOOLBAR)); //noinspection unchecked final StringConverter converter = filterableTableView.stringConverter(tableColumn); comparatorAsc = (o1, o2) -> {//from www. j a v a 2 s . c om //noinspection unchecked Object value1 = filterableTableView.valueForColumn(o1, tableColumn); //noinspection unchecked Object value2 = filterableTableView.valueForColumn(o2, tableColumn); if (value1 == null) { if (value2 == null) { return 0; } else { return 1; } } else if (value2 == null) { return -1; } if (value1 instanceof Comparable) { //noinspection unchecked return ((Comparable) value1).compareTo(value2); } //noinspection unchecked return converter.toString(value1).compareTo(converter.toString(value2)); }; comparatorDsc = comparatorAsc.reversed(); sortToggleGroup.getToggles().addAll(sortAsc, sortDsc); sortAsc.setOnAction(event -> { Toggle tg = sortToggleGroup.getSelectedToggle(); if (tg == sortDsc) { //noinspection unchecked filterableTableView.sortProperty().setValue(comparatorDsc); } else if (tg == sortAsc) { //noinspection unchecked filterableTableView.sortProperty().setValue(comparatorAsc); } else { //noinspection unchecked filterableTableView.sortProperty().setValue(null); } }); sortDsc.setOnAction(sortAsc.getOnAction()); buttonBar.getChildren().addAll(sortAsc, sortDsc); }