mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
fixed problems with caching
This commit is contained in:
parent
71ce70bf4b
commit
00b41cf537
@ -50,9 +50,9 @@ public class CachingTabPane extends TabPane
|
||||
selectedTabIndex = (indexObject == null) ? 0 : (int) indexObject;
|
||||
|
||||
// if selectedTabIndex = 0 the the change listener will not fire so we load it manually
|
||||
// if (selectedTabIndex == 0) loadView();
|
||||
if (selectedTabIndex == 0) loadView();
|
||||
|
||||
//getSelectionModel().select(selectedTabIndex);
|
||||
getSelectionModel().select(selectedTabIndex);
|
||||
}
|
||||
|
||||
public ViewController loadViewAndGetChildController(String fxmlView)
|
||||
|
@ -26,9 +26,9 @@ public class Popups
|
||||
}
|
||||
|
||||
// Confirm
|
||||
public static void openConfirmPopup(String title, String message)
|
||||
public static Action openConfirmPopup(String title, String message)
|
||||
{
|
||||
openConfirmPopup(title, message, null);
|
||||
return openConfirmPopup(title, message, null);
|
||||
}
|
||||
|
||||
public static Action openConfirmPopup(String title, String message, String masthead)
|
||||
@ -36,6 +36,11 @@ public class Popups
|
||||
List<Action> actions = new ArrayList<>();
|
||||
actions.add(Dialog.Actions.OK);
|
||||
actions.add(Dialog.Actions.CANCEL);
|
||||
return openConfirmPopup(title, message, masthead, actions);
|
||||
}
|
||||
|
||||
public static Action openConfirmPopup(String title, String message, String masthead, List<Action> actions)
|
||||
{
|
||||
return Dialogs.create().owner(BitSquare.getPrimaryStage()).title(title).message(message).masthead(masthead).actions(actions).showConfirm();
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import io.bitsquare.di.GuiceFXMLLoader;
|
||||
import io.bitsquare.gui.CachedViewController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.ViewController;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.util.BitSquareValidator;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.locale.*;
|
||||
@ -37,6 +38,8 @@ import javafx.stage.Stage;
|
||||
import javafx.util.Callback;
|
||||
import javafx.util.StringConverter;
|
||||
import javax.inject.Inject;
|
||||
import org.controlsfx.control.action.Action;
|
||||
import org.controlsfx.dialog.Dialog;
|
||||
|
||||
// TODO separate in 2 view/controllers
|
||||
public class SettingsController extends CachedViewController
|
||||
@ -90,8 +93,14 @@ public class SettingsController extends CachedViewController
|
||||
countryList = FXCollections.observableArrayList(new ArrayList<>());
|
||||
arbitratorList = FXCollections.observableArrayList(new ArrayList<>());
|
||||
|
||||
addLanguage(LanguageUtil.getDefaultLanguageLocale());
|
||||
addCountry(CountryUtil.getDefaultCountry());
|
||||
if (Locale.getDefault() != null)
|
||||
{
|
||||
addLanguage(LanguageUtil.getDefaultLanguageLocale());
|
||||
addCountry(CountryUtil.getDefaultCountry());
|
||||
}
|
||||
|
||||
// Add english as default as well
|
||||
addLanguage(LanguageUtil.getEnglishLanguageLocale());
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,12 +138,6 @@ public class SettingsController extends CachedViewController
|
||||
@Override
|
||||
public ViewController loadViewAndGetChildController(NavigationItem navigationItem)
|
||||
{
|
||||
|
||||
/*if (childController instanceof CachedViewController)
|
||||
((CachedViewController) childController).deactivate();
|
||||
else if (childController != null)
|
||||
childController.terminate();*/
|
||||
|
||||
// TODO
|
||||
// caching causes exception
|
||||
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()), false);
|
||||
@ -211,7 +214,7 @@ public class SettingsController extends CachedViewController
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void onAddArbitrator()
|
||||
public void onOpenArbitratorScreen()
|
||||
{
|
||||
loadViewAndGetChildController(NavigationItem.ARBITRATOR_OVERVIEW);
|
||||
}
|
||||
@ -255,6 +258,7 @@ public class SettingsController extends CachedViewController
|
||||
@FXML
|
||||
public void onAddBankAccount()
|
||||
{
|
||||
saveBankAccount();
|
||||
resetBankAccountInput();
|
||||
}
|
||||
|
||||
@ -268,17 +272,13 @@ public class SettingsController extends CachedViewController
|
||||
void onSaveBankAccount()
|
||||
{
|
||||
saveBankAccount();
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Private methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// General Settings
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void setupGeneralSettingsScreen()
|
||||
{
|
||||
initLanguage();
|
||||
@ -321,9 +321,7 @@ public class SettingsController extends CachedViewController
|
||||
if (item != null && !empty)
|
||||
{
|
||||
label.setText(item.getDisplayName());
|
||||
|
||||
removeButton.setOnAction(actionEvent -> removeLanguage(item));
|
||||
|
||||
setGraphic(hBox);
|
||||
}
|
||||
else
|
||||
@ -407,9 +405,7 @@ public class SettingsController extends CachedViewController
|
||||
if (item != null && !empty)
|
||||
{
|
||||
label.setText(item.getName());
|
||||
|
||||
removeButton.setOnAction(actionEvent -> removeCountry(item));
|
||||
|
||||
setGraphic(hBox);
|
||||
}
|
||||
else
|
||||
@ -477,9 +473,7 @@ public class SettingsController extends CachedViewController
|
||||
if (item != null && !empty)
|
||||
{
|
||||
label.setText(item.getName());
|
||||
|
||||
removeButton.setOnAction(actionEvent -> removeArbitrator(item));
|
||||
|
||||
setGraphic(hBox);
|
||||
}
|
||||
else
|
||||
@ -493,44 +487,43 @@ public class SettingsController extends CachedViewController
|
||||
arbitratorsListView.setItems(arbitratorList);
|
||||
}
|
||||
|
||||
private void addLanguage(Locale item)
|
||||
private void addLanguage(Locale locale)
|
||||
{
|
||||
if (!languageList.contains(item) && item != null)
|
||||
if (locale != null && !languageList.contains(locale))
|
||||
{
|
||||
languageList.add(item);
|
||||
settings.addAcceptedLanguageLocale(item);
|
||||
|
||||
languageList.add(locale);
|
||||
settings.addAcceptedLanguageLocale(locale);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeLanguage(Locale item)
|
||||
private void removeLanguage(Locale locale)
|
||||
{
|
||||
languageList.remove(item);
|
||||
settings.removeAcceptedLanguageLocale(item);
|
||||
languageList.remove(locale);
|
||||
settings.removeAcceptedLanguageLocale(locale);
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
private void addCountry(Country item)
|
||||
private void addCountry(Country country)
|
||||
{
|
||||
if (!countryList.contains(item) && item != null)
|
||||
if (!countryList.contains(country) && country != null)
|
||||
{
|
||||
countryList.add(item);
|
||||
settings.addAcceptedCountry(item);
|
||||
countryList.add(country);
|
||||
settings.addAcceptedCountry(country);
|
||||
saveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeCountry(Country item)
|
||||
private void removeCountry(Country country)
|
||||
{
|
||||
countryList.remove(item);
|
||||
settings.removeAcceptedCountry(item);
|
||||
countryList.remove(country);
|
||||
settings.removeAcceptedCountry(country);
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
private void removeArbitrator(Arbitrator item)
|
||||
private void removeArbitrator(Arbitrator arbitrator)
|
||||
{
|
||||
arbitratorList.remove(item);
|
||||
settings.removeAcceptedArbitrator(item);
|
||||
arbitratorList.remove(arbitrator);
|
||||
settings.removeAcceptedArbitrator(arbitrator);
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
@ -545,10 +538,7 @@ public class SettingsController extends CachedViewController
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Bank Account Settings
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void initBankAccountScreen()
|
||||
{
|
||||
initBankAccountComboBox();
|
||||
@ -578,14 +568,13 @@ public class SettingsController extends CachedViewController
|
||||
bankAccountCurrencyComboBox.getSelectionModel().selectFirst();
|
||||
bankAccountRegionComboBox.getSelectionModel().select(3);
|
||||
bankAccountCountryComboBox.getSelectionModel().select(5);
|
||||
bankAccountTitleTextField.setText("dummy");
|
||||
bankAccountHolderNameTextField.setText("dummy");
|
||||
bankAccountPrimaryIDTextField.setText("dummy");
|
||||
bankAccountSecondaryIDTextField.setText("dummy");
|
||||
bankAccountTitleTextField.setText("dummy title");
|
||||
bankAccountHolderNameTextField.setText("dummy name");
|
||||
bankAccountPrimaryIDTextField.setText("dummy primary ID");
|
||||
bankAccountSecondaryIDTextField.setText("dummy secondary ID");
|
||||
|
||||
if (user.getCurrentBankAccount() == null)
|
||||
{
|
||||
onSaveBankAccount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -616,20 +605,19 @@ public class SettingsController extends CachedViewController
|
||||
bankAccountComboBox.setItems(FXCollections.observableArrayList(user.getBankAccounts()));
|
||||
bankAccountComboBox.setConverter(new StringConverter<BankAccount>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public String toString(BankAccount bankAccount)
|
||||
{
|
||||
return bankAccount.getAccountTitle();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BankAccount fromString(String s)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
BankAccount currentBankAccount = user.getCurrentBankAccount();
|
||||
if (currentBankAccount != null)
|
||||
{
|
||||
@ -644,14 +632,12 @@ public class SettingsController extends CachedViewController
|
||||
bankAccountTypesComboBox.setItems(FXCollections.observableArrayList(BankAccountType.getAllBankAccountTypes()));
|
||||
bankAccountTypesComboBox.setConverter(new StringConverter<BankAccountType>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public String toString(BankAccountType bankAccountTypeInfo)
|
||||
{
|
||||
return Localisation.get(bankAccountTypeInfo.toString());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BankAccountType fromString(String s)
|
||||
{
|
||||
@ -762,6 +748,20 @@ public class SettingsController extends CachedViewController
|
||||
saveUser();
|
||||
|
||||
initBankAccountScreen();
|
||||
|
||||
if (!settings.getAcceptedCountries().contains(bankAccount.getCountry()))
|
||||
{
|
||||
List<Action> actions = new ArrayList<>();
|
||||
actions.add(Dialog.Actions.YES);
|
||||
actions.add(Dialog.Actions.NO);
|
||||
|
||||
Action response = Popups.openConfirmPopup("Warning",
|
||||
"The country of your bank account is not included in the accepted countries in the general settings.\n\nDo you want to add it automatically?",
|
||||
null,
|
||||
actions);
|
||||
if (response == Dialog.Actions.YES)
|
||||
addCountry(bankAccount.getCountry());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
<ComboBox fx:id="countryComboBox" onAction="#onAddCountry" visible="false" prefWidth="150.0" promptText="Add country"/>
|
||||
</HBox>
|
||||
|
||||
<Button onAction="#onAddArbitrator" text="Add arbitrator" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
|
||||
<Button onAction="#onOpenArbitratorScreen" text="Add arbitrator" GridPane.columnIndex="1" GridPane.rowIndex="5"/>
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints/>
|
||||
|
@ -196,6 +196,8 @@ public class CreateOfferController extends CachedViewController
|
||||
|
||||
private void setupBindings()
|
||||
{
|
||||
// TODO check that entered decimal places are nto exceeded supported
|
||||
|
||||
viewModel.amount.addListener((ov, oldValue, newValue) -> {
|
||||
double amount = BitSquareFormatter.parseToDouble(newValue);
|
||||
double price = BitSquareFormatter.parseToDouble(viewModel.price.get());
|
||||
@ -224,6 +226,17 @@ public class CreateOfferController extends CachedViewController
|
||||
}
|
||||
});
|
||||
|
||||
volumeTextField.focusedProperty().addListener((observableValue, oldValue, newValue) -> {
|
||||
if (oldValue && !newValue)
|
||||
{
|
||||
if (!volumeTextField.getText().equals(viewModel.volume.get()))
|
||||
{
|
||||
Popups.openWarningPopup("Warning", "The total volume you have entered leads to invalid fractional Bitcoin amounts.\nThe amount has been adjusted and a new total volume be calculated from it.");
|
||||
volumeTextField.setText(viewModel.volume.get());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
buyLabel.textProperty().bind(viewModel.directionLabel);
|
||||
amountTextField.textProperty().bindBidirectional(viewModel.amount);
|
||||
priceTextField.textProperty().bindBidirectional(viewModel.price);
|
||||
|
@ -132,7 +132,7 @@ public class BitSquareFormatter
|
||||
|
||||
public static String formatDouble(double value)
|
||||
{
|
||||
return formatDouble(value, 2);
|
||||
return formatDouble(value, 4);
|
||||
}
|
||||
|
||||
public static String formatDouble(double value, int fractionDigits)
|
||||
|
@ -33,9 +33,13 @@ public class LanguageUtil
|
||||
return allLocales;
|
||||
}
|
||||
|
||||
|
||||
public static Locale getDefaultLanguageLocale()
|
||||
{
|
||||
return new Locale(Locale.getDefault().getLanguage(), "");
|
||||
}
|
||||
|
||||
public static Locale getEnglishLanguageLocale()
|
||||
{
|
||||
return new Locale(Locale.ENGLISH.getLanguage(), "");
|
||||
}
|
||||
}
|
||||
|
@ -23,29 +23,32 @@
|
||||
</root>
|
||||
|
||||
<logger name="io.bitsquare" level="TRACE"/>
|
||||
|
||||
<logger name="com.google.bitcoin" level="WARN"/>
|
||||
|
||||
|
||||
<logger name="net.tomp2p" level="WARN"/>
|
||||
|
||||
<logger name="io.netty.util" level="WARN"/>
|
||||
<logger name="io.netty.channel" level="WARN"/>
|
||||
<logger name="io.netty.buffer" level="WARN"/>
|
||||
|
||||
|
||||
<!--
|
||||
<logger name="com.google.bitcoin.core.Wallet" level="INFO"/>
|
||||
<logger name="com.google.bitcoin.core.MemoryPool" level="WARN" additivity="false"/>
|
||||
<logger name="com.google.bitcoin.net.discovery.DnsDiscovery" level="WARN" additivity="false"/>
|
||||
|
||||
<logger name="com.google.bitcoin.core.DownloadListener" level="WARN" additivity="false"/>
|
||||
<logger name="com.google.bitcoin.core.TransactionOutput" level="WARN" additivity="false"/>
|
||||
<logger name="com.google.bitcoin.core.BitcoinSerializer" level="WARN" additivity="false"/>
|
||||
<logger name="com.google.bitcoin.core.Peer" level="WARN" additivity="false"/>
|
||||
<logger name="com.google.bitcoin.core.PeerGroup" level="WARN" additivity="false"/>
|
||||
<logger name="com.google.bitcoin.core.PeerSocketHandler" level="WARN" additivity="false"/>
|
||||
<logger name="com.google.bitcoin.net.NioClientManager" level="WARN" additivity="false"/>
|
||||
<logger name="com.google.bitcoin.net.ConnectionHandler" level="WARN" additivity="false"/>
|
||||
-->
|
||||
<logger name="io.bitsquare.gui.ViewController" level="OFF"/>
|
||||
<logger name="io.bitsquare.gui.CachedViewController" level="OFF"/>
|
||||
<logger name="io.bitsquare.gui.util.Profiler" level="OFF"/>
|
||||
|
||||
|
||||
<logger name="com.google.bitcoin.core.Wallet" level="OFF"/>
|
||||
<logger name="com.google.bitcoin.core.MemoryPool" level="OFF"/>
|
||||
<logger name="com.google.bitcoin.net.discovery.DnsDiscovery" level="OFF"/>
|
||||
|
||||
<logger name="com.google.bitcoin.core.DownloadListener" level="OFF"/>
|
||||
<logger name="com.google.bitcoin.core.TransactionOutput" level="OFF"/>
|
||||
<logger name="com.google.bitcoin.core.BitcoinSerializer" level="OFF"/>
|
||||
<logger name="com.google.bitcoin.core.Peer" level="OFF"/>
|
||||
<logger name="com.google.bitcoin.core.PeerGroup" level="OFF"/>
|
||||
<logger name="com.google.bitcoin.core.PeerSocketHandler" level="OFF"/>
|
||||
<logger name="com.google.bitcoin.net.NioClientManager" level="OFF"/>
|
||||
<logger name="com.google.bitcoin.net.ConnectionHandler" level="OFF"/>
|
||||
-->
|
||||
|
||||
</configuration>
|
||||
|
Loading…
Reference in New Issue
Block a user