Search in sources :

Example 6 with ListView

use of javafx.scene.control.ListView in project bisq-desktop by bisq-network.

the class ArbitratorRegistrationView method buildUI.

private void buildUI() {
    GridPane gridPane = new GridPane();
    gridPane.setPadding(new Insets(30, 25, -1, 25));
    gridPane.setHgap(5);
    gridPane.setVgap(5);
    ColumnConstraints columnConstraints1 = new ColumnConstraints();
    columnConstraints1.setHalignment(HPos.RIGHT);
    columnConstraints1.setHgrow(Priority.SOMETIMES);
    columnConstraints1.setMinWidth(200);
    ColumnConstraints columnConstraints2 = new ColumnConstraints();
    columnConstraints2.setHgrow(Priority.ALWAYS);
    gridPane.getColumnConstraints().addAll(columnConstraints1, columnConstraints2);
    root.getChildren().add(gridPane);
    addTitledGroupBg(gridPane, gridRow, 3, Res.get("account.tab.arbitratorRegistration"));
    TextField pubKeyTextField = FormBuilder.addLabelTextField(gridPane, gridRow, Res.get("account.arbitratorRegistration.pubKey"), model.registrationPubKeyAsHex.get(), Layout.FIRST_ROW_DISTANCE).second;
    pubKeyTextField.textProperty().bind(model.registrationPubKeyAsHex);
    Tuple2<Label, ListView> tuple = addLabelListView(gridPane, ++gridRow, Res.get("shared.yourLanguage"));
    GridPane.setValignment(tuple.first, VPos.TOP);
    // noinspection unchecked
    languagesListView = tuple.second;
    languagesListView.disableProperty().bind(model.registrationEditDisabled);
    languagesListView.setMinHeight(3 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setMaxHeight(6 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {

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

                final Label label = new AutoTooltipLabel();

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

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

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

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

                @Override
                public void updateItem(final String item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(LanguageUtil.getDisplayName(item));
                        removeButton.setOnAction(e -> onRemoveLanguage(item));
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
    // noinspection unchecked
    languageComboBox = addLabelComboBox(gridPane, ++gridRow).second;
    languageComboBox.disableProperty().bind(model.registrationEditDisabled);
    languageComboBox.setPromptText(Res.get("shared.addLanguage"));
    languageComboBox.setConverter(new StringConverter<String>() {

        @Override
        public String toString(String code) {
            return LanguageUtil.getDisplayName(code);
        }

        @Override
        public String fromString(String s) {
            return null;
        }
    });
    languageComboBox.setOnAction(e -> onAddLanguage());
    Button registerButton = addButtonAfterGroup(gridPane, ++gridRow, Res.get("account.arbitratorRegistration.register"));
    registerButton.disableProperty().bind(model.registrationEditDisabled);
    registerButton.setOnAction(e -> onRegister());
    Button revokeButton = addButton(gridPane, ++gridRow, Res.get("account.arbitratorRegistration.revoke"));
    revokeButton.setDefaultButton(false);
    revokeButton.disableProperty().bind(model.revokeButtonDisabled);
    revokeButton.setOnAction(e -> onRevoke());
    addTitledGroupBg(gridPane, ++gridRow, 2, Res.get("shared.information"), Layout.GROUP_DISTANCE);
    Label infoLabel = addMultilineLabel(gridPane, gridRow);
    GridPane.setMargin(infoLabel, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
    infoLabel.setText(Res.get("account.arbitratorRegistration.info.msg"));
}
Also used : Button(javafx.scene.control.Button) Arbitrator(bisq.core.arbitration.Arbitrator) HPos(javafx.geometry.HPos) ListView(javafx.scene.control.ListView) ColumnConstraints(javafx.scene.layout.ColumnConstraints) ListCell(javafx.scene.control.ListCell) UnlockArbitrationRegistrationWindow(bisq.desktop.main.overlays.windows.UnlockArbitrationRegistrationWindow) Layout(bisq.desktop.util.Layout) VBox(javafx.scene.layout.VBox) FxmlView(bisq.desktop.common.view.FxmlView) Inject(javax.inject.Inject) Tuple2(bisq.common.util.Tuple2) Insets(javafx.geometry.Insets) ComboBox(javafx.scene.control.ComboBox) ListChangeListener(javafx.collections.ListChangeListener) VPos(javafx.geometry.VPos) Res(bisq.core.locale.Res) Callback(javafx.util.Callback) GridPane(javafx.scene.layout.GridPane) Popup(bisq.desktop.main.overlays.popups.Popup) TextField(javafx.scene.control.TextField) Label(javafx.scene.control.Label) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FormBuilder(bisq.desktop.util.FormBuilder) StringConverter(javafx.util.StringConverter) Priority(javafx.scene.layout.Priority) ImageUtil(bisq.desktop.util.ImageUtil) AnchorPane(javafx.scene.layout.AnchorPane) ImageView(javafx.scene.image.ImageView) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) AppOptionKeys(bisq.core.app.AppOptionKeys) LanguageUtil(bisq.core.locale.LanguageUtil) UserThread(bisq.common.UserThread) Named(com.google.inject.name.Named) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) ChangeListener(javafx.beans.value.ChangeListener) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) ColumnConstraints(javafx.scene.layout.ColumnConstraints) ListCell(javafx.scene.control.ListCell) Label(javafx.scene.control.Label) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) ListView(javafx.scene.control.ListView) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) TextField(javafx.scene.control.TextField) ImageView(javafx.scene.image.ImageView) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) AnchorPane(javafx.scene.layout.AnchorPane)

