Search in sources :

Example 1 with ListCell

use of javafx.scene.control.ListCell in project bitsquare by bitsquare.

the class AltCoinAccountsView method buildForm.

///////////////////////////////////////////////////////////////////////////////////////////
// Base form
///////////////////////////////////////////////////////////////////////////////////////////
private void buildForm() {
    addTitledGroupBg(root, gridRow, 1, "Manage accounts");
    Tuple2<Label, ListView> tuple = addLabelListView(root, gridRow, "Your altcoin accounts:", Layout.FIRST_ROW_DISTANCE);
    GridPane.setValignment(tuple.first, VPos.TOP);
    paymentAccountsListView = tuple.second;
    paymentAccountsListView.setPrefHeight(2 * Layout.LIST_ROW_HEIGHT + 14);
    paymentAccountsListView.setCellFactory(new Callback<ListView<PaymentAccount>, ListCell<PaymentAccount>>() {

        @Override
        public ListCell<PaymentAccount> call(ListView<PaymentAccount> list) {
            return new ListCell<PaymentAccount>() {

                final Label label = new Label();

                final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);

                final Button removeButton = new Button("", icon);

                final AnchorPane pane = new AnchorPane(label, removeButton);

                {
                    label.setLayoutY(5);
                    removeButton.setId("icon-button");
                    AnchorPane.setRightAnchor(removeButton, 0d);
                }

                @Override
                public void updateItem(final PaymentAccount item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(item.getAccountName());
                        removeButton.setOnAction(e -> onDeleteAccount(item));
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
    Tuple3<Button, Button, Button> tuple3 = add3ButtonsAfterGroup(root, ++gridRow, "Add new account", "Export Accounts", "Import Accounts");
    addAccountButton = tuple3.first;
    exportButton = tuple3.second;
    importButton = tuple3.third;
}
Also used : Button(javafx.scene.control.Button) PaymentAccountFactory(io.bitsquare.payment.PaymentAccountFactory) PaymentMethod(io.bitsquare.payment.PaymentMethod) Popup(io.bitsquare.gui.main.overlays.popups.Popup) ListView(javafx.scene.control.ListView) ListCell(javafx.scene.control.ListCell) TradeCurrency(io.bitsquare.locale.TradeCurrency) Tuple2(io.bitsquare.common.util.Tuple2) PaymentMethodForm(io.bitsquare.gui.components.paymentmethods.PaymentMethodForm) Inject(javax.inject.Inject) PaymentAccount(io.bitsquare.payment.PaymentAccount) Layout(io.bitsquare.gui.util.Layout) VPos(javafx.geometry.VPos) Callback(javafx.util.Callback) GridPane(javafx.scene.layout.GridPane) BSFormatter(io.bitsquare.gui.util.BSFormatter) Label(javafx.scene.control.Label) CryptoCurrency(io.bitsquare.locale.CryptoCurrency) UserThread(io.bitsquare.common.UserThread) ImageUtil(io.bitsquare.gui.util.ImageUtil) io.bitsquare.gui.util.validation(io.bitsquare.gui.util.validation) ActivatableViewAndModel(io.bitsquare.gui.common.view.ActivatableViewAndModel) TimeUnit(java.util.concurrent.TimeUnit) FormBuilder(io.bitsquare.gui.util.FormBuilder) Tuple3(io.bitsquare.common.util.Tuple3) AnchorPane(javafx.scene.layout.AnchorPane) ImageView(javafx.scene.image.ImageView) CryptoCurrencyForm(io.bitsquare.gui.components.paymentmethods.CryptoCurrencyForm) FxmlView(io.bitsquare.gui.common.view.FxmlView) ChangeListener(javafx.beans.value.ChangeListener) TitledGroupBg(io.bitsquare.gui.components.TitledGroupBg) PaymentAccount(io.bitsquare.payment.PaymentAccount) ListCell(javafx.scene.control.ListCell) Label(javafx.scene.control.Label) ListView(javafx.scene.control.ListView) Button(javafx.scene.control.Button) ImageView(javafx.scene.image.ImageView) AnchorPane(javafx.scene.layout.AnchorPane)

Example 2 with ListCell

use of javafx.scene.control.ListCell in project Gargoyle by callakrsos.

the class UtubeDownloaderComposite method initialize.

@FXML
public void initialize() {
    btnDownload.setDisable(true);
    this.txtDownloadLocation.setText(System.getProperty("user.home"));
    this.txtDownloadLocation.setPromptText("Downlaod Location");
    // this.lvDownlaodCont.setCellFactory(new Callback<ListView<UtubeItemDVO>, ListCell<UtubeItemDVO>>() {
    //
    // @Override
    // public ListCell<UtubeItemDVO> call(ListView<UtubeItemDVO> param) {
    // return new UtubeListCell();
    // }
    // });
    // this.lvDownlaodCont.setOnDragDetected(ev -> {
    // ev.setDragDetect(true);
    // });
    txtUtubeURL.setOnDragOver(ev -> {
        if (ev.getDragboard().hasUrl()) {
            ev.acceptTransferModes(TransferMode.LINK);
            ev.consume();
        }
    });
    txtUtubeURL.setOnDragDropped(ev -> {
        Dragboard dragboard = ev.getDragboard();
        String url = dragboard.getUrl();
        txtUtubeURL.setText(url);
    });
    txtUtubeURL.textProperty().addListener((oba, o, n) -> {
        btnDownload.setDisable(n.trim().isEmpty());
    });
    // 초기값
    this.cbQuality.getItems().addAll(YoutubeQuality.values());
    // 디폴트
    this.cbQuality.getSelectionModel().select(YoutubeQuality.p480);
    this.cbQuality.setCellFactory(new Callback<ListView<YoutubeQuality>, ListCell<YoutubeQuality>>() {

        @Override
        public ListCell<YoutubeQuality> call(ListView<YoutubeQuality> param) {
            return new TextFieldListCell<>(new StringConverter<YoutubeQuality>() {

                @Override
                public String toString(YoutubeQuality object) {
                    return object.name();
                }

                @Override
                public YoutubeQuality fromString(String string) {
                    return YoutubeQuality.valueOf(string);
                }
            });
        }
    });
    this.wasDownloading.addListener((oba, o, n) -> {
        if (n != null)
            this.btnDownload.setDisable(n.booleanValue());
    });
    this.downloadedFile.addListener((oba, o, n) -> {
        if (n != null && n.exists()) {
            //				btnOpen.setDisable(false);
            this.txtFileName.setText(n.getName());
        } else {
        //				btnOpen.setDisable(true);
        }
    });
}
Also used : ListView(javafx.scene.control.ListView) YoutubeQuality(com.github.axet.vget.vhs.YouTubeInfo.YoutubeQuality) ListCell(javafx.scene.control.ListCell) TextFieldListCell(javafx.scene.control.cell.TextFieldListCell) StringConverter(javafx.util.StringConverter) Dragboard(javafx.scene.input.Dragboard) FXML(javafx.fxml.FXML)

Example 3 with ListCell

use of javafx.scene.control.ListCell in project Gargoyle by callakrsos.

the class FxSVNHistoryDataSupplier method createEntryListView.

//	MenuItem createDiffMenu(){
//
//	}
ListView<SVNLogEntry> createEntryListView(ObservableList<SVNLogEntry> list) {
    ListView<SVNLogEntry> listView = new ListView<SVNLogEntry>(list);
    listView.setCellFactory(new Callback<ListView<SVNLogEntry>, ListCell<SVNLogEntry>>() {

        @Override
        public ListCell<SVNLogEntry> call(ListView<SVNLogEntry> param) {
            ListCell<SVNLogEntry> listCell = new ListCell<SVNLogEntry>() {

                /* (non-Javadoc)
					 * @see javafx.scene.control.Cell#updateItem(java.lang.Object, boolean)
					 */
                @Override
                protected void updateItem(SVNLogEntry item, boolean empty) {
                    super.updateItem(item, empty);
                    if (empty) {
                        setText(null);
                    } else {
                        long revision = item.getRevision();
                        String author = item.getAuthor();
                        String dateString = YYYY_MM_DD_HH_MM_SS_PATTERN.format(item.getDate());
                        String message = item.getMessage();
                        setText(String.format("Resivion :%d author %s date :%s message :%s ", revision, author, dateString, message));
                    }
                }
            };
            return listCell;
        }
    });
    listView.setPrefSize(600, ListView.USE_COMPUTED_SIZE);
    listView.addEventHandler(MouseEvent.MOUSE_CLICKED, ev -> {
        if (ev.getClickCount() == 2 && ev.getButton() == MouseButton.PRIMARY) {
            SVNLogEntry selectedItem = listView.getSelectionModel().getSelectedItem();
            if (selectedItem != null) {
                Map<String, SVNLogEntryPath> changedPaths = selectedItem.getChangedPaths();
                if (ValueUtil.isNotEmpty(changedPaths)) {
                    ObservableList<GargoyleSVNLogEntryPath> collect = createStream(Arrays.asList(selectedItem)).collect(FxCollectors.toObservableList());
                    Node showing = null;
                    if (collect.isEmpty()) {
                        showing = new Label("Empty.");
                        showing.setStyle("-fx-text-fill:black");
                    } else {
                        showing = createHistoryListView(collect);
                    }
                    FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), showing);
                }
            }
        }
    });
    return listView;
}
Also used : SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) ListCell(javafx.scene.control.ListCell) Node(javafx.scene.Node) Label(javafx.scene.control.Label) ListView(javafx.scene.control.ListView) SVNLogEntryPath(org.tmatesoft.svn.core.SVNLogEntryPath)

Example 4 with ListCell

use of javafx.scene.control.ListCell in project jabref by JabRef.

the class ErrorConsoleController method createCellFactory.

private Callback<ListView<LogEventViewModel>, ListCell<LogEventViewModel>> createCellFactory() {
    return cell -> new ListCell<LogEventViewModel>() {

        private HBox graphic;

        private Node icon;

        private VBox message;

        private Label heading;

        private Label stacktrace;

        {
            graphic = new HBox(10);
            heading = new Label();
            stacktrace = new Label();
            message = new VBox();
            message.getChildren().setAll(heading, stacktrace);
            setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
        }

        @Override
        public void updateItem(LogEventViewModel event, boolean empty) {
            super.updateItem(event, empty);
            if (event == null || empty) {
                setGraphic(null);
            } else {
                icon = event.getIcon().getGraphicNode();
                heading.setText(event.getDisplayText());
                heading.getStyleClass().setAll(event.getStyleClass());
                stacktrace.setText(event.getStackTrace().orElse(""));
                graphic.getStyleClass().setAll(event.getStyleClass());
                graphic.getChildren().setAll(icon, message);
                setGraphic(graphic);
            }
        }
    };
}
Also used : Button(javafx.scene.control.Button) KeyBindingRepository(org.jabref.gui.keyboard.KeyBindingRepository) HBox(javafx.scene.layout.HBox) Label(javafx.scene.control.Label) ListView(javafx.scene.control.ListView) ListCell(javafx.scene.control.ListCell) AbstractController(org.jabref.gui.AbstractController) Node(javafx.scene.Node) DialogService(org.jabref.gui.DialogService) IconTheme(org.jabref.gui.IconTheme) KeyEvent(javafx.scene.input.KeyEvent) VBox(javafx.scene.layout.VBox) Inject(javax.inject.Inject) FXML(javafx.fxml.FXML) SelectionMode(javafx.scene.control.SelectionMode) ListChangeListener(javafx.collections.ListChangeListener) ClipBoardManager(org.jabref.gui.ClipBoardManager) ObservableList(javafx.collections.ObservableList) Callback(javafx.util.Callback) ContentDisplay(javafx.scene.control.ContentDisplay) KeyBinding(org.jabref.gui.keyboard.KeyBinding) BuildInfo(org.jabref.logic.util.BuildInfo) HBox(javafx.scene.layout.HBox) ListCell(javafx.scene.control.ListCell) Node(javafx.scene.Node) Label(javafx.scene.control.Label) VBox(javafx.scene.layout.VBox)

Example 5 with ListCell

use of javafx.scene.control.ListCell in project jabref by JabRef.

the class ViewModelListCellFactory method call.

@Override
public ListCell<T> call(ListView<T> param) {
    return new ListCell<T>() {

        @Override
        protected void updateItem(T item, boolean empty) {
            super.updateItem(item, empty);
            T viewModel = getItem();
            if (empty || viewModel == null) {
                setText(null);
                setGraphic(null);
                setOnMouseClicked(null);
                setTooltip(null);
            } else {
                if (toText != null) {
                    setText(toText.call(viewModel));
                }
                if (toGraphic != null) {
                    setGraphic(toGraphic.call(viewModel));
                }
                if (toOnMouseClickedEvent != null) {
                    setOnMouseClicked(toOnMouseClickedEvent.call(viewModel));
                }
                if (toStyleClass != null) {
                    getStyleClass().setAll(toStyleClass.call(viewModel));
                }
                if (toTooltip != null) {
                    String tooltipText = toTooltip.call(viewModel);
                    if (StringUtil.isNotBlank(tooltipText)) {
                        setTooltip(new Tooltip(tooltipText));
                    }
                }
            }
            getListView().refresh();
        }
    };
}
Also used : ListCell(javafx.scene.control.ListCell) Tooltip(javafx.scene.control.Tooltip)

Aggregations

ListCell (javafx.scene.control.ListCell)8 ListView (javafx.scene.control.ListView)7 Label (javafx.scene.control.Label)5 FXML (javafx.fxml.FXML)4 Callback (javafx.util.Callback)4 ObservableList (javafx.collections.ObservableList)3 Node (javafx.scene.Node)3 Button (javafx.scene.control.Button)3 MalformedURLException (java.net.MalformedURLException)2 FXCollections (javafx.collections.FXCollections)2 SelectionMode (javafx.scene.control.SelectionMode)2 MouseEvent (javafx.scene.input.MouseEvent)2 VBox (javafx.scene.layout.VBox)2 CartProduct (BasicCommonClasses.CartProduct)1 CatalogProduct (BasicCommonClasses.CatalogProduct)1 SmartCode (BasicCommonClasses.SmartCode)1 ICustomer (CustomerContracts.ICustomer)1 CustomerProductCellFormat (CustomerGuiHelpers.CustomerProductCellFormat)1 TempCustomerPassingData (CustomerGuiHelpers.TempCustomerPassingData)1 AbstractApplicationScreen (GuiUtils.AbstractApplicationScreen)1