formatting, rename packages

This commit is contained in:
Manfred Karrer 2014-05-01 00:30:55 +02:00
parent 256388e4e3
commit 7d0676a995
25 changed files with 1354 additions and 1306 deletions

View file

@ -2,6 +2,8 @@ package io.bitsquare;
import com.google.inject.Guice;
import com.google.inject.Injector;
import io.bitsquare.bank.BankAccount;
import io.bitsquare.bank.BankAccountType;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.di.BitSquareModule;
import io.bitsquare.di.GuiceFXMLLoader;
@ -10,6 +12,7 @@ import io.bitsquare.settings.Settings;
import io.bitsquare.storage.Storage;
import io.bitsquare.user.Arbitrator;
import io.bitsquare.user.User;
import io.bitsquare.util.MockData;
import javafx.application.Application;
import javafx.scene.Parent;
import javafx.scene.Scene;
@ -100,32 +103,35 @@ public class BitSquare extends Application
storage.write(settings.getClass().getName(), settings);
/*
BankAccount bankAccount1 = new BankAccount(new BankAccountType(BankAccountType.BankAccountTypeEnum.SEPA,"Iban", "Bic"),
MockData.getCurrencies().get(0),
MockData.getLocales().get(0),
"Main account",
"Manfred Karrer",
"564613242346",
"23432432434"
);
BankAccount bankAccount2 = new BankAccount(new BankAccountType(BankAccountType.BankAccountTypeEnum.OK_PAY,"Number", "ID"),
MockData.getCurrencies().get(0),
MockData.getLocales().get(0),
"OK account",
"Manfred Karrer",
"22312123123123123",
"asdasdasdas"
);
user.addBankAccount(bankAccount2);
user.addBankAccount(bankAccount1);
user.setAccountID(UUID.randomUUID().toString());
storage.write(user.getClass().getName(), user);
*/
initMockUser(storage, user);
}
else
{
settings.updateFromStorage(savedSettings);
}
}
private void initMockUser(Storage storage, User user)
{
BankAccount bankAccount1 = new BankAccount(new BankAccountType(BankAccountType.BankAccountTypeEnum.SEPA, "Iban", "Bic"),
MockData.getCurrencies().get(0),
MockData.getLocales().get(0),
"Main account",
"Manfred Karrer",
"564613242346",
"23432432434"
);
BankAccount bankAccount2 = new BankAccount(new BankAccountType(BankAccountType.BankAccountTypeEnum.OK_PAY, "Number", "ID"),
MockData.getCurrencies().get(0),
MockData.getLocales().get(0),
"OK account",
"Manfred Karrer",
"22312123123123123",
"asdasdasdas"
);
user.addBankAccount(bankAccount2);
user.addBankAccount(bankAccount1);
user.setAccountID(UUID.randomUUID().toString());
storage.write(user.getClass().getName(), user);
}
}

View file

@ -18,12 +18,14 @@ public class BlockChainFacade
public boolean verifyEmbeddedData(String address)
{
// tx id 76982adc582657b2eb68f3e43341596a68aadc4ef6b9590e88e93387d4d5d1f9
// address: mjbxLbuVpU1cNXLJbrJZyirYwweoRPVVTj
return true;
/*
/*
if (findAddressInBlockChain(address) && isFeePayed(address))
return getDataForTxWithAddress(address) != null;
else
return true; */
return true; */
}
private boolean findAddressInBlockChain(String address)

View file

@ -3,5 +3,4 @@ package io.bitsquare.gui;
public interface ChildController
{
void setNavigationController(NavigationController navigationController);
}

View file

