Refactored MainView

This commit is contained in:
Manfred Karrer 2014-09-09 15:42:49 +02:00
parent 11cff6dcdb
commit dcceb85669
32 changed files with 763 additions and 464 deletions

View file

@ -22,6 +22,7 @@ import io.bitsquare.btc.BlockChainFacade;
import io.bitsquare.btc.FeePolicy; import io.bitsquare.btc.FeePolicy;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletFacade;
import io.bitsquare.crypto.CryptoFacade; import io.bitsquare.crypto.CryptoFacade;
import io.bitsquare.gui.view.MainViewCB;
import io.bitsquare.msg.BootstrappedPeerFactory; import io.bitsquare.msg.BootstrappedPeerFactory;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.P2PNode; import io.bitsquare.msg.P2PNode;
@ -63,6 +64,7 @@ public class BitSquareModule extends AbstractModule {
bind(BootstrappedPeerFactory.class).asEagerSingleton(); bind(BootstrappedPeerFactory.class).asEagerSingleton();
bind(TradeManager.class).asEagerSingleton(); bind(TradeManager.class).asEagerSingleton();
bind(MainViewCB.class).asEagerSingleton();
//bind(String.class).annotatedWith(Names.named("networkType")).toInstance(WalletFacade.MAIN_NET); //bind(String.class).annotatedWith(Names.named("networkType")).toInstance(WalletFacade.MAIN_NET);

View file

@ -22,7 +22,7 @@ import io.bitsquare.gui.util.ImageUtil;
public enum NavigationItem { public enum NavigationItem {
// app // app
MAIN("/io/bitsquare/gui/MainView.fxml"), MAIN("/io/bitsquare/gui/view/MainView.fxml"),
// main menu screens // main menu screens
HOME("/io/bitsquare/gui/home/HomeView.fxml", ImageUtil.HOME, ImageUtil.HOME_ACTIVE), HOME("/io/bitsquare/gui/home/HomeView.fxml", ImageUtil.HOME, ImageUtil.HOME_ACTIVE),

View file

@ -18,7 +18,7 @@
package io.bitsquare.gui.components; package io.bitsquare.gui.components;
import io.bitsquare.BitSquare; import io.bitsquare.BitSquare;
import io.bitsquare.gui.MainController; import io.bitsquare.gui.view.MainViewCB;
import io.bitsquare.locale.BSResources; import io.bitsquare.locale.BSResources;
import com.google.bitcoin.store.BlockStoreException; import com.google.bitcoin.store.BlockStoreException;
@ -56,7 +56,7 @@ public class Popups {
// Supports blurring the content background // Supports blurring the content background
public static void openInfo(String message, String masthead) { public static void openInfo(String message, String masthead) {
MainController.GET_INSTANCE().blurContentScreen(); MainViewCB.getInstance().blurContentScreen();
List<Action> actions = new ArrayList<>(); List<Action> actions = new ArrayList<>();
// Dialogs are a bit limited. There is no callback for the InformationDialog button click, so we added // Dialogs are a bit limited. There is no callback for the InformationDialog button click, so we added
@ -65,7 +65,7 @@ public class Popups {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
Dialog.Actions.CLOSE.handle(actionEvent); Dialog.Actions.CLOSE.handle(actionEvent);
MainController.GET_INSTANCE().removeContentScreenBlur(); MainViewCB.getInstance().removeContentScreenBlur();
} }
}); });
openInfo(message, masthead, actions); openInfo(message, masthead, actions);

View file

@ -17,8 +17,8 @@
package io.bitsquare.gui.components.btc; package io.bitsquare.gui.components.btc;
import io.bitsquare.gui.MainController;
import io.bitsquare.gui.components.Popups; import io.bitsquare.gui.components.Popups;
import io.bitsquare.gui.view.MainViewCB;
import com.google.bitcoin.core.Coin; import com.google.bitcoin.core.Coin;
import com.google.bitcoin.uri.BitcoinURI; import com.google.bitcoin.uri.BitcoinURI;
@ -124,13 +124,13 @@ public class AddressTextField extends AnchorPane {
PopOver popOver = new PopOver(pane); PopOver popOver = new PopOver(pane);
popOver.setDetachedTitle("Scan QR code for this address"); popOver.setDetachedTitle("Scan QR code for this address");
popOver.setDetached(true); popOver.setDetached(true);
popOver.setOnHiding(windowEvent -> MainController.GET_INSTANCE().removeContentScreenBlur()); popOver.setOnHiding(windowEvent -> MainViewCB.getInstance().removeContentScreenBlur());
Window window = getScene().getWindow(); Window window = getScene().getWindow();
double x = Math.round(window.getX() + (window.getWidth() - 320) / 2); double x = Math.round(window.getX() + (window.getWidth() - 320) / 2);
double y = Math.round(window.getY() + (window.getHeight() - 240) / 2); double y = Math.round(window.getY() + (window.getHeight() - 240) / 2);
popOver.show(getScene().getWindow(), x, y); popOver.show(getScene().getWindow(), x, y);
MainController.GET_INSTANCE().blurContentScreen(); MainViewCB.getInstance().blurContentScreen();
} }
}); });

View file

