remove filter, add country flags, add account selector, update models

This commit is contained in:
Manfred Karrer 2014-04-29 02:28:53 +02:00
parent 8856e31d78
commit a3bee7652b
261 changed files with 628 additions and 367 deletions

View File

@ -1,6 +1,7 @@
package io.bitsquare.bank; package io.bitsquare.bank;
import java.io.Serializable; import java.io.Serializable;
import java.util.Currency;
import java.util.Locale; import java.util.Locale;
public class BankAccount implements Serializable public class BankAccount implements Serializable
@ -13,25 +14,27 @@ public class BankAccount implements Serializable
private String accountPrimaryID; private String accountPrimaryID;
private String accountSecondaryID; private String accountSecondaryID;
private String accountHolderName; private String accountHolderName;
private Locale locale; private Locale countryLocale;
private Currency currency;
private String uid; private String uid;
// TODO just for mock yet // TODO just for mock yet
public BankAccount(BankAccountType bankAccountType) public BankAccount(BankAccountType bankAccountType)
{ {
this.bankAccountType = bankAccountType; this.bankAccountType = bankAccountType;
} }
public BankAccount(BankAccountType bankAccountType, String accountPrimaryID, String accountSecondaryID, String accountHolderName, Locale locale) public BankAccount(BankAccountType bankAccountType, String accountPrimaryID, String accountSecondaryID, String accountHolderName, Locale countryLocale, Currency currency)
{ {
this.bankAccountType = bankAccountType; this.bankAccountType = bankAccountType;
this.accountPrimaryID = accountPrimaryID; this.accountPrimaryID = accountPrimaryID;
this.accountSecondaryID = accountSecondaryID; this.accountSecondaryID = accountSecondaryID;
this.accountHolderName = accountHolderName; this.accountHolderName = accountHolderName;
this.locale = locale; this.countryLocale = countryLocale;
this.currency = currency;
uid = bankAccountType + "_" + accountPrimaryID + "_" + accountSecondaryID + "_" + accountHolderName + "_" + locale.getISO3Country(); uid = bankAccountType + "_" + accountPrimaryID + "_" + accountSecondaryID + "_" + accountHolderName + "_" + countryLocale.getISO3Country();
} }
public String getAccountPrimaryID() public String getAccountPrimaryID()
@ -54,6 +57,16 @@ public class BankAccount implements Serializable
return bankAccountType; return bankAccountType;
} }
public Currency getCurrency()
{
return currency;
}
public Locale getCountryLocale()
{
return countryLocale;
}
public String getUid() public String getUid()
{ {
return uid; return uid;
@ -67,8 +80,16 @@ public class BankAccount implements Serializable
", primaryID='" + accountPrimaryID + '\'' + ", primaryID='" + accountPrimaryID + '\'' +
", secondaryID='" + accountSecondaryID + '\'' + ", secondaryID='" + accountSecondaryID + '\'' +
", holderName='" + accountHolderName + '\'' + ", holderName='" + accountHolderName + '\'' +
", country='" + locale.getISO3Country() + '\'' + ", currency='" + currency.getCurrencyCode() + '\'' +
", country='" + countryLocale.getISO3Country() + '\'' +
", v='" + VERSION + '\'' + ", v='" + VERSION + '\'' +
'}'; '}';
} }
public String getShortName()
{
return bankAccountType + " " + accountPrimaryID + " / " + accountSecondaryID + " / " + currency.getCurrencyCode();
}
} }

View File

@ -16,8 +16,10 @@ public class WalletUtil
Transaction transaction = WalletUtil.getTransaction(wallet); Transaction transaction = WalletUtil.getTransaction(wallet);
if (transaction != null && transaction.getConfidence() != null) if (transaction != null && transaction.getConfidence() != null)
{ {
int appearedAtChainHeight = (transaction.getConfidence().getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) ? transaction.getConfidence().getAppearedAtChainHeight() : 0; if (transaction.getConfidence().getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING)
return wallet.getLastBlockSeenHeight() - appearedAtChainHeight + 1; return wallet.getLastBlockSeenHeight() - transaction.getConfidence().getAppearedAtChainHeight() + 1;
else
return 0;
} }
else else
{ {

View File

@ -1,6 +1,7 @@
package io.bitsquare.gui; package io.bitsquare.gui;
import com.google.inject.Inject; import com.google.inject.Inject;
import io.bitsquare.bank.BankAccount;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletFacade;
import io.bitsquare.di.GuiceFXMLLoader; import io.bitsquare.di.GuiceFXMLLoader;
import io.bitsquare.gui.components.NetworkSyncPane; import io.bitsquare.gui.components.NetworkSyncPane;
@ -25,12 +26,12 @@ import javafx.scene.control.*;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.util.StringConverter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.Currency;
import java.util.Date; import java.util.Date;
import java.util.ResourceBundle; import java.util.ResourceBundle;
@ -171,7 +172,7 @@ public class MainController implements Initializable, NavigationController, Wall
addNavButton(leftNavPane, "Funds", Icons.FUNDS, Icons.FUNDS, NavigationController.FUNDS); addNavButton(leftNavPane, "Funds", Icons.FUNDS, Icons.FUNDS, NavigationController.FUNDS);
addNavButton(leftNavPane, "Message", Icons.MSG, Icons.MSG, NavigationController.MSG); addNavButton(leftNavPane, "Message", Icons.MSG, Icons.MSG, NavigationController.MSG);
addBalanceInfo(rightNavPane); addBalanceInfo(rightNavPane);
addCurrencyComboBox(); addAccountComboBox();
addNavButton(rightNavPane, "Settings", Icons.SETTINGS, Icons.SETTINGS, NavigationController.SETTINGS); addNavButton(rightNavPane, "Settings", Icons.SETTINGS, Icons.SETTINGS, NavigationController.SETTINGS);
@ -255,24 +256,44 @@ public class MainController implements Initializable, NavigationController, Wall
return balanceLabel; return balanceLabel;
} }
private void addCurrencyComboBox() private void addAccountComboBox()
{ {
Pane holder = new Pane(); if (user.getBankAccounts().size() > 1)
ComboBox currencyComboBox = new ComboBox(FXCollections.observableArrayList(settings.getAllCurrencies()));
currencyComboBox.setLayoutY(12);
currencyComboBox.setValue(Settings.getCurrency());
currencyComboBox.valueProperty().addListener(new ChangeListener<Currency>()
{ {
@Override ComboBox accountComboBox = new ComboBox(FXCollections.observableArrayList(user.getBankAccounts()));
public void changed(ObservableValue ov, Currency oldValue, Currency newValue) accountComboBox.setLayoutY(12);
accountComboBox.setValue(user.getCurrentBankAccount());
accountComboBox.setConverter(new StringConverter<BankAccount>()
{ {
orderBookFilter.setCurrency(newValue); @Override
settings.setCurrency(newValue); public String toString(BankAccount bankAccount)
} {
}); return bankAccount.getShortName();
holder.getChildren().add(currencyComboBox); }
rightNavPane.getChildren().add(holder);
@Override
public BankAccount fromString(String s)
{
return null;
}
});
accountComboBox.valueProperty().addListener(new ChangeListener<BankAccount>()
{
@Override
public void changed(ObservableValue ov, BankAccount oldValue, BankAccount newValue)
{
user.setCurrentBankAccount(newValue);
orderBookFilter.setCurrency(newValue.getCurrency());
orderBookFilter.setCountryLocale(newValue.getCountryLocale());
}
});
Pane holder = new Pane();
holder.getChildren().add(accountComboBox);
rightNavPane.getChildren().add(holder);
}
} }

View File