@ -5,8 +5,8 @@ import io.bitsquare.bank.BankAccount;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.di.GuiceFXMLLoader;
import io.bitsquare.gui.components.NetworkSyncPane;
import io.bitsquare.gui.market.MarketController;
import io.bitsquare.gui.setup.SetupController;
import io.bitsquare.gui.trade.TradeController;
import io.bitsquare.gui.util.Formatter;
import io.bitsquare.gui.util.Icons;
import io.bitsquare.gui.util.Localisation;
@ -56,6 +56,11 @@ public class MainController implements Initializable, NavigationController, Wall
@FXML
public AnchorPane anchorPane;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public MainController(User user, WalletFacade walletFacade)
{
@ -63,6 +68,11 @@ public class MainController implements Initializable, NavigationController, Wall
this.walletFacade = walletFacade;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: Initializable
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public void initialize(URL url, ResourceBundle rb)
{
@ -87,6 +97,10 @@ public class MainController implements Initializable, NavigationController, Wall
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: NavigationController
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public ChildController navigateToView(String fxmlView, String title)
{
@ -102,9 +116,9 @@ public class MainController implements Initializable, NavigationController, Wall
return null;
}
if (childController instanceof TradeController)
if (childController instanceof MarketController)
{
((TradeController) childController).cleanup();
((MarketController) childController).cleanup();
}
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(fxmlView), Localisation.getResourceBundle());
@ -122,6 +136,11 @@ public class MainController implements Initializable, NavigationController, Wall
return null;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: WalletFacade.DownloadListener
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public void progress(double percent, int blocksSoFar, Date date)
{
@ -136,15 +155,10 @@ public class MainController implements Initializable, NavigationController, Wall
Platform.runLater(networkSyncPane::doneDownload);
}
public ChildController navigateToView(String fxmlView, Direction direction)
{
childController = navigateToView(fxmlView, direction == Direction.BUY ? "Orderbook Buy" : "Orderbook Sell");
if (childController instanceof TradeController && direction != null)
{
((TradeController) childController).setDirection(direction);
}
return childController;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
private void buildSetupView()
{
@ -165,8 +179,8 @@ public class MainController implements Initializable, NavigationController, Wall
toggleGroup = new ToggleGroup();
ToggleButton homeButton = addNavButton(leftNavPane, "Overview", Icons.HOME, Icons.HOME, NavigationController.HOME);
ToggleButton buyButton = addNavButton(leftNavPane, "Buy BTC", Icons.NAV_BUY, Icons.NAV_BUY_ACTIVE, NavigationController.TRADE, Direction.BUY);
ToggleButton sellButton = addNavButton(leftNavPane, "Sell BTC", Icons.NAV_SELL, Icons.NAV_SELL_ACTIVE, NavigationController.TRADE, Direction.SELL);
ToggleButton buyButton = addNavButton(leftNavPane, "Buy BTC", Icons.NAV_BUY, Icons.NAV_BUY_ACTIVE, NavigationController.MARKET, Direction.BUY);
ToggleButton sellButton = addNavButton(leftNavPane, "Sell BTC", Icons.NAV_SELL, Icons.NAV_SELL_ACTIVE, NavigationController.MARKET, Direction.SELL);
addNavButton(leftNavPane, "Orders", Icons.ORDERS, Icons.ORDERS, NavigationController.ORDERS);
addNavButton(leftNavPane, "History", Icons.HISTORY, Icons.HISTORY, NavigationController.HISTORY);
addNavButton(leftNavPane, "Funds", Icons.FUNDS, Icons.FUNDS, NavigationController.FUNDS);
@ -201,12 +215,18 @@ public class MainController implements Initializable, NavigationController, Wall
prevToggleButtonIcon = ((ImageView) (toggleButton.getGraphic())).getImage();
((ImageView) (toggleButton.getGraphic())).setImage(Icons.getIconImage(iconIdActivated));
if (childController instanceof TradeController && direction != null)
if (childController instanceof MarketController && direction != null)
{
((TradeController) childController).setDirection(direction);
((MarketController) childController).setDirection(direction);
}
else
navigateToView(navTarget, direction);
{
childController = navigateToView(navTarget, direction == Direction.BUY ? "Orderbook Buy" : "Orderbook Sell");
if (childController instanceof MarketController && direction != null)
{
((MarketController) childController).setDirection(direction);
}
}
prevToggleButton = toggleButton;

View file

@ -2,20 +2,19 @@ package io.bitsquare.gui;
public interface NavigationController
{
public static final String SETUP = "/io/bitsquare/gui/setup/SetupView.fxml";
public static final String HOME = "/io/bitsquare/gui/home/HomeView.fxml";
public static final String TRADE = "/io/bitsquare/gui/trade/TradeView.fxml";
public static final String MARKET = "/io/bitsquare/gui/market/MarketView.fxml";
public static final String ORDERS = "/io/bitsquare/gui/orders/OrdersView.fxml";
public static final String FUNDS = "/io/bitsquare/gui/funds/FundsView.fxml";
public static final String MSG = "/io/bitsquare/gui/msg/MsgView.fxml";
public static final String HISTORY = "/io/bitsquare/gui/history/HistoryView.fxml";
public static final String SETTINGS = "/io/bitsquare/gui/settings/SettingsView.fxml";
public static final String TRADE__ORDER_BOOK = "/io/bitsquare/gui/trade/orderbook/OrderBookView.fxml";
public static final String TRADE__PROCESS = "/io/bitsquare/gui/trade/tradeprocess/TradeProcessView.fxml";
public static final String TRADE__CREATE_OFFER = "/io/bitsquare/gui/trade/offer/CreateOfferView.fxml";
public static final String ORDER_BOOK = "/io/bitsquare/gui/market/orderbook/OrderBookView.fxml";
public static final String TRADE = "/io/bitsquare/gui/market/trade/TradeView.fxml";
public static final String CREATE_OFFER = "/io/bitsquare/gui/market/offer/CreateOfferView.fxml";
ChildController navigateToView(String fxmlView, String title);
}

View file

@ -1,9 +1,9 @@
package io.bitsquare.gui.trade;
package io.bitsquare.gui.market;
import io.bitsquare.di.GuiceFXMLLoader;
import io.bitsquare.gui.ChildController;
import io.bitsquare.gui.NavigationController;
import io.bitsquare.gui.trade.orderbook.OrderBookController;
import io.bitsquare.gui.market.orderbook.OrderBookController;
import io.bitsquare.gui.util.Localisation;
import io.bitsquare.trade.Direction;
import javafx.fxml.FXML;
@ -16,20 +16,36 @@ import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
public class TradeController implements Initializable, NavigationController, ChildController
public class MarketController implements Initializable, NavigationController, ChildController
{
@FXML
private TabPane tabPane;
private ChildController childController;
private boolean orderbookCreated;
private NavigationController navigationController;
private OrderBookController orderBookController;
@FXML
private TabPane tabPane;
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: Initializable
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public void initialize(URL url, ResourceBundle rb)
{
navigateToView(NavigationController.ORDER_BOOK, "Orderbook");
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: NavigationController
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public ChildController navigateToView(String fxmlView, String title)
{
if (fxmlView.equals(NavigationController.TRADE__ORDER_BOOK) && orderbookCreated)
if (fxmlView.equals(NavigationController.ORDER_BOOK) && orderbookCreated)
{
tabPane.getSelectionModel().select(0);
return null;
@ -49,7 +65,7 @@ public class TradeController implements Initializable, NavigationController, Chi
tab.setContent(view);
tabPane.getTabs().add(tab);
if (fxmlView.equals(NavigationController.TRADE__ORDER_BOOK))
if (fxmlView.equals(NavigationController.ORDER_BOOK))
{
tab.setClosable(false);
orderbookCreated = true;
@ -65,11 +81,10 @@ public class TradeController implements Initializable, NavigationController, Chi
return null;
}
@Override
public void initialize(URL url, ResourceBundle rb)
{
navigateToView(NavigationController.TRADE__ORDER_BOOK, "Orderbook");
}
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: ChildController
///////////////////////////////////////////////////////////////////////////////////////////
@Override
public void setNavigationController(NavigationController navigationController)
@ -78,11 +93,10 @@ public class TradeController implements Initializable, NavigationController, Chi
this.navigationController = navigationController;
}
public void setDirection(Direction direction)
{
tabPane.getSelectionModel().select(0);
orderBookController.setDirection(direction);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Public methods
///////////////////////////////////////////////////////////////////////////////////////////
public void cleanup()
{
@ -93,5 +107,16 @@ public class TradeController implements Initializable, NavigationController, Chi
}
}
///////////////////////////////////////////////////////////////////////////////////////////
// Setter
///////////////////////////////////////////////////////////////////////////////////////////
public void setDirection(Direction direction)
{
tabPane.getSelectionModel().select(0);
orderBookController.setDirection(direction);
}
}

View file

@ -4,4 +4,4 @@
<?import javafx.scene.layout.AnchorPane?>
<TabPane fx:id="tabPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="io.bitsquare.gui.trade.TradeController"/>
fx:controller="io.bitsquare.gui.market.MarketController"/>

View file

@ -1,4 +1,4 @@
package io.bitsquare.gui.trade.offer;
package io.bitsquare.gui.market.offer;
import com.google.bitcoin.core.InsufficientMoneyException;
import com.google.inject.Inject;
@ -172,7 +172,7 @@ public class CreateOfferController implements Initializable, ChildController, Wa
TabPane tabPane = ((TabPane) (holderPane.getParent().getParent()));
tabPane.getTabs().remove(tabPane.getSelectionModel().getSelectedItem());
navigationController.navigateToView(NavigationController.TRADE__ORDER_BOOK, "Orderbook");
navigationController.navigateToView(NavigationController.ORDER_BOOK, "Orderbook");
});
}

View file

@ -5,7 +5,7 @@
<?import javafx.scene.layout.*?>
<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"
fx:controller="io.bitsquare.gui.trade.offer.CreateOfferController">
fx:controller="io.bitsquare.gui.market.offer.CreateOfferController">
<children>
<VBox spacing="10" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="5.0"
AnchorPane.bottomAnchor="10.0">

View file

@ -1,11 +1,11 @@
package io.bitsquare.gui.trade.orderbook;
package io.bitsquare.gui.market.orderbook;
import com.google.inject.Inject;
import io.bitsquare.bank.BankAccountType;
import io.bitsquare.gui.ChildController;
import io.bitsquare.gui.NavigationController;
import io.bitsquare.gui.trade.offer.CreateOfferController;
import io.bitsquare.gui.trade.tradeprocess.TradeProcessController;
import io.bitsquare.gui.market.offer.CreateOfferController;
import io.bitsquare.gui.market.trade.TradeController;
import io.bitsquare.gui.util.Converter;
import io.bitsquare.gui.util.Formatter;
import io.bitsquare.gui.util.Icons;
@ -125,7 +125,7 @@ public class OrderBookController implements Initializable, ChildController
});
createOfferButton.setOnAction(e -> {
ChildController nextController = navigationController.navigateToView(NavigationController.TRADE__CREATE_OFFER, "Create offer");
ChildController nextController = navigationController.navigateToView(NavigationController.CREATE_OFFER, "Create offer");
((CreateOfferController) nextController).setOrderBookFilter(orderBookFilter);
});
}
@ -153,13 +153,13 @@ public class OrderBookController implements Initializable, ChildController
private void openTradeTab(OrderBookListItem orderBookListItem)
{
String title = orderBookListItem.getOffer().getDirection() == Direction.BUY ? "Trade: Sell Bitcoin" : "Trade: Buy Bitcoin";
TradeProcessController tradeProcessController = (TradeProcessController) navigationController.navigateToView(NavigationController.TRADE__PROCESS, title);
TradeController tradeController = (TradeController) navigationController.navigateToView(NavigationController.TRADE, title);
double requestedAmount = orderBookListItem.getOffer().getAmount();
if (!amount.getText().equals(""))
requestedAmount = Converter.stringToDouble(amount.getText());
tradeProcessController.initWithData(orderBookListItem.getOffer(), requestedAmount);
tradeController.initWithData(orderBookListItem.getOffer(), requestedAmount);
}
private void updateOfferList()

View file

@ -1,4 +1,4 @@
package io.bitsquare.gui.trade.orderbook;
package io.bitsquare.gui.market.orderbook;
import io.bitsquare.gui.util.Formatter;
import io.bitsquare.trade.Offer;

View file

@ -6,7 +6,7 @@
<?import javafx.scene.layout.*?>
<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"
fx:controller="io.bitsquare.gui.trade.orderbook.OrderBookController">
fx:controller="io.bitsquare.gui.market.orderbook.OrderBookController">
<children>
<HBox fx:id="topHBox" prefHeight="22.0" AnchorPane.topAnchor="10.0" AnchorPane.leftAnchor="10.0"

View file

@ -1,4 +1,4 @@
package io.bitsquare.gui.trade.tradeprocess;
package io.bitsquare.gui.market.trade;
import com.google.inject.Inject;
import io.bitsquare.btc.BlockChainFacade;
@ -12,10 +12,8 @@ import io.bitsquare.gui.components.processbar.ProcessStepItem;
import io.bitsquare.gui.util.Converter;
import io.bitsquare.gui.util.FormBuilder;
import io.bitsquare.gui.util.Formatter;
import io.bitsquare.settings.Settings;
import io.bitsquare.storage.Storage;
import io.bitsquare.gui.util.Popups;
import io.bitsquare.trade.*;
import io.bitsquare.user.User;
import io.bitsquare.util.Utils;
import javafx.animation.AnimationTimer;
import javafx.fxml.FXML;
@ -25,7 +23,6 @@ import javafx.scene.control.*;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import org.controlsfx.dialog.Dialogs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -36,28 +33,26 @@ import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
public class TradeProcessController implements Initializable, ChildController, WalletFacade.WalletListener
public class TradeController implements Initializable, ChildController, WalletFacade.WalletListener
{
private static final Logger log = LoggerFactory.getLogger(TradeProcessController.class);
private static final Logger log = LoggerFactory.getLogger(TradeController.class);
private static final int SIM_DELAY = 1000;
private Trading trading;
private User user;
private WalletFacade walletFacade;
private BlockChainFacade blockChainFacade;
private Settings settings;
private Storage storage;
private Offer offer;
private Trade trade;
private Contract contract;
private double requestedAmount;
private boolean offererIsOnline;
private int row;
private List<ProcessStepItem> processStepItems = new ArrayList();
private NavigationController navigationController;
private TextField amountTextField, totalToPayLabel, totalLabel;
private Label statusTextField;
private Label statusTextField, infoLabel;
private Button nextButton;
private ProgressBar progressBar;
@ -66,26 +61,19 @@ public class TradeProcessController implements Initializable, ChildController, W
@FXML
private ProcessStepBar<String> processStepBar;
@FXML
private GridPane formGridPane;
@FXML
private VBox vBox;
private Label infoLabel;
private int gridRow;
private GridPane gridPane;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor(s)
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public TradeProcessController(Trading trading, User user, WalletFacade walletFacade, BlockChainFacade blockChainFacade, Settings settings, Storage storage)
public TradeController(Trading trading, WalletFacade walletFacade, BlockChainFacade blockChainFacade)
{
this.trading = trading;
this.user = user;
this.walletFacade = walletFacade;
this.blockChainFacade = blockChainFacade;
this.settings = settings;
this.storage = storage;
}
@ -154,56 +142,48 @@ public class TradeProcessController implements Initializable, ChildController, W
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
// trade process
///////////////////////////////////////////////////////////////////////////////////////////
private void buildTakeOfferScreen()
{
row = -1;
int gridRow = -1;
FormBuilder.addHeaderLabel(formGridPane, "Take offer:", ++gridRow);
amountTextField = FormBuilder.addTextField(formGridPane, "Amount BTC:", Formatter.formatAmount(requestedAmount), ++gridRow, true, true);
FormBuilder.addHeaderLabel(gridPane, "Take offer:", ++row);
amountTextField = FormBuilder.addTextField(gridPane, "Amount BTC:", Formatter.formatAmount(requestedAmount), ++row, true, true);
amountTextField.textProperty().addListener(e -> {
setVolume();
applyVolume();
totalToPayLabel.setText(getTotalToPay());
});
Label amountRangeLabel = new Label("(" + Formatter.formatAmount(offer.getMinAmount()) + " - " + Formatter.formatAmount(offer.getAmount()) + ")");
formGridPane.add(amountRangeLabel, 2, gridRow);
gridPane.add(amountRangeLabel, 2, row);
FormBuilder.addTextField(formGridPane, "Price:", Formatter.formatPriceWithCurrencyPair(offer.getPrice(), offer.getCurrency()), ++gridRow);
totalLabel = FormBuilder.addTextField(formGridPane, "Total:", Formatter.formatVolume(getVolume(), offer.getCurrency()), ++gridRow);
FormBuilder.addTextField(formGridPane, "Offer fee:", Formatter.formatSatoshis(Fees.OFFER_TAKER_FEE, true), ++gridRow);
totalToPayLabel = FormBuilder.addTextField(formGridPane, "Total to pay:", getTotalToPay(), ++gridRow);
FormBuilder.addTextField(gridPane, "Price:", Formatter.formatPriceWithCurrencyPair(offer.getPrice(), offer.getCurrency()), ++row);
totalLabel = FormBuilder.addTextField(gridPane, "Total:", Formatter.formatVolume(getVolume(), offer.getCurrency()), ++row);
FormBuilder.addTextField(gridPane, "Offer fee:", Formatter.formatSatoshis(Fees.OFFER_TAKER_FEE, true), ++row);
totalToPayLabel = FormBuilder.addTextField(gridPane, "Total to pay:", getTotalToPay(), ++row);
nextButton = FormBuilder.addButton(formGridPane, "Take offer and pay", ++gridRow);
nextButton = FormBuilder.addButton(gridPane, "Take offer and pay", ++row);
nextButton.setDefaultButton(true);
nextButton.setOnAction(e -> {
initTrade();
});
nextButton.setOnAction(e -> initTrade());
// details
FormBuilder.addVSpacer(formGridPane, ++gridRow);
FormBuilder.addHeaderLabel(formGridPane, "Offerer details:", ++gridRow);
TextField isOnlineTextField = FormBuilder.addTextField(formGridPane, "Online status:", "Checking offerers online status...", ++gridRow);
FormBuilder.addVSpacer(gridPane, ++row);
FormBuilder.addHeaderLabel(gridPane, "Offerer details:", ++row);
TextField isOnlineTextField = FormBuilder.addTextField(gridPane, "Online status:", "Checking offerers online status...", ++row);
ProgressIndicator isOnlineChecker = new ProgressIndicator();
isOnlineChecker.setPrefSize(20, 20);
isOnlineChecker.setLayoutY(3);
Pane isOnlineCheckerHolder = new Pane();
isOnlineCheckerHolder.getChildren().addAll(isOnlineChecker);
formGridPane.add(isOnlineCheckerHolder, 2, gridRow);
gridPane.add(isOnlineCheckerHolder, 2, row);
checkIfOffererIsOnline(isOnlineCheckerHolder, isOnlineTextField);
FormBuilder.addTextField(formGridPane, "Bank account type:", offer.getBankAccountTypeEnum().toString(), ++gridRow);
FormBuilder.addTextField(formGridPane, "Bank account country:", offer.getBankAccountCountryLocale().getDisplayCountry(), ++gridRow);
FormBuilder.addTextField(formGridPane, "Arbitrator:", offer.getArbitrator().getName(), ++gridRow);
FormBuilder.addTextField(gridPane, "Bank account type:", offer.getBankAccountTypeEnum().toString(), ++row);
FormBuilder.addTextField(gridPane, "Bank account country:", offer.getBankAccountCountryLocale().getDisplayCountry(), ++row);
FormBuilder.addTextField(gridPane, "Arbitrator:", offer.getArbitrator().getName(), ++row);
Label arbitratorLink = new Label(offer.getArbitrator().getUrl());
arbitratorLink.setId("label-url");
formGridPane.add(arbitratorLink, 2, gridRow);
gridPane.add(arbitratorLink, 2, row);
arbitratorLink.setOnMouseClicked(e -> {
try
{
@ -214,93 +194,67 @@ public class TradeProcessController implements Initializable, ChildController, W
}
});
FormBuilder.addVSpacer(formGridPane, ++gridRow);
FormBuilder.addHeaderLabel(formGridPane, "More details:", ++gridRow);
FormBuilder.addTextField(formGridPane, "Offer ID:", offer.getUid().toString(), ++gridRow);
FormBuilder.addTextField(formGridPane, "Account ID:", offer.getAccountID(), ++gridRow);
FormBuilder.addTextField(formGridPane, "Messaging ID:", offer.getMessageID(), ++gridRow);
FormBuilder.addTextField(formGridPane, "Supported languages:", Formatter.languageLocalesToString(offer.getAcceptedLanguageLocales()), ++gridRow);
FormBuilder.addTextField(formGridPane, "Supported countries:", Formatter.countryLocalesToString(offer.getAcceptedCountryLocales()), ++gridRow);
FormBuilder.addVSpacer(gridPane, ++row);
FormBuilder.addHeaderLabel(gridPane, "More details:", ++row);
FormBuilder.addTextField(gridPane, "Offer ID:", offer.getUid().toString(), ++row);
FormBuilder.addTextField(gridPane, "Account ID:", offer.getAccountID(), ++row);
FormBuilder.addTextField(gridPane, "Messaging ID:", offer.getMessageID(), ++row);
FormBuilder.addTextField(gridPane, "Supported languages:", Formatter.languageLocalesToString(offer.getAcceptedLanguageLocales()), ++row);
FormBuilder.addTextField(gridPane, "Supported countries:", Formatter.countryLocalesToString(offer.getAcceptedCountryLocales()), ++row);
}
private boolean tradeAmountValid()
{
double tradeAmount = Converter.stringToDouble(amountTextField.getText());
return tradeAmount <= offer.getAmount() && tradeAmount >= offer.getMinAmount();
}
private void initTrade()
{
if (tradeAmountValid())
if (!tradeAmountValid())
{
if (blockChainFacade.verifyEmbeddedData(offer.getAccountID()))
{
if (!blockChainFacade.isAccountIDBlacklisted(offer.getAccountID()))
{
amountTextField.setEditable(false);
formGridPane.getChildren().clear();
int gridRow = -1;
FormBuilder.addHeaderLabel(formGridPane, "Trade request inited", ++gridRow, 0);
statusTextField = FormBuilder.addLabel(formGridPane, "Current activity:", "Request confirmation from offerer to take that offer.", ++gridRow);
GridPane.setColumnSpan(statusTextField, 2);
FormBuilder.addLabel(formGridPane, "Progress:", "", ++gridRow);
progressBar = new ProgressBar();
progressBar.setProgress(0.0);
progressBar.setPrefWidth(300);
GridPane.setFillWidth(progressBar, true);
formGridPane.add(progressBar, 1, gridRow);
FormBuilder.addLabel(formGridPane, "Status:", "", ++gridRow);
ProgressIndicator progressIndicator = new ProgressIndicator();
progressIndicator.setPrefSize(20, 20);
progressIndicator.setLayoutY(2);
Pane progressIndicatorHolder = new Pane();
progressIndicatorHolder.getChildren().addAll(progressIndicator);
formGridPane.add(progressIndicatorHolder, 1, gridRow);
trade.setTradeAmount(Converter.stringToDouble(amountTextField.getText()));
trading.sendTakeOfferRequest(trade);
Utils.setTimeout(SIM_DELAY, (AnimationTimer animationTimer) -> {
onTakeOfferRequestConfirmed();
progressBar.setProgress(1.0 / 3.0);
return null;
});
}
else
{
Dialogs.create()
.title("Offerers account ID is blacklisted")
.message("Offerers account ID is blacklisted.")
.nativeTitleBar()
.lightweight()
.showError();
}
}
else
{
Dialogs.create()
.title("Offerers account ID not valid")
.message("Offerers registration tx is not found in blockchain or does not match the requirements.")
.nativeTitleBar()
.lightweight()
.showError();
}
Popups.openErrorPopup("Your input is not valid", "The requested amount you entered is outside of the range of the offered amount.");
return;
}
else
if (!blockChainFacade.verifyEmbeddedData(offer.getAccountID()))
{
Dialogs.create()
.title("Your input is not valid")
.message("The requested amount you entered is outside of the range of the offered amount.")
.nativeTitleBar()
.lightweight()
.showError();
Popups.openErrorPopup("Offerers account ID not valid", "Offerers registration tx is not found in blockchain or does not match the requirements.");
return;
}
if (blockChainFacade.isAccountIDBlacklisted(offer.getAccountID()))
{
Popups.openErrorPopup("Offerers account ID is blacklisted", "Offerers account ID is blacklisted.");
return;
}
amountTextField.setEditable(false);
gridPane.getChildren().clear();
row = -1;
FormBuilder.addHeaderLabel(gridPane, "Trade request inited", ++row, 0);
statusTextField = FormBuilder.addLabel(gridPane, "Current activity:", "Request confirmation from offerer to take that offer.", ++row);
GridPane.setColumnSpan(statusTextField, 2);
FormBuilder.addLabel(gridPane, "Progress:", "", ++row);
progressBar = new ProgressBar();
progressBar.setProgress(0.0);
progressBar.setPrefWidth(300);
GridPane.setFillWidth(progressBar, true);
gridPane.add(progressBar, 1, row);
FormBuilder.addLabel(gridPane, "Status:", "", ++row);
ProgressIndicator progressIndicator = new ProgressIndicator();
progressIndicator.setPrefSize(20, 20);
progressIndicator.setLayoutY(2);
Pane progressIndicatorHolder = new Pane();
progressIndicatorHolder.getChildren().addAll(progressIndicator);
gridPane.add(progressIndicatorHolder, 1, row);
trade.setTradeAmount(Converter.stringToDouble(amountTextField.getText()));
trading.sendTakeOfferRequest(trade);
Utils.setTimeout(SIM_DELAY, (AnimationTimer animationTimer) -> {
onTakeOfferRequestConfirmed();
progressBar.setProgress(1.0 / 3.0);
return null;
});
}
private void onTakeOfferRequestConfirmed()
@ -348,11 +302,11 @@ public class TradeProcessController implements Initializable, ChildController, W
{
processStepBar.next();
formGridPane.getChildren().clear();
gridPane.getChildren().clear();
gridRow = -1;
FormBuilder.addHeaderLabel(formGridPane, "Bank transfer", ++gridRow, 0);
infoLabel = FormBuilder.addLabel(formGridPane, "Status:", "Wait for Bank transfer.", ++gridRow);
row = -1;
FormBuilder.addHeaderLabel(gridPane, "Bank transfer", ++row, 0);
infoLabel = FormBuilder.addLabel(gridPane, "Status:", "Wait for Bank transfer.", ++row);
Utils.setTimeout(SIM_DELAY, (AnimationTimer animationTimer) -> {
onBankTransferInited();
@ -362,12 +316,12 @@ public class TradeProcessController implements Initializable, ChildController, W
private void onBankTransferInited()
{
int gridRow = 1;
row = 1;
infoLabel.setText("Bank transfer has been inited.");
Label label = FormBuilder.addLabel(formGridPane, "", "Check your bank account and continue when you have received the money.", ++gridRow);
Label label = FormBuilder.addLabel(gridPane, "", "Check your bank account and continue when you have received the money.", ++row);
GridPane.setColumnSpan(label, 2);
formGridPane.add(nextButton, 1, ++gridRow);
gridPane.add(nextButton, 1, ++row);
nextButton.setText("I have received the bank transfer");
nextButton.setOnAction(e -> releaseBTC());
}
@ -380,15 +334,14 @@ public class TradeProcessController implements Initializable, ChildController, W
nextButton.setText("Close");
nextButton.setOnAction(e -> close());
formGridPane.getChildren().clear();
gridRow = -1;
FormBuilder.addHeaderLabel(formGridPane, "Trade successfully completed", ++gridRow);
FormBuilder.addTextField(formGridPane, "You have payed:", getTotalToPay(), ++gridRow);
FormBuilder.addTextField(formGridPane, "You have received:", getTotalToReceive(), ++gridRow);
formGridPane.add(nextButton, 1, ++gridRow);
gridPane.getChildren().clear();
row = -1;
FormBuilder.addHeaderLabel(gridPane, "Trade successfully completed", ++row);
FormBuilder.addTextField(gridPane, "You have payed:", getTotalToPay(), ++row);
FormBuilder.addTextField(gridPane, "You have received:", getTotalToReceive(), ++row);
gridPane.add(nextButton, 1, ++row);
}
private void close()
{
walletFacade.removeRegistrationWalletListener(this);
@ -396,26 +349,21 @@ public class TradeProcessController implements Initializable, ChildController, W
TabPane tabPane = ((TabPane) (rootContainer.getParent().getParent()));
tabPane.getTabs().remove(tabPane.getSelectionModel().getSelectedItem());
navigationController.navigateToView(NavigationController.TRADE__ORDER_BOOK, "Orderbook");
navigationController.navigateToView(NavigationController.ORDER_BOOK, "Orderbook");
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
// Other Private methods
private boolean tradeAmountValid()
{
double tradeAmount = Converter.stringToDouble(amountTextField.getText());
return tradeAmount <= offer.getAmount() && tradeAmount >= offer.getMinAmount();
}
private boolean takerIsSelling()
{
return offer.getDirection() == Direction.BUY;
}
private String getTotalToReceive()
{
if (takerIsSelling())
return Formatter.formatVolume(getVolume(), offer.getCurrency());
else
return Formatter.formatAmount(offer.getAmount(), true, true);
}
private void checkIfOffererIsOnline(Node isOnlineChecker, TextField isOnlineTextField)
{
@ -423,13 +371,12 @@ public class TradeProcessController implements Initializable, ChildController, W
Utils.setTimeout(3000, (AnimationTimer animationTimer) -> {
offererIsOnline = Math.random() > 0.3 ? true : false;
isOnlineTextField.setText(offererIsOnline ? "Online" : "Offline");
formGridPane.getChildren().remove(isOnlineChecker);
gridPane.getChildren().remove(isOnlineChecker);
return null;
});
}
private void setVolume()
private void applyVolume()
{
totalLabel.setText(Formatter.formatVolume(getVolume(), offer.getCurrency()));
}
@ -456,5 +403,13 @@ public class TradeProcessController implements Initializable, ChildController, W
return result;
}
private String getTotalToReceive()
{
if (takerIsSelling())
return Formatter.formatVolume(getVolume(), offer.getCurrency());
else
return Formatter.formatAmount(offer.getAmount(), true, true);
}
}

View file

@ -5,7 +5,7 @@
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.layout.*?>
<AnchorPane fx:id="rootContainer" fx:controller="io.bitsquare.gui.trade.tradeprocess.TradeProcessController"
<AnchorPane fx:id="rootContainer" fx:controller="io.bitsquare.gui.market.trade.TradeController"
xmlns:fx="http://javafx.com/fxml">
<ScrollPane fitToWidth="true" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
AnchorPane.bottomAnchor="0">
@ -17,7 +17,7 @@
</padding>
<ProcessStepBar fx:id="processStepBar"/>
<VSpacer prefHeight="5"/>
<GridPane fx:id="formGridPane" vgap="5" hgap="5">
<GridPane fx:id="gridPane" vgap="5" hgap="5">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</padding>

View file

@ -65,7 +65,7 @@ public class SetupController implements Initializable, ChildController, WalletFa
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor(s)
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject

View file

@ -11,8 +11,6 @@ import java.util.Locale;
public class Formatter
{
public static String formatPrice(double price)
{
return formatDouble(price);

View file

@ -0,0 +1,16 @@
package io.bitsquare.gui.util;
import org.controlsfx.dialog.Dialogs;
public class Popups
{
public static void openErrorPopup(String title, String message)
{
Dialogs.create()
.title(title)
.message(message)
.nativeTitleBar()
.lightweight()
.showError();
}
}

View file

@ -16,11 +16,21 @@ public class Settings implements Serializable
private List<Locale> acceptedCountryLocales = new ArrayList<>();
private List<Arbitrator> arbitrators = new ArrayList<>();
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public Settings()
{
}
///////////////////////////////////////////////////////////////////////////////////////////
// Public API
///////////////////////////////////////////////////////////////////////////////////////////
public void updateFromStorage(Settings savedSettings)
{
if (savedSettings != null)
@ -49,7 +59,11 @@ public class Settings implements Serializable
arbitrators.add(arbitrator);
}
//getters
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public List<Arbitrator> getArbitrators()
{
return arbitrators;
@ -60,7 +74,6 @@ public class Settings implements Serializable
return acceptedLanguageLocales;
}
public List<Locale> getAcceptedCountryLocales()
{
return acceptedCountryLocales;

View file

@ -1,6 +1,5 @@
package io.bitsquare.storage;
import io.bitsquare.user.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -13,56 +12,62 @@ import java.util.Map;
*/
public class Storage
{
private static final Logger log = LoggerFactory.getLogger(Storage.class);
//TODO save in users preferences location
private final String preferencesFileName = "preferences.ser";
private final String storageFile;
private DataVO dataVO;
private Map<String, Object> dict;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
public Storage()
{
storageFile = Storage.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/" + preferencesFileName;
dataVO = readDataVO();
if (dataVO == null)
dict = readDataVO();
if (dict == null)
{
dataVO = new DataVO();
dataVO.dict = new HashMap<String, Object>();
writeDataVO(dataVO);
dict = new HashMap<>();
writeDataVO(dict);
}
}
public void updateUserFromStorage(User user)
{
User savedUser = (User) read(user.getClass().getName());
if (savedUser != null)
user.updateFromStorage(savedUser);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Public API
///////////////////////////////////////////////////////////////////////////////////////////
public void write(String key, Object value)
{
//log.info("Write object with key = " + key + " / value = " + value);
dataVO.dict.put(key, value);
writeDataVO(dataVO);
dict.put(key, value);
writeDataVO(dict);
}
public Object read(String key)
{
dataVO = readDataVO();
Object result = dataVO.dict.get(key);
dict = readDataVO();
Object result = dict.get(key);
//log.info("Read object with key = " + key + " result = " + result);
return result;
}
private void writeDataVO(DataVO dataVO)
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
private void writeDataVO(Map<String, Object> dict)
{
try
{
FileOutputStream fileOut = new FileOutputStream(storageFile);
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(dataVO);
out.writeObject(dict);
out.close();
fileOut.close();
} catch (IOException i)
@ -71,9 +76,9 @@ public class Storage
}
}
private DataVO readDataVO()
private Map<String, Object> readDataVO()
{
DataVO dataVO = null;
Map<String, Object> dict = null;
File file = new File(storageFile);
if (file.exists())
{
@ -81,7 +86,7 @@ public class Storage
{
FileInputStream fileIn = new FileInputStream(file);
ObjectInputStream in = new ObjectInputStream(fileIn);
dataVO = (DataVO) in.readObject();
dict = (Map<String, Object>) in.readObject();
in.close();
fileIn.close();
} catch (IOException i)
@ -92,16 +97,6 @@ public class Storage
c.printStackTrace();
}
}
return dataVO;
return dict;
}
}
class DataVO implements Serializable
{
private static final long serialVersionUID = -1127046445783201376L;
public Map<String, Object> dict;
}

View file

@ -7,27 +7,37 @@ import java.util.UUID;
public class Contract
{
private User taker;
private String offererPubKey;
private Trade trade;
private String takerPubKey;
private String offererPubKey;
public Contract(Trade trade, String takerPubKey)
public Contract(User taker, Trade trade, String takerPubKey)
{
this.taker = taker;
this.trade = trade;
this.takerPubKey = takerPubKey;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
public void setOffererPubKey(String offererPubKey)
{
this.offererPubKey = offererPubKey;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public UUID getUid()
{
return trade.getUid();
}
public void setTaker(User taker)
{
this.taker = taker;
}
public User getTaker()
{
return taker;
@ -38,9 +48,9 @@ public class Contract
return takerPubKey;
}
public void setTakerPubKey(String takerPubKey)
public Trade getTrade()
{
this.takerPubKey = takerPubKey;
return trade;
}
public String getOffererPubKey()
@ -48,19 +58,4 @@ public class Contract
return offererPubKey;
}
public void setOffererPubKey(String offererPubKey)
{
this.offererPubKey = offererPubKey;
}
public Trade getTrade()
{
return trade;
}
public void setTrade(Trade trade)
{
this.trade = trade;
}
}

View file

@ -85,8 +85,7 @@ public class Trading
log.info("create new contract");
KeyPair address = walletFacade.createNewAddress();
Contract contract = new Contract(trade, address.getPubKey());
contract.setTaker(user);
Contract contract = new Contract(user, trade, address.getPubKey());
contracts.put(trade.getUid().toString(), contract);
return contract;
}

View file

@ -1,7 +1,7 @@
package io.bitsquare.trade.orderbook;
import com.google.inject.Inject;
import io.bitsquare.gui.trade.orderbook.OrderBookListItem;
import io.bitsquare.gui.market.orderbook.OrderBookListItem;
import io.bitsquare.gui.util.Converter;
import io.bitsquare.gui.util.Formatter;
import io.bitsquare.settings.Settings;
@ -43,7 +43,7 @@ public class MockOrderBook extends OrderBook
price = 500 - Math.random() * 50;
}
Offer offer = new Offer(UUID.randomUUID().toString(),
Offer offer = new Offer("mjbxLbuVpU1cNXLJbrJZyirYwweoRPVVTj",
UUID.randomUUID().toString(),
direction,
price,

View file

@ -2,8 +2,7 @@ package io.bitsquare.trade.orderbook;
import com.google.inject.Inject;
import io.bitsquare.bank.BankAccount;
import io.bitsquare.bank.BankAccountType;
import io.bitsquare.gui.trade.orderbook.OrderBookListItem;
import io.bitsquare.gui.market.orderbook.OrderBookListItem;
import io.bitsquare.settings.Settings;
import io.bitsquare.trade.Direction;
import io.bitsquare.trade.Offer;
@ -23,29 +22,30 @@ public class OrderBook
{
private static final Logger log = LoggerFactory.getLogger(OrderBook.class);
private FilteredList<OrderBookListItem> filteredList;
private SortedList<OrderBookListItem> offerList;
protected ObservableList<OrderBookListItem> allOffers = FXCollections.observableArrayList();
private Settings settings;
private User user;
protected ObservableList<OrderBookListItem> allOffers = FXCollections.observableArrayList();
private FilteredList<OrderBookListItem> filteredList = new FilteredList<>(allOffers);
// FilteredList does not support sorting, so we need to wrap it to a SortedList
private SortedList<OrderBookListItem> offerList = new SortedList<>(filteredList);
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public OrderBook(Settings settings, User user)
{
this.settings = settings;
this.user = user;
filteredList = new FilteredList<>(allOffers);
// FilteredList does not support sorting, so we need to wrap it to a SortedList
offerList = new SortedList<>(filteredList);
}
public SortedList<OrderBookListItem> getOfferList()
{
return offerList;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Public API
///////////////////////////////////////////////////////////////////////////////////////////
public void updateFilter(OrderBookFilter orderBookFilter)
{
@ -130,6 +130,20 @@ public class OrderBook
});
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getter
///////////////////////////////////////////////////////////////////////////////////////////
public SortedList<OrderBookListItem> getOfferList()
{
return offerList;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private Methods
///////////////////////////////////////////////////////////////////////////////////////////
private boolean countryInList(Locale orderBookFilterLocale, List<Locale> offerConstraintsLocales)
{
for (Locale locale : offerConstraintsLocales)
@ -152,16 +166,4 @@ public class OrderBook
}
return false;
}
private boolean matchBankAccountTypeEnum(BankAccountType.BankAccountTypeEnum orderBookFilterBankAccountType, List<BankAccountType.BankAccountTypeEnum> offerConstraintsBankAccountTypes)
{
for (BankAccountType.BankAccountTypeEnum bankAccountType : offerConstraintsBankAccountTypes)
{
if (bankAccountType.equals(orderBookFilterBankAccountType))
return true;
}
return false;
}
}

View file

@ -11,7 +11,10 @@ public class OrderBookFilter
private double amount;
private Direction direction;
// setters
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
public void setAmount(double amount)
{
@ -32,7 +35,10 @@ public class OrderBookFilter
}
// getters
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public double getAmount()
{
return amount;
@ -48,12 +54,16 @@ public class OrderBookFilter
return price;
}
public SimpleBooleanProperty getChangedProperty()
{
return changedProperty;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private Methods
///////////////////////////////////////////////////////////////////////////////////////////
private void triggerChange()
{
changedProperty.set(!changedProperty.get());

View file

@ -16,7 +16,7 @@ public class User implements Serializable
private String accountID;
private String messageID;
private boolean online;
private boolean isOnline;
private List<BankAccount> bankAccounts = new ArrayList<>();
private BankAccount currentBankAccount = null;
@ -24,39 +24,34 @@ public class User implements Serializable
{
}
///////////////////////////////////////////////////////////////////////////////////////////
// Public Methods
///////////////////////////////////////////////////////////////////////////////////////////
public void updateFromStorage(User savedUser)
{
if (savedUser != null)
{
accountID = savedUser.getAccountID();
messageID = savedUser.getMessageID();
online = savedUser.isOnline();
isOnline = savedUser.getIsOnline();
bankAccounts = savedUser.getBankAccounts();
currentBankAccount = savedUser.getCurrentBankAccount();
}
}
public String getStringifiedBankAccounts()
{
String bankAccountUIDs = "";
for (Iterator<BankAccount> iterator = getBankAccounts().iterator(); iterator.hasNext(); )
{
BankAccount bankAccount = iterator.next();
bankAccountUIDs += bankAccount.getStringifiedBankAccount();
if (iterator.hasNext())
bankAccountUIDs += ", ";
}
return bankAccountUIDs;
}
public void addBankAccount(BankAccount bankAccount)
{
bankAccounts.add(bankAccount);
currentBankAccount = bankAccount;
}
// setter
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
public void setMessageID(String messageID)
{
this.messageID = messageID;
@ -78,14 +73,30 @@ public class User implements Serializable
triggerChange();
}
public void setOnline(boolean online)
public void setIsOnline(boolean isOnline)
{
this.online = online;
this.isOnline = isOnline;
}
// getter
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public String getStringifiedBankAccounts()
{
String bankAccountUIDs = "";
for (Iterator<BankAccount> iterator = getBankAccounts().iterator(); iterator.hasNext(); )
{
BankAccount bankAccount = iterator.next();
bankAccountUIDs += bankAccount.getStringifiedBankAccount();
if (iterator.hasNext())
bankAccountUIDs += ", ";
}
return bankAccountUIDs;
}
public String getMessageID()
{
return messageID;
@ -106,18 +117,21 @@ public class User implements Serializable
return currentBankAccount;
}
public boolean isOnline()
public boolean getIsOnline()
{
return online;
return isOnline;
}
public SimpleBooleanProperty getChangedProperty()
{
return changedProperty;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private Methods
///////////////////////////////////////////////////////////////////////////////////////////
private void triggerChange()
{
changedProperty.set(!changedProperty.get());