Search in sources :

Example 6 with FilteredList

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);
}
Also used : Button(javafx.scene.control.Button) TempCustomerPassingData(CustomerGuiHelpers.TempCustomerPassingData) Initializable(javafx.fxml.Initializable) ListView(javafx.scene.control.ListView) URL(java.net.URL) ListCell(javafx.scene.control.ListCell) MouseEvent(javafx.scene.input.MouseEvent) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) IConfiramtionDialog(UtilsContracts.IConfiramtionDialog) ICustomer(CustomerContracts.ICustomer) Logger(org.apache.log4j.Logger) CatalogProduct(BasicCommonClasses.CatalogProduct) ResourceBundle(java.util.ResourceBundle) BarcodeEventHandler(UtilsImplementations.BarcodeEventHandler) Subscribe(com.google.common.eventbus.Subscribe) Callback(javafx.util.Callback) CustomerProductCellFormat(CustomerGuiHelpers.CustomerProductCellFormat) GridPane(javafx.scene.layout.GridPane) CartProduct(BasicCommonClasses.CartProduct) Label(javafx.scene.control.Label) MalformedURLException(java.net.MalformedURLException) SmartCode(BasicCommonClasses.SmartCode) StackTraceUtil(UtilsImplementations.StackTraceUtil) JFXListView(com.jfoenix.controls.JFXListView) FilteredList(javafx.collections.transformation.FilteredList) SMException(SMExceptions.SMException) DialogMessagesService(GuiUtils.DialogMessagesService) File(java.io.File) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) InjectionFactory(UtilsImplementations.InjectionFactory) ActionEvent(javafx.event.ActionEvent) IBarcodeEventHandler(UtilsContracts.IBarcodeEventHandler) Stage(javafx.stage.Stage) ImageView(javafx.scene.image.ImageView) LocalDate(java.time.LocalDate) SmartcodeScanEvent(UtilsContracts.SmartcodeScanEvent) ObservableValue(javafx.beans.value.ObservableValue) ObservableList(javafx.collections.ObservableList) AbstractApplicationScreen(GuiUtils.AbstractApplicationScreen) ChangeListener(javafx.beans.value.ChangeListener) Image(javafx.scene.image.Image) JFXTextField(com.jfoenix.controls.JFXTextField) ListView(javafx.scene.control.ListView) JFXListView(com.jfoenix.controls.JFXListView) ListCell(javafx.scene.control.ListCell) CartProduct(BasicCommonClasses.CartProduct) CustomerProductCellFormat(CustomerGuiHelpers.CustomerProductCellFormat)

Example 7 with FilteredList

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) {
        }
    }
}
Also used : DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Dispute(io.bitsquare.arbitration.Dispute) SortedList(javafx.collections.transformation.SortedList) FilteredList(javafx.collections.transformation.FilteredList) ObservableList(javafx.collections.ObservableList) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat)

Example 8 with FilteredList

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);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Date(java.util.Date) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Dispute(bisq.core.arbitration.Dispute) SortedList(javafx.collections.transformation.SortedList) FilteredList(javafx.collections.transformation.FilteredList) List(java.util.List) ObservableList(javafx.collections.ObservableList) ArrayList(java.util.ArrayList) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat)

Example 9 with FilteredList

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);
}
Also used : java.util(java.util) Initializable(javafx.fxml.Initializable) TradeName(eu.ggnet.dwoss.rules.TradeName) javafx.scene.control(javafx.scene.control) URL(java.net.URL) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) MULTIPLE(javafx.scene.control.SelectionMode.MULTIPLE) Ui(eu.ggnet.saft.Ui) FxController(eu.ggnet.saft.api.ui.FxController) java.time(java.time) ProductTask(eu.ggnet.dwoss.uniqueunit.ui.ProductTask) SortedList(javafx.collections.transformation.SortedList) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct) DateFormats(eu.ggnet.dwoss.util.DateFormats) javafx.scene.input(javafx.scene.input) Logger(org.slf4j.Logger) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) Predicate(java.util.function.Predicate) ProductGroup(eu.ggnet.dwoss.rules.ProductGroup) FilteredList(javafx.collections.transformation.FilteredList) ClosedListener(eu.ggnet.saft.api.ui.ClosedListener) Collectors(java.util.stream.Collectors) FXML(javafx.fxml.FXML) ActionEvent(javafx.event.ActionEvent) FxSaft(eu.ggnet.saft.core.ui.FxSaft) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) SortedList(javafx.collections.transformation.SortedList) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct) Product(eu.ggnet.dwoss.uniqueunit.ee.entity.Product) PicoProduct(eu.ggnet.dwoss.uniqueunit.api.PicoProduct)