Example 7 with ListView

use of javafx.scene.control.ListView in project bisq-desktop by bisq-network.

the class ArbitratorSelectionView method addLanguageGroup.

// /////////////////////////////////////////////////////////////////////////////////////////
// UI builder
// /////////////////////////////////////////////////////////////////////////////////////////
private void addLanguageGroup() {
    addTitledGroupBg(root, gridRow, 1, Res.get("account.arbitratorSelection.whichLanguages"));
    Tuple2<Label, ListView> tuple = addLabelListView(root, gridRow, Res.get("shared.yourLanguage"), Layout.FIRST_ROW_DISTANCE);
    GridPane.setValignment(tuple.first, VPos.TOP);
    // noinspection unchecked
    languagesListView = tuple.second;
    languagesListView.setMinHeight(3 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setMaxHeight(6 * Layout.LIST_ROW_HEIGHT + 2);
    languagesListView.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {

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

                final Label label = new AutoTooltipLabel();

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

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

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

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

                @Override
                public void updateItem(final String item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(LanguageUtil.getDisplayName(item));
                        removeButton.setOnAction(e -> onRemoveLanguage(item));
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
    // noinspection unchecked
    languageComboBox = addLabelComboBox(root, ++gridRow, "", 15).second;
    languageComboBox.setPromptText(Res.get("shared.addLanguage"));
    languageComboBox.setConverter(new StringConverter<String>() {

        @Override
        public String toString(String code) {
            return LanguageUtil.getDisplayName(code);
        }

        @Override
        public String fromString(String s) {
            return null;
        }
    });
    languageComboBox.setOnAction(e -> onAddLanguage());
}
Also used : TableGroupHeadline(bisq.desktop.components.TableGroupHeadline) Button(javafx.scene.control.Button) HPos(javafx.geometry.HPos) ListView(javafx.scene.control.ListView) ListCell(javafx.scene.control.ListCell) Layout(bisq.desktop.util.Layout) FxmlView(bisq.desktop.common.view.FxmlView) TableColumn(javafx.scene.control.TableColumn) Inject(javax.inject.Inject) Tuple2(bisq.common.util.Tuple2) TableCell(javafx.scene.control.TableCell) FormBuilder.addLabelComboBox(bisq.desktop.util.FormBuilder.addLabelComboBox) Insets(javafx.geometry.Insets) ComboBox(javafx.scene.control.ComboBox) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) VPos(javafx.geometry.VPos) Res(bisq.core.locale.Res) TableView(javafx.scene.control.TableView) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) GridPane(javafx.scene.layout.GridPane) FormBuilder.addLabelListView(bisq.desktop.util.FormBuilder.addLabelListView) Popup(bisq.desktop.main.overlays.popups.Popup) Label(javafx.scene.control.Label) AutoTooltipTableColumn(bisq.desktop.components.AutoTooltipTableColumn) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) TableRow(javafx.scene.control.TableRow) FormBuilder.addTitledGroupBg(bisq.desktop.util.FormBuilder.addTitledGroupBg) CheckBox(javafx.scene.control.CheckBox) StringConverter(javafx.util.StringConverter) FormBuilder.addCheckBox(bisq.desktop.util.FormBuilder.addCheckBox) BooleanProperty(javafx.beans.property.BooleanProperty) ImageUtil(bisq.desktop.util.ImageUtil) AnchorPane(javafx.scene.layout.AnchorPane) ImageView(javafx.scene.image.ImageView) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) LanguageUtil(bisq.core.locale.LanguageUtil) UserThread(bisq.common.UserThread) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) AutoTooltipCheckBox(bisq.desktop.components.AutoTooltipCheckBox) ChangeListener(javafx.beans.value.ChangeListener) ListCell(javafx.scene.control.ListCell) Label(javafx.scene.control.Label) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) ListView(javafx.scene.control.ListView) FormBuilder.addLabelListView(bisq.desktop.util.FormBuilder.addLabelListView) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) ImageView(javafx.scene.image.ImageView) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) AnchorPane(javafx.scene.layout.AnchorPane)

