Skip to content

Commit

Permalink
Merge pull request #1774 from devinbileck/fix-preferences-view-combob…
Browse files Browse the repository at this point in the history
…ox-selection

Fix preferences view combobox selection
  • Loading branch information
ripcurlx authored Oct 16, 2018
2 parents 866ea00 + 26d03af commit ad5e232
Showing 1 changed file with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,10 @@ public void updateItem(final FiatCurrency item, boolean empty) {
new Popup<>().warning(Res.get("setting.preferences.cannotRemovePrefCurrency")).show();
} else {
preferences.removeFiatCurrency(item);
if (!allFiatCurrencies.contains(item))
if (!allFiatCurrencies.contains(item)) {
allFiatCurrencies.add(item);
allFiatCurrencies.sort(TradeCurrency::compareTo);
}
}
});
setGraphic(pane);
Expand Down Expand Up @@ -415,8 +417,10 @@ public void updateItem(final CryptoCurrency item, boolean empty) {
new Popup<>().warning(Res.get("setting.preferences.cannotRemovePrefCurrency")).show();
} else {
preferences.removeCryptoCurrency(item);
if (!allCryptoCurrencies.contains(item))
if (!allCryptoCurrencies.contains(item)) {
allCryptoCurrencies.add(item);
allCryptoCurrencies.sort(TradeCurrency::compareTo);
}
}
});
setGraphic(pane);
Expand All @@ -431,6 +435,17 @@ public void updateItem(final CryptoCurrency item, boolean empty) {

fiatCurrenciesComboBox = FormBuilder.<FiatCurrency>addLabelComboBox(root, ++gridRow).second;
fiatCurrenciesComboBox.setPromptText(Res.get("setting.preferences.addFiat"));
fiatCurrenciesComboBox.setButtonCell(new ListCell<FiatCurrency>() {
@Override
protected void updateItem(final FiatCurrency item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText(Res.get("setting.preferences.addFiat"));
} else {
setText(item.getNameAndCode());
}
}
});
fiatCurrenciesComboBox.setConverter(new StringConverter<FiatCurrency>() {
@Override
public String toString(FiatCurrency tradeCurrency) {
Expand All @@ -447,6 +462,17 @@ public FiatCurrency fromString(String s) {
cryptoCurrenciesComboBox = labelComboBoxTuple2.second;
GridPane.setColumnIndex(cryptoCurrenciesComboBox, 3);
cryptoCurrenciesComboBox.setPromptText(Res.get("setting.preferences.addAltcoin"));
cryptoCurrenciesComboBox.setButtonCell(new ListCell<CryptoCurrency>() {
@Override
protected void updateItem(final CryptoCurrency item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText(Res.get("setting.preferences.addAltcoin"));
} else {
setText(item.getNameAndCode());
}
}
});
cryptoCurrenciesComboBox.setConverter(new StringConverter<CryptoCurrency>() {
@Override
public String toString(CryptoCurrency tradeCurrency) {
Expand Down Expand Up @@ -609,7 +635,7 @@ private void activateDisplayCurrencies() {

fiatCurrenciesComboBox.setItems(allFiatCurrencies);
fiatCurrenciesListView.setItems(fiatCurrencies);
fiatCurrenciesComboBox.setOnAction(e -> {
fiatCurrenciesComboBox.setOnHiding(e -> {
FiatCurrency selectedItem = fiatCurrenciesComboBox.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
preferences.addFiatCurrency(selectedItem);
Expand All @@ -624,7 +650,7 @@ private void activateDisplayCurrencies() {
});
cryptoCurrenciesComboBox.setItems(allCryptoCurrencies);
cryptoCurrenciesListView.setItems(cryptoCurrencies);
cryptoCurrenciesComboBox.setOnAction(e -> {
cryptoCurrenciesComboBox.setOnHiding(e -> {
CryptoCurrency selectedItem = cryptoCurrenciesComboBox.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
preferences.addCryptoCurrency(selectedItem);
Expand Down

0 comments on commit ad5e232

Please sign in to comment.