@ -50,7 +50,8 @@ public class SetupController implements Initializable, ChildController, WalletFa
private NavigationController navigationController; private NavigationController navigationController;
private ImageView confirmIconImageView; private ImageView confirmIconImageView;
private TextField balanceLabel, confirmationsLabel, accountHolderName, accountPrimaryID, accountSecondaryID; private TextField balanceLabel, confirmationsLabel, accountHolderName, accountPrimaryID, accountSecondaryID;
private ComboBox countryComboBox, bankTransferTypeComboBox; private ComboBox countryComboBox, bankTransferTypeComboBox, currencyComboBox;
private Button addBankAccountButton;
@FXML @FXML
private AnchorPane rootContainer; private AnchorPane rootContainer;
@ -123,15 +124,19 @@ public class SetupController implements Initializable, ChildController, WalletFa
} }
// TODO need checks per bankTransferType // TODO need checks per bankTransferType
private boolean verifyBankAccountData(Object bankTransferTypeSelectedItem, String accountPrimaryID, String accountSecondaryID, String accountHolderName) private boolean verifyBankAccountData()
{ {
boolean result = bankTransferTypeSelectedItem != null; boolean accountIDsByBankTransferTypeValid = Verification.verifyAccountIDsByBankTransferType(bankTransferTypeComboBox.getSelectionModel().getSelectedItem(),
result &= bankTransferTypeSelectedItem.toString().length() > 0; accountPrimaryID.getText(),
result &= accountPrimaryID.length() > 0; accountSecondaryID.getText());
result &= accountSecondaryID.length() > 0;
result &= accountHolderName.length() > 0; return bankTransferTypeComboBox.getSelectionModel().getSelectedItem() != null
result &= Verification.verifyAccountIDsByBankTransferType(bankTransferTypeSelectedItem, accountPrimaryID, accountSecondaryID); && countryComboBox.getSelectionModel().getSelectedItem() != null
return result; && currencyComboBox.getSelectionModel().getSelectedItem() != null
&& accountPrimaryID.getText().length() > 0
&& accountSecondaryID.getText().length() > 0
&& accountHolderName.getText().length() > 0
&& accountIDsByBankTransferTypeValid;
} }
private Image getConfirmIconImage(int numBroadcastPeers, int depthInBlocks) private Image getConfirmIconImage(int numBroadcastPeers, int depthInBlocks)
@ -222,35 +227,52 @@ public class SetupController implements Initializable, ChildController, WalletFa
accountPrimaryID = FormBuilder.addInputField(formGridPane, "Bank account primary ID", "", ++gridRow); accountPrimaryID = FormBuilder.addInputField(formGridPane, "Bank account primary ID", "", ++gridRow);
accountSecondaryID = FormBuilder.addInputField(formGridPane, "Bank account secondary ID:", "", ++gridRow); accountSecondaryID = FormBuilder.addInputField(formGridPane, "Bank account secondary ID:", "", ++gridRow);
countryComboBox = FormBuilder.addComboBox(formGridPane, "Country:", settings.getAllLocales("displayCountry"), ++gridRow); currencyComboBox = FormBuilder.addComboBox(formGridPane, "Currency used for bank account:", settings.getAllCurrencies(), ++gridRow);
countryComboBox.setPromptText("Select country"); currencyComboBox.setPromptText("Select currency");
countryComboBox.setConverter(new StringConverter() currencyComboBox.setConverter(new StringConverter<Currency>()
{ {
@Override @Override
public String toString(Object o) public String toString(Currency currency)
{ {
return ((Locale) o).getDisplayCountry(); return currency.getCurrencyCode() + " (" + currency.getDisplayName() + ")";
} }
@Override @Override
public Object fromString(String s) public Currency fromString(String s)
{ {
return s; return null;
}
});
countryComboBox = FormBuilder.addComboBox(formGridPane, "Country of bank account:", settings.getAllLocales(), ++gridRow);
countryComboBox.setPromptText("Select country");
countryComboBox.setConverter(new StringConverter<Locale>()
{
@Override
public String toString(Locale locale)
{
return locale.getDisplayCountry();
}
@Override
public Locale fromString(String s)
{
return null;
} }
}); });
Button addButton = new Button("Add other Bank account"); addBankAccountButton = new Button("Add other Bank account");
formGridPane.add(addButton, 1, ++gridRow); formGridPane.add(addBankAccountButton, 1, ++gridRow);
nextButton.setText("Create account"); nextButton.setText("Create account");
checkCreateAccountButtonState(); checkCreateAccountButtonState();
skipButton.setText("Register later"); skipButton.setText("Register later");
// handlers // handlers
accountHolderName.focusedProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState()); accountHolderName.textProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState());
accountPrimaryID.focusedProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState()); accountPrimaryID.textProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState());
accountSecondaryID.focusedProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState()); accountSecondaryID.textProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState());
bankTransferTypeComboBox.valueProperty().addListener((ov, oldValue, newValue) -> { bankTransferTypeComboBox.valueProperty().addListener((ov, oldValue, newValue) -> {
if (newValue != null && newValue instanceof BankAccountType) if (newValue != null && newValue instanceof BankAccountType)
@ -265,31 +287,13 @@ public class SetupController implements Initializable, ChildController, WalletFa
} }
}); });
countryComboBox.valueProperty().addListener((ov, oldValue, newValue) -> { currencyComboBox.valueProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState());
if (newValue != null && newValue instanceof BankAccountType) countryComboBox.valueProperty().addListener((ov, oldValue, newValue) -> checkCreateAccountButtonState());
{
if (newValue != null)
{
checkCreateAccountButtonState();
}
}
});
addButton.setOnAction(e -> { addBankAccountButton.setOnAction(e -> {
if (bankTransferTypeComboBox.getSelectionModel() != null addBankAccount();
&& verifyBankAccountData(bankTransferTypeComboBox.getSelectionModel().getSelectedItem(), if (verifyBankAccountData())
accountPrimaryID.getText(),
accountSecondaryID.getText(),
accountHolderName.getText()))
{ {
user.addBankAccount(new BankAccount(
(BankAccountType) bankTransferTypeComboBox.getSelectionModel().getSelectedItem(),
accountPrimaryID.getText(),
accountSecondaryID.getText(),
accountHolderName.getText(),
(Locale) countryComboBox.getSelectionModel().getSelectedItem())
);
bankTransferTypeComboBox.getSelectionModel().clearSelection(); bankTransferTypeComboBox.getSelectionModel().clearSelection();
accountPrimaryID.setText(""); accountPrimaryID.setText("");
accountPrimaryID.setPromptText(""); accountPrimaryID.setPromptText("");
@ -299,21 +303,7 @@ public class SetupController implements Initializable, ChildController, WalletFa
}); });
nextButton.setOnAction(e -> { nextButton.setOnAction(e -> {
boolean inputValid = verifyBankAccountData(bankTransferTypeComboBox.getSelectionModel().getSelectedItem(), addBankAccount();
accountPrimaryID.getText(),
accountSecondaryID.getText(),
accountHolderName.getText());
if (bankTransferTypeComboBox.getSelectionModel() != null && countryComboBox.getSelectionModel() != null && inputValid)
{
BankAccount bankAccount = new BankAccount((BankAccountType) bankTransferTypeComboBox.getSelectionModel().getSelectedItem(),
accountPrimaryID.getText(),
accountSecondaryID.getText(),
accountHolderName.getText(),
(Locale) countryComboBox.getSelectionModel().getSelectedItem());
user.addBankAccount(bankAccount);
}
if (user.getBankAccounts().size() > 0) if (user.getBankAccounts().size() > 0)
{ {
@ -342,16 +332,24 @@ public class SetupController implements Initializable, ChildController, WalletFa
skipButton.setOnAction(e -> close()); skipButton.setOnAction(e -> close());
} }
private void addBankAccount()
{
if (verifyBankAccountData())
{
BankAccount bankAccount = new BankAccount((BankAccountType) bankTransferTypeComboBox.getSelectionModel().getSelectedItem(),
accountPrimaryID.getText(),
accountSecondaryID.getText(),
accountHolderName.getText(),
(Locale) countryComboBox.getSelectionModel().getSelectedItem(),
(Currency) currencyComboBox.getSelectionModel().getSelectedItem());
user.addBankAccount(bankAccount);
}
}
private void checkCreateAccountButtonState() private void checkCreateAccountButtonState()
{ {
boolean enabled = accountHolderName.getText().length() > 0 nextButton.setDisable(!verifyBankAccountData());
&& accountPrimaryID.getText().length() > 0 addBankAccountButton.setDisable(!verifyBankAccountData());
&& accountSecondaryID.getText().length() > 0
&& bankTransferTypeComboBox.getSelectionModel() != null
&& bankTransferTypeComboBox.getSelectionModel().getSelectedItem() != null
&& countryComboBox.getSelectionModel() != null
&& countryComboBox.getSelectionModel().getSelectedItem() != null;
nextButton.setDisable(!enabled);
} }
private void buildStep2() private void buildStep2()
@ -361,8 +359,8 @@ public class SetupController implements Initializable, ChildController, WalletFa
formGridPane.getChildren().clear(); formGridPane.getChildren().clear();
int gridRow = -1; int gridRow = -1;
Map<String, BankAccount> bankAccounts = user.getBankAccounts(); List<BankAccount> bankAccounts = user.getBankAccounts();
Iterator iterator = bankAccounts.entrySet().iterator(); Iterator iterator = bankAccounts.iterator();
int index = 0; int index = 0;
while (iterator.hasNext()) while (iterator.hasNext())
{ {

View File

@ -1,6 +1,7 @@
package io.bitsquare.gui.trade.orderbook; package io.bitsquare.gui.trade.orderbook;
import com.google.inject.Inject; import com.google.inject.Inject;
import io.bitsquare.bank.BankAccountType;
import io.bitsquare.gui.ChildController; import io.bitsquare.gui.ChildController;
import io.bitsquare.gui.NavigationController; import io.bitsquare.gui.NavigationController;
import io.bitsquare.gui.trade.offer.CreateOfferController; import io.bitsquare.gui.trade.offer.CreateOfferController;
@ -8,36 +9,39 @@ import io.bitsquare.gui.trade.tradeprocess.TradeProcessController;
import io.bitsquare.gui.util.Converter; import io.bitsquare.gui.util.Converter;
import io.bitsquare.gui.util.Formatter; import io.bitsquare.gui.util.Formatter;
import io.bitsquare.gui.util.Icons; import io.bitsquare.gui.util.Icons;
import io.bitsquare.gui.util.Localisation;
import io.bitsquare.settings.Settings; import io.bitsquare.settings.Settings;
import io.bitsquare.trade.Direction; import io.bitsquare.trade.Direction;
import io.bitsquare.trade.orderbook.OrderBook; import io.bitsquare.trade.orderbook.OrderBook;
import io.bitsquare.trade.orderbook.OrderBookFilter; import io.bitsquare.trade.orderbook.OrderBookFilter;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.value.ChangeListener; import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.control.Button; import javafx.geometry.Pos;
import javafx.scene.control.TableColumn; import javafx.scene.control.*;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane; import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane; import javafx.util.Callback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URL; import java.net.URL;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.ParseException; import java.text.ParseException;
import java.util.Arrays; import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle; import java.util.ResourceBundle;
public class OrderBookController implements Initializable, ChildController public class OrderBookController implements Initializable, ChildController
{ {
private static final Logger log = LoggerFactory.getLogger(OrderBookController.class);
private NavigationController navigationController; private NavigationController navigationController;
private OrderBook orderBook; private OrderBook orderBook;
private Settings settings;
private OrderBookListItem selectedOrderBookListItem; private OrderBookListItem selectedOrderBookListItem;
private final OrderBookFilter orderBookFilter; private final OrderBookFilter orderBookFilter;
@ -51,41 +55,27 @@ public class OrderBookController implements Initializable, ChildController
@FXML @FXML
public HBox topHBox; public HBox topHBox;
@FXML @FXML
private Button tradeButton;
@FXML
public TextField volume, amount, price; public TextField volume, amount, price;
@FXML @FXML
public Pane filterPane;
@FXML
public TableView<OrderBookListItem> orderBookTable; public TableView<OrderBookListItem> orderBookTable;
@FXML @FXML
public TableColumn priceColumn, amountColumn, volumeColumn; public TableColumn priceColumn, amountColumn, volumeColumn;
@FXML @FXML
private ImageView tradeButtonImageView; private TableColumn<OrderBookListItem, OrderBookListItem> directionColumn, countryColumn, bankAccountTypeColumn;
@Inject @Inject
public OrderBookController(OrderBook orderBook, OrderBookFilter orderBookFilter, Settings settings) public OrderBookController(OrderBook orderBook, OrderBookFilter orderBookFilter)
{ {
this.orderBook = orderBook; this.orderBook = orderBook;
this.orderBookFilter = orderBookFilter; this.orderBookFilter = orderBookFilter;
this.settings = settings;
} }
@Override @Override
public void initialize(URL url, ResourceBundle rb) public void initialize(URL url, ResourceBundle rb)
{ {
orderBookFilter.getCurrencyProperty().addListener(new ChangeListener<String>() setCountryColumnCellFactory();
{ setBankAccountTypeColumnCellFactory();
@Override setDirectionColumnCellFactory();
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue)
{
updateOfferList();
}
});
createFilterPane();
updateOfferList();
amount.textProperty().addListener(new ChangeListener<String>() amount.textProperty().addListener(new ChangeListener<String>()
{ {
@ -93,7 +83,6 @@ public class OrderBookController implements Initializable, ChildController
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue)
{ {
orderBookFilter.setAmount(textInputToNumber(oldValue, newValue)); orderBookFilter.setAmount(textInputToNumber(oldValue, newValue));
updateOfferList();
updateVolume(); updateVolume();
} }
}); });
@ -104,19 +93,24 @@ public class OrderBookController implements Initializable, ChildController
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue)
{ {
orderBookFilter.setPrice(textInputToNumber(oldValue, newValue)); orderBookFilter.setPrice(textInputToNumber(oldValue, newValue));
updateOfferList();
updateVolume(); updateVolume();
} }
}); });
orderBookTable.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> { orderBookTable.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
selectedOrderBookListItem = orderBookTable.getSelectionModel().getSelectedItem(); selectedOrderBookListItem = orderBookTable.getSelectionModel().getSelectedItem();
tradeButton.setDisable(selectedOrderBookListItem == null);
}); });
tradeButton.setOnAction(e -> openTradeTab(selectedOrderBookListItem)); orderBookFilter.getChangedProperty().addListener(new ChangeListener<Boolean>()
tradeButton.setDisable(true); {
tradeButton.setDefaultButton(true); @Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue)
{
updateOfferList();
}
});
updateOfferList();
} }
@Override @Override
@ -128,26 +122,8 @@ public class OrderBookController implements Initializable, ChildController
public void setDirection(Direction direction) public void setDirection(Direction direction)
{ {
orderBookTable.getSelectionModel().clearSelection(); orderBookTable.getSelectionModel().clearSelection();
tradeButton.setDisable(true);
price.setText(""); price.setText("");
String title;
Image icon;
if (direction == Direction.SELL)
{
title = "SELL";
icon = sellIcon;
}
else
{
title = "BUY";
icon = buyIcon;
}
tradeButton.setText(title);
tradeButtonImageView.setImage(icon);
orderBookFilter.setDirection(direction); orderBookFilter.setDirection(direction);
updateOfferList();
} }
private void openTradeTab(OrderBookListItem orderBookListItem) private void openTradeTab(OrderBookListItem orderBookListItem)
@ -167,8 +143,8 @@ public class OrderBookController implements Initializable, ChildController
if (createOfferButton == null) if (createOfferButton == null)
{ {
createOfferButton = new Button("Create new offer"); createOfferButton = new Button("Create new offer");
holderPane.setBottomAnchor(createOfferButton, 375.0); holderPane.setBottomAnchor(createOfferButton, 360.0);
holderPane.setLeftAnchor(createOfferButton, 200.0); holderPane.setLeftAnchor(createOfferButton, 10.0);
holderPane.getChildren().add(createOfferButton); holderPane.getChildren().add(createOfferButton);
createOfferButton.setOnAction(e -> { createOfferButton.setOnAction(e -> {
@ -178,7 +154,7 @@ public class OrderBookController implements Initializable, ChildController
} }
createOfferButton.setVisible(true); createOfferButton.setVisible(true);
holderPane.setBottomAnchor(orderBookTable, 410.0); holderPane.setBottomAnchor(orderBookTable, 390.0);
} }
private void updateOfferList() private void updateOfferList()
@ -199,18 +175,167 @@ public class OrderBookController implements Initializable, ChildController
} }
} }
private void createFilterPane() private void setDirectionColumnCellFactory()
{ {
OrderBook mockOrderBook = new OrderBook(settings); directionColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue()));
orderBookFilter.setOfferConstraints(mockOrderBook.getRandomOfferConstraints()); directionColumn.setCellFactory(new Callback<TableColumn<OrderBookListItem, OrderBookListItem>, TableCell<OrderBookListItem, OrderBookListItem>>()
{
@Override
public TableCell<OrderBookListItem, OrderBookListItem> call(TableColumn<OrderBookListItem, OrderBookListItem> directionColumn)
{
return new TableCell<OrderBookListItem, OrderBookListItem>()
{
final ImageView iconView = new ImageView();
final Button button = new Button();
//OrderBookFilterTextItemBuilder.build(filterPane, "Bank transfer types: ", orderBookFilter.getOfferConstraints().getBankAccountTypes(), settings.getAllBankAccountTypes()); {
OrderBookFilterTextItemBuilder.build(filterPane, "Countries: ", orderBookFilter.getOfferConstraints().getCountries(), settings.getAllCountries()); button.setGraphic(iconView);
OrderBookFilterTextItemBuilder.build(filterPane, "Languages: ", orderBookFilter.getOfferConstraints().getLanguages(), settings.getAllLanguages()); button.setMinWidth(70);
OrderBookFilterTextItemBuilder.build(filterPane, "Collateral: ", Arrays.asList(String.valueOf(orderBookFilter.getOfferConstraints().getCollateral())), settings.getAllCollaterals()); }
OrderBookFilterTextItemBuilder.build(filterPane, "Arbitrator: ", Arrays.asList(orderBookFilter.getOfferConstraints().getArbitrator()), settings.getAllArbitrators());
@Override
public void updateItem(final OrderBookListItem orderBookListItem, boolean empty)
{
super.updateItem(orderBookListItem, empty);
if (orderBookListItem != null)
{
String title;
Image icon;
if (orderBookListItem.getOffer().getDirection() == Direction.SELL)
{
icon = buyIcon;
title = Formatter.formatDirection(Direction.BUY, true);
}
else
{
icon = sellIcon;
title = Formatter.formatDirection(Direction.SELL, true);
}
iconView.setImage(icon);
button.setText(title);
setGraphic(button);
button.setOnAction(event -> openTradeTab(orderBookListItem));
}
else
{
setGraphic(null);
}
}
};
}
});
} }
private void setCountryColumnCellFactory()
{
countryColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue()));
countryColumn.setCellFactory(new Callback<TableColumn<OrderBookListItem, OrderBookListItem>, TableCell<OrderBookListItem, OrderBookListItem>>()
{
@Override
public TableCell<OrderBookListItem, OrderBookListItem> call(TableColumn<OrderBookListItem, OrderBookListItem> directionColumn)
{
return new TableCell<OrderBookListItem, OrderBookListItem>()
{
final HBox hBox = new HBox();
{
hBox.setSpacing(3);
hBox.setAlignment(Pos.CENTER);
setGraphic(hBox);
}
@Override
public void updateItem(final OrderBookListItem orderBookListItem, boolean empty)
{
super.updateItem(orderBookListItem, empty);
if (orderBookListItem != null)
{
hBox.getChildren().clear();
setText("");
List<Locale> countryLocales = orderBookListItem.getOffer().getOfferConstraints().getCountryLocales();
int i = 0;
String countries = "";
for (Locale countryLocale : countryLocales)
{
countries += countryLocale.getDisplayCountry();
if (i < countryLocales.size() - 1)
countries += ", ";
if (i < 4)
{
try
{
ImageView imageView = Icons.getIconImageView("/images/countries/" + countryLocale.getCountry().toLowerCase() + ".png");
hBox.getChildren().add(imageView);
} catch (Exception e)
{
log.warn("Country icon not found: " + "/images/countries/" + countryLocale.getCountry().toLowerCase() + ".png country name: " + countryLocale.getDisplayCountry());
}
}
else
{
setText("...");
}
i++;
}
Tooltip.install(this, new Tooltip(countries));
}
else
{
setText("");
hBox.getChildren().clear();
}
}
};
}
});
}
private void setBankAccountTypeColumnCellFactory()
{
bankAccountTypeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper(offer.getValue()));
bankAccountTypeColumn.setCellFactory(new Callback<TableColumn<OrderBookListItem, OrderBookListItem>, TableCell<OrderBookListItem, OrderBookListItem>>()
{
@Override
public TableCell<OrderBookListItem, OrderBookListItem> call(TableColumn<OrderBookListItem, OrderBookListItem> directionColumn)
{
return new TableCell<OrderBookListItem, OrderBookListItem>()
{
@Override
public void updateItem(final OrderBookListItem orderBookListItem, boolean empty)
{
super.updateItem(orderBookListItem, empty);
if (orderBookListItem != null)
{
List<BankAccountType.BankAccountTypeEnum> bankAccountTypeEnums = orderBookListItem.getOffer().getOfferConstraints().getBankAccountTypes();
String text = "";
int i = 0;
for (BankAccountType.BankAccountTypeEnum bankAccountTypeEnum : bankAccountTypeEnums)
{
text += Localisation.get(bankAccountTypeEnum.toString());
i++;
if (i < bankAccountTypeEnums.size())
text += ", ";
}
setText(text);
if (text.length() > 20)
Tooltip.install(this, new Tooltip(text));
}
else
{
setText("");
}
}
};
}
});
}
private double textInputToNumber(String oldValue, String newValue) private double textInputToNumber(String oldValue, String newValue)
{ {

View File

@ -1,10 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import io.bitsquare.gui.components.HSpacer?>
<?import javafx.geometry.*?> <?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.control.cell.PropertyValueFactory?> <?import javafx.scene.control.cell.PropertyValueFactory?>
<?import javafx.scene.image.ImageView?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane fx:id="holderPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" <AnchorPane fx:id="holderPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns:fx="http://javafx.com/fxml/1" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns:fx="http://javafx.com/fxml/1"
@ -14,14 +12,6 @@
<HBox fx:id="topHBox" prefHeight="22.0" AnchorPane.topAnchor="10.0" AnchorPane.leftAnchor="10.0" <HBox fx:id="topHBox" prefHeight="22.0" AnchorPane.topAnchor="10.0" AnchorPane.leftAnchor="10.0"
AnchorPane.rightAnchor="10.0"> AnchorPane.rightAnchor="10.0">
<children> <children>
<Label text="Filter:" prefWidth="190" id="form-header-text"/>
<Button fx:id="tradeButton">
<graphic>
<ImageView fx:id="tradeButtonImageView"/>
</graphic>
</Button>
<HSpacer prefWidth="10"/>
<TextField fx:id="amount" prefHeight="26.0" prefWidth="60.0" alignment="CENTER_RIGHT"> <TextField fx:id="amount" prefHeight="26.0" prefWidth="60.0" alignment="CENTER_RIGHT">
<HBox.margin> <HBox.margin>
<Insets left="0.0"/> <Insets left="0.0"/>
@ -50,29 +40,27 @@
</children> </children>
</HBox> </HBox>
<VBox fx:id="filterPane" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="40.0" <TableView fx:id="orderBookTable" id="orderbook-table" AnchorPane.leftAnchor="10.0"
AnchorPane.bottomAnchor="10.0" prefWidth="180.0">
<Separator prefWidth="190"/>
</VBox>
<TableView fx:id="orderBookTable" id="orderbook-table" AnchorPane.leftAnchor="200.0"
AnchorPane.topAnchor="40.0" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="10.0"> AnchorPane.topAnchor="40.0" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="10.0">
<columns> <columns>
<TableColumn text="Amount (Min.)" fx:id="amountColumn" prefWidth="210"> <TableColumn text="Amount (Min.)" fx:id="amountColumn" prefWidth="120">
<cellValueFactory> <cellValueFactory>
<PropertyValueFactory property="amount"/> <PropertyValueFactory property="amount"/>
</cellValueFactory> </cellValueFactory>
</TableColumn> </TableColumn>
<TableColumn text="Price" fx:id="priceColumn" prefWidth="160"> <TableColumn text="Price" fx:id="priceColumn" prefWidth="100">
<cellValueFactory> <cellValueFactory>
<PropertyValueFactory property="price"/> <PropertyValueFactory property="price"/>
</cellValueFactory> </cellValueFactory>
</TableColumn> </TableColumn>
<TableColumn text="Volume (Min.)" fx:id="volumeColumn" prefWidth="200"> <TableColumn text="Volume (Min.)" fx:id="volumeColumn" prefWidth="160">
<cellValueFactory> <cellValueFactory>
<PropertyValueFactory property="volume"/> <PropertyValueFactory property="volume"/>
</cellValueFactory> </cellValueFactory>
</TableColumn> </TableColumn>
<TableColumn text="Country" fx:id="countryColumn" prefWidth="100" sortable="false"/>
<TableColumn text="Bank transfer type" fx:id="bankAccountTypeColumn" prefWidth="180"/>
<TableColumn text="" fx:id="directionColumn" prefWidth="100" sortable="false"/>
</columns> </columns>
</TableView> </TableView>

View File

@ -288,7 +288,7 @@ public class TradeProcessController implements Initializable, ChildController
FormBuilder.addLabel(contractGridPane, "Price:", Formatter.formatPriceWithCurrencyPair(offer.getPrice(), offer.getCurrency()), ++row); FormBuilder.addLabel(contractGridPane, "Price:", Formatter.formatPriceWithCurrencyPair(offer.getPrice(), offer.getCurrency()), ++row);
collateralLabel2 = FormBuilder.addLabel(contractGridPane, "Collateral:", "", ++row); collateralLabel2 = FormBuilder.addLabel(contractGridPane, "Collateral:", "", ++row);
setCollateral(); setCollateral();
FormBuilder.addLabel(contractGridPane, "Language:", Formatter.formatList(offerConstraints.getLanguages()), ++row); // FormBuilder.addLabel(contractGridPane, "Language:", Formatter.formatList(offerConstraints.getLanguageLocales()), ++row);
FormBuilder.addLabel(contractGridPane, "Arbitrator:", offerConstraints.getArbitrator(), ++row); FormBuilder.addLabel(contractGridPane, "Arbitrator:", offerConstraints.getArbitrator(), ++row);
// FormBuilder.addLabel(contractGridPane, "Identity verification:", Formatter.formatList(offerConstraints.getIdentityVerifications()), ++row); // FormBuilder.addLabel(contractGridPane, "Identity verification:", Formatter.formatList(offerConstraints.getIdentityVerifications()), ++row);
FormBuilder.addLabel(contractGridPane, "Bank transfer reference ID:", "Purchase xyz 01.04.2014", ++row); FormBuilder.addLabel(contractGridPane, "Bank transfer reference ID:", "Purchase xyz 01.04.2014", ++row);
@ -297,7 +297,7 @@ public class TradeProcessController implements Initializable, ChildController
FormBuilder.addHeaderLabel(contractGridPane, "Offerer data:", ++row); FormBuilder.addHeaderLabel(contractGridPane, "Offerer data:", ++row);
FormBuilder.addLabel(contractGridPane, "Account ID:", offerer.getAccountID(), ++row); FormBuilder.addLabel(contractGridPane, "Account ID:", offerer.getAccountID(), ++row);
FormBuilder.addLabel(contractGridPane, "Messaging ID:", offerer.getMessageID(), ++row); FormBuilder.addLabel(contractGridPane, "Messaging ID:", offerer.getMessageID(), ++row);
FormBuilder.addLabel(contractGridPane, "Country:", offerer.getCountry(), ++row); //FormBuilder.addLabel(contractGridPane, "Country:", offerer.getCountry(), ++row);
offererPubKeyLabel = FormBuilder.addLabel(contractGridPane, "Payment public key:", contract.getOffererPubKey(), ++row); offererPubKeyLabel = FormBuilder.addLabel(contractGridPane, "Payment public key:", contract.getOffererPubKey(), ++row);
FormBuilder.addLabel(contractGridPane, "Bank transfer type:", offerer.getCurrentBankAccount().getBankAccountType().toString(), ++row); FormBuilder.addLabel(contractGridPane, "Bank transfer type:", offerer.getCurrentBankAccount().getBankAccountType().toString(), ++row);
offererAccountPrimaryID = FormBuilder.addLabel(contractGridPane, "Bank account IBAN:", offerer.getCurrentBankAccount().getAccountPrimaryID(), ++row); offererAccountPrimaryID = FormBuilder.addLabel(contractGridPane, "Bank account IBAN:", offerer.getCurrentBankAccount().getAccountPrimaryID(), ++row);
@ -308,7 +308,7 @@ public class TradeProcessController implements Initializable, ChildController
FormBuilder.addHeaderLabel(contractGridPane, "Offer taker data:", ++row); FormBuilder.addHeaderLabel(contractGridPane, "Offer taker data:", ++row);
FormBuilder.addLabel(contractGridPane, "Account ID:", taker.getAccountID(), ++row); FormBuilder.addLabel(contractGridPane, "Account ID:", taker.getAccountID(), ++row);
FormBuilder.addLabel(contractGridPane, "Messaging ID:", taker.getMessageID(), ++row); FormBuilder.addLabel(contractGridPane, "Messaging ID:", taker.getMessageID(), ++row);
FormBuilder.addLabel(contractGridPane, "Country:", taker.getCountry(), ++row); // FormBuilder.addLabel(contractGridPane, "Country:", taker.getCountry(), ++row);
FormBuilder.addLabel(contractGridPane, "Payment public key:", contract.getTakerPubKey(), ++row); FormBuilder.addLabel(contractGridPane, "Payment public key:", contract.getTakerPubKey(), ++row);
FormBuilder.addLabel(contractGridPane, "Bank transfer type:", taker.getCurrentBankAccount().getBankAccountType().toString(), ++row); FormBuilder.addLabel(contractGridPane, "Bank transfer type:", taker.getCurrentBankAccount().getBankAccountType().toString(), ++row);
FormBuilder.addLabel(contractGridPane, "Bank account IBAN:", taker.getCurrentBankAccount().getAccountPrimaryID(), ++row); FormBuilder.addLabel(contractGridPane, "Bank account IBAN:", taker.getCurrentBankAccount().getAccountPrimaryID(), ++row);

View File

@ -43,30 +43,81 @@ public class Settings
currency = Currency.getInstance("USD"); currency = Currency.getInstance("USD");
} }
public ArrayList<Locale> getAllLocales()
//TODO remove duplicated entries, insert separators
public ArrayList<Currency> getAllCurrencies()
{ {
ArrayList<Currency> currencies = new ArrayList<>(); ArrayList<Locale> list = new ArrayList<Locale>(Arrays.asList(Locale.getAvailableLocales()));
currencies.add(Currency.getInstance("USD")); list.removeIf(new Predicate<Locale>()
currencies.add(Currency.getInstance("EUR")); {
currencies.add(Currency.getInstance("CNY")); @Override
currencies.add(Currency.getInstance("RUB")); public boolean test(Locale locale)
{
return locale == null || locale.getCountry().equals("") || locale.getLanguage().equals("");
}
});
currencies.add(Currency.getInstance("JPY")); list.sort(new Comparator<Locale>()
currencies.add(Currency.getInstance("GBP")); {
currencies.add(Currency.getInstance("CAD")); @Override
currencies.add(Currency.getInstance("AUD")); public int compare(Locale locale1, Locale locale2)
currencies.add(Currency.getInstance("CHF")); {
currencies.add(Currency.getInstance("CNY")); return locale1.getDisplayCountry().compareTo(locale2.getDisplayCountry());
}
});
/* Set<Currency> otherCurrenciesSet = Currency.getAvailableCurrencies(); Locale defaultLocale = Locale.getDefault();
ArrayList<Currency> otherCurrenciesList = new ArrayList<>(); list.remove(defaultLocale);
otherCurrenciesList.addAll(otherCurrenciesSet); list.add(0, defaultLocale);
Collections.sort(otherCurrenciesList, new CurrencyComparator());
currencies.addAll(otherCurrenciesList); */ return list;
return currencies; }
public List<Currency> getAllCurrencies()
{
ArrayList<Currency> mainCurrencies = new ArrayList<>();
mainCurrencies.add(Currency.getInstance("USD"));
mainCurrencies.add(Currency.getInstance("EUR"));
mainCurrencies.add(Currency.getInstance("CNY"));
mainCurrencies.add(Currency.getInstance("RUB"));
mainCurrencies.add(Currency.getInstance("JPY"));
mainCurrencies.add(Currency.getInstance("GBP"));
mainCurrencies.add(Currency.getInstance("CAD"));
mainCurrencies.add(Currency.getInstance("AUD"));
mainCurrencies.add(Currency.getInstance("CHF"));
mainCurrencies.add(Currency.getInstance("CNY"));
Set<Currency> allCurrenciesSet = Currency.getAvailableCurrencies();
allCurrenciesSet.removeAll(mainCurrencies);
List<Currency> allCurrenciesList = new ArrayList<>(allCurrenciesSet);
allCurrenciesList.sort(new Comparator<Currency>()
{
@Override
public int compare(Currency a, Currency b)
{
return a.getCurrencyCode().compareTo(b.getCurrencyCode());
}
});
List<Currency> resultList = new ArrayList<>(mainCurrencies);
resultList.addAll(allCurrenciesList);
Currency defaultCurrency = Currency.getInstance(Locale.getDefault());
resultList.remove(defaultCurrency);
resultList.add(0, defaultCurrency);
return resultList;
}
public ArrayList<BankAccountType.BankAccountTypeEnum> getAllBankAccountTypeEnums()
{
ArrayList<BankAccountType.BankAccountTypeEnum> bankAccountTypeEnums = new ArrayList<>();
bankAccountTypeEnums.add(BankAccountType.BankAccountTypeEnum.SEPA);
bankAccountTypeEnums.add(BankAccountType.BankAccountTypeEnum.WIRE);
bankAccountTypeEnums.add(BankAccountType.BankAccountTypeEnum.INTERNATIONAL);
bankAccountTypeEnums.add(BankAccountType.BankAccountTypeEnum.OK_PAY);
bankAccountTypeEnums.add(BankAccountType.BankAccountTypeEnum.NET_TELLER);
bankAccountTypeEnums.add(BankAccountType.BankAccountTypeEnum.PERFECT_MONEY);
bankAccountTypeEnums.add(BankAccountType.BankAccountTypeEnum.OTHER);
return bankAccountTypeEnums;
} }
public ArrayList<BankAccountType> getAllBankAccountTypes() public ArrayList<BankAccountType> getAllBankAccountTypes()
@ -82,74 +133,6 @@ public class Settings
return bankTransferTypes; return bankTransferTypes;
} }
public ArrayList<String> getAllCountries()
{
ArrayList<String> bankTransferTypes = new ArrayList<>();
bankTransferTypes.add("USA");
bankTransferTypes.add("GB");
bankTransferTypes.add("DE");
bankTransferTypes.add("FR");
bankTransferTypes.add("ES");
bankTransferTypes.add("CH");
bankTransferTypes.add("RUS");
bankTransferTypes.add("AUS");
bankTransferTypes.add("CAN");
bankTransferTypes.add("AT");
return bankTransferTypes;
}
public ArrayList<Locale> getAllLocales(String sortField)
{
ArrayList<Locale> list = new ArrayList<Locale>(Arrays.asList(Locale.getAvailableLocales()));
list.removeIf(new Predicate<Locale>()
{
@Override
public boolean test(Locale locale)
{
return locale == null || locale.getCountry().equals("") || locale.getLanguage().equals("");
}
});
list.sort(new Comparator()
{
@Override
public int compare(Object o1, Object o2)
{
if (sortField.equals("displayCountry"))
return (((Locale) o1).getDisplayCountry()).compareTo(((Locale) o2).getDisplayCountry());
else
return 1;
}
});
Locale defaultLocale = Locale.getDefault();
list.remove(defaultLocale);
list.add(0, defaultLocale);
return list;
}
/*public ArrayList<String> getAllLanguages()
{
ArrayList<String> result = new ArrayList<>();
for (Locale locale : Locale.getAvailableLocales())
{
result.add(locale.getDisplayLanguage());
}
return result;
} */
public ArrayList<String> getAllLanguages()
{
ArrayList<String> bankTransferTypes = new ArrayList<>();
bankTransferTypes.add("English");
bankTransferTypes.add("Chinese");
bankTransferTypes.add("Spanish");
bankTransferTypes.add("Russian");
bankTransferTypes.add("French");
bankTransferTypes.add("Italian");
return bankTransferTypes;
}
public ArrayList<String> getAllArbitrators() public ArrayList<String> getAllArbitrators()
{ {

View File

@ -3,51 +3,59 @@ package io.bitsquare.trade;
import io.bitsquare.bank.BankAccountType; import io.bitsquare.bank.BankAccountType;
import java.util.List; import java.util.List;
import java.util.Locale;
public class OfferConstraints public class OfferConstraints
{ {
//TODO remove
private double collateral; private double collateral;
private List<String> countries;
private List<String> languages;
private List<BankAccountType> bankAccountTypes;
private String arbitrator; private String arbitrator;
private String identityVerification; private String identityVerification;
public OfferConstraints(List<String> countries, private List<Locale> countryLocales;
List<String> languages, private List<Locale> languageLocales;
private List<BankAccountType.BankAccountTypeEnum> bankAccountTypes;
public OfferConstraints(List<Locale> countryLocales,
List<Locale> languageLocales,
double collateral, double collateral,
List<BankAccountType> bankAccountTypes, List<BankAccountType.BankAccountTypeEnum> bankAccountTypes,
String arbitrator, String arbitrator,
String identityVerification) String identityVerification)
{ {
this.countries = countries; this.countryLocales = countryLocales;
this.languages = languages; this.languageLocales = languageLocales;
this.collateral = collateral;
this.bankAccountTypes = bankAccountTypes; this.bankAccountTypes = bankAccountTypes;
this.collateral = collateral;
this.arbitrator = arbitrator; this.arbitrator = arbitrator;
this.identityVerification = identityVerification; this.identityVerification = identityVerification;
} }
public double getCollateral()
/**
* @return List of ISO3 country codes
*/
public List<Locale> getCountryLocales()
{ {
return collateral; return countryLocales;
} }
public List<String> getCountries() /**
* @return List of ISO3 language codes
*/
public List<Locale> getLanguageLocales()
{ {
return countries; return languageLocales;
} }
public List<String> getLanguages() public List<BankAccountType.BankAccountTypeEnum> getBankAccountTypes()
{
return languages;
}
public List<BankAccountType> getBankAccountTypes()
{ {
return bankAccountTypes; return bankAccountTypes;
} }
public String getArbitrator() public String getArbitrator()
{ {
return arbitrator; return arbitrator;
@ -57,4 +65,9 @@ public class OfferConstraints
{ {
return identityVerification; return identityVerification;
} }
public double getCollateral()
{
return collateral;
}
} }

View File

@ -1,7 +1,6 @@
package io.bitsquare.trade.orderbook; package io.bitsquare.trade.orderbook;
import com.google.inject.Inject; import com.google.inject.Inject;
import io.bitsquare.bank.BankAccount;
import io.bitsquare.bank.BankAccountType; import io.bitsquare.bank.BankAccountType;
import io.bitsquare.gui.trade.orderbook.OrderBookListItem; import io.bitsquare.gui.trade.orderbook.OrderBookListItem;
import io.bitsquare.gui.util.Converter; import io.bitsquare.gui.util.Converter;
@ -30,7 +29,7 @@ public class OrderBook
orderBookListItems = FXCollections.observableArrayList(); orderBookListItems = FXCollections.observableArrayList();
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
{ {
orderBookListItems.add(getOfferListVO()); orderBookListItems.add(getOrderBookListItem());
} }
} }
@ -61,10 +60,9 @@ public class OrderBook
return result; return result;
} }
private OrderBookListItem getOfferListVO() private OrderBookListItem getOrderBookListItem()
{ {
Offer i = getOffer(); return new OrderBookListItem(getOffer());
return new OrderBookListItem(i);
} }
public ArrayList<Currency> getCurrencies() public ArrayList<Currency> getCurrencies()
@ -94,20 +92,17 @@ public class OrderBook
private Offer getOffer() private Offer getOffer()
{ {
User offerer = new User();
offerer.setAccountID(UUID.randomUUID().toString());
offerer.setMessageID(UUID.randomUUID().toString());
offerer.setOnline(Math.random() > 0.5 ? true : false);
offerer.setLanguageLocales(getLanguageLocales());
double amount = Math.random() * 10 + 0.1; double amount = Math.random() * 10 + 0.1;
amount = Converter.convertToDouble(Formatter.formatAmount(amount)); amount = Converter.convertToDouble(Formatter.formatAmount(amount));
double minAmount = Math.random() * amount; double minAmount = Math.random() * amount;
minAmount = Converter.convertToDouble(Formatter.formatAmount(minAmount)); minAmount = Converter.convertToDouble(Formatter.formatAmount(minAmount));
String country = getCountries().get(0);
BankAccountType bankAccountType = getBankTransferTypes().get(0);
BankAccount bankAccount = new BankAccount(bankAccountType);
User offerer = new User();
offerer.setAccountID(UUID.randomUUID().toString());
offerer.setMessageID(UUID.randomUUID().toString());
offerer.setCountry(country);
offerer.addBankAccount(bankAccount);
Direction direction = Direction.BUY; Direction direction = Direction.BUY;
double price = 500 + Math.random() * 50; double price = 500 + Math.random() * 50;
if (Math.random() > 0.5) if (Math.random() > 0.5)
@ -129,10 +124,10 @@ public class OrderBook
public OfferConstraints getRandomOfferConstraints() public OfferConstraints getRandomOfferConstraints()
{ {
OfferConstraints offerConstraints = new OfferConstraints(getCountries(), OfferConstraints offerConstraints = new OfferConstraints(getCountryLocales(),
getLanguages(), getLanguageLocales(),
Double.valueOf(getCollaterals().get(0)), Double.valueOf(getCollaterals().get(0)),
getBankTransferTypes(), getBankTransferTypeEnums(),
getArbitrators().get(0), getArbitrators().get(0),
randomizeStrings(settings.getAllIdentityVerifications(), false).get(0)); randomizeStrings(settings.getAllIdentityVerifications(), false).get(0));
@ -140,22 +135,28 @@ public class OrderBook
} }
private List<String> getCountries() private List<Locale> getCountryLocales()
{ {
return randomizeStrings(settings.getAllCountries(), false); return randomizeList(settings.getAllLocales(), false);
} }
private List<String> getLanguages() private List<Locale> getLanguageLocales()
{ {
return randomizeStrings(settings.getAllLanguages(), false); return randomizeList(settings.getAllLocales(), false);
} }
private List<BankAccountType> getBankTransferTypes() private List<BankAccountType> getBankTransferTypes()
{ {
return randomizeBankAccountTypes(settings.getAllBankAccountTypes(), false); return randomizeBankAccountTypes(settings.getAllBankAccountTypes(), false);
} }
private List<BankAccountType.BankAccountTypeEnum> getBankTransferTypeEnums()
{
return randomizeBankAccountTypeEnums(settings.getAllBankAccountTypeEnums(), false);
}
private List<String> getArbitrators() private List<String> getArbitrators()
{ {
return randomizeStrings(settings.getAllArbitrators(), false); return randomizeStrings(settings.getAllArbitrators(), false);
@ -166,6 +167,16 @@ public class OrderBook
return randomizeStrings(settings.getAllCollaterals(), false); return randomizeStrings(settings.getAllCollaterals(), false);
} }
private List<BankAccountType.BankAccountTypeEnum> randomizeBankAccountTypeEnums(List<BankAccountType.BankAccountTypeEnum> list, boolean optional)
{
int e = new Random().nextInt(list.size());
if (!optional && list.size() > 0)
e = Math.max(e, 1);
int s = (e == 0) ? 0 : new Random().nextInt(e);
list = list.subList(s, e);
return list;
}
private List<BankAccountType> randomizeBankAccountTypes(List<BankAccountType> list, boolean optional) private List<BankAccountType> randomizeBankAccountTypes(List<BankAccountType> list, boolean optional)
{ {
int e = new Random().nextInt(list.size()); int e = new Random().nextInt(list.size());
@ -186,6 +197,17 @@ public class OrderBook
return list; return list;
} }
private List randomizeList(List list, boolean optional)
{
int e = new Random().nextInt(list.size());
if (!optional && list.size() > 0)
e = Math.max(e, 1);
int s = (e == 0) ? 0 : new Random().nextInt(e);
list = list.subList(s, e);
return list;
}
private List<Double> randomizeDouble(List<Double> list, boolean optional) private List<Double> randomizeDouble(List<Double> list, boolean optional)
{ {
int e = new Random().nextInt(list.size()); int e = new Random().nextInt(list.size());

View File

@ -2,10 +2,10 @@ package io.bitsquare.trade.orderbook;
import io.bitsquare.trade.Direction; import io.bitsquare.trade.Direction;
import io.bitsquare.trade.OfferConstraints; import io.bitsquare.trade.OfferConstraints;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.StringProperty;
import java.util.Currency; import java.util.Currency;
import java.util.Locale;
public class OrderBookFilter public class OrderBookFilter
{ {
@ -13,22 +13,65 @@ public class OrderBookFilter
private double amount; private double amount;
private Direction direction; private Direction direction;
private Currency currency; private Currency currency;
private final StringProperty currencyProperty = new SimpleStringProperty(); private Locale countryLocale;
private Locale languageLocale;
private OfferConstraints offerConstraints; private OfferConstraints offerConstraints;
public SimpleBooleanProperty changedPropertyProperty()
{
return changedProperty;
}
private final SimpleBooleanProperty changedProperty = new SimpleBooleanProperty();
// setters
public void setCurrency(Currency currency)
{
this.currency = currency;
triggerChange();
}
public void setAmount(double amount) public void setAmount(double amount)
{ {
this.amount = amount; this.amount = amount;
triggerChange();
} }
public double getAmount() public void setPrice(double price)
{ {
return amount; this.price = price;
triggerChange();
} }
public void setDirection(Direction direction) public void setDirection(Direction direction)
{ {
this.direction = direction; this.direction = direction;
triggerChange();
}
public void setOfferConstraints(OfferConstraints offerConstraints)
{
this.offerConstraints = offerConstraints;
triggerChange();
}
public void setCountryLocale(Locale countryLocale)
{
this.countryLocale = countryLocale;
triggerChange();
}
public void setLanguageLocale(Locale languageLocale)
{
this.languageLocale = languageLocale;
triggerChange();
}
// getters
public double getAmount()
{
return amount;
} }
public Direction getDirection() public Direction getDirection()
@ -41,34 +84,33 @@ public class OrderBookFilter
return price; return price;
} }
public void setPrice(double price)
{
this.price = price;
}
public Currency getCurrency() public Currency getCurrency()
{ {
return currency; return currency;
} }
public StringProperty getCurrencyProperty()
{
return currencyProperty;
}
public void setCurrency(Currency currency)
{
this.currency = currency;
currencyProperty.set(currency.getCurrencyCode());
}
public OfferConstraints getOfferConstraints() public OfferConstraints getOfferConstraints()
{ {
return offerConstraints; return offerConstraints;
} }
public void setOfferConstraints(OfferConstraints offerConstraints) public Locale getCountryLocale()
{ {
this.offerConstraints = offerConstraints; return countryLocale;
}
public Locale getLanguageLocale()
{
return languageLocale;
}
public SimpleBooleanProperty getChangedProperty()
{
return changedProperty;
}
private void triggerChange()
{
changedProperty.set(!changedProperty.get());
} }
} }

View File

@ -3,9 +3,10 @@ package io.bitsquare.user;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.List;
import java.util.Locale;
public class User implements Serializable public class User implements Serializable
{ {
@ -14,13 +15,14 @@ public class User implements Serializable
private String accountID; private String accountID;
private String messageID; private String messageID;
private boolean online; private boolean online;
private List<BankAccount> bankAccounts = new ArrayList<>();
private BankAccount currentBankAccount = null; private BankAccount currentBankAccount = null;
private List<Locale> languageLocales = new ArrayList<>();
private Map<String, BankAccount> bankAccounts = new HashMap<>(); private Locale currentLanguageLocale = null;
private String country;
public User() public User()
{ {
addLanguageLocales(Locale.getDefault());
} }
public void updateFromStorage(User savedUser) public void updateFromStorage(User savedUser)
@ -32,17 +34,18 @@ public class User implements Serializable
online = savedUser.isOnline(); online = savedUser.isOnline();
currentBankAccount = savedUser.getCurrentBankAccount(); currentBankAccount = savedUser.getCurrentBankAccount();
bankAccounts = savedUser.getBankAccounts(); bankAccounts = savedUser.getBankAccounts();
country = savedUser.getCountry(); languageLocales = savedUser.getLanguageLocales();
currentLanguageLocale = savedUser.getCurrentLanguageLocale();
} }
} }
public String getStringifiedBankAccounts() public String getStringifiedBankAccounts()
{ {
String bankAccountUIDs = ""; String bankAccountUIDs = "";
for (Iterator<Map.Entry<String, BankAccount>> iterator = getBankAccounts().entrySet().iterator(); iterator.hasNext(); ) for (Iterator<BankAccount> iterator = getBankAccounts().iterator(); iterator.hasNext(); )
{ {
Map.Entry<String, BankAccount> entry = iterator.next(); BankAccount bankAccount = iterator.next();
bankAccountUIDs += entry.getValue().getStringifiedBankAccount(); bankAccountUIDs += bankAccount.getStringifiedBankAccount();
if (iterator.hasNext()) if (iterator.hasNext())
bankAccountUIDs += ", "; bankAccountUIDs += ", ";
@ -50,52 +53,71 @@ public class User implements Serializable
return bankAccountUIDs; return bankAccountUIDs;
} }
public void addLanguageLocales(Locale locale)
{
languageLocales.add(locale);
currentLanguageLocale = locale;
}
public void addBankAccount(BankAccount bankAccount) public void addBankAccount(BankAccount bankAccount)
{ {
if (currentBankAccount == null)
currentBankAccount = bankAccount;
bankAccounts.put(bankAccount.getUid(), bankAccount); bankAccounts.add(bankAccount);
} currentBankAccount = bankAccount;
public Map<String, BankAccount> getBankAccounts()
{
return bankAccounts;
}
public BankAccount getBankAccountByUID(String uid)
{
return bankAccounts.get(uid);
}
public String getMessageID()
{
return messageID;
} }
// setter
public void setMessageID(String messageID) public void setMessageID(String messageID)
{ {
this.messageID = messageID; this.messageID = messageID;
} }
public String getAccountID()
{
return accountID;
}
public void setAccountID(String accountID) public void setAccountID(String accountID)
{ {
this.accountID = accountID; this.accountID = accountID;
} }
public void setCountry(String country)
public void setBankAccounts(List<BankAccount> bankAccounts)
{ {
this.country = country; this.bankAccounts = bankAccounts;
} }
public String getCountry() public void setCurrentBankAccount(BankAccount currentBankAccount)
{ {
return country; this.currentBankAccount = currentBankAccount;
}
public void setLanguageLocales(List<Locale> languageLocales)
{
this.languageLocales = languageLocales;
}
public void setCurrentLanguageLocale(Locale currentLanguageLocale)
{
this.currentLanguageLocale = currentLanguageLocale;
}
public void setOnline(boolean online)
{
this.online = online;
}
// getter
public String getMessageID()
{
return messageID;
}
public String getAccountID()
{
return accountID;
}
public List<BankAccount> getBankAccounts()
{
return bankAccounts;
} }
public BankAccount getCurrentBankAccount() public BankAccount getCurrentBankAccount()
@ -103,6 +125,16 @@ public class User implements Serializable
return currentBankAccount; return currentBankAccount;
} }
public List<Locale> getLanguageLocales()
{
return languageLocales;
}
public Locale getCurrentLanguageLocale()
{
return currentLanguageLocale;
}
public boolean isOnline() public boolean isOnline()
{ {
return online; return online;

View File

@ -1 +1,8 @@
currency=Währung currency=Währung
SEPA=Sepa
WIRE=Wire
INTERNATIONAL=International
OK_PAY=OK Pay
NET_TELLER=Netteller
PERFECT_MONEY=Perfect Money
OTHER=Other

View File

@ -1 +1,8 @@
currency=Currency currency=Currency
SEPA=Sepa
WIRE=Wire
INTERNATIONAL=International
OK_PAY=OK Pay
NET_TELLER=Netteller
PERFECT_MONEY=Perfect Money
OTHER=Other

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Some files were not shown because too many files have changed in this diff Show More