Example 10 with FilteredList

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;
}
Also used : CombinedListWidget(org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget) ShortcutCategoryDTO(org.phoenicis.library.dto.ShortcutCategoryDTO) StringBindings(org.phoenicis.javafx.utils.StringBindings) ObjectExpression(javafx.beans.binding.ObjectExpression) MappedList(org.phoenicis.javafx.collections.MappedList) MouseEvent(javafx.scene.input.MouseEvent) ShortcutEditing(org.phoenicis.javafx.components.library.panelstates.ShortcutEditing) Bindings(javafx.beans.binding.Bindings) SidebarBase(org.phoenicis.javafx.components.common.control.SidebarBase) org.phoenicis.javafx.components.library.control(org.phoenicis.javafx.components.library.control) ListWidgetElement(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement) ShortcutInformation(org.phoenicis.javafx.components.library.panelstates.ShortcutInformation) ShortcutCreation(org.phoenicis.javafx.components.library.panelstates.ShortcutCreation) TabPane(javafx.scene.control.TabPane) None(org.phoenicis.javafx.components.common.panelstates.None) FeaturePanelSkin(org.phoenicis.javafx.components.common.skin.FeaturePanelSkin) ShortcutDTO(org.phoenicis.library.dto.ShortcutDTO) SwitchBinding(org.phoenicis.javafx.utils.SwitchBinding) SortedList(javafx.collections.transformation.SortedList) ListWidgetType(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetType) ObjectProperty(javafx.beans.property.ObjectProperty) Node(javafx.scene.Node) FilteredList(javafx.collections.transformation.FilteredList) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) Observable(javafx.beans.Observable) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) OpenDetailsPanel(org.phoenicis.javafx.components.common.panelstates.OpenDetailsPanel) DetailsPanel(org.phoenicis.javafx.components.common.control.DetailsPanel) Optional(java.util.Optional) ObjectBindings(org.phoenicis.javafx.utils.ObjectBindings) ObservableList(javafx.collections.ObservableList) ConcatenatedList(org.phoenicis.javafx.collections.ConcatenatedList) Comparator(java.util.Comparator) CombinedListWidget(org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget) MouseEvent(javafx.scene.input.MouseEvent) ListWidgetElement(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement) ShortcutInformation(org.phoenicis.javafx.components.library.panelstates.ShortcutInformation) ShortcutDTO(org.phoenicis.library.dto.ShortcutDTO) MappedList(org.phoenicis.javafx.collections.MappedList) ShortcutCategoryDTO(org.phoenicis.library.dto.ShortcutCategoryDTO) None(org.phoenicis.javafx.components.common.panelstates.None)

Aggregations

FilteredList (javafx.collections.transformation.FilteredList)10 ObservableList (javafx.collections.ObservableList)8 SortedList (javafx.collections.transformation.SortedList)7 URL (java.net.URL)3 FXML (javafx.fxml.FXML)3 Initializable (javafx.fxml.Initializable)3 Tab (javafx.scene.control.Tab)3 ConcatenatedList (org.phoenicis.javafx.collections.ConcatenatedList)3 MappedList (org.phoenicis.javafx.collections.MappedList)3 DateFormat (java.text.DateFormat)2 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 HashMap (java.util.HashMap)2 ObjectProperty (javafx.beans.property.ObjectProperty)2 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)2 FXCollections (javafx.collections.FXCollections)2 ActionEvent (javafx.event.ActionEvent)2 MouseEvent (javafx.scene.input.MouseEvent)2 EngineCategoryDTO (org.phoenicis.engines.dto.EngineCategoryDTO)2 EngineSubCategoryPanel (org.phoenicis.javafx.components.engine.control.EngineSubCategoryPanel)2