Example 8 with ListView

use of javafx.scene.control.ListView in project dolphin-platform by canoo.

the class StructuredListCell method simpleSelect.

private void simpleSelect() {
    ListView lv = getListView();
    int index = getIndex();
    MultipleSelectionModel sm = lv.getSelectionModel();
    lv.getSelectionModel().clearAndSelect(index);
}
Also used : ListView(javafx.scene.control.ListView) MultipleSelectionModel(javafx.scene.control.MultipleSelectionModel)

Example 9 with ListView

use of javafx.scene.control.ListView in project TestFX by TestFX.

the class GlassRobotClipboardBug method setup.

@Before
public void setup() throws Exception {
    FxToolkit.setupSceneRoot(() -> {
        ListView<String> listView = new ListView<>();
        listView.getItems().addAll("item.1", "item.2", "item.3");
        listView.setOnDragDetected(event -> {
            ClipboardContent content = new ClipboardContent();
            // <-- BUG
            content.putString("item.1");
            Dragboard dragboard = listView.startDragAndDrop(TransferMode.MOVE);
            dragboard.setContent(content);
            event.consume();
        });
        return new HBox(listView);
    });
    FxToolkit.setupStage(Stage::show);
}
Also used : HBox(javafx.scene.layout.HBox) ListView(javafx.scene.control.ListView) ClipboardContent(javafx.scene.input.ClipboardContent) Stage(javafx.stage.Stage) Dragboard(javafx.scene.input.Dragboard) Before(org.junit.Before)

Example 10 with ListView

use of javafx.scene.control.ListView in project trex-stateless-gui by cisco-system-traffic-generator.

the class TestTrafficProfiles method testExportProfileToYAML.

@Test
public void testExportProfileToYAML() throws Exception {
    prepareProfile();
    openTrafficProfilesDialog();
    final ListView profileList = lookup("#traffic-profile-dialog-profiles-list-view").query();
    Assert.assertTrue(profileList.getItems().contains("profile.yaml"));
    final FileChooser fileChooser = Mockito.spy(FileChooser.class);
    FileChooserFactory.set(fileChooser);
    final File result = new File(FileManager.getLocalFilePath() + "/profile.yaml");
    Mockito.doReturn(result).when(fileChooser).showSaveDialog(Mockito.any());
    tryCall(() -> {
        clickOn("profile.yaml");
        clickOn("#export-profile-to-yaml-button");
        FileChooserFactory.set(null);
    }, () -> true);
    final File expected = new File(getResourcesFolder() + "/profile.yaml");
    Assert.assertTrue(FileUtils.contentEquals(expected, result));
}
Also used : ListView(javafx.scene.control.ListView) FileChooser(javafx.stage.FileChooser) File(java.io.File) Test(org.junit.Test)

Aggregations

ListView (javafx.scene.control.ListView)28 Label (javafx.scene.control.Label)15 ListCell (javafx.scene.control.ListCell)13 Button (javafx.scene.control.Button)12 Callback (javafx.util.Callback)10 GridPane (javafx.scene.layout.GridPane)9 ChangeListener (javafx.beans.value.ChangeListener)8 Insets (javafx.geometry.Insets)8 ImageView (javafx.scene.image.ImageView)8 Inject (javax.inject.Inject)8 AutoTooltipLabel (bisq.desktop.components.AutoTooltipLabel)7 AnchorPane (javafx.scene.layout.AnchorPane)7 UserThread (bisq.common.UserThread)6 Tuple2 (bisq.common.util.Tuple2)6 Res (bisq.core.locale.Res)6 FxmlView (bisq.desktop.common.view.FxmlView)6 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)6 Popup (bisq.desktop.main.overlays.popups.Popup)6 File (java.io.File)6 ObservableList (javafx.collections.ObservableList)6