use of javafx.collections.transformation.FilteredList in project SmartCity-Market by TechnionYP5777.
the class CustomerMainScreen method initialize.
@Override
public void initialize(URL location, ResourceBundle __) {
AbstractApplicationScreen.fadeTransition(customerMainScreenPane);
barcodeEventHandler.register(this);
customer = TempCustomerPassingData.customer;
filteredProductList = new FilteredList<>(productsObservableList, s -> true);
searchField.textProperty().addListener(obs -> {
String filter = searchField.getText();
filteredProductList.setPredicate((filter == null || filter.length() == 0) ? s -> true : s -> s.getCatalogProduct().getName().contains(filter));
});
productsListView.setItems(filteredProductList);
productsListView.setCellFactory(new Callback<ListView<CartProduct>, ListCell<CartProduct>>() {
@Override
public ListCell<CartProduct> call(ListView<CartProduct> __) {
return new CustomerProductCellFormat();
}
});
productsListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<CartProduct>() {
@Override
public void changed(ObservableValue<? extends CartProduct> __, CartProduct oldValue, CartProduct newValue) {
updateProductInfoPaine(newValue.getCatalogProduct(), newValue.getTotalAmount(), ProductInfoPaneVisibleMode.PRESSED_PRODUCT);
}
});
productsListView.depthProperty().set(1);
productsListView.setExpanded(true);
setAbilityAndVisibilityOfProductInfoPane(false);
}
use of javafx.collections.transformation.FilteredList in project bitsquare by bitsquare.
the class TraderDisputeView method activate.
@Override
protected void activate() {
filterTextField.textProperty().addListener(filterTextFieldListener);
disputeManager.cleanupDisputes();
filteredList = new FilteredList<>(disputeManager.getDisputesAsObservableList());
applyFilteredListPredicate(filterTextField.getText());
sortedList = new SortedList<>(filteredList);
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
tableView.setItems(sortedList);
// sortedList.setComparator((o1, o2) -> o2.getOpeningDate().compareTo(o1.getOpeningDate()));
selectedDisputeSubscription = EasyBind.subscribe(tableView.getSelectionModel().selectedItemProperty(), this::onSelectDispute);
Dispute selectedItem = tableView.getSelectionModel().getSelectedItem();
if (selectedItem != null)
tableView.getSelectionModel().select(selectedItem);
scrollToBottom();
scene = root.getScene();
if (scene != null)
scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEventEventHandler);
// If doPrint=true we print out a html page which opens tabs with all deposit txs
// (firefox needs about:config change to allow > 20 tabs)
// Useful to check if there any funds in not finished trades (no payout tx done).
// Last check 10.02.2017 found 8 trades and we contacted all traders as far as possible (email if available
// otherwise in-app private notification)
boolean doPrint = false;
if (doPrint) {
try {
DateFormat formatter = new SimpleDateFormat("dd/MM/yy");
Date startDate = formatter.parse("10/02/17");
// print all from start
startDate = new Date(0);
HashMap<String, Dispute> map = new HashMap<>();
disputeManager.getDisputesAsObservableList().stream().forEach(dispute -> {
map.put(dispute.getDepositTxId(), dispute);
});
final Date finalStartDate = startDate;
List<Dispute> disputes = new ArrayList<>(map.values());
disputes.sort((o1, o2) -> o1.getOpeningDate().compareTo(o2.getOpeningDate()));
List<List<Dispute>> subLists = Lists.partition(disputes, 1000);
StringBuilder sb = new StringBuilder();
subLists.stream().forEach(list -> {
StringBuilder sb1 = new StringBuilder("\n<html><head><script type=\"text/javascript\">function load(){\n");
StringBuilder sb2 = new StringBuilder("\n}</script></head><body onload=\"load()\">\n");
list.stream().forEach(dispute -> {
if (dispute.getOpeningDate().after(finalStartDate)) {
String txId = dispute.getDepositTxId();
sb1.append("window.open(\"https://blockchain.info/tx/").append(txId).append("\", '_blank');\n");
sb2.append("Dispute ID: ").append(dispute.getId()).append(" Tx ID: ").append("<a href=\"https://blockchain.info/tx/").append(txId).append("\">").append(txId).append("</a> ").append("Opening date: ").append(formatter.format(dispute.getOpeningDate())).append("<br/>\n");
}
});
sb2.append("</body></html>");
String res = sb1.toString() + sb2.toString();
sb.append(res).append("\n\n\n");
});
log.info(sb.toString());
} catch (ParseException ignore) {
}
}
}
use of javafx.collections.transformation.FilteredList in project bisq-desktop by bisq-network.
the class TraderDisputeView method activate.
@Override
protected void activate() {
filterTextField.textProperty().addListener(filterTextFieldListener);
disputeManager.cleanupDisputes();
filteredList = new FilteredList<>(disputeManager.getDisputesAsObservableList());
applyFilteredListPredicate(filterTextField.getText());
sortedList = new SortedList<>(filteredList);
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
tableView.setItems(sortedList);
// sortedList.setComparator((o1, o2) -> o2.getOpeningDate().compareTo(o1.getOpeningDate()));
selectedDisputeSubscription = EasyBind.subscribe(tableView.getSelectionModel().selectedItemProperty(), this::onSelectDispute);
Dispute selectedItem = tableView.getSelectionModel().getSelectedItem();
if (selectedItem != null)
tableView.getSelectionModel().select(selectedItem);
scrollToBottom();
scene = root.getScene();
if (scene != null)
scene.addEventHandler(KeyEvent.KEY_RELEASED, keyEventEventHandler);
// If doPrint=true we print out a html page which opens tabs with all deposit txs
// (firefox needs about:config change to allow > 20 tabs)
// Useful to check if there any funds in not finished trades (no payout tx done).
// Last check 10.02.2017 found 8 trades and we contacted all traders as far as possible (email if available
// otherwise in-app private notification)
boolean doPrint = false;
// noinspection ConstantConditions
if (doPrint) {
try {
DateFormat formatter = new SimpleDateFormat("dd/MM/yy");
// noinspection UnusedAssignment
Date startDate = formatter.parse("10/02/17");
// print all from start
startDate = new Date(0);
HashMap<String, Dispute> map = new HashMap<>();
disputeManager.getDisputesAsObservableList().stream().forEach(dispute -> map.put(dispute.getDepositTxId(), dispute));
final Date finalStartDate = startDate;
List<Dispute> disputes = new ArrayList<>(map.values());
disputes.sort((o1, o2) -> o1.getOpeningDate().compareTo(o2.getOpeningDate()));
List<List<Dispute>> subLists = Lists.partition(disputes, 1000);
StringBuilder sb = new StringBuilder();
// We don't translate that as it is not intended for the public
subLists.stream().forEach(list -> {
StringBuilder sb1 = new StringBuilder("\n<html><head><script type=\"text/javascript\">function load(){\n");
StringBuilder sb2 = new StringBuilder("\n}</script></head><body onload=\"load()\">\n");
list.stream().forEach(dispute -> {
if (dispute.getOpeningDate().after(finalStartDate)) {
String txId = dispute.getDepositTxId();
sb1.append("window.open(\"https://blockchain.info/tx/").append(txId).append("\", '_blank');\n");
sb2.append("Dispute ID: ").append(dispute.getId()).append(" Tx ID: ").append("<a href=\"https://blockchain.info/tx/").append(txId).append("\">").append(txId).append("</a> ").append("Opening date: ").append(formatter.format(dispute.getOpeningDate())).append("<br/>\n");
}
});
sb2.append("</body></html>");
String res = sb1.toString() + sb2.toString();
sb.append(res).append("\n\n\n");
});
log.info(sb.toString());
} catch (ParseException ignore) {
}
}
GUIUtil.requestFocus(filterTextField);
}
use of javafx.collections.transformation.FilteredList in project dwoss by gg-net.
the class ProductListController method initialize.
/**
* Adding the filters to the combo box. Setting the cell values and the
* filtered list containing the data.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
tableView.getSelectionModel().setSelectionMode(MULTIPLE);
menuTradeName.getItems().addAll(FXCollections.observableArrayList(TradeName.values()));
menuProductGroup.getItems().addAll(ProductGroup.values());
tableView.setOnDragDetected((MouseEvent event) -> {
ArrayList<Product> selectedProducts = new ArrayList<>();
selectedProducts.addAll(tableView.getSelectionModel().getSelectedItems());
ArrayList<PicoProduct> selectedPicoProducts = new ArrayList<>();
if (selectedProducts.isEmpty())
return;
Dragboard db = tableView.startDragAndDrop(TransferMode.ANY);
ClipboardContent content = new ClipboardContent();
selectedPicoProducts.addAll(selectedProducts.stream().map(p -> new PicoProduct(p.getId(), p.getName())).collect(Collectors.toList()));
content.put(PICO_PRODUCT_DATA_FORMAT, selectedPicoProducts);
db.setContent(content);
event.consume();
});
setCellValues();
progressBar.progressProperty().bind(LOADING_TASK.progressProperty());
progressBar.visibleProperty().bind(LOADING_TASK.runningProperty());
filteredProducts = new FilteredList<>(LOADING_TASK.getPartialResults(), p -> true);
// filteredList does not allow sorting so it needs to be wrapped in a sortedList
SortedList<Product> sortedProducts = new SortedList<>(filteredProducts);
sortedProducts.comparatorProperty().bind(tableView.comparatorProperty());
tableView.setItems(sortedProducts);
editButton.disableProperty().bind(tableView.getSelectionModel().selectedItemProperty().isNull());
Ui.progress().observe(LOADING_TASK);
Ui.exec(LOADING_TASK);
}
use of javafx.collections.transformation.FilteredList in project POL-POM-5 by PhoenicisOrg.
the class LibraryFeaturePanelSkin method createCombinedListWidget.
private CombinedListWidget<ShortcutDTO> createCombinedListWidget() {
final FilteredList<ShortcutDTO> filteredShortcuts = ConcatenatedList.create(new MappedList<>(getControl().getCategories().sorted(Comparator.comparing(ShortcutCategoryDTO::getName)), ShortcutCategoryDTO::getShortcuts)).filtered(getControl().getFilter()::filter);
filteredShortcuts.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl().getFilter()::filter, getControl().getFilter().searchTermProperty(), getControl().getFilter().selectedShortcutCategoryProperty()));
final SortedList<ShortcutDTO> sortedShortcuts = filteredShortcuts.sorted(Comparator.comparing(shortcut -> shortcut.getInfo().getName()));
final ObservableList<ListWidgetElement<ShortcutDTO>> listWidgetEntries = new MappedList<>(sortedShortcuts, ListWidgetElement::create);
final CombinedListWidget<ShortcutDTO> combinedListWidget = new CombinedListWidget<>(listWidgetEntries, this.selectedListWidget);
// bind direction: controller property -> skin property
getControl().selectedShortcutProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
combinedListWidget.select(newValue);
} else {
combinedListWidget.deselect();
}
});
// bind direction: skin property -> controller properties
combinedListWidget.selectedElementProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
final ShortcutDTO selectedItem = newValue.getItem();
final MouseEvent event = newValue.getEvent();
getControl().setSelectedShortcut(selectedItem);
getControl().setOpenedDetailsPanel(new ShortcutInformation(selectedItem));
if (event.getClickCount() == 2) {
getControl().runShortcut(selectedItem);
}
} else {
getControl().setSelectedShortcut(null);
getControl().setOpenedDetailsPanel(new None());
}
});
return combinedListWidget;
}
Aggregations