mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-20 02:12:00 +01:00
Add fixes for not shown combobox selection values
This commit is contained in:
parent
f9478a5afc
commit
adae6519f7
@ -205,6 +205,8 @@ public abstract class MutableOfferView<M extends MutableOfferViewModel> extends
|
||||
balanceTextField.setFormatter(model.getBtcFormatter());
|
||||
|
||||
paymentAccountsComboBox.setConverter(GUIUtil.getPaymentAccountsComboBoxStringConverter());
|
||||
paymentAccountsComboBox.setButtonCell(GUIUtil.getComboBoxButtonCell(Res.get("shared.selectTradingAccount"),
|
||||
paymentAccountsComboBox, false));
|
||||
|
||||
doSetFocus();
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import bisq.desktop.components.InputTextField;
|
||||
import bisq.desktop.components.TitledGroupBg;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.util.FormBuilder;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
import bisq.desktop.util.ImageUtil;
|
||||
import bisq.desktop.util.Layout;
|
||||
|
||||
@ -191,6 +192,9 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
||||
// selectBaseCurrencyNetwork
|
||||
selectBaseCurrencyNetworkComboBox = FormBuilder.addComboBox(root, gridRow,
|
||||
Res.get("settings.preferences.selectCurrencyNetwork"), Layout.FIRST_ROW_DISTANCE);
|
||||
|
||||
selectBaseCurrencyNetworkComboBox.setButtonCell(GUIUtil.getComboBoxButtonCell(Res.get("settings.preferences.selectCurrencyNetwork"),
|
||||
selectBaseCurrencyNetworkComboBox, false));
|
||||
selectBaseCurrencyNetworkComboBox.setConverter(new StringConverter<>() {
|
||||
@Override
|
||||
public String toString(BaseCurrencyNetwork baseCurrencyNetwork) {
|
||||
@ -209,8 +213,12 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
||||
Res.get("shared.language"));
|
||||
userCountryComboBox = FormBuilder.addComboBox(root, ++gridRow,
|
||||
Res.get("shared.country"));
|
||||
userCountryComboBox.setButtonCell(GUIUtil.getComboBoxButtonCell(Res.get("shared.country"), userCountryComboBox,
|
||||
false));
|
||||
blockChainExplorerComboBox = FormBuilder.addComboBox(root, ++gridRow,
|
||||
Res.get("setting.preferences.explorer"));
|
||||
blockChainExplorerComboBox.setButtonCell(GUIUtil.getComboBoxButtonCell(Res.get("setting.preferences.explorer"),
|
||||
blockChainExplorerComboBox, false));
|
||||
|
||||
Tuple3<Label, InputTextField, CheckBox> tuple = addTopLabelInputTextFieldCheckBox(root, ++gridRow,
|
||||
Res.get("setting.preferences.txFee"), Res.get("setting.preferences.useCustomValue"));
|
||||
|
@ -58,7 +58,6 @@ import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.ContentDisplay;
|
||||
import javafx.scene.control.DatePicker;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.RadioButton;
|
||||
import javafx.scene.control.TextArea;
|
||||
@ -83,6 +82,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static bisq.desktop.util.GUIUtil.getComboBoxButtonCell;
|
||||
|
||||
public class FormBuilder {
|
||||
public static final String MATERIAL_DESIGN_ICONS = "'Material Design Icons'";
|
||||
public static final String FONTAWESOME_ICONS = "FontAwesome";
|
||||
@ -749,18 +750,7 @@ public class FormBuilder {
|
||||
|
||||
// Default ComboBox does not show promptText after clear selection.
|
||||
// https://stackoverflow.com/questions/50569330/how-to-reset-combobox-and-display-prompttext?noredirect=1&lq=1
|
||||
comboBox.setButtonCell(new ListCell<>() {
|
||||
@Override
|
||||
protected void updateItem(T item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (empty || item == null) {
|
||||
setText(title);
|
||||
} else {
|
||||
setText(comboBox.getConverter().toString(item));
|
||||
}
|
||||
}
|
||||
});
|
||||
comboBox.setButtonCell(getComboBoxButtonCell(title, comboBox));
|
||||
|
||||
GridPane.setRowIndex(comboBox, rowIndex);
|
||||
GridPane.setColumnIndex(comboBox, 0);
|
||||
@ -770,7 +760,6 @@ public class FormBuilder {
|
||||
return comboBox;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Label + SearchComboBox
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -121,6 +121,8 @@ import java.util.function.Consumer;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
@Slf4j
|
||||
@ -878,4 +880,29 @@ public class GUIUtil {
|
||||
|
||||
return gridRow;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> ListCell<T> getComboBoxButtonCell(String title, ComboBox<T> comboBox) {
|
||||
return getComboBoxButtonCell(title, comboBox, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> ListCell<T> getComboBoxButtonCell(String title, ComboBox<T> comboBox, Boolean hideOriginalPrompt) {
|
||||
return new ListCell<>() {
|
||||
@Override
|
||||
protected void updateItem(T item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
|
||||
// See https://github.com/jfoenixadmin/JFoenix/issues/610
|
||||
if (hideOriginalPrompt)
|
||||
this.setVisible(item != null || !empty);
|
||||
|
||||
if (empty || item == null) {
|
||||
setText(title);
|
||||
} else {
|
||||
setText(comboBox.getConverter().toString(item));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user