@ -0,0 +1,210 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.model;
import io.bitsquare.bank.BankAccount;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.UIModel;
import io.bitsquare.gui.util.Profiler;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.listeners.BootstrapListener;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.trade.TradeManager;
import io.bitsquare.user.User;
import com.google.bitcoin.core.Coin;
import com.google.inject.Inject;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.ObservableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MainModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(MainModel.class);
private final User user;
private final WalletFacade walletFacade;
private final MessageFacade messageFacade;
private final TradeManager tradeManager;
private final Persistence persistence;
private boolean messageFacadeInited;
private boolean walletFacadeInited;
public final BooleanProperty backendInited = new SimpleBooleanProperty();
public final DoubleProperty networkSyncProgress = new SimpleDoubleProperty();
public final BooleanProperty networkSyncComplete = new SimpleBooleanProperty();
public final BooleanProperty takeOfferRequested = new SimpleBooleanProperty();
public final ObjectProperty<Coin> balance = new SimpleObjectProperty<>();
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
private MainModel(User user, WalletFacade walletFacade, MessageFacade messageFacade,
TradeManager tradeManager, Persistence persistence) {
this.user = user;
this.walletFacade = walletFacade;
this.messageFacade = messageFacade;
this.tradeManager = tradeManager;
this.persistence = persistence;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void initialized() {
super.initialized();
}
@Override
public void activate() {
super.activate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void deactivate() {
super.deactivate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void terminate() {
super.terminate();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Public
///////////////////////////////////////////////////////////////////////////////////////////
public void initBackend() {
Profiler.printMsgWithTime("MainModel.initFacades");
messageFacade.init(new BootstrapListener() {
@Override
public void onCompleted() {
messageFacadeInited = true;
if (walletFacadeInited) onFacadesInitialised();
}
@Override
public void onFailed(Throwable throwable) {
log.error(throwable.toString());
}
});
walletFacade.initialize(() -> {
walletFacadeInited = true;
if (messageFacadeInited)
onFacadesInitialised();
walletFacade.addBalanceListener(new BalanceListener() {
@Override
public void onBalanceChanged(Coin balance) {
updateBalance(balance);
}
});
updateBalance(walletFacade.getWalletBalance());
});
}
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
public void setSelectedNavigationItem(NavigationItem navigationItem) {
persistence.write(this, "selectedNavigationItem", navigationItem);
}
public void setCurrentBankAccount(BankAccount bankAccount) {
user.setCurrentBankAccount(bankAccount);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public ObservableList<BankAccount> getBankAccounts() {
return user.getBankAccounts();
}
public ObjectProperty<BankAccount> currentBankAccountProperty() {
return user.currentBankAccountProperty();
}
public NavigationItem getSelectedNavigationItem() {
NavigationItem selectedNavigationItem = (NavigationItem) persistence.read(this, "selectedNavigationItem");
// Set default
// TODO set HOME later
if (selectedNavigationItem == null)
selectedNavigationItem = NavigationItem.BUY;
return selectedNavigationItem;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private
///////////////////////////////////////////////////////////////////////////////////////////
private void onFacadesInitialised() {
Profiler.printMsgWithTime("MainModel.onFacadesInitialised");
// TODO Check this: never called on regtest
// Consider to use version from Mike Hearn
walletFacade.addDownloadListener(new WalletFacade.DownloadListener() {
@Override
public void progress(double percent) {
networkSyncProgress.set(percent);
}
@Override
public void downloadComplete() {
networkSyncComplete.set(true);
}
});
tradeManager.addTakeOfferRequestListener((offerId, sender) -> takeOfferRequested.set(true));
backendInited.set(true);
}
private void updateBalance(Coin balance) {
this.balance.set(balance);
}
}

View file

@ -0,0 +1,166 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.pm;
import io.bitsquare.bank.BankAccount;
import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.PresentationModel;
import io.bitsquare.gui.model.MainModel;
import io.bitsquare.gui.util.BSFormatter;
import com.google.inject.Inject;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.util.StringConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MainPM extends PresentationModel<MainModel> {
private static final Logger log = LoggerFactory.getLogger(MainPM.class);
public final BooleanProperty backendInited = new SimpleBooleanProperty();
public final StringProperty balance = new SimpleStringProperty();
public final StringProperty bankAccountsComboBoxPrompt = new SimpleStringProperty();
public final BooleanProperty bankAccountsComboBoxDisable = new SimpleBooleanProperty();
public final StringProperty splashScreenInfoText = new SimpleStringProperty();
public final BooleanProperty networkSyncComplete = new SimpleBooleanProperty();
public final BooleanProperty takeOfferRequested = new SimpleBooleanProperty();
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
private MainPM(MainModel model) {
super(model);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override
public void initialized() {
super.initialized();
backendInited.bind(model.backendInited);
networkSyncComplete.bind(model.networkSyncComplete);
takeOfferRequested.bind(model.takeOfferRequested);
model.networkSyncProgress.addListener((ov, oldValue, newValue) -> {
if ((double) newValue > 0)
splashScreenInfoText.set("Synchronise with network " + BSFormatter.formatToPercent((double) newValue));
else if ((double) newValue == 1)
splashScreenInfoText.set("Synchronise with network completed.");
else
splashScreenInfoText.set("Synchronise with network...");
});
model.balance.addListener((ov, oldValue, newValue) -> balance.set(BSFormatter.formatCoinWithCode
(newValue)));
model.getBankAccounts().addListener((ListChangeListener<BankAccount>) change -> {
bankAccountsComboBoxDisable.set(change.getList().isEmpty());
bankAccountsComboBoxPrompt.set(change.getList().isEmpty() ? "No accounts" : "");
});
bankAccountsComboBoxDisable.set(model.getBankAccounts().isEmpty());
bankAccountsComboBoxPrompt.set(model.getBankAccounts().isEmpty() ? "No accounts" : "");
}
@Override
public void activate() {
super.activate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void deactivate() {
super.deactivate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void terminate() {
super.terminate();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Public
///////////////////////////////////////////////////////////////////////////////////////////
public void initBackend() {
model.initBackend();
}
///////////////////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////////////////
public void setSelectedNavigationItem(NavigationItem navigationItem) {
model.setSelectedNavigationItem(navigationItem);
}
public void setCurrentBankAccount(BankAccount bankAccount) {
model.setCurrentBankAccount(bankAccount);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
public NavigationItem getSelectedNavigationItem() {
return model.getSelectedNavigationItem();
}
public ObservableList<BankAccount> getBankAccounts() {
return model.getBankAccounts();
}
public ObjectProperty<BankAccount> currentBankAccountProperty() {
return model.currentBankAccountProperty();
}
public StringConverter<BankAccount> getBankAccountsConverter() {
return new StringConverter<BankAccount>() {
@Override
public String toString(BankAccount bankAccount) {
return bankAccount.getAccountTitle();
}
@Override
public BankAccount fromString(String s) {
return null;
}
};
}
}

View file

@ -22,7 +22,7 @@ import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.components.InputTextField; import io.bitsquare.gui.components.InputTextField;
import io.bitsquare.gui.trade.orderbook.OrderBookController; import io.bitsquare.gui.trade.orderbook.OrderBookController;
import io.bitsquare.gui.trade.takeoffer.TakeOfferController; import io.bitsquare.gui.trade.takeoffer.TakeOfferController;
import io.bitsquare.gui.view.trade.CreateOfferCB; import io.bitsquare.gui.view.trade.CreateOfferViewCB;
import io.bitsquare.trade.Direction; import io.bitsquare.trade.Direction;
import io.bitsquare.util.BSFXMLLoader; import io.bitsquare.util.BSFXMLLoader;
@ -47,7 +47,7 @@ public class TradeController extends CachedViewController {
private static final Logger log = LoggerFactory.getLogger(TradeController.class); private static final Logger log = LoggerFactory.getLogger(TradeController.class);
protected OrderBookController orderBookController; protected OrderBookController orderBookController;
protected CreateOfferCB createOfferCodeBehind; protected CreateOfferViewCB createOfferCodeBehind;
protected TakeOfferController takeOfferController; protected TakeOfferController takeOfferController;
protected BSFXMLLoader orderBookLoader; protected BSFXMLLoader orderBookLoader;
private Node createOfferView; private Node createOfferView;

View file

@ -21,14 +21,14 @@ import io.bitsquare.bank.BankAccountType;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletFacade;
import io.bitsquare.gui.CachedViewController; import io.bitsquare.gui.CachedViewController;
import io.bitsquare.gui.CodeBehind; import io.bitsquare.gui.CodeBehind;
import io.bitsquare.gui.MainController;
import io.bitsquare.gui.NavigationItem; import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.ViewController; import io.bitsquare.gui.ViewController;
import io.bitsquare.gui.components.Popups; import io.bitsquare.gui.components.Popups;
import io.bitsquare.gui.trade.takeoffer.TakeOfferController; import io.bitsquare.gui.trade.takeoffer.TakeOfferController;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.gui.util.ImageUtil;
import io.bitsquare.gui.view.trade.CreateOfferCB; import io.bitsquare.gui.view.MainViewCB;
import io.bitsquare.gui.view.trade.CreateOfferViewCB;
import io.bitsquare.locale.BSResources; import io.bitsquare.locale.BSResources;
import io.bitsquare.locale.Country; import io.bitsquare.locale.Country;
import io.bitsquare.locale.CurrencyUtil; import io.bitsquare.locale.CurrencyUtil;
@ -245,7 +245,7 @@ public class OrderBookController extends CachedViewController {
} }
if (nextController != null) if (nextController != null)
((CreateOfferCB) nextController).setOrderBookFilter(orderBookFilter); ((CreateOfferViewCB) nextController).setOrderBookFilter(orderBookFilter);
} }
else { else {
openSetupScreen(); openSetupScreen();
@ -270,16 +270,16 @@ public class OrderBookController extends CachedViewController {
private void openSetupScreen() { private void openSetupScreen() {
MainController.GET_INSTANCE().blurContentScreen(); MainViewCB.getInstance().blurContentScreen();
List<Action> actions = new ArrayList<>(); List<Action> actions = new ArrayList<>();
actions.add(new AbstractAction(BSResources.get("shared.ok")) { actions.add(new AbstractAction(BSResources.get("shared.ok")) {
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
Dialog.Actions.OK.handle(actionEvent); Dialog.Actions.OK.handle(actionEvent);
MainController.GET_INSTANCE().removeContentScreenBlur(); MainViewCB.getInstance().removeContentScreenBlur();
MainController.GET_INSTANCE().loadViewAndGetChildController(NavigationItem.ACCOUNT); MainViewCB.getInstance().triggerMainMenuButton(NavigationItem.ACCOUNT);
MainController.GET_INSTANCE() MainViewCB.getInstance()
.setPreviousNavigationItem((orderBookFilter.getDirection() == Direction.BUY) ? .setPreviousNavigationItem((orderBookFilter.getDirection() == Direction.BUY) ?
NavigationItem.BUY : NavigationItem.SELL); NavigationItem.BUY : NavigationItem.SELL);
} }

View file

@ -291,6 +291,14 @@ public class BSFormatter {
return decimalFormat.format(collateral / 10) + " %"; return decimalFormat.format(collateral / 10) + " %";
} }
public static String formatToPercent(double value) {
DecimalFormat decimalFormat = (DecimalFormat) DecimalFormat.getInstance(locale);
decimalFormat.setMinimumFractionDigits(1);
decimalFormat.setMaximumFractionDigits(1);
decimalFormat.setGroupingUsed(false);
return decimalFormat.format(value / 100) + " %";
}
public static String formatVolumeWithMinVolume(Fiat volume, Fiat minVolume) { public static String formatVolumeWithMinVolume(Fiat volume, Fiat minVolume) {
return formatFiat(volume) + " (" + formatFiat(minVolume) + ")"; return formatFiat(volume) + " (" + formatFiat(minVolume) + ")";
} }

View file

@ -19,7 +19,7 @@
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<TabPane fx:id="root" fx:controller="io.bitsquare.gui.view.AccountCB" <TabPane fx:id="root" fx:controller="io.bitsquare.gui.view.AccountViewCB"
prefHeight="630.0" prefWidth="1000.0" prefHeight="630.0" prefWidth="1000.0"
AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"

View file

@ -19,10 +19,9 @@ package io.bitsquare.gui.view;
import io.bitsquare.gui.CachedCodeBehind; import io.bitsquare.gui.CachedCodeBehind;
import io.bitsquare.gui.CodeBehind; import io.bitsquare.gui.CodeBehind;
import io.bitsquare.gui.MainController;
import io.bitsquare.gui.NavigationItem; import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.pm.AccountPM; import io.bitsquare.gui.pm.AccountPM;
import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.gui.view.account.AccountSetupViewCB;
import io.bitsquare.util.BSFXMLLoader; import io.bitsquare.util.BSFXMLLoader;
import java.io.IOException; import java.io.IOException;
@ -40,9 +39,9 @@ import javafx.scene.layout.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class AccountCB extends CachedCodeBehind<AccountPM> { public class AccountViewCB extends CachedCodeBehind<AccountPM> {
private static final Logger log = LoggerFactory.getLogger(AccountCB.class); private static final Logger log = LoggerFactory.getLogger(AccountViewCB.class);
public Tab tab; public Tab tab;
@ -52,7 +51,7 @@ public class AccountCB extends CachedCodeBehind<AccountPM> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private AccountCB(AccountPM presentationModel) { private AccountViewCB(AccountPM presentationModel) {
super(presentationModel); super(presentationModel);
} }
@ -111,8 +110,8 @@ public class AccountCB extends CachedCodeBehind<AccountPM> {
Initializable childController = loader.getController(); Initializable childController = loader.getController();
((CodeBehind) childController).setParentController(this); ((CodeBehind) childController).setParentController(this);
if (childController instanceof AccountSetupCB) if (childController instanceof AccountSetupViewCB)
((AccountSetupCB) childController).setRemoveCallBack(() -> { ((AccountSetupViewCB) childController).setRemoveCallBack(() -> {
removeSetup(); removeSetup();
return null; return null;
}); });
@ -132,11 +131,11 @@ public class AccountCB extends CachedCodeBehind<AccountPM> {
private void removeSetup() { private void removeSetup() {
childController = null; childController = null;
NavigationItem previousItem = MainController.GET_INSTANCE().getPreviousNavigationItem(); NavigationItem previousItem = MainViewCB.getInstance().getPreviousNavigationItem();
if (previousItem == null) if (previousItem == null)
previousItem = NavigationItem.HOME; previousItem = NavigationItem.HOME;
MainController.GET_INSTANCE().loadViewAndGetChildController(previousItem); MainViewCB.getInstance().triggerMainMenuButton(previousItem);
} }
} }

View file

@ -17,7 +17,7 @@
--> -->
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<StackPane fx:id="root" fx:controller="io.bitsquare.gui.MainController" <StackPane fx:id="root" fx:controller="io.bitsquare.gui.view.MainViewCB"
prefHeight="750" prefWidth="1000" stylesheets="/io/bitsquare/gui/bitsquare.css" prefHeight="750" prefWidth="1000" stylesheets="/io/bitsquare/gui/bitsquare.css"
xmlns:fx="http://javafx.com/fxml"> xmlns:fx="http://javafx.com/fxml">
</StackPane> </StackPane>

View file

@ -15,27 +15,21 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>. * along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/ */
package io.bitsquare.gui; package io.bitsquare.gui.view;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.gui.CachedCodeBehind;
import io.bitsquare.btc.listeners.BalanceListener; import io.bitsquare.gui.CodeBehind;
import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.components.NetworkSyncPane; import io.bitsquare.gui.components.NetworkSyncPane;
import io.bitsquare.gui.orders.OrdersController; import io.bitsquare.gui.orders.OrdersController;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.pm.MainPM;
import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.gui.util.ImageUtil;
import io.bitsquare.gui.util.Profiler; import io.bitsquare.gui.util.Profiler;
import io.bitsquare.gui.util.Transitions; import io.bitsquare.gui.util.Transitions;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.listeners.BootstrapListener;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.trade.TradeManager;
import io.bitsquare.user.User;
import io.bitsquare.util.AWTSystemTray; import io.bitsquare.util.AWTSystemTray;
import io.bitsquare.util.BSFXMLLoader; import io.bitsquare.util.BSFXMLLoader;
import com.google.bitcoin.core.Coin;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
@ -45,9 +39,6 @@ import java.util.ResourceBundle;
import javax.inject.Inject; import javax.inject.Inject;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.Observable;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.Pos; import javafx.geometry.Pos;
@ -55,9 +46,6 @@ import javafx.scene.*;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.image.*; import javafx.scene.image.*;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.util.StringConverter;
import net.tomp2p.peers.PeerAddress;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -68,32 +56,35 @@ import org.slf4j.LoggerFactory;
* frozen for too long. Pre-loading of views is not implemented yet, and after a quick test it seemed that it does not * frozen for too long. Pre-loading of views is not implemented yet, and after a quick test it seemed that it does not
* give much improvements. * give much improvements.
*/ */
public class MainController extends ViewController { public class MainViewCB extends CachedCodeBehind<MainPM> {
private static final Logger log = LoggerFactory.getLogger(MainController.class); private static final Logger log = LoggerFactory.getLogger(MainViewCB.class);
private static MainController INSTANCE; //TODO
private static MainViewCB instance;
private final User user; private boolean showNetworkSyncPaneRequested;
private final WalletFacade walletFacade; private VBox baseOverlayContainer;
private final MessageFacade messageFacade;
private final TradeManager tradeManager;
private final Persistence persistence;
private final ViewBuilder viewBuilder;
private final ToggleGroup navButtonsGroup = new ToggleGroup(); private final ToggleGroup navButtonsGroup = new ToggleGroup();
private NavigationItem previousNavigationItem;
private AnchorPane contentPane;
private HBox leftNavPane, rightNavPane;
private NetworkSyncPane networkSyncPane;
private BorderPane baseContentContainer;
private AnchorPane contentScreen;
private MenuBar menuBar;
private Label loadingLabel;
private ToggleButton buyButton, sellButton, homeButton, msgButton, ordersButton, fundsButton, settingsButton, private ToggleButton buyButton, sellButton, homeButton, msgButton, ordersButton, fundsButton, settingsButton,
accountButton; accountButton;
private Pane ordersButtonButtonHolder; private Pane ordersButtonButtonPane;
private boolean messageFacadeInited;
private boolean walletFacadeInited;
private NavigationItem previousNavigationItem;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Static // Static
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public static MainController GET_INSTANCE() { //TODO
return INSTANCE; public static MainViewCB getInstance() {
return instance;
} }
@ -102,17 +93,11 @@ public class MainController extends ViewController {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private MainController(User user, WalletFacade walletFacade, MessageFacade messageFacade, private MainViewCB(MainPM presentationModel) {
TradeManager tradeManager, Persistence persistence) { super(presentationModel);
this.user = user;
this.walletFacade = walletFacade;
this.messageFacade = messageFacade;
this.tradeManager = tradeManager;
this.persistence = persistence;
viewBuilder = new ViewBuilder(); //TODO
MainViewCB.instance = this;
MainController.INSTANCE = this;
} }
@ -120,14 +105,27 @@ public class MainController extends ViewController {
// Lifecycle // Lifecycle
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("EmptyMethod")
@Override @Override
public void initialize(URL url, ResourceBundle rb) { public void initialize(URL url, ResourceBundle rb) {
super.initialize(url, rb); super.initialize(url, rb);
Profiler.printMsgWithTime("MainController.initialize"); Profiler.printMsgWithTime("MainController.initialize");
Platform.runLater(() -> viewBuilder.buildSplashScreen((StackPane) root, this)); startup();
} }
@Override
public void activate() {
super.activate();
}
@SuppressWarnings("EmptyMethod")
@Override
public void deactivate() {
super.deactivate();
}
@SuppressWarnings("EmptyMethod")
@Override @Override
public void terminate() { public void terminate() {
super.terminate(); super.terminate();
@ -138,8 +136,7 @@ public class MainController extends ViewController {
// Navigation // Navigation
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override public Initializable triggerMainMenuButton(NavigationItem navigationItem) {
public Initializable loadViewAndGetChildController(NavigationItem navigationItem) {
switch (navigationItem) { switch (navigationItem) {
case HOME: case HOME:
homeButton.fire(); homeButton.fire();
@ -169,176 +166,256 @@ public class MainController extends ViewController {
return childController; return childController;
} }
@Override
public Initializable loadView(NavigationItem navigationItem) {
super.loadView((navigationItem));
final BSFXMLLoader loader = new BSFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()));
try {
final Node view = loader.load();
contentPane.getChildren().setAll(view);
childController = loader.getController();
if (childController instanceof CodeBehind)
((CodeBehind) childController).setParentController(this);
presentationModel.setSelectedNavigationItem(navigationItem);
return childController;
} catch (IOException e) {
e.getStackTrace();
log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
}
return null;
}
public void setPreviousNavigationItem(NavigationItem previousNavigationItem) {
this.previousNavigationItem = previousNavigationItem;
}
public NavigationItem getPreviousNavigationItem() {
return previousNavigationItem;
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Blur effect // Blur
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public void removeContentScreenBlur() { public void removeContentScreenBlur() {
Transitions.removeBlur(viewBuilder.baseContentContainer); Transitions.removeBlur(baseContentContainer);
} }
public void blurContentScreen() { public void blurContentScreen() {
Transitions.blur(viewBuilder.baseContentContainer); Transitions.blur(baseContentContainer);
} }
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Startup Handlers // Private Methods: Startup
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
void onViewInitialized() { private void startup() {
Profiler.printMsgWithTime("MainController.onViewInitialized"); buildBaseContainers();
Platform.runLater(this::initFacades);
} }
private void onFacadesInitialised() { private void buildBaseContainers() {
Profiler.printMsgWithTime("MainController.onFacadesInitialised"); Profiler.printMsgWithTime("MainController.ViewBuilder.buildBaseContainers");
// never called on regtest
walletFacade.addDownloadListener(new WalletFacade.DownloadListener() { baseContentContainer = getBaseContentContainer();
@Override baseContentContainer.setOpacity(0);
public void progress(double percent) { baseOverlayContainer = getSplashScreen();
viewBuilder.loadingLabel.setText("Synchronise with network..."); ((StackPane) root).getChildren().addAll(baseContentContainer, baseOverlayContainer);
if (viewBuilder.networkSyncPane == null)
viewBuilder.setShowNetworkSyncPane(); Platform.runLater(this::buildContentView);
} }
@Override private void buildContentView() {
public void downloadComplete() { Profiler.printMsgWithTime("MainController.ViewBuilder.buildContentView");
viewBuilder.loadingLabel.setText("Synchronise with network done.");
if (viewBuilder.networkSyncPane != null) menuBar = getMenuBar();
viewBuilder.networkSyncPane.downloadComplete(); contentScreen = getContentScreen();
if (showNetworkSyncPaneRequested)
addNetworkSyncPane();
baseContentContainer.setTop(menuBar);
baseContentContainer.setCenter(contentScreen);
Platform.runLater(this::onBaseContainersCreated);
} }
// We need to wait until the backend is initialized as we need it for menu items like the balance field
private void onBaseContainersCreated() {
Profiler.printMsgWithTime("MainController.onBaseContainersCreated");
presentationModel.backendInited.addListener((ov, oldValue, newValue) -> {
if (newValue)
onBackendInited();
}); });
tradeManager.addTakeOfferRequestListener(this::onTakeOfferRequested); presentationModel.initBackend();
Platform.runLater(this::addNavigation);
} }
private void onNavigationAdded() { private void onBackendInited() {
Profiler.printMsgWithTime("MainController.onNavigationAdded"); Profiler.printMsgWithTime("MainController.onBackendInited");
Platform.runLater(this::loadContentView); addMainNavigation();
} }
private void onContentViewLoaded() { private void onMainNavigationAdded() {
Profiler.printMsgWithTime("MainController.onContentViewLoaded"); Profiler.printMsgWithTime("MainController.ondMainNavigationAdded");
Platform.runLater(this::fadeOutSplash); triggerMainMenuButton(presentationModel.getSelectedNavigationItem());
Platform.runLater(this::onContentAdded);
} }
private void fadeOutSplash() { private void onContentAdded() {
Profiler.printMsgWithTime("MainController.fadeOutSplash"); Profiler.printMsgWithTime("MainController.onContentAdded");
Transitions.blur(viewBuilder.splashVBox, 700, false, true);
Transitions.fadeIn(viewBuilder.menuBar);
Transitions.fadeIn(viewBuilder.contentScreen);
}
presentationModel.takeOfferRequested.addListener((ov, olaValue, newValue) -> {
///////////////////////////////////////////////////////////////////////////////////////////
// Handlers
///////////////////////////////////////////////////////////////////////////////////////////
//TODO make ordersButton also reacting to jump to pending tab
private void onTakeOfferRequested(String offerId, PeerAddress sender) {
final Button alertButton = new Button("", ImageUtil.getIconImageView(ImageUtil.MSG_ALERT)); final Button alertButton = new Button("", ImageUtil.getIconImageView(ImageUtil.MSG_ALERT));
alertButton.setId("nav-alert-button"); alertButton.setId("nav-alert-button");
alertButton.relocate(36, 19); alertButton.relocate(36, 19);
alertButton.setOnAction((e) -> { alertButton.setOnAction((e) -> {
ordersButton.fire(); ordersButton.fire();
//TODO
OrdersController.GET_INSTANCE().setSelectedTabIndex(1); OrdersController.GET_INSTANCE().setSelectedTabIndex(1);
}); });
Tooltip.install(alertButton, new Tooltip("Someone accepted your offer")); Tooltip.install(alertButton, new Tooltip("Your offer has been accepted"));
ordersButtonButtonHolder.getChildren().add(alertButton); ordersButtonButtonPane.getChildren().add(alertButton);
AWTSystemTray.setAlert(); AWTSystemTray.setAlert();
});
Platform.runLater(this::fadeOutSplash);
}
private void fadeOutSplash() {
Profiler.printMsgWithTime("MainController.fadeOutSplash");
Transitions.blur(baseOverlayContainer, 700, false, true);
Transitions.fadeIn(baseContentContainer);
} }
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Private startup methods // Private
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private void initFacades() { private BorderPane getBaseContentContainer() {
Profiler.printMsgWithTime("MainController.initFacades"); BorderPane borderPane = new BorderPane();
messageFacade.init(new BootstrapListener() { borderPane.setId("base-content-container");
@Override return borderPane;
public void onCompleted() {
messageFacadeInited = true;
if (walletFacadeInited) onFacadesInitialised();
} }
@Override private VBox getSplashScreen() {
public void onFailed(Throwable throwable) { VBox vBox = new VBox();
log.error(throwable.toString()); vBox.setAlignment(Pos.CENTER);
vBox.setSpacing(10);
vBox.setId("splash");
ImageView logo = ImageUtil.getIconImageView(ImageUtil.SPLASH_LOGO);
logo.setFitWidth(300);
logo.setFitHeight(300);
Label subTitle = new Label("The decentralized Bitcoin exchange");
subTitle.setAlignment(Pos.CENTER);
subTitle.setId("logo-sub-title-label");
loadingLabel = new Label();
loadingLabel.setAlignment(Pos.CENTER);
loadingLabel.setPadding(new Insets(80, 0, 0, 0));
loadingLabel.textProperty().bind(presentationModel.splashScreenInfoText);
vBox.getChildren().addAll(logo, subTitle, loadingLabel);
return vBox;
} }
private MenuBar getMenuBar() {
MenuBar menuBar = new MenuBar();
menuBar.setUseSystemMenuBar(false);
Menu fileMenu = new Menu("_File");
fileMenu.setMnemonicParsing(true);
MenuItem backupMenuItem = new MenuItem("Backup wallet");
fileMenu.getItems().addAll(backupMenuItem);
Menu settingsMenu = new Menu("_Settings");
settingsMenu.setMnemonicParsing(true);
MenuItem changePwMenuItem = new MenuItem("Change password");
settingsMenu.getItems().addAll(changePwMenuItem);
Menu helpMenu = new Menu("_Help");
helpMenu.setMnemonicParsing(true);
MenuItem faqMenuItem = new MenuItem("FAQ");
MenuItem forumMenuItem = new MenuItem("Forum");
helpMenu.getItems().addAll(faqMenuItem, forumMenuItem);
menuBar.getMenus().setAll(fileMenu, settingsMenu, helpMenu);
return menuBar;
}
private AnchorPane getContentScreen() {
AnchorPane anchorPane = new AnchorPane();
anchorPane.setId("content-pane");
leftNavPane = new HBox();
leftNavPane.setSpacing(10);
AnchorPane.setLeftAnchor(leftNavPane, 10d);
AnchorPane.setTopAnchor(leftNavPane, 0d);
rightNavPane = new HBox();
rightNavPane.setSpacing(10);
AnchorPane.setRightAnchor(rightNavPane, 10d);
AnchorPane.setTopAnchor(rightNavPane, 0d);
contentPane = new AnchorPane();
contentPane.setId("content-pane");
AnchorPane.setLeftAnchor(contentPane, 0d);
AnchorPane.setRightAnchor(contentPane, 0d);
AnchorPane.setTopAnchor(contentPane, 60d);
AnchorPane.setBottomAnchor(contentPane, 20d);
anchorPane.getChildren().addAll(leftNavPane, rightNavPane, contentPane);
return anchorPane;
}
private void addNetworkSyncPane() {
networkSyncPane = new NetworkSyncPane();
networkSyncPane.setSpacing(10);
networkSyncPane.setPrefHeight(20);
AnchorPane.setLeftAnchor(networkSyncPane, 0d);
AnchorPane.setBottomAnchor(networkSyncPane, 5d);
presentationModel.networkSyncComplete.addListener((ov, old, newValue) -> {
if (newValue)
networkSyncPane.downloadComplete();
}); });
walletFacade.initialize(() -> { contentScreen.getChildren().addAll(networkSyncPane);
walletFacadeInited = true;
if (messageFacadeInited) onFacadesInitialised();
});
} }
private void addNavigation() { private void addMainNavigation() {
Profiler.printMsgWithTime("MainController.addNavigation"); homeButton = addNavButton(leftNavPane, "Overview", NavigationItem.HOME);
buyButton = addNavButton(leftNavPane, "Buy BTC", NavigationItem.BUY);
sellButton = addNavButton(leftNavPane, "Sell BTC", NavigationItem.SELL);
homeButton = addNavButton(viewBuilder.leftNavPane, "Overview", NavigationItem.HOME); ordersButtonButtonPane = new Pane();
buyButton = addNavButton(viewBuilder.leftNavPane, "Buy BTC", NavigationItem.BUY); ordersButton = addNavButton(ordersButtonButtonPane, "Orders", NavigationItem.ORDERS);
sellButton = addNavButton(viewBuilder.leftNavPane, "Sell BTC", NavigationItem.SELL); leftNavPane.getChildren().add(ordersButtonButtonPane);
ordersButtonButtonHolder = new Pane(); fundsButton = addNavButton(leftNavPane, "Funds", NavigationItem.FUNDS);
ordersButton = addNavButton(ordersButtonButtonHolder, "Orders", NavigationItem.ORDERS);
viewBuilder.leftNavPane.getChildren().add(ordersButtonButtonHolder);
fundsButton = addNavButton(viewBuilder.leftNavPane, "Funds", NavigationItem.FUNDS);
final Pane msgButtonHolder = new Pane(); final Pane msgButtonHolder = new Pane();
msgButton = addNavButton(msgButtonHolder, "Message", NavigationItem.MSG); msgButton = addNavButton(msgButtonHolder, "Message", NavigationItem.MSG);
viewBuilder.leftNavPane.getChildren().add(msgButtonHolder); leftNavPane.getChildren().add(msgButtonHolder);
addBalanceInfo(viewBuilder.rightNavPane); addBalanceInfo(rightNavPane);
addAccountComboBox(viewBuilder.rightNavPane); addBankAccountComboBox(rightNavPane);
settingsButton = addNavButton(viewBuilder.rightNavPane, "Settings", NavigationItem.SETTINGS); settingsButton = addNavButton(rightNavPane, "Settings", NavigationItem.SETTINGS);
accountButton = addNavButton(viewBuilder.rightNavPane, "Account", NavigationItem.ACCOUNT); accountButton = addNavButton(rightNavPane, "Account", NavigationItem.ACCOUNT);
Platform.runLater(this::onNavigationAdded); onMainNavigationAdded();
}
private void loadContentView() {
Profiler.printMsgWithTime("MainController.loadContentView");
NavigationItem selectedNavigationItem = (NavigationItem) persistence.read(this, "selectedNavigationItem");
if (selectedNavigationItem == null)
selectedNavigationItem = NavigationItem.BUY;
loadViewAndGetChildController(selectedNavigationItem);
Platform.runLater(this::onContentViewLoaded);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private methods
///////////////////////////////////////////////////////////////////////////////////////////
private void loadView(NavigationItem navigationItem) {
final BSFXMLLoader loader = new BSFXMLLoader(getClass().getResource(navigationItem.getFxmlUrl()));
try {
final Node view = loader.load();
viewBuilder.contentPane.getChildren().setAll(view);
childController = loader.getController();
//TODO Remove that when all UIs are converted to CodeBehind
if (childController instanceof ViewController)
((ViewController) childController).setParentController(this);
else if (childController instanceof CodeBehind)
((CodeBehind) childController).setParentController(this);
persistence.write(this, "selectedNavigationItem", navigationItem);
} catch (IOException e) {
log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
e.getStackTrace();
}
} }
private ToggleButton addNavButton(Pane parent, String title, NavigationItem navigationItem) { private ToggleButton addNavButton(Pane parent, String title, NavigationItem navigationItem) {
@ -380,13 +457,8 @@ public class MainController extends ViewController {
balanceTextField.setEditable(false); balanceTextField.setEditable(false);
balanceTextField.setPrefWidth(110); balanceTextField.setPrefWidth(110);
balanceTextField.setId("nav-balance-label"); balanceTextField.setId("nav-balance-label");
balanceTextField.setText(BSFormatter.formatCoinWithCode(walletFacade.getWalletBalance())); balanceTextField.textProperty().bind(presentationModel.balance);
walletFacade.addBalanceListener(new BalanceListener() {
@Override
public void onBalanceChanged(Coin balance) {
balanceTextField.setText(BSFormatter.formatCoinWithCode(walletFacade.getWalletBalance()));
}
});
final Label titleLabel = new Label("Balance"); final Label titleLabel = new Label("Balance");
titleLabel.setMouseTransparent(true); titleLabel.setMouseTransparent(true);
@ -402,37 +474,22 @@ public class MainController extends ViewController {
parent.getChildren().add(vBox); parent.getChildren().add(vBox);
} }
private void addAccountComboBox(Pane parent) { private void addBankAccountComboBox(Pane parent) {
final ObservableList<BankAccount> accounts = user.getBankAccounts(); final ComboBox<BankAccount> comboBox = new ComboBox<>(presentationModel.getBankAccounts());
final ComboBox<BankAccount> comboBox =
new ComboBox<>(FXCollections.observableArrayList(accounts));
comboBox.setLayoutY(12); comboBox.setLayoutY(12);
comboBox.setVisibleRowCount(5); comboBox.setVisibleRowCount(5);
comboBox.setConverter(new StringConverter<BankAccount>() { comboBox.setConverter(presentationModel.getBankAccountsConverter());
@Override
public String toString(BankAccount bankAccount) {
return bankAccount.getAccountTitle();
}
@Override comboBox.valueProperty().addListener((ov, oldValue, newValue) ->
public BankAccount fromString(String s) { presentationModel.setCurrentBankAccount(newValue));
return null;
}
});
comboBox.setItems(accounts); comboBox.disableProperty().bind(presentationModel.bankAccountsComboBoxDisable);
comboBox.valueProperty().addListener((ov, oldValue, newValue) -> user.setCurrentBankAccount(newValue)); comboBox.promptTextProperty().bind(presentationModel.bankAccountsComboBoxPrompt);
accounts.addListener((Observable observable) -> {
comboBox.setPromptText((accounts.size() == 0) ? "No accounts" : ""); presentationModel.currentBankAccountProperty().addListener((ov, oldValue, newValue) ->
comboBox.setDisable((accounts.isEmpty())); comboBox.getSelectionModel().select(newValue));
});
comboBox.setPromptText((accounts.isEmpty()) ? "No accounts" : ""); comboBox.getSelectionModel().select(presentationModel.currentBankAccountProperty().get());
comboBox.setDisable((accounts.isEmpty()));
user.currentBankAccountProperty().addListener((ov, oldValue, newValue) -> {
if (newValue != null)
comboBox.getSelectionModel().select(newValue);
});
comboBox.getSelectionModel().select(user.getCurrentBankAccount());
final Label titleLabel = new Label("Bank account"); final Label titleLabel = new Label("Bank account");
titleLabel.setMouseTransparent(true); titleLabel.setMouseTransparent(true);
@ -448,149 +505,5 @@ public class MainController extends ViewController {
parent.getChildren().add(vBox); parent.getChildren().add(vBox);
} }
public void setPreviousNavigationItem(NavigationItem previousNavigationItem) {
this.previousNavigationItem = previousNavigationItem;
}
public NavigationItem getPreviousNavigationItem() {
return previousNavigationItem;
}
}
class ViewBuilder {
HBox leftNavPane, rightNavPane;
AnchorPane contentPane;
NetworkSyncPane networkSyncPane;
BorderPane baseContentContainer;
AnchorPane contentScreen;
VBox splashVBox;
MenuBar menuBar;
StackPane root;
Label loadingLabel;
boolean showNetworkSyncPane;
void buildSplashScreen(StackPane root, MainController controller) {
Profiler.printMsgWithTime("MainController.ViewBuilder.buildSplashScreen");
this.root = root;
baseContentContainer = new BorderPane();
baseContentContainer.setId("base-content-container");
splashVBox = getSplashScreen();
root.getChildren().addAll(baseContentContainer, splashVBox);
Platform.runLater(() -> buildContentView(controller));
}
void buildContentView(MainController controller) {
Profiler.printMsgWithTime("MainController.ViewBuilder.buildContentView");
menuBar = getMenuBar();
baseContentContainer.setTop(menuBar);
contentScreen = getContentScreen();
baseContentContainer.setCenter(contentScreen);
Platform.runLater(controller::onViewInitialized);
}
AnchorPane getContentScreen() {
AnchorPane anchorPane = new AnchorPane();
anchorPane.setId("content-pane");
leftNavPane = new HBox();
// leftNavPane.setAlignment(Pos.CENTER);
leftNavPane.setSpacing(10);
AnchorPane.setLeftAnchor(leftNavPane, 10d);
AnchorPane.setTopAnchor(leftNavPane, 0d);
rightNavPane = new HBox();
// rightNavPane.setAlignment(Pos.CENTER);
rightNavPane.setSpacing(10);
AnchorPane.setRightAnchor(rightNavPane, 10d);
AnchorPane.setTopAnchor(rightNavPane, 0d);
contentPane = new AnchorPane();
contentPane.setId("content-pane");
AnchorPane.setLeftAnchor(contentPane, 0d);
AnchorPane.setRightAnchor(contentPane, 0d);
AnchorPane.setTopAnchor(contentPane, 60d);
AnchorPane.setBottomAnchor(contentPane, 20d);
anchorPane.getChildren().addAll(leftNavPane, rightNavPane, contentPane);
anchorPane.setOpacity(0);
if (showNetworkSyncPane)
addNetworkSyncPane();
return anchorPane;
}
void setShowNetworkSyncPane() {
showNetworkSyncPane = true;
if (contentScreen != null)
addNetworkSyncPane();
}
private void addNetworkSyncPane() {
networkSyncPane = new NetworkSyncPane();
networkSyncPane.setSpacing(10);
networkSyncPane.setPrefHeight(20);
AnchorPane.setLeftAnchor(networkSyncPane, 0d);
AnchorPane.setBottomAnchor(networkSyncPane, 5d);
contentScreen.getChildren().addAll(networkSyncPane);
}
VBox getSplashScreen() {
VBox splashVBox = new VBox();
splashVBox.setAlignment(Pos.CENTER);
splashVBox.setSpacing(10);
splashVBox.setId("splash");
ImageView logo = ImageUtil.getIconImageView(ImageUtil.SPLASH_LOGO);
logo.setFitWidth(300);
logo.setFitHeight(300);
Label subTitle = new Label("The decentralized Bitcoin exchange");
subTitle.setAlignment(Pos.CENTER);
subTitle.setId("logo-sub-title-label");
loadingLabel = new Label("Initializing...");
loadingLabel.setAlignment(Pos.CENTER);
loadingLabel.setPadding(new Insets(80, 0, 0, 0));
splashVBox.getChildren().addAll(logo, subTitle, loadingLabel);
return splashVBox;
}
MenuBar getMenuBar() {
MenuBar menuBar = new MenuBar();
// on mac we could place menu bar in the systems menu
// menuBar.setUseSystemMenuBar(true);
menuBar.setUseSystemMenuBar(false);
Menu fileMenu = new Menu("_File");
fileMenu.setMnemonicParsing(true);
MenuItem backupMenuItem = new MenuItem("Backup wallet");
fileMenu.getItems().addAll(backupMenuItem);
Menu settingsMenu = new Menu("_Settings");
settingsMenu.setMnemonicParsing(true);
MenuItem changePwMenuItem = new MenuItem("Change password");
settingsMenu.getItems().addAll(changePwMenuItem);
Menu helpMenu = new Menu("_Help");
helpMenu.setMnemonicParsing(true);
MenuItem faqMenuItem = new MenuItem("FAQ");
MenuItem forumMenuItem = new MenuItem("Forum");
helpMenu.getItems().addAll(faqMenuItem, forumMenuItem);
menuBar.getMenus().setAll(fileMenu, settingsMenu, helpMenu);
menuBar.setOpacity(0);
return menuBar;
}
} }

View file

@ -19,7 +19,7 @@
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.AccountSettingsCB" <AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.AccountSettingsViewCB"
prefHeight="660.0" prefWidth="1000.0" prefHeight="660.0" prefWidth="1000.0"
xmlns:fx="http://javafx.com/fxml"> xmlns:fx="http://javafx.com/fxml">

View file

@ -22,7 +22,7 @@ import io.bitsquare.gui.CodeBehind;
import io.bitsquare.gui.NavigationItem; import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.PresentationModel; import io.bitsquare.gui.PresentationModel;
import io.bitsquare.gui.pm.account.AccountSettingsPM; import io.bitsquare.gui.pm.account.AccountSettingsPM;
import io.bitsquare.gui.view.account.content.AdjustableAccountContent; import io.bitsquare.gui.view.account.content.ContextAware;
import io.bitsquare.util.BSFXMLLoader; import io.bitsquare.util.BSFXMLLoader;
import java.io.IOException; import java.io.IOException;
@ -45,9 +45,9 @@ import de.jensd.fx.fontawesome.AwesomeIcon;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class AccountSettingsCB extends CachedCodeBehind<AccountSettingsPM> { public class AccountSettingsViewCB extends CachedCodeBehind<AccountSettingsPM> {
private static final Logger log = LoggerFactory.getLogger(AccountSettingsCB.class); private static final Logger log = LoggerFactory.getLogger(AccountSettingsViewCB.class);
public VBox leftVBox; public VBox leftVBox;
public AnchorPane content; public AnchorPane content;
@ -56,7 +56,7 @@ public class AccountSettingsCB extends CachedCodeBehind<AccountSettingsPM> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private AccountSettingsCB(AccountSettingsPM presentationModel) { private AccountSettingsViewCB(AccountSettingsPM presentationModel) {
super(presentationModel); super(presentationModel);
} }
@ -133,11 +133,11 @@ class MenuItem extends ToggleButton {
private CodeBehind<? extends PresentationModel> childController; private CodeBehind<? extends PresentationModel> childController;
private final AccountSettingsCB parentCB; private final AccountSettingsViewCB parentCB;
private final Parent content; private final Parent content;
private final NavigationItem navigationItem; private final NavigationItem navigationItem;
MenuItem(AccountSettingsCB parentCB, Parent content, String title, NavigationItem navigationItem, MenuItem(AccountSettingsViewCB parentCB, Parent content, String title, NavigationItem navigationItem,
ToggleGroup toggleGroup) { ToggleGroup toggleGroup) {
this.parentCB = parentCB; this.parentCB = parentCB;
this.content = content; this.content = content;
@ -193,7 +193,7 @@ class MenuItem extends ToggleButton {
((AnchorPane) content).getChildren().setAll(view); ((AnchorPane) content).getChildren().setAll(view);
childController = loader.getController(); childController = loader.getController();
childController.setParentController(parentCB); childController.setParentController(parentCB);
((AdjustableAccountContent) childController).isSettingsMode(true); ((ContextAware) childController).useSettingsContext(true);
} catch (IOException e) { } catch (IOException e) {
log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl()); log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
e.getStackTrace(); e.getStackTrace();

View file

@ -19,7 +19,7 @@
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.AccountSetupCB" <AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.AccountSetupViewCB"
xmlns:fx="http://javafx.com/fxml"> xmlns:fx="http://javafx.com/fxml">
<VBox fx:id="leftVBox" spacing="5" prefWidth="300" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="20" <VBox fx:id="leftVBox" spacing="5" prefWidth="300" AnchorPane.bottomAnchor="20" AnchorPane.leftAnchor="20"

View file

@ -23,12 +23,12 @@ import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.PresentationModel; import io.bitsquare.gui.PresentationModel;
import io.bitsquare.gui.pm.account.AccountSetupPM; import io.bitsquare.gui.pm.account.AccountSetupPM;
import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.gui.util.ImageUtil;
import io.bitsquare.gui.view.account.content.AdjustableAccountContent; import io.bitsquare.gui.view.account.content.ContextAware;
import io.bitsquare.gui.view.account.content.FiatAccountCB; import io.bitsquare.gui.view.account.content.FiatAccountViewCB;
import io.bitsquare.gui.view.account.content.PasswordCB; import io.bitsquare.gui.view.account.content.PasswordViewCB;
import io.bitsquare.gui.view.account.content.RegistrationCB; import io.bitsquare.gui.view.account.content.RegistrationViewCB;
import io.bitsquare.gui.view.account.content.RestrictionsCB; import io.bitsquare.gui.view.account.content.RestrictionsViewCB;
import io.bitsquare.gui.view.account.content.SeedWordsCB; import io.bitsquare.gui.view.account.content.SeedWordsViewCB;
import io.bitsquare.util.BSFXMLLoader; import io.bitsquare.util.BSFXMLLoader;
import java.io.IOException; import java.io.IOException;
@ -50,9 +50,9 @@ import javafx.scene.layout.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class AccountSetupCB extends CachedCodeBehind<AccountSetupPM> { public class AccountSetupViewCB extends CachedCodeBehind<AccountSetupPM> {
private static final Logger log = LoggerFactory.getLogger(AccountSetupCB.class); private static final Logger log = LoggerFactory.getLogger(AccountSetupViewCB.class);
private WizardItem seedWords, password, fiatAccount, restrictions, registration; private WizardItem seedWords, password, fiatAccount, restrictions, registration;
private Callable<Void> requestCloseCallable; private Callable<Void> requestCloseCallable;
@ -66,7 +66,7 @@ public class AccountSetupCB extends CachedCodeBehind<AccountSetupPM> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private AccountSetupCB(AccountSetupPM presentationModel) { private AccountSetupViewCB(AccountSetupPM presentationModel) {
super(presentationModel); super(presentationModel);
} }
@ -122,23 +122,23 @@ public class AccountSetupCB extends CachedCodeBehind<AccountSetupPM> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public void onCompleted(CodeBehind<? extends PresentationModel> childView) { public void onCompleted(CodeBehind<? extends PresentationModel> childView) {
if (childView instanceof SeedWordsCB) { if (childView instanceof SeedWordsViewCB) {
seedWords.onCompleted(); seedWords.onCompleted();
childController = password.show(); childController = password.show();
} }
else if (childView instanceof PasswordCB) { else if (childView instanceof PasswordViewCB) {
password.onCompleted(); password.onCompleted();
childController = restrictions.show(); childController = restrictions.show();
} }
else if (childView instanceof RestrictionsCB) { else if (childView instanceof RestrictionsViewCB) {
restrictions.onCompleted(); restrictions.onCompleted();
childController = fiatAccount.show(); childController = fiatAccount.show();
} }
else if (childView instanceof FiatAccountCB) { else if (childView instanceof FiatAccountViewCB) {
fiatAccount.onCompleted(); fiatAccount.onCompleted();
childController = registration.show(); childController = registration.show();
} }
else if (childView instanceof RegistrationCB) { else if (childView instanceof RegistrationViewCB) {
registration.onCompleted(); registration.onCompleted();
childController = null; childController = null;
@ -171,11 +171,12 @@ class WizardItem extends HBox {
private final ImageView imageView; private final ImageView imageView;
private final Label titleLabel; private final Label titleLabel;
private final Label subTitleLabel; private final Label subTitleLabel;
private final AccountSetupCB parentCB; private final AccountSetupViewCB parentCB;
private final Parent content; private final Parent content;
private final NavigationItem navigationItem; private final NavigationItem navigationItem;
WizardItem(AccountSetupCB parentCB, Parent content, String title, String subTitle, NavigationItem navigationItem) { WizardItem(AccountSetupViewCB parentCB, Parent content, String title, String subTitle,
NavigationItem navigationItem) {
this.parentCB = parentCB; this.parentCB = parentCB;
this.content = content; this.content = content;
this.navigationItem = navigationItem; this.navigationItem = navigationItem;
@ -236,7 +237,7 @@ class WizardItem extends HBox {
((AnchorPane) content).getChildren().setAll(view); ((AnchorPane) content).getChildren().setAll(view);
childController = loader.getController(); childController = loader.getController();
childController.setParentController(parentCB); childController.setParentController(parentCB);
((AdjustableAccountContent) childController).isSettingsMode(false); ((ContextAware) childController).useSettingsContext(false);
} catch (IOException e) { } catch (IOException e) {
log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl()); log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
e.getStackTrace(); e.getStackTrace();

View file

@ -21,7 +21,7 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.content.ChangePasswordCB" hgap="5.0" vgap="5.0" <GridPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.content.ChangePasswordViewCB" hgap="5.0" vgap="5.0"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
xmlns:fx="http://javafx.com/fxml"> xmlns:fx="http://javafx.com/fxml">

View file

@ -21,7 +21,7 @@ import io.bitsquare.gui.CachedCodeBehind;
import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.Help;
import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.help.HelpId;
import io.bitsquare.gui.pm.account.content.ChangePasswordPM; import io.bitsquare.gui.pm.account.content.ChangePasswordPM;
import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.gui.view.account.AccountSetupViewCB;
import java.net.URL; import java.net.URL;
@ -36,9 +36,9 @@ import javafx.scene.layout.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class ChangePasswordCB extends CachedCodeBehind<ChangePasswordPM> implements AdjustableAccountContent { public class ChangePasswordViewCB extends CachedCodeBehind<ChangePasswordPM> implements ContextAware {
private static final Logger log = LoggerFactory.getLogger(ChangePasswordCB.class); private static final Logger log = LoggerFactory.getLogger(ChangePasswordViewCB.class);
@FXML private HBox buttonsHBox; @FXML private HBox buttonsHBox;
@FXML private Button saveButton, skipButton; @FXML private Button saveButton, skipButton;
@ -50,7 +50,7 @@ public class ChangePasswordCB extends CachedCodeBehind<ChangePasswordPM> impleme
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private ChangePasswordCB(ChangePasswordPM presentationModel) { private ChangePasswordViewCB(ChangePasswordPM presentationModel) {
super(presentationModel); super(presentationModel);
} }
@ -93,8 +93,8 @@ public class ChangePasswordCB extends CachedCodeBehind<ChangePasswordPM> impleme
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public void isSettingsMode(boolean isSettingsMode) { public void useSettingsContext(boolean useSettingsContext) {
if (isSettingsMode) if (useSettingsContext)
buttonsHBox.getChildren().remove(skipButton); buttonsHBox.getChildren().remove(skipButton);
} }
@ -107,8 +107,8 @@ public class ChangePasswordCB extends CachedCodeBehind<ChangePasswordPM> impleme
private void onSaved() { private void onSaved() {
boolean result = presentationModel.requestSavePassword(); boolean result = presentationModel.requestSavePassword();
if (result) { if (result) {
if (parentController instanceof AccountSetupCB) if (parentController instanceof AccountSetupViewCB)
((AccountSetupCB) parentController).onCompleted(this); ((AccountSetupViewCB) parentController).onCompleted(this);
} }
else { else {
log.debug(presentationModel.getErrorMessage()); // TODO use validating TF log.debug(presentationModel.getErrorMessage()); // TODO use validating TF
@ -122,8 +122,8 @@ public class ChangePasswordCB extends CachedCodeBehind<ChangePasswordPM> impleme
@FXML @FXML
private void onSkipped() { private void onSkipped() {
if (parentController instanceof AccountSetupCB) if (parentController instanceof AccountSetupViewCB)
((AccountSetupCB) parentController).onCompleted(this); ((AccountSetupViewCB) parentController).onCompleted(this);
} }
} }

View file

@ -17,6 +17,6 @@
package io.bitsquare.gui.view.account.content; package io.bitsquare.gui.view.account.content;
public interface AdjustableAccountContent { public interface ContextAware {
void isSettingsMode(boolean isSettingsMode); void useSettingsContext(boolean useSettingsContext);
} }

View file

@ -23,7 +23,7 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.content.FiatAccountCB" hgap="5.0" vgap="5.0" <GridPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.content.FiatAccountViewCB" hgap="5.0" vgap="5.0"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
xmlns:fx="http://javafx.com/fxml"> xmlns:fx="http://javafx.com/fxml">

View file

@ -26,7 +26,7 @@ import io.bitsquare.gui.help.Help;
import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.help.HelpId;
import io.bitsquare.gui.pm.account.content.FiatAccountPm; import io.bitsquare.gui.pm.account.content.FiatAccountPm;
import io.bitsquare.gui.util.validation.InputValidator; import io.bitsquare.gui.util.validation.InputValidator;
import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.gui.view.account.AccountSetupViewCB;
import io.bitsquare.locale.Country; import io.bitsquare.locale.Country;
import io.bitsquare.locale.Region; import io.bitsquare.locale.Region;
@ -52,9 +52,9 @@ import org.slf4j.LoggerFactory;
import static javafx.beans.binding.Bindings.createBooleanBinding; import static javafx.beans.binding.Bindings.createBooleanBinding;
public class FiatAccountCB extends CachedCodeBehind<FiatAccountPm> implements AdjustableAccountContent { public class FiatAccountViewCB extends CachedCodeBehind<FiatAccountPm> implements ContextAware {
private static final Logger log = LoggerFactory.getLogger(FiatAccountCB.class); private static final Logger log = LoggerFactory.getLogger(FiatAccountViewCB.class);
@FXML private HBox buttonsHBox; @FXML private HBox buttonsHBox;
@FXML private ComboBox<Region> regionComboBox; @FXML private ComboBox<Region> regionComboBox;
@ -71,7 +71,7 @@ public class FiatAccountCB extends CachedCodeBehind<FiatAccountPm> implements Ad
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private FiatAccountCB(FiatAccountPm presentationModel) { private FiatAccountViewCB(FiatAccountPm presentationModel) {
super(presentationModel); super(presentationModel);
} }
@ -126,8 +126,8 @@ public class FiatAccountCB extends CachedCodeBehind<FiatAccountPm> implements Ad
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public void isSettingsMode(boolean isSettingsMode) { public void useSettingsContext(boolean useSettingsContext) {
if (isSettingsMode) if (useSettingsContext)
buttonsHBox.getChildren().remove(completedButton); buttonsHBox.getChildren().remove(completedButton);
} }
@ -177,7 +177,7 @@ public class FiatAccountCB extends CachedCodeBehind<FiatAccountPm> implements Ad
@FXML @FXML
private void onCompleted() { private void onCompleted() {
if (parentController != null) if (parentController != null)
((AccountSetupCB) parentController).onCompleted(this); ((AccountSetupViewCB) parentController).onCompleted(this);
} }
@FXML @FXML

View file

@ -21,7 +21,7 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.content.PasswordCB" hgap="5.0" vgap="5.0" <GridPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.content.PasswordViewCB" hgap="5.0" vgap="5.0"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
xmlns:fx="http://javafx.com/fxml"> xmlns:fx="http://javafx.com/fxml">

View file

@ -21,7 +21,7 @@ import io.bitsquare.gui.CachedCodeBehind;
import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.Help;
import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.help.HelpId;
import io.bitsquare.gui.pm.account.content.PasswordPM; import io.bitsquare.gui.pm.account.content.PasswordPM;
import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.gui.view.account.AccountSetupViewCB;
import java.net.URL; import java.net.URL;
@ -36,9 +36,9 @@ import javafx.scene.layout.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class PasswordCB extends CachedCodeBehind<PasswordPM> implements AdjustableAccountContent { public class PasswordViewCB extends CachedCodeBehind<PasswordPM> implements ContextAware {
private static final Logger log = LoggerFactory.getLogger(PasswordCB.class); private static final Logger log = LoggerFactory.getLogger(PasswordViewCB.class);
@FXML private HBox buttonsHBox; @FXML private HBox buttonsHBox;
@FXML private Button saveButton, skipButton; @FXML private Button saveButton, skipButton;
@ -50,7 +50,7 @@ public class PasswordCB extends CachedCodeBehind<PasswordPM> implements Adjustab
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private PasswordCB(PasswordPM presentationModel) { private PasswordViewCB(PasswordPM presentationModel) {
super(presentationModel); super(presentationModel);
} }
@ -93,8 +93,8 @@ public class PasswordCB extends CachedCodeBehind<PasswordPM> implements Adjustab
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public void isSettingsMode(boolean isSettingsMode) { public void useSettingsContext(boolean useSettingsContext) {
if (isSettingsMode) if (useSettingsContext)
buttonsHBox.getChildren().remove(skipButton); buttonsHBox.getChildren().remove(skipButton);
} }
@ -107,8 +107,8 @@ public class PasswordCB extends CachedCodeBehind<PasswordPM> implements Adjustab
private void onSaved() { private void onSaved() {
boolean result = presentationModel.requestSavePassword(); boolean result = presentationModel.requestSavePassword();
if (result) { if (result) {
if (parentController instanceof AccountSetupCB) if (parentController instanceof AccountSetupViewCB)
((AccountSetupCB) parentController).onCompleted(this); ((AccountSetupViewCB) parentController).onCompleted(this);
} }
else { else {
// TODO use validating passwordTF // TODO use validating passwordTF
@ -118,8 +118,8 @@ public class PasswordCB extends CachedCodeBehind<PasswordPM> implements Adjustab
@FXML @FXML
private void onSkipped() { private void onSkipped() {
if (parentController instanceof AccountSetupCB) if (parentController instanceof AccountSetupViewCB)
((AccountSetupCB) parentController).onCompleted(this); ((AccountSetupViewCB) parentController).onCompleted(this);
} }
@FXML @FXML

View file

@ -23,7 +23,7 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.content.RegistrationCB" hgap="5.0" vgap="5.0" <GridPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.content.RegistrationViewCB" hgap="5.0" vgap="5.0"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
xmlns:fx="http://javafx.com/fxml"> xmlns:fx="http://javafx.com/fxml">

View file

@ -18,14 +18,14 @@
package io.bitsquare.gui.view.account.content; package io.bitsquare.gui.view.account.content;
import io.bitsquare.gui.CachedCodeBehind; import io.bitsquare.gui.CachedCodeBehind;
import io.bitsquare.gui.MainController;
import io.bitsquare.gui.components.Popups; import io.bitsquare.gui.components.Popups;
import io.bitsquare.gui.components.btc.AddressTextField; import io.bitsquare.gui.components.btc.AddressTextField;
import io.bitsquare.gui.components.btc.BalanceTextField; import io.bitsquare.gui.components.btc.BalanceTextField;
import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.Help;
import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.help.HelpId;
import io.bitsquare.gui.pm.account.content.RegistrationPM; import io.bitsquare.gui.pm.account.content.RegistrationPM;
import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.gui.view.MainViewCB;
import io.bitsquare.gui.view.account.AccountSetupViewCB;
import io.bitsquare.locale.BSResources; import io.bitsquare.locale.BSResources;
import java.net.URL; import java.net.URL;
@ -48,9 +48,9 @@ import org.controlsfx.dialog.Dialog;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class RegistrationCB extends CachedCodeBehind<RegistrationPM> implements AdjustableAccountContent { public class RegistrationViewCB extends CachedCodeBehind<RegistrationPM> implements ContextAware {
private static final Logger log = LoggerFactory.getLogger(RegistrationCB.class); private static final Logger log = LoggerFactory.getLogger(RegistrationViewCB.class);
@FXML private TextField feeTextField; @FXML private TextField feeTextField;
@ -64,7 +64,7 @@ public class RegistrationCB extends CachedCodeBehind<RegistrationPM> implements
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private RegistrationCB(RegistrationPM presentationModel) { private RegistrationViewCB(RegistrationPM presentationModel) {
super(presentationModel); super(presentationModel);
} }
@ -95,7 +95,7 @@ public class RegistrationCB extends CachedCodeBehind<RegistrationPM> implements
presentationModel.showTransactionPublishedScreen.addListener((o, oldValue, newValue) -> { presentationModel.showTransactionPublishedScreen.addListener((o, oldValue, newValue) -> {
if (newValue) { if (newValue) {
MainController.GET_INSTANCE().blurContentScreen(); MainViewCB.getInstance().blurContentScreen();
List<Action> actions = new ArrayList<>(); List<Action> actions = new ArrayList<>();
actions.add(new AbstractAction(BSResources.get("shared.copyTxId")) { actions.add(new AbstractAction(BSResources.get("shared.copyTxId")) {
@ -111,13 +111,13 @@ public class RegistrationCB extends CachedCodeBehind<RegistrationPM> implements
@Override @Override
public void handle(ActionEvent actionEvent) { public void handle(ActionEvent actionEvent) {
try { try {
if (parentController instanceof AccountSetupCB) if (parentController instanceof AccountSetupViewCB)
((AccountSetupCB) parentController).onCompleted(RegistrationCB.this); ((AccountSetupViewCB) parentController).onCompleted(RegistrationViewCB.this);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
Dialog.Actions.CLOSE.handle(actionEvent); Dialog.Actions.CLOSE.handle(actionEvent);
MainController.GET_INSTANCE().removeContentScreenBlur(); MainViewCB.getInstance().removeContentScreenBlur();
} }
}); });
@ -155,8 +155,8 @@ public class RegistrationCB extends CachedCodeBehind<RegistrationPM> implements
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public void isSettingsMode(boolean isSettingsMode) { public void useSettingsContext(boolean useSettingsContext) {
if (isSettingsMode) { if (useSettingsContext) {
// TODO // TODO
} }
} }

View file

@ -20,7 +20,7 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.content.RestrictionsCB" hgap="5.0" vgap="5.0" <GridPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.content.RestrictionsViewCB" hgap="5.0" vgap="5.0"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
xmlns:fx="http://javafx.com/fxml"> xmlns:fx="http://javafx.com/fxml">

View file

@ -25,7 +25,7 @@ import io.bitsquare.gui.help.Help;
import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.help.HelpId;
import io.bitsquare.gui.pm.account.content.RestrictionsPM; import io.bitsquare.gui.pm.account.content.RestrictionsPM;
import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.gui.util.ImageUtil;
import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.gui.view.account.AccountSetupViewCB;
import io.bitsquare.locale.Country; import io.bitsquare.locale.Country;
import io.bitsquare.locale.Region; import io.bitsquare.locale.Region;
import io.bitsquare.util.BSFXMLLoader; import io.bitsquare.util.BSFXMLLoader;
@ -53,9 +53,9 @@ import javafx.util.StringConverter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class RestrictionsCB extends CachedCodeBehind<RestrictionsPM> implements AdjustableAccountContent { public class RestrictionsViewCB extends CachedCodeBehind<RestrictionsPM> implements ContextAware {
private static final Logger log = LoggerFactory.getLogger(RestrictionsCB.class); private static final Logger log = LoggerFactory.getLogger(RestrictionsViewCB.class);
@FXML private ListView languagesListView, countriesListView, arbitratorsListView; @FXML private ListView languagesListView, countriesListView, arbitratorsListView;
@FXML private ComboBox<Locale> languageComboBox; @FXML private ComboBox<Locale> languageComboBox;
@ -69,7 +69,7 @@ public class RestrictionsCB extends CachedCodeBehind<RestrictionsPM> implements
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private RestrictionsCB(RestrictionsPM presentationModel) { private RestrictionsViewCB(RestrictionsPM presentationModel) {
super(presentationModel); super(presentationModel);
} }
@ -116,8 +116,8 @@ public class RestrictionsCB extends CachedCodeBehind<RestrictionsPM> implements
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public void isSettingsMode(boolean isSettingsMode) { public void useSettingsContext(boolean useSettingsContext) {
if (isSettingsMode) if (useSettingsContext)
((GridPane) root).getChildren().remove(completedButton); ((GridPane) root).getChildren().remove(completedButton);
} }
@ -160,8 +160,8 @@ public class RestrictionsCB extends CachedCodeBehind<RestrictionsPM> implements
@FXML @FXML
private void onCompleted() { private void onCompleted() {
if (parentController instanceof AccountSetupCB) if (parentController instanceof AccountSetupViewCB)
((AccountSetupCB) parentController).onCompleted(this); ((AccountSetupViewCB) parentController).onCompleted(this);
} }
@FXML @FXML

View file

@ -22,7 +22,7 @@
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?> <?import javafx.scene.text.*?>
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.content.SeedWordsCB" hgap="5.0" vgap="5.0" <GridPane fx:id="root" fx:controller="io.bitsquare.gui.view.account.content.SeedWordsViewCB" hgap="5.0" vgap="5.0"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
xmlns:fx="http://javafx.com/fxml"> xmlns:fx="http://javafx.com/fxml">

View file

@ -21,7 +21,7 @@ import io.bitsquare.gui.CachedCodeBehind;
import io.bitsquare.gui.help.Help; import io.bitsquare.gui.help.Help;
import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.help.HelpId;
import io.bitsquare.gui.pm.account.content.SeedWordsPM; import io.bitsquare.gui.pm.account.content.SeedWordsPM;
import io.bitsquare.gui.view.account.AccountSetupCB; import io.bitsquare.gui.view.account.AccountSetupViewCB;
import java.net.URL; import java.net.URL;
@ -36,9 +36,9 @@ import javafx.scene.layout.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class SeedWordsCB extends CachedCodeBehind<SeedWordsPM> implements AdjustableAccountContent { public class SeedWordsViewCB extends CachedCodeBehind<SeedWordsPM> implements ContextAware {
private static final Logger log = LoggerFactory.getLogger(SeedWordsCB.class); private static final Logger log = LoggerFactory.getLogger(SeedWordsViewCB.class);
@FXML private Button completedButton; @FXML private Button completedButton;
@FXML private TextArea seedWordsTextArea; @FXML private TextArea seedWordsTextArea;
@ -49,7 +49,7 @@ public class SeedWordsCB extends CachedCodeBehind<SeedWordsPM> implements Adjust
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private SeedWordsCB(SeedWordsPM presentationModel) { private SeedWordsViewCB(SeedWordsPM presentationModel) {
super(presentationModel); super(presentationModel);
} }
@ -89,8 +89,8 @@ public class SeedWordsCB extends CachedCodeBehind<SeedWordsPM> implements Adjust
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public void isSettingsMode(boolean isSettingsMode) { public void useSettingsContext(boolean useSettingsContext) {
if (isSettingsMode) if (useSettingsContext)
((GridPane) root).getChildren().remove(completedButton); ((GridPane) root).getChildren().remove(completedButton);
} }
@ -101,8 +101,8 @@ public class SeedWordsCB extends CachedCodeBehind<SeedWordsPM> implements Adjust
@FXML @FXML
private void onCompleted() { private void onCompleted() {
if (parentController instanceof AccountSetupCB) if (parentController instanceof AccountSetupViewCB)
((AccountSetupCB) parentController).onCompleted(this); ((AccountSetupViewCB) parentController).onCompleted(this);
} }
@FXML @FXML

View file

@ -26,7 +26,7 @@
<?import javafx.scene.image.*?> <?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?> <?import javafx.scene.text.*?>
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.view.trade.CreateOfferCB" <AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.view.trade.CreateOfferViewCB"
AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0"
AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0"
xmlns:fx="http://javafx.com/fxml"> xmlns:fx="http://javafx.com/fxml">

View file

@ -18,7 +18,6 @@
package io.bitsquare.gui.view.trade; package io.bitsquare.gui.view.trade;
import io.bitsquare.gui.CachedCodeBehind; import io.bitsquare.gui.CachedCodeBehind;
import io.bitsquare.gui.MainController;
import io.bitsquare.gui.NavigationItem; import io.bitsquare.gui.NavigationItem;
import io.bitsquare.gui.components.InfoDisplay; import io.bitsquare.gui.components.InfoDisplay;
import io.bitsquare.gui.components.InputTextField; import io.bitsquare.gui.components.InputTextField;
@ -29,6 +28,7 @@ import io.bitsquare.gui.help.Help;
import io.bitsquare.gui.help.HelpId; import io.bitsquare.gui.help.HelpId;
import io.bitsquare.gui.pm.trade.CreateOfferPM; import io.bitsquare.gui.pm.trade.CreateOfferPM;
import io.bitsquare.gui.util.ImageUtil; import io.bitsquare.gui.util.ImageUtil;
import io.bitsquare.gui.view.MainViewCB;
import io.bitsquare.locale.BSResources; import io.bitsquare.locale.BSResources;
import io.bitsquare.trade.orderbook.OrderBookFilter; import io.bitsquare.trade.orderbook.OrderBookFilter;
@ -70,8 +70,8 @@ import static javafx.beans.binding.Bindings.createStringBinding;
// TODO Implement other positioning method in InoutTextField to display it over the field instead of right side // TODO Implement other positioning method in InoutTextField to display it over the field instead of right side
// priceAmountHBox is too large after redesign as to be used as layoutReference. // priceAmountHBox is too large after redesign as to be used as layoutReference.
public class CreateOfferCB extends CachedCodeBehind<CreateOfferPM> { public class CreateOfferViewCB extends CachedCodeBehind<CreateOfferPM> {
private static final Logger log = LoggerFactory.getLogger(CreateOfferCB.class); private static final Logger log = LoggerFactory.getLogger(CreateOfferViewCB.class);
private boolean detailsVisible; private boolean detailsVisible;
private boolean advancedScreenInited; private boolean advancedScreenInited;
@ -105,7 +105,7 @@ public class CreateOfferCB extends CachedCodeBehind<CreateOfferPM> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private CreateOfferCB(CreateOfferPM presentationModel) { private CreateOfferViewCB(CreateOfferPM presentationModel) {
super(presentationModel); super(presentationModel);
} }
@ -234,7 +234,7 @@ public class CreateOfferCB extends CachedCodeBehind<CreateOfferPM> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private void openAccountSettings() { private void openAccountSettings() {
MainController.GET_INSTANCE().loadViewAndGetChildController(NavigationItem.ACCOUNT); MainViewCB.getInstance().triggerMainMenuButton(NavigationItem.ACCOUNT);
} }
private void close() { private void close() {
@ -306,7 +306,7 @@ public class CreateOfferCB extends CachedCodeBehind<CreateOfferPM> {
presentationModel.showTransactionPublishedScreen.addListener((o, oldValue, newValue) -> { presentationModel.showTransactionPublishedScreen.addListener((o, oldValue, newValue) -> {
if (newValue) { if (newValue) {
MainController.GET_INSTANCE().blurContentScreen(); MainViewCB.getInstance().blurContentScreen();
// Dialogs are a bit limited. There is no callback for the InformationDialog button click, so we added // Dialogs are a bit limited. There is no callback for the InformationDialog button click, so we added
// our own actions. // our own actions.
@ -329,7 +329,7 @@ public class CreateOfferCB extends CachedCodeBehind<CreateOfferPM> {
e.printStackTrace(); e.printStackTrace();
} }
Dialog.Actions.CLOSE.handle(actionEvent); Dialog.Actions.CLOSE.handle(actionEvent);
MainController.GET_INSTANCE().removeContentScreenBlur(); MainViewCB.getInstance().removeContentScreenBlur();
} }
}); });