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"));
}
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());
}
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);
}
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);
}
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));
}
Aggregations