mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-21 05:14:31 -04:00
formatting, rename packages
This commit is contained in:
parent
256388e4e3
commit
7d0676a995
25 changed files with 1354 additions and 1306 deletions
|
@ -2,6 +2,8 @@ package io.bitsquare;
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
import io.bitsquare.bank.BankAccount;
|
||||||
|
import io.bitsquare.bank.BankAccountType;
|
||||||
import io.bitsquare.btc.WalletFacade;
|
import io.bitsquare.btc.WalletFacade;
|
||||||
import io.bitsquare.di.BitSquareModule;
|
import io.bitsquare.di.BitSquareModule;
|
||||||
import io.bitsquare.di.GuiceFXMLLoader;
|
import io.bitsquare.di.GuiceFXMLLoader;
|
||||||
|
@ -10,6 +12,7 @@ import io.bitsquare.settings.Settings;
|
||||||
import io.bitsquare.storage.Storage;
|
import io.bitsquare.storage.Storage;
|
||||||
import io.bitsquare.user.Arbitrator;
|
import io.bitsquare.user.Arbitrator;
|
||||||
import io.bitsquare.user.User;
|
import io.bitsquare.user.User;
|
||||||
|
import io.bitsquare.util.MockData;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
@ -100,32 +103,35 @@ public class BitSquare extends Application
|
||||||
|
|
||||||
storage.write(settings.getClass().getName(), settings);
|
storage.write(settings.getClass().getName(), settings);
|
||||||
|
|
||||||
/*
|
initMockUser(storage, 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);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
settings.updateFromStorage(savedSettings);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,14 @@ public class BlockChainFacade
|
||||||
|
|
||||||
public boolean verifyEmbeddedData(String address)
|
public boolean verifyEmbeddedData(String address)
|
||||||
{
|
{
|
||||||
|
// tx id 76982adc582657b2eb68f3e43341596a68aadc4ef6b9590e88e93387d4d5d1f9
|
||||||
|
// address: mjbxLbuVpU1cNXLJbrJZyirYwweoRPVVTj
|
||||||
return true;
|
return true;
|
||||||
/*
|
/*
|
||||||
if (findAddressInBlockChain(address) && isFeePayed(address))
|
if (findAddressInBlockChain(address) && isFeePayed(address))
|
||||||
return getDataForTxWithAddress(address) != null;
|
return getDataForTxWithAddress(address) != null;
|
||||||
else
|
else
|
||||||
return true; */
|
return true; */
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean findAddressInBlockChain(String address)
|
private boolean findAddressInBlockChain(String address)
|
||||||
|
|
|
@ -3,5 +3,4 @@ package io.bitsquare.gui;
|
||||||
public interface ChildController
|
public interface ChildController
|
||||||
{
|
{
|
||||||
void setNavigationController(NavigationController navigationController);
|
void setNavigationController(NavigationController navigationController);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ 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;
|
||||||
|
import io.bitsquare.gui.market.MarketController;
|
||||||
import io.bitsquare.gui.setup.SetupController;
|
import io.bitsquare.gui.setup.SetupController;
|
||||||
import io.bitsquare.gui.trade.TradeController;
|
|
||||||
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.gui.util.Localisation;
|
||||||
|
@ -56,6 +56,11 @@ public class MainController implements Initializable, NavigationController, Wall
|
||||||
@FXML
|
@FXML
|
||||||
public AnchorPane anchorPane;
|
public AnchorPane anchorPane;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Constructor
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MainController(User user, WalletFacade walletFacade)
|
public MainController(User user, WalletFacade walletFacade)
|
||||||
{
|
{
|
||||||
|
@ -63,6 +68,11 @@ public class MainController implements Initializable, NavigationController, Wall
|
||||||
this.walletFacade = walletFacade;
|
this.walletFacade = walletFacade;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Interface implementation: Initializable
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle rb)
|
public void initialize(URL url, ResourceBundle rb)
|
||||||
{
|
{
|
||||||
|
@ -87,6 +97,10 @@ public class MainController implements Initializable, NavigationController, Wall
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Interface implementation: NavigationController
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChildController navigateToView(String fxmlView, String title)
|
public ChildController navigateToView(String fxmlView, String title)
|
||||||
{
|
{
|
||||||
|
@ -102,9 +116,9 @@ public class MainController implements Initializable, NavigationController, Wall
|
||||||
return null;
|
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());
|
final GuiceFXMLLoader loader = new GuiceFXMLLoader(getClass().getResource(fxmlView), Localisation.getResourceBundle());
|
||||||
|
@ -122,6 +136,11 @@ public class MainController implements Initializable, NavigationController, Wall
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Interface implementation: WalletFacade.DownloadListener
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void progress(double percent, int blocksSoFar, Date date)
|
public void progress(double percent, int blocksSoFar, Date date)
|
||||||
{
|
{
|
||||||
|
@ -136,15 +155,10 @@ public class MainController implements Initializable, NavigationController, Wall
|
||||||
Platform.runLater(networkSyncPane::doneDownload);
|
Platform.runLater(networkSyncPane::doneDownload);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChildController navigateToView(String fxmlView, Direction direction)
|
|
||||||
{
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
childController = navigateToView(fxmlView, direction == Direction.BUY ? "Orderbook Buy" : "Orderbook Sell");
|
// Private methods
|
||||||
if (childController instanceof TradeController && direction != null)
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
{
|
|
||||||
((TradeController) childController).setDirection(direction);
|
|
||||||
}
|
|
||||||
return childController;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildSetupView()
|
private void buildSetupView()
|
||||||
{
|
{
|
||||||
|
@ -165,8 +179,8 @@ public class MainController implements Initializable, NavigationController, Wall
|
||||||
toggleGroup = new ToggleGroup();
|
toggleGroup = new ToggleGroup();
|
||||||
|
|
||||||
ToggleButton homeButton = addNavButton(leftNavPane, "Overview", Icons.HOME, Icons.HOME, NavigationController.HOME);
|
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 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.TRADE, Direction.SELL);
|
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, "Orders", Icons.ORDERS, Icons.ORDERS, NavigationController.ORDERS);
|
||||||
addNavButton(leftNavPane, "History", Icons.HISTORY, Icons.HISTORY, NavigationController.HISTORY);
|
addNavButton(leftNavPane, "History", Icons.HISTORY, Icons.HISTORY, NavigationController.HISTORY);
|
||||||
addNavButton(leftNavPane, "Funds", Icons.FUNDS, Icons.FUNDS, NavigationController.FUNDS);
|
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();
|
prevToggleButtonIcon = ((ImageView) (toggleButton.getGraphic())).getImage();
|
||||||
((ImageView) (toggleButton.getGraphic())).setImage(Icons.getIconImage(iconIdActivated));
|
((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
|
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;
|
prevToggleButton = toggleButton;
|
||||||
|
|
||||||
|
|
|
@ -2,20 +2,19 @@ package io.bitsquare.gui;
|
||||||
|
|
||||||
public interface NavigationController
|
public interface NavigationController
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final String SETUP = "/io/bitsquare/gui/setup/SetupView.fxml";
|
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 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 ORDERS = "/io/bitsquare/gui/orders/OrdersView.fxml";
|
||||||
public static final String FUNDS = "/io/bitsquare/gui/funds/FundsView.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 MSG = "/io/bitsquare/gui/msg/MsgView.fxml";
|
||||||
public static final String HISTORY = "/io/bitsquare/gui/history/HistoryView.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 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 ORDER_BOOK = "/io/bitsquare/gui/market/orderbook/OrderBookView.fxml";
|
||||||
public static final String TRADE__PROCESS = "/io/bitsquare/gui/trade/tradeprocess/TradeProcessView.fxml";
|
public static final String TRADE = "/io/bitsquare/gui/market/trade/TradeView.fxml";
|
||||||
public static final String TRADE__CREATE_OFFER = "/io/bitsquare/gui/trade/offer/CreateOfferView.fxml";
|
public static final String CREATE_OFFER = "/io/bitsquare/gui/market/offer/CreateOfferView.fxml";
|
||||||
|
|
||||||
ChildController navigateToView(String fxmlView, String title);
|
ChildController navigateToView(String fxmlView, String title);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package io.bitsquare.gui.trade;
|
package io.bitsquare.gui.market;
|
||||||
|
|
||||||
import io.bitsquare.di.GuiceFXMLLoader;
|
import io.bitsquare.di.GuiceFXMLLoader;
|
||||||
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.orderbook.OrderBookController;
|
import io.bitsquare.gui.market.orderbook.OrderBookController;
|
||||||
import io.bitsquare.gui.util.Localisation;
|
import io.bitsquare.gui.util.Localisation;
|
||||||
import io.bitsquare.trade.Direction;
|
import io.bitsquare.trade.Direction;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
@ -16,20 +16,36 @@ import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ResourceBundle;
|
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 ChildController childController;
|
||||||
private boolean orderbookCreated;
|
private boolean orderbookCreated;
|
||||||
private NavigationController navigationController;
|
private NavigationController navigationController;
|
||||||
private OrderBookController orderBookController;
|
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
|
@Override
|
||||||
public ChildController navigateToView(String fxmlView, String title)
|
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);
|
tabPane.getSelectionModel().select(0);
|
||||||
return null;
|
return null;
|
||||||
|
@ -49,7 +65,7 @@ public class TradeController implements Initializable, NavigationController, Chi
|
||||||
tab.setContent(view);
|
tab.setContent(view);
|
||||||
tabPane.getTabs().add(tab);
|
tabPane.getTabs().add(tab);
|
||||||
|
|
||||||
if (fxmlView.equals(NavigationController.TRADE__ORDER_BOOK))
|
if (fxmlView.equals(NavigationController.ORDER_BOOK))
|
||||||
{
|
{
|
||||||
tab.setClosable(false);
|
tab.setClosable(false);
|
||||||
orderbookCreated = true;
|
orderbookCreated = true;
|
||||||
|
@ -65,11 +81,10 @@ public class TradeController implements Initializable, NavigationController, Chi
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(URL url, ResourceBundle rb)
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
{
|
// Interface implementation: ChildController
|
||||||
navigateToView(NavigationController.TRADE__ORDER_BOOK, "Orderbook");
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNavigationController(NavigationController navigationController)
|
public void setNavigationController(NavigationController navigationController)
|
||||||
|
@ -78,11 +93,10 @@ public class TradeController implements Initializable, NavigationController, Chi
|
||||||
this.navigationController = navigationController;
|
this.navigationController = navigationController;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDirection(Direction direction)
|
|
||||||
{
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
tabPane.getSelectionModel().select(0);
|
// Public methods
|
||||||
orderBookController.setDirection(direction);
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
}
|
|
||||||
|
|
||||||
public void cleanup()
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,4 +4,4 @@
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<TabPane fx:id="tabPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
<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"
|
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"/>
|
|
@ -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.bitcoin.core.InsufficientMoneyException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
@ -172,7 +172,7 @@ public class CreateOfferController implements Initializable, ChildController, Wa
|
||||||
TabPane tabPane = ((TabPane) (holderPane.getParent().getParent()));
|
TabPane tabPane = ((TabPane) (holderPane.getParent().getParent()));
|
||||||
tabPane.getTabs().remove(tabPane.getSelectionModel().getSelectedItem());
|
tabPane.getTabs().remove(tabPane.getSelectionModel().getSelectedItem());
|
||||||
|
|
||||||
navigationController.navigateToView(NavigationController.TRADE__ORDER_BOOK, "Orderbook");
|
navigationController.navigateToView(NavigationController.ORDER_BOOK, "Orderbook");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<?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"
|
||||||
fx:controller="io.bitsquare.gui.trade.offer.CreateOfferController">
|
fx:controller="io.bitsquare.gui.market.offer.CreateOfferController">
|
||||||
<children>
|
<children>
|
||||||
<VBox spacing="10" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="5.0"
|
<VBox spacing="10" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="5.0"
|
||||||
AnchorPane.bottomAnchor="10.0">
|
AnchorPane.bottomAnchor="10.0">
|
|
@ -1,11 +1,11 @@
|
||||||
package io.bitsquare.gui.trade.orderbook;
|
package io.bitsquare.gui.market.orderbook;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import io.bitsquare.bank.BankAccountType;
|
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.market.offer.CreateOfferController;
|
||||||
import io.bitsquare.gui.trade.tradeprocess.TradeProcessController;
|
import io.bitsquare.gui.market.trade.TradeController;
|
||||||
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;
|
||||||
|
@ -125,7 +125,7 @@ public class OrderBookController implements Initializable, ChildController
|
||||||
});
|
});
|
||||||
|
|
||||||
createOfferButton.setOnAction(e -> {
|
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);
|
((CreateOfferController) nextController).setOrderBookFilter(orderBookFilter);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -153,13 +153,13 @@ public class OrderBookController implements Initializable, ChildController
|
||||||
private void openTradeTab(OrderBookListItem orderBookListItem)
|
private void openTradeTab(OrderBookListItem orderBookListItem)
|
||||||
{
|
{
|
||||||
String title = orderBookListItem.getOffer().getDirection() == Direction.BUY ? "Trade: Sell Bitcoin" : "Trade: Buy Bitcoin";
|
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();
|
double requestedAmount = orderBookListItem.getOffer().getAmount();
|
||||||
if (!amount.getText().equals(""))
|
if (!amount.getText().equals(""))
|
||||||
requestedAmount = Converter.stringToDouble(amount.getText());
|
requestedAmount = Converter.stringToDouble(amount.getText());
|
||||||
|
|
||||||
tradeProcessController.initWithData(orderBookListItem.getOffer(), requestedAmount);
|
tradeController.initWithData(orderBookListItem.getOffer(), requestedAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateOfferList()
|
private void updateOfferList()
|
|
@ -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.gui.util.Formatter;
|
||||||
import io.bitsquare.trade.Offer;
|
import io.bitsquare.trade.Offer;
|
|
@ -6,7 +6,7 @@
|
||||||
<?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"
|
||||||
fx:controller="io.bitsquare.gui.trade.orderbook.OrderBookController">
|
fx:controller="io.bitsquare.gui.market.orderbook.OrderBookController">
|
||||||
<children>
|
<children>
|
||||||
|
|
||||||
<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"
|
|
@ -1,4 +1,4 @@
|
||||||
package io.bitsquare.gui.trade.tradeprocess;
|
package io.bitsquare.gui.market.trade;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import io.bitsquare.btc.BlockChainFacade;
|
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.Converter;
|
||||||
import io.bitsquare.gui.util.FormBuilder;
|
import io.bitsquare.gui.util.FormBuilder;
|
||||||
import io.bitsquare.gui.util.Formatter;
|
import io.bitsquare.gui.util.Formatter;
|
||||||
import io.bitsquare.settings.Settings;
|
import io.bitsquare.gui.util.Popups;
|
||||||
import io.bitsquare.storage.Storage;
|
|
||||||
import io.bitsquare.trade.*;
|
import io.bitsquare.trade.*;
|
||||||
import io.bitsquare.user.User;
|
|
||||||
import io.bitsquare.util.Utils;
|
import io.bitsquare.util.Utils;
|
||||||
import javafx.animation.AnimationTimer;
|
import javafx.animation.AnimationTimer;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
@ -25,7 +23,6 @@ import javafx.scene.control.*;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.layout.VBox;
|
|
||||||
import org.controlsfx.dialog.Dialogs;
|
import org.controlsfx.dialog.Dialogs;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -36,28 +33,26 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
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 static final int SIM_DELAY = 1000;
|
||||||
|
|
||||||
private Trading trading;
|
private Trading trading;
|
||||||
private User user;
|
|
||||||
private WalletFacade walletFacade;
|
private WalletFacade walletFacade;
|
||||||
private BlockChainFacade blockChainFacade;
|
private BlockChainFacade blockChainFacade;
|
||||||
private Settings settings;
|
|
||||||
private Storage storage;
|
|
||||||
private Offer offer;
|
private Offer offer;
|
||||||
private Trade trade;
|
private Trade trade;
|
||||||
private Contract contract;
|
private Contract contract;
|
||||||
private double requestedAmount;
|
private double requestedAmount;
|
||||||
private boolean offererIsOnline;
|
private boolean offererIsOnline;
|
||||||
|
private int row;
|
||||||
|
|
||||||
private List<ProcessStepItem> processStepItems = new ArrayList();
|
private List<ProcessStepItem> processStepItems = new ArrayList();
|
||||||
|
|
||||||
private NavigationController navigationController;
|
private NavigationController navigationController;
|
||||||
private TextField amountTextField, totalToPayLabel, totalLabel;
|
private TextField amountTextField, totalToPayLabel, totalLabel;
|
||||||
private Label statusTextField;
|
private Label statusTextField, infoLabel;
|
||||||
private Button nextButton;
|
private Button nextButton;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
|
|
||||||
|
@ -66,26 +61,19 @@ public class TradeProcessController implements Initializable, ChildController, W
|
||||||
@FXML
|
@FXML
|
||||||
private ProcessStepBar<String> processStepBar;
|
private ProcessStepBar<String> processStepBar;
|
||||||
@FXML
|
@FXML
|
||||||
private GridPane formGridPane;
|
private GridPane gridPane;
|
||||||
@FXML
|
|
||||||
private VBox vBox;
|
|
||||||
private Label infoLabel;
|
|
||||||
private int gridRow;
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor(s)
|
// Constructor
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
@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.trading = trading;
|
||||||
this.user = user;
|
|
||||||
this.walletFacade = walletFacade;
|
this.walletFacade = walletFacade;
|
||||||
this.blockChainFacade = blockChainFacade;
|
this.blockChainFacade = blockChainFacade;
|
||||||
this.settings = settings;
|
|
||||||
this.storage = storage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,56 +142,48 @@ public class TradeProcessController implements Initializable, ChildController, W
|
||||||
// Private methods
|
// Private methods
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// trade process
|
// trade process
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
private void buildTakeOfferScreen()
|
private void buildTakeOfferScreen()
|
||||||
{
|
{
|
||||||
|
row = -1;
|
||||||
|
|
||||||
int gridRow = -1;
|
FormBuilder.addHeaderLabel(gridPane, "Take offer:", ++row);
|
||||||
|
amountTextField = FormBuilder.addTextField(gridPane, "Amount BTC:", Formatter.formatAmount(requestedAmount), ++row, true, true);
|
||||||
FormBuilder.addHeaderLabel(formGridPane, "Take offer:", ++gridRow);
|
|
||||||
amountTextField = FormBuilder.addTextField(formGridPane, "Amount BTC:", Formatter.formatAmount(requestedAmount), ++gridRow, true, true);
|
|
||||||
amountTextField.textProperty().addListener(e -> {
|
amountTextField.textProperty().addListener(e -> {
|
||||||
setVolume();
|
applyVolume();
|
||||||
totalToPayLabel.setText(getTotalToPay());
|
totalToPayLabel.setText(getTotalToPay());
|
||||||
|
|
||||||
});
|
});
|
||||||
Label amountRangeLabel = new Label("(" + Formatter.formatAmount(offer.getMinAmount()) + " - " + Formatter.formatAmount(offer.getAmount()) + ")");
|
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);
|
FormBuilder.addTextField(gridPane, "Price:", Formatter.formatPriceWithCurrencyPair(offer.getPrice(), offer.getCurrency()), ++row);
|
||||||
totalLabel = FormBuilder.addTextField(formGridPane, "Total:", Formatter.formatVolume(getVolume(), offer.getCurrency()), ++gridRow);
|
totalLabel = FormBuilder.addTextField(gridPane, "Total:", Formatter.formatVolume(getVolume(), offer.getCurrency()), ++row);
|
||||||
FormBuilder.addTextField(formGridPane, "Offer fee:", Formatter.formatSatoshis(Fees.OFFER_TAKER_FEE, true), ++gridRow);
|
FormBuilder.addTextField(gridPane, "Offer fee:", Formatter.formatSatoshis(Fees.OFFER_TAKER_FEE, true), ++row);
|
||||||
totalToPayLabel = FormBuilder.addTextField(formGridPane, "Total to pay:", getTotalToPay(), ++gridRow);
|
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.setDefaultButton(true);
|
||||||
nextButton.setOnAction(e -> {
|
nextButton.setOnAction(e -> initTrade());
|
||||||
initTrade();
|
|
||||||
});
|
|
||||||
|
|
||||||
// details
|
// details
|
||||||
FormBuilder.addVSpacer(formGridPane, ++gridRow);
|
FormBuilder.addVSpacer(gridPane, ++row);
|
||||||
FormBuilder.addHeaderLabel(formGridPane, "Offerer details:", ++gridRow);
|
FormBuilder.addHeaderLabel(gridPane, "Offerer details:", ++row);
|
||||||
TextField isOnlineTextField = FormBuilder.addTextField(formGridPane, "Online status:", "Checking offerers online status...", ++gridRow);
|
TextField isOnlineTextField = FormBuilder.addTextField(gridPane, "Online status:", "Checking offerers online status...", ++row);
|
||||||
ProgressIndicator isOnlineChecker = new ProgressIndicator();
|
ProgressIndicator isOnlineChecker = new ProgressIndicator();
|
||||||
isOnlineChecker.setPrefSize(20, 20);
|
isOnlineChecker.setPrefSize(20, 20);
|
||||||
isOnlineChecker.setLayoutY(3);
|
isOnlineChecker.setLayoutY(3);
|
||||||
Pane isOnlineCheckerHolder = new Pane();
|
Pane isOnlineCheckerHolder = new Pane();
|
||||||
isOnlineCheckerHolder.getChildren().addAll(isOnlineChecker);
|
isOnlineCheckerHolder.getChildren().addAll(isOnlineChecker);
|
||||||
formGridPane.add(isOnlineCheckerHolder, 2, gridRow);
|
gridPane.add(isOnlineCheckerHolder, 2, row);
|
||||||
checkIfOffererIsOnline(isOnlineCheckerHolder, isOnlineTextField);
|
checkIfOffererIsOnline(isOnlineCheckerHolder, isOnlineTextField);
|
||||||
|
|
||||||
FormBuilder.addTextField(formGridPane, "Bank account type:", offer.getBankAccountTypeEnum().toString(), ++gridRow);
|
FormBuilder.addTextField(gridPane, "Bank account type:", offer.getBankAccountTypeEnum().toString(), ++row);
|
||||||
FormBuilder.addTextField(formGridPane, "Bank account country:", offer.getBankAccountCountryLocale().getDisplayCountry(), ++gridRow);
|
FormBuilder.addTextField(gridPane, "Bank account country:", offer.getBankAccountCountryLocale().getDisplayCountry(), ++row);
|
||||||
FormBuilder.addTextField(formGridPane, "Arbitrator:", offer.getArbitrator().getName(), ++gridRow);
|
FormBuilder.addTextField(gridPane, "Arbitrator:", offer.getArbitrator().getName(), ++row);
|
||||||
Label arbitratorLink = new Label(offer.getArbitrator().getUrl());
|
Label arbitratorLink = new Label(offer.getArbitrator().getUrl());
|
||||||
arbitratorLink.setId("label-url");
|
arbitratorLink.setId("label-url");
|
||||||
formGridPane.add(arbitratorLink, 2, gridRow);
|
gridPane.add(arbitratorLink, 2, row);
|
||||||
arbitratorLink.setOnMouseClicked(e -> {
|
arbitratorLink.setOnMouseClicked(e -> {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -214,93 +194,67 @@ public class TradeProcessController implements Initializable, ChildController, W
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
FormBuilder.addVSpacer(formGridPane, ++gridRow);
|
FormBuilder.addVSpacer(gridPane, ++row);
|
||||||
FormBuilder.addHeaderLabel(formGridPane, "More details:", ++gridRow);
|
FormBuilder.addHeaderLabel(gridPane, "More details:", ++row);
|
||||||
FormBuilder.addTextField(formGridPane, "Offer ID:", offer.getUid().toString(), ++gridRow);
|
FormBuilder.addTextField(gridPane, "Offer ID:", offer.getUid().toString(), ++row);
|
||||||
FormBuilder.addTextField(formGridPane, "Account ID:", offer.getAccountID(), ++gridRow);
|
FormBuilder.addTextField(gridPane, "Account ID:", offer.getAccountID(), ++row);
|
||||||
FormBuilder.addTextField(formGridPane, "Messaging ID:", offer.getMessageID(), ++gridRow);
|
FormBuilder.addTextField(gridPane, "Messaging ID:", offer.getMessageID(), ++row);
|
||||||
FormBuilder.addTextField(formGridPane, "Supported languages:", Formatter.languageLocalesToString(offer.getAcceptedLanguageLocales()), ++gridRow);
|
FormBuilder.addTextField(gridPane, "Supported languages:", Formatter.languageLocalesToString(offer.getAcceptedLanguageLocales()), ++row);
|
||||||
FormBuilder.addTextField(formGridPane, "Supported countries:", Formatter.countryLocalesToString(offer.getAcceptedCountryLocales()), ++gridRow);
|
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()
|
private void initTrade()
|
||||||
{
|
{
|
||||||
if (tradeAmountValid())
|
if (!tradeAmountValid())
|
||||||
{
|
{
|
||||||
if (blockChainFacade.verifyEmbeddedData(offer.getAccountID()))
|
Popups.openErrorPopup("Your input is not valid", "The requested amount you entered is outside of the range of the offered amount.");
|
||||||
{
|
return;
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (!blockChainFacade.verifyEmbeddedData(offer.getAccountID()))
|
||||||
{
|
{
|
||||||
Dialogs.create()
|
Popups.openErrorPopup("Offerers account ID not valid", "Offerers registration tx is not found in blockchain or does not match the requirements.");
|
||||||
.title("Your input is not valid")
|
return;
|
||||||
.message("The requested amount you entered is outside of the range of the offered amount.")
|
|
||||||
.nativeTitleBar()
|
|
||||||
.lightweight()
|
|
||||||
.showError();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
private void onTakeOfferRequestConfirmed()
|
||||||
|
@ -348,11 +302,11 @@ public class TradeProcessController implements Initializable, ChildController, W
|
||||||
{
|
{
|
||||||
processStepBar.next();
|
processStepBar.next();
|
||||||
|
|
||||||
formGridPane.getChildren().clear();
|
gridPane.getChildren().clear();
|
||||||
|
|
||||||
gridRow = -1;
|
row = -1;
|
||||||
FormBuilder.addHeaderLabel(formGridPane, "Bank transfer", ++gridRow, 0);
|
FormBuilder.addHeaderLabel(gridPane, "Bank transfer", ++row, 0);
|
||||||
infoLabel = FormBuilder.addLabel(formGridPane, "Status:", "Wait for Bank transfer.", ++gridRow);
|
infoLabel = FormBuilder.addLabel(gridPane, "Status:", "Wait for Bank transfer.", ++row);
|
||||||
|
|
||||||
Utils.setTimeout(SIM_DELAY, (AnimationTimer animationTimer) -> {
|
Utils.setTimeout(SIM_DELAY, (AnimationTimer animationTimer) -> {
|
||||||
onBankTransferInited();
|
onBankTransferInited();
|
||||||
|
@ -362,12 +316,12 @@ public class TradeProcessController implements Initializable, ChildController, W
|
||||||
|
|
||||||
private void onBankTransferInited()
|
private void onBankTransferInited()
|
||||||
{
|
{
|
||||||
int gridRow = 1;
|
row = 1;
|
||||||
infoLabel.setText("Bank transfer has been inited.");
|
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);
|
GridPane.setColumnSpan(label, 2);
|
||||||
|
|
||||||
formGridPane.add(nextButton, 1, ++gridRow);
|
gridPane.add(nextButton, 1, ++row);
|
||||||
nextButton.setText("I have received the bank transfer");
|
nextButton.setText("I have received the bank transfer");
|
||||||
nextButton.setOnAction(e -> releaseBTC());
|
nextButton.setOnAction(e -> releaseBTC());
|
||||||
}
|
}
|
||||||
|
@ -380,15 +334,14 @@ public class TradeProcessController implements Initializable, ChildController, W
|
||||||
nextButton.setText("Close");
|
nextButton.setText("Close");
|
||||||
nextButton.setOnAction(e -> close());
|
nextButton.setOnAction(e -> close());
|
||||||
|
|
||||||
formGridPane.getChildren().clear();
|
gridPane.getChildren().clear();
|
||||||
gridRow = -1;
|
row = -1;
|
||||||
FormBuilder.addHeaderLabel(formGridPane, "Trade successfully completed", ++gridRow);
|
FormBuilder.addHeaderLabel(gridPane, "Trade successfully completed", ++row);
|
||||||
FormBuilder.addTextField(formGridPane, "You have payed:", getTotalToPay(), ++gridRow);
|
FormBuilder.addTextField(gridPane, "You have payed:", getTotalToPay(), ++row);
|
||||||
FormBuilder.addTextField(formGridPane, "You have received:", getTotalToReceive(), ++gridRow);
|
FormBuilder.addTextField(gridPane, "You have received:", getTotalToReceive(), ++row);
|
||||||
formGridPane.add(nextButton, 1, ++gridRow);
|
gridPane.add(nextButton, 1, ++row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void close()
|
private void close()
|
||||||
{
|
{
|
||||||
walletFacade.removeRegistrationWalletListener(this);
|
walletFacade.removeRegistrationWalletListener(this);
|
||||||
|
@ -396,26 +349,21 @@ public class TradeProcessController implements Initializable, ChildController, W
|
||||||
TabPane tabPane = ((TabPane) (rootContainer.getParent().getParent()));
|
TabPane tabPane = ((TabPane) (rootContainer.getParent().getParent()));
|
||||||
tabPane.getTabs().remove(tabPane.getSelectionModel().getSelectedItem());
|
tabPane.getTabs().remove(tabPane.getSelectionModel().getSelectedItem());
|
||||||
|
|
||||||
navigationController.navigateToView(NavigationController.TRADE__ORDER_BOOK, "Orderbook");
|
navigationController.navigateToView(NavigationController.ORDER_BOOK, "Orderbook");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Other Private methods
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
private boolean tradeAmountValid()
|
||||||
// Private methods
|
{
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
double tradeAmount = Converter.stringToDouble(amountTextField.getText());
|
||||||
|
return tradeAmount <= offer.getAmount() && tradeAmount >= offer.getMinAmount();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean takerIsSelling()
|
private boolean takerIsSelling()
|
||||||
{
|
{
|
||||||
return offer.getDirection() == Direction.BUY;
|
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)
|
private void checkIfOffererIsOnline(Node isOnlineChecker, TextField isOnlineTextField)
|
||||||
{
|
{
|
||||||
|
@ -423,13 +371,12 @@ public class TradeProcessController implements Initializable, ChildController, W
|
||||||
Utils.setTimeout(3000, (AnimationTimer animationTimer) -> {
|
Utils.setTimeout(3000, (AnimationTimer animationTimer) -> {
|
||||||
offererIsOnline = Math.random() > 0.3 ? true : false;
|
offererIsOnline = Math.random() > 0.3 ? true : false;
|
||||||
isOnlineTextField.setText(offererIsOnline ? "Online" : "Offline");
|
isOnlineTextField.setText(offererIsOnline ? "Online" : "Offline");
|
||||||
formGridPane.getChildren().remove(isOnlineChecker);
|
gridPane.getChildren().remove(isOnlineChecker);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void applyVolume()
|
||||||
private void setVolume()
|
|
||||||
{
|
{
|
||||||
totalLabel.setText(Formatter.formatVolume(getVolume(), offer.getCurrency()));
|
totalLabel.setText(Formatter.formatVolume(getVolume(), offer.getCurrency()));
|
||||||
}
|
}
|
||||||
|
@ -456,5 +403,13 @@ public class TradeProcessController implements Initializable, ChildController, W
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getTotalToReceive()
|
||||||
|
{
|
||||||
|
if (takerIsSelling())
|
||||||
|
return Formatter.formatVolume(getVolume(), offer.getCurrency());
|
||||||
|
else
|
||||||
|
return Formatter.formatAmount(offer.getAmount(), true, true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.ScrollPane?>
|
<?import javafx.scene.control.ScrollPane?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?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">
|
xmlns:fx="http://javafx.com/fxml">
|
||||||
<ScrollPane fitToWidth="true" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
|
<ScrollPane fitToWidth="true" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
|
||||||
AnchorPane.bottomAnchor="0">
|
AnchorPane.bottomAnchor="0">
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
</padding>
|
</padding>
|
||||||
<ProcessStepBar fx:id="processStepBar"/>
|
<ProcessStepBar fx:id="processStepBar"/>
|
||||||
<VSpacer prefHeight="5"/>
|
<VSpacer prefHeight="5"/>
|
||||||
<GridPane fx:id="formGridPane" vgap="5" hgap="5">
|
<GridPane fx:id="gridPane" vgap="5" hgap="5">
|
||||||
<padding>
|
<padding>
|
||||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||||
</padding>
|
</padding>
|
|
@ -65,7 +65,7 @@ public class SetupController implements Initializable, ChildController, WalletFa
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor(s)
|
// Constructor
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
@ -11,8 +11,6 @@ import java.util.Locale;
|
||||||
|
|
||||||
public class Formatter
|
public class Formatter
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public static String formatPrice(double price)
|
public static String formatPrice(double price)
|
||||||
{
|
{
|
||||||
return formatDouble(price);
|
return formatDouble(price);
|
||||||
|
|
16
src/main/java/io/bitsquare/gui/util/Popups.java
Normal file
16
src/main/java/io/bitsquare/gui/util/Popups.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,11 +16,21 @@ public class Settings implements Serializable
|
||||||
private List<Locale> acceptedCountryLocales = new ArrayList<>();
|
private List<Locale> acceptedCountryLocales = new ArrayList<>();
|
||||||
private List<Arbitrator> arbitrators = new ArrayList<>();
|
private List<Arbitrator> arbitrators = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Constructor
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public Settings()
|
public Settings()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Public API
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public void updateFromStorage(Settings savedSettings)
|
public void updateFromStorage(Settings savedSettings)
|
||||||
{
|
{
|
||||||
if (savedSettings != null)
|
if (savedSettings != null)
|
||||||
|
@ -49,7 +59,11 @@ public class Settings implements Serializable
|
||||||
arbitrators.add(arbitrator);
|
arbitrators.add(arbitrator);
|
||||||
}
|
}
|
||||||
|
|
||||||
//getters
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Getters
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public List<Arbitrator> getArbitrators()
|
public List<Arbitrator> getArbitrators()
|
||||||
{
|
{
|
||||||
return arbitrators;
|
return arbitrators;
|
||||||
|
@ -60,7 +74,6 @@ public class Settings implements Serializable
|
||||||
return acceptedLanguageLocales;
|
return acceptedLanguageLocales;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Locale> getAcceptedCountryLocales()
|
public List<Locale> getAcceptedCountryLocales()
|
||||||
{
|
{
|
||||||
return acceptedCountryLocales;
|
return acceptedCountryLocales;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package io.bitsquare.storage;
|
package io.bitsquare.storage;
|
||||||
|
|
||||||
import io.bitsquare.user.User;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -13,56 +12,62 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class Storage
|
public class Storage
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(Storage.class);
|
private static final Logger log = LoggerFactory.getLogger(Storage.class);
|
||||||
|
|
||||||
|
//TODO save in users preferences location
|
||||||
private final String preferencesFileName = "preferences.ser";
|
private final String preferencesFileName = "preferences.ser";
|
||||||
private final String storageFile;
|
private final String storageFile;
|
||||||
private DataVO dataVO;
|
private Map<String, Object> dict;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Constructor
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public Storage()
|
public Storage()
|
||||||
{
|
{
|
||||||
storageFile = Storage.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/" + preferencesFileName;
|
storageFile = Storage.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/" + preferencesFileName;
|
||||||
|
|
||||||
dataVO = readDataVO();
|
dict = readDataVO();
|
||||||
if (dataVO == null)
|
if (dict == null)
|
||||||
{
|
{
|
||||||
dataVO = new DataVO();
|
dict = new HashMap<>();
|
||||||
dataVO.dict = new HashMap<String, Object>();
|
writeDataVO(dict);
|
||||||
writeDataVO(dataVO);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void updateUserFromStorage(User user)
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
{
|
// Public API
|
||||||
User savedUser = (User) read(user.getClass().getName());
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
if (savedUser != null)
|
|
||||||
user.updateFromStorage(savedUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void write(String key, Object value)
|
public void write(String key, Object value)
|
||||||
{
|
{
|
||||||
//log.info("Write object with key = " + key + " / value = " + value);
|
//log.info("Write object with key = " + key + " / value = " + value);
|
||||||
dataVO.dict.put(key, value);
|
dict.put(key, value);
|
||||||
writeDataVO(dataVO);
|
writeDataVO(dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object read(String key)
|
public Object read(String key)
|
||||||
{
|
{
|
||||||
dataVO = readDataVO();
|
dict = readDataVO();
|
||||||
Object result = dataVO.dict.get(key);
|
Object result = dict.get(key);
|
||||||
//log.info("Read object with key = " + key + " result = " + result);
|
//log.info("Read object with key = " + key + " result = " + result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeDataVO(DataVO dataVO)
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Private methods
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
private void writeDataVO(Map<String, Object> dict)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileOutputStream fileOut = new FileOutputStream(storageFile);
|
FileOutputStream fileOut = new FileOutputStream(storageFile);
|
||||||
ObjectOutputStream out = new ObjectOutputStream(fileOut);
|
ObjectOutputStream out = new ObjectOutputStream(fileOut);
|
||||||
out.writeObject(dataVO);
|
out.writeObject(dict);
|
||||||
out.close();
|
out.close();
|
||||||
fileOut.close();
|
fileOut.close();
|
||||||
} catch (IOException i)
|
} 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);
|
File file = new File(storageFile);
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
{
|
{
|
||||||
|
@ -81,7 +86,7 @@ public class Storage
|
||||||
{
|
{
|
||||||
FileInputStream fileIn = new FileInputStream(file);
|
FileInputStream fileIn = new FileInputStream(file);
|
||||||
ObjectInputStream in = new ObjectInputStream(fileIn);
|
ObjectInputStream in = new ObjectInputStream(fileIn);
|
||||||
dataVO = (DataVO) in.readObject();
|
dict = (Map<String, Object>) in.readObject();
|
||||||
in.close();
|
in.close();
|
||||||
fileIn.close();
|
fileIn.close();
|
||||||
} catch (IOException i)
|
} catch (IOException i)
|
||||||
|
@ -92,16 +97,6 @@ public class Storage
|
||||||
c.printStackTrace();
|
c.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dataVO;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class DataVO implements Serializable
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -1127046445783201376L;
|
|
||||||
|
|
||||||
public Map<String, Object> dict;
|
|
||||||
}
|
}
|
|
@ -7,27 +7,37 @@ import java.util.UUID;
|
||||||
public class Contract
|
public class Contract
|
||||||
{
|
{
|
||||||
private User taker;
|
private User taker;
|
||||||
private String offererPubKey;
|
|
||||||
private Trade trade;
|
private Trade trade;
|
||||||
private String takerPubKey;
|
private String takerPubKey;
|
||||||
|
private String offererPubKey;
|
||||||
|
|
||||||
|
public Contract(User taker, Trade trade, String takerPubKey)
|
||||||
public Contract(Trade trade, String takerPubKey)
|
|
||||||
{
|
{
|
||||||
|
this.taker = taker;
|
||||||
this.trade = trade;
|
this.trade = trade;
|
||||||
this.takerPubKey = takerPubKey;
|
this.takerPubKey = takerPubKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Setters
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public void setOffererPubKey(String offererPubKey)
|
||||||
|
{
|
||||||
|
this.offererPubKey = offererPubKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Getters
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public UUID getUid()
|
public UUID getUid()
|
||||||
{
|
{
|
||||||
return trade.getUid();
|
return trade.getUid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTaker(User taker)
|
|
||||||
{
|
|
||||||
this.taker = taker;
|
|
||||||
}
|
|
||||||
|
|
||||||
public User getTaker()
|
public User getTaker()
|
||||||
{
|
{
|
||||||
return taker;
|
return taker;
|
||||||
|
@ -38,9 +48,9 @@ public class Contract
|
||||||
return takerPubKey;
|
return takerPubKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTakerPubKey(String takerPubKey)
|
public Trade getTrade()
|
||||||
{
|
{
|
||||||
this.takerPubKey = takerPubKey;
|
return trade;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOffererPubKey()
|
public String getOffererPubKey()
|
||||||
|
@ -48,19 +58,4 @@ public class Contract
|
||||||
return offererPubKey;
|
return offererPubKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOffererPubKey(String offererPubKey)
|
|
||||||
{
|
|
||||||
this.offererPubKey = offererPubKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Trade getTrade()
|
|
||||||
{
|
|
||||||
return trade;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTrade(Trade trade)
|
|
||||||
{
|
|
||||||
this.trade = trade;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,8 +85,7 @@ public class Trading
|
||||||
log.info("create new contract");
|
log.info("create new contract");
|
||||||
KeyPair address = walletFacade.createNewAddress();
|
KeyPair address = walletFacade.createNewAddress();
|
||||||
|
|
||||||
Contract contract = new Contract(trade, address.getPubKey());
|
Contract contract = new Contract(user, trade, address.getPubKey());
|
||||||
contract.setTaker(user);
|
|
||||||
contracts.put(trade.getUid().toString(), contract);
|
contracts.put(trade.getUid().toString(), contract);
|
||||||
return contract;
|
return contract;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package io.bitsquare.trade.orderbook;
|
package io.bitsquare.trade.orderbook;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
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.Converter;
|
||||||
import io.bitsquare.gui.util.Formatter;
|
import io.bitsquare.gui.util.Formatter;
|
||||||
import io.bitsquare.settings.Settings;
|
import io.bitsquare.settings.Settings;
|
||||||
|
@ -43,7 +43,7 @@ public class MockOrderBook extends OrderBook
|
||||||
price = 500 - Math.random() * 50;
|
price = 500 - Math.random() * 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
Offer offer = new Offer(UUID.randomUUID().toString(),
|
Offer offer = new Offer("mjbxLbuVpU1cNXLJbrJZyirYwweoRPVVTj",
|
||||||
UUID.randomUUID().toString(),
|
UUID.randomUUID().toString(),
|
||||||
direction,
|
direction,
|
||||||
price,
|
price,
|
||||||
|
|
|
@ -2,8 +2,7 @@ package io.bitsquare.trade.orderbook;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import io.bitsquare.bank.BankAccount;
|
import io.bitsquare.bank.BankAccount;
|
||||||
import io.bitsquare.bank.BankAccountType;
|
import io.bitsquare.gui.market.orderbook.OrderBookListItem;
|
||||||
import io.bitsquare.gui.trade.orderbook.OrderBookListItem;
|
|
||||||
import io.bitsquare.settings.Settings;
|
import io.bitsquare.settings.Settings;
|
||||||
import io.bitsquare.trade.Direction;
|
import io.bitsquare.trade.Direction;
|
||||||
import io.bitsquare.trade.Offer;
|
import io.bitsquare.trade.Offer;
|
||||||
|
@ -23,29 +22,30 @@ public class OrderBook
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(OrderBook.class);
|
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 Settings settings;
|
||||||
private User user;
|
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
|
@Inject
|
||||||
public OrderBook(Settings settings, User user)
|
public OrderBook(Settings settings, User user)
|
||||||
{
|
{
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.user = user;
|
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)
|
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)
|
private boolean countryInList(Locale orderBookFilterLocale, List<Locale> offerConstraintsLocales)
|
||||||
{
|
{
|
||||||
for (Locale locale : offerConstraintsLocales)
|
for (Locale locale : offerConstraintsLocales)
|
||||||
|
@ -152,16 +166,4 @@ public class OrderBook
|
||||||
}
|
}
|
||||||
return false;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,10 @@ public class OrderBookFilter
|
||||||
private double amount;
|
private double amount;
|
||||||
private Direction direction;
|
private Direction direction;
|
||||||
|
|
||||||
// setters
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Setters
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public void setAmount(double amount)
|
public void setAmount(double amount)
|
||||||
{
|
{
|
||||||
|
@ -32,7 +35,10 @@ public class OrderBookFilter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// getters
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Getters
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public double getAmount()
|
public double getAmount()
|
||||||
{
|
{
|
||||||
return amount;
|
return amount;
|
||||||
|
@ -48,12 +54,16 @@ public class OrderBookFilter
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SimpleBooleanProperty getChangedProperty()
|
public SimpleBooleanProperty getChangedProperty()
|
||||||
{
|
{
|
||||||
return changedProperty;
|
return changedProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Private Methods
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private void triggerChange()
|
private void triggerChange()
|
||||||
{
|
{
|
||||||
changedProperty.set(!changedProperty.get());
|
changedProperty.set(!changedProperty.get());
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class User implements Serializable
|
||||||
|
|
||||||
private String accountID;
|
private String accountID;
|
||||||
private String messageID;
|
private String messageID;
|
||||||
private boolean online;
|
private boolean isOnline;
|
||||||
private List<BankAccount> bankAccounts = new ArrayList<>();
|
private List<BankAccount> bankAccounts = new ArrayList<>();
|
||||||
private BankAccount currentBankAccount = null;
|
private BankAccount currentBankAccount = null;
|
||||||
|
|
||||||
|
@ -24,39 +24,34 @@ public class User implements Serializable
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Public Methods
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public void updateFromStorage(User savedUser)
|
public void updateFromStorage(User savedUser)
|
||||||
{
|
{
|
||||||
if (savedUser != null)
|
if (savedUser != null)
|
||||||
{
|
{
|
||||||
accountID = savedUser.getAccountID();
|
accountID = savedUser.getAccountID();
|
||||||
messageID = savedUser.getMessageID();
|
messageID = savedUser.getMessageID();
|
||||||
online = savedUser.isOnline();
|
isOnline = savedUser.getIsOnline();
|
||||||
bankAccounts = savedUser.getBankAccounts();
|
bankAccounts = savedUser.getBankAccounts();
|
||||||
currentBankAccount = savedUser.getCurrentBankAccount();
|
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)
|
public void addBankAccount(BankAccount bankAccount)
|
||||||
{
|
{
|
||||||
bankAccounts.add(bankAccount);
|
bankAccounts.add(bankAccount);
|
||||||
currentBankAccount = bankAccount;
|
currentBankAccount = bankAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// setter
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Setters
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public void setMessageID(String messageID)
|
public void setMessageID(String messageID)
|
||||||
{
|
{
|
||||||
this.messageID = messageID;
|
this.messageID = messageID;
|
||||||
|
@ -78,14 +73,30 @@ public class User implements Serializable
|
||||||
triggerChange();
|
triggerChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIsOnline(boolean isOnline)
|
||||||
public void setOnline(boolean online)
|
|
||||||
{
|
{
|
||||||
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()
|
public String getMessageID()
|
||||||
{
|
{
|
||||||
return messageID;
|
return messageID;
|
||||||
|
@ -106,18 +117,21 @@ public class User implements Serializable
|
||||||
return currentBankAccount;
|
return currentBankAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getIsOnline()
|
||||||
public boolean isOnline()
|
|
||||||
{
|
{
|
||||||
return online;
|
return isOnline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SimpleBooleanProperty getChangedProperty()
|
public SimpleBooleanProperty getChangedProperty()
|
||||||
{
|
{
|
||||||
return changedProperty;
|
return changedProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Private Methods
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private void triggerChange()
|
private void triggerChange()
|
||||||
{
|
{
|
||||||
changedProperty.set(!changedProperty.get());
|
changedProperty.set(!changedProperty.get());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue