mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-21 22:31:44 +01:00
Move Enum to Navigation, renamings
This commit is contained in:
parent
33e8a8f921
commit
f0f5ddd4ec
25 changed files with 440 additions and 463 deletions
|
@ -20,7 +20,7 @@ package io.bitsquare;
|
|||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.di.BitSquareModule;
|
||||
import io.bitsquare.gui.AWTSystemTray;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.util.Profiler;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
|
@ -114,7 +114,7 @@ public class BitSquare extends Application {
|
|||
ViewLoader.setInjector(injector);
|
||||
|
||||
final ViewLoader loader =
|
||||
new ViewLoader(getClass().getResource(NavigationItem.MAIN.getFxmlUrl()), false);
|
||||
new ViewLoader(getClass().getResource(Navigation.Item.MAIN.getFxmlUrl()), false);
|
||||
try {
|
||||
final Parent view = loader.load();
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import io.bitsquare.btc.BlockChainFacade;
|
|||
import io.bitsquare.btc.FeePolicy;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.crypto.CryptoFacade;
|
||||
import io.bitsquare.gui.NavigationManager;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.OverlayManager;
|
||||
import io.bitsquare.gui.main.trade.orderbook.OrderBook;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
|
@ -71,7 +71,7 @@ public class BitSquareModule extends AbstractModule {
|
|||
|
||||
bind(TradeManager.class).asEagerSingleton();
|
||||
bind(OrderBook.class).asEagerSingleton();
|
||||
bind(NavigationManager.class).asEagerSingleton();
|
||||
bind(Navigation.class).asEagerSingleton();
|
||||
bind(OverlayManager.class).asEagerSingleton();
|
||||
bind(BSFormatter.class).asEagerSingleton();
|
||||
|
||||
|
|
248
src/main/java/io/bitsquare/gui/Navigation.java
Normal file
248
src/main/java/io/bitsquare/gui/Navigation.java
Normal file
|
@ -0,0 +1,248 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Navigation {
|
||||
private static final Logger log = LoggerFactory.getLogger(Navigation.class);
|
||||
|
||||
|
||||
// New listeners can be added during iteration so we use CopyOnWriteArrayList to prevent invalid array
|
||||
// modification
|
||||
private List<Listener> listeners = new CopyOnWriteArrayList<>();
|
||||
private Persistence persistence;
|
||||
private Item[] currentItems;
|
||||
|
||||
// Used for returning to the last important view
|
||||
// After setup is done we want to return to the last opened view (e.g. sell/buy)
|
||||
private Item[] itemsForReturning;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public Navigation(Persistence persistence) {
|
||||
this.persistence = persistence;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Public methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void navigationTo(Item... items) {
|
||||
log.trace("navigationTo " + Arrays.asList(items).toString());
|
||||
List<Item> temp = new ArrayList<>();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
Item item = items[i];
|
||||
temp.add(item);
|
||||
if (currentItems == null ||
|
||||
(currentItems != null &&
|
||||
currentItems.length > i &&
|
||||
item != currentItems[i] &&
|
||||
i != items.length - 1)) {
|
||||
List<Item> temp2 = new ArrayList<>(temp);
|
||||
for (int n = i + 1; n < items.length; n++) {
|
||||
Item[] newTemp = new Item[i + 1];
|
||||
currentItems = temp2.toArray(newTemp);
|
||||
navigationTo(currentItems);
|
||||
item = items[n];
|
||||
temp2.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
currentItems = items;
|
||||
|
||||
persistence.write(this, "navigationItems", items);
|
||||
log.trace("navigationTo notify listeners " + Arrays.asList(items).toString() + " / " + listeners
|
||||
.size());
|
||||
listeners.stream().forEach((e) -> e.onNavigationRequested(items));
|
||||
}
|
||||
|
||||
public void navigateToLastStoredItem() {
|
||||
Item[] items = (Item[]) persistence.read(this, "navigationItems");
|
||||
if (items == null || items.length == 0)
|
||||
items = new Item[]{Item.MAIN, Item.HOME};
|
||||
|
||||
navigationTo(items);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Listeners
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void addListener(Listener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(Listener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public Item[] getItemsForReturning() {
|
||||
return itemsForReturning;
|
||||
}
|
||||
|
||||
public Item[] getCurrentItems() {
|
||||
return currentItems;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Setters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void setItemsForReturning(Item[] itemsForReturning) {
|
||||
this.itemsForReturning = itemsForReturning;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Interface
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static interface Listener {
|
||||
void onNavigationRequested(Item... items);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Enum
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static enum Item {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Application
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MAIN("/io/bitsquare/gui/main/MainView.fxml"),
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Main menu screens
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HOME("/io/bitsquare/gui/main/home/HomeView.fxml", ImageUtil.HOME, ImageUtil.HOME_ACTIVE),
|
||||
BUY("/io/bitsquare/gui/main/trade/BuyView.fxml", ImageUtil.BUY, ImageUtil.BUY_ACTIVE),
|
||||
SELL("/io/bitsquare/gui/main/trade/SellView.fxml", ImageUtil.SELL, ImageUtil.SELL_ACTIVE),
|
||||
ORDERS("/io/bitsquare/gui/main/orders/OrdersView.fxml", ImageUtil.ORDERS, ImageUtil.ORDERS_ACTIVE),
|
||||
FUNDS("/io/bitsquare/gui/main/funds/FundsView.fxml", ImageUtil.FUNDS, ImageUtil.FUNDS_ACTIVE),
|
||||
MSG("/io/bitsquare/gui/main/msg/MsgView.fxml", ImageUtil.MSG, ImageUtil.MSG_ACTIVE),
|
||||
SETTINGS("/io/bitsquare/gui/main/settings/SettingsView.fxml", ImageUtil.SETTINGS, ImageUtil.SETTINGS_ACTIVE),
|
||||
ACCOUNT("/io/bitsquare/gui/main/account/AccountView.fxml", ImageUtil.ACCOUNT, ImageUtil.ACCOUNT_ACTIVE),
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sub menus
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// buy/sell (trade)
|
||||
ORDER_BOOK("/io/bitsquare/gui/main/trade/orderbook/OrderBookView.fxml"),
|
||||
CREATE_OFFER("/io/bitsquare/gui/main/trade/createoffer/CreateOfferView.fxml"),
|
||||
TAKE_OFFER("/io/bitsquare/gui/main/trade/takeoffer/TakeOfferView.fxml"),
|
||||
|
||||
// orders
|
||||
OFFER("/io/bitsquare/gui/main/orders/offer/OfferView.fxml"),
|
||||
PENDING_TRADE("/io/bitsquare/gui/main/orders/pending/PendingTradeView.fxml"),
|
||||
CLOSED_TRADE("/io/bitsquare/gui/main/orders/closed/ClosedTradeView.fxml"),
|
||||
|
||||
// funds
|
||||
DEPOSIT("/io/bitsquare/gui/main/funds/deposit/DepositView.fxml"),
|
||||
WITHDRAWAL("/io/bitsquare/gui/main/funds/withdrawal/WithdrawalView.fxml"),
|
||||
TRANSACTIONS("/io/bitsquare/gui/main/funds/transactions/TransactionsView.fxml"),
|
||||
|
||||
// account
|
||||
ACCOUNT_SETUP("/io/bitsquare/gui/main/account/setup/AccountSetupView.fxml"),
|
||||
ACCOUNT_SETTINGS("/io/bitsquare/gui/main/account/settings/AccountSettingsView.fxml"),
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Content in sub menus
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// account content
|
||||
SEED_WORDS("/io/bitsquare/gui/main/account/content/seedwords/SeedWordsView.fxml"),
|
||||
ADD_PASSWORD("/io/bitsquare/gui/main/account/content/password/PasswordView.fxml"),
|
||||
CHANGE_PASSWORD("/io/bitsquare/gui/main/account/content/password/PasswordView.fxml"),
|
||||
RESTRICTIONS("/io/bitsquare/gui/main/account/content/restrictions/RestrictionsView.fxml"),
|
||||
REGISTRATION("/io/bitsquare/gui/main/account/content/registration/RegistrationView.fxml"),
|
||||
FIAT_ACCOUNT("/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.fxml"),
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Popups
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// arbitrator
|
||||
ARBITRATOR_PROFILE("/io/bitsquare/gui/main/arbitrators/profile/ArbitratorProfileView.fxml"),
|
||||
ARBITRATOR_BROWSER("/io/bitsquare/gui/main/arbitrators/browser/ArbitratorBrowserView.fxml"),
|
||||
ARBITRATOR_REGISTRATION("/io/bitsquare/gui/main/arbitrators/registration/ArbitratorRegistrationView.fxml");
|
||||
|
||||
|
||||
private final String fxmlUrl;
|
||||
private String icon;
|
||||
private String activeIcon;
|
||||
|
||||
/**
|
||||
* @param fxmlUrl
|
||||
* @param icon
|
||||
* @param activeIcon
|
||||
*/
|
||||
Item(String fxmlUrl, String icon, String activeIcon) {
|
||||
this.fxmlUrl = fxmlUrl;
|
||||
this.icon = icon;
|
||||
this.activeIcon = activeIcon;
|
||||
}
|
||||
|
||||
Item(String fxmlUrl) {
|
||||
this.fxmlUrl = fxmlUrl;
|
||||
}
|
||||
|
||||
public String getFxmlUrl() {
|
||||
return fxmlUrl;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public String getActiveIcon() {
|
||||
return activeIcon;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,122 +0,0 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
|
||||
public enum NavigationItem {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Application
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MAIN("/io/bitsquare/gui/main/MainView.fxml"),
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Main menu screens
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HOME("/io/bitsquare/gui/main/home/HomeView.fxml", ImageUtil.HOME, ImageUtil.HOME_ACTIVE),
|
||||
BUY("/io/bitsquare/gui/main/trade/BuyView.fxml", ImageUtil.BUY, ImageUtil.BUY_ACTIVE),
|
||||
SELL("/io/bitsquare/gui/main/trade/SellView.fxml", ImageUtil.SELL, ImageUtil.SELL_ACTIVE),
|
||||
ORDERS("/io/bitsquare/gui/main/orders/OrdersView.fxml", ImageUtil.ORDERS, ImageUtil.ORDERS_ACTIVE),
|
||||
FUNDS("/io/bitsquare/gui/main/funds/FundsView.fxml", ImageUtil.FUNDS, ImageUtil.FUNDS_ACTIVE),
|
||||
MSG("/io/bitsquare/gui/main/msg/MsgView.fxml", ImageUtil.MSG, ImageUtil.MSG_ACTIVE),
|
||||
SETTINGS("/io/bitsquare/gui/main/settings/SettingsView.fxml", ImageUtil.SETTINGS, ImageUtil.SETTINGS_ACTIVE),
|
||||
ACCOUNT("/io/bitsquare/gui/main/account/AccountView.fxml", ImageUtil.ACCOUNT, ImageUtil.ACCOUNT_ACTIVE),
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Sub menus
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// buy/sell (trade)
|
||||
ORDER_BOOK("/io/bitsquare/gui/main/trade/orderbook/OrderBookView.fxml"),
|
||||
CREATE_OFFER("/io/bitsquare/gui/main/trade/createoffer/CreateOfferView.fxml"),
|
||||
TAKE_OFFER("/io/bitsquare/gui/main/trade/takeoffer/TakeOfferView.fxml"),
|
||||
|
||||
// orders
|
||||
OFFER("/io/bitsquare/gui/main/orders/offer/OfferView.fxml"),
|
||||
PENDING_TRADE("/io/bitsquare/gui/main/orders/pending/PendingTradeView.fxml"),
|
||||
CLOSED_TRADE("/io/bitsquare/gui/main/orders/closed/ClosedTradeView.fxml"),
|
||||
|
||||
// funds
|
||||
DEPOSIT("/io/bitsquare/gui/main/funds/deposit/DepositView.fxml"),
|
||||
WITHDRAWAL("/io/bitsquare/gui/main/funds/withdrawal/WithdrawalView.fxml"),
|
||||
TRANSACTIONS("/io/bitsquare/gui/main/funds/transactions/TransactionsView.fxml"),
|
||||
|
||||
// account
|
||||
ACCOUNT_SETUP("/io/bitsquare/gui/main/account/setup/AccountSetupView.fxml"),
|
||||
ACCOUNT_SETTINGS("/io/bitsquare/gui/main/account/settings/AccountSettingsView.fxml"),
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Content in sub menus
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// account content
|
||||
SEED_WORDS("/io/bitsquare/gui/main/account/content/seedwords/SeedWordsView.fxml"),
|
||||
ADD_PASSWORD("/io/bitsquare/gui/main/account/content/password/PasswordView.fxml"),
|
||||
CHANGE_PASSWORD("/io/bitsquare/gui/main/account/content/password/PasswordView.fxml"),
|
||||
RESTRICTIONS("/io/bitsquare/gui/main/account/content/restrictions/RestrictionsView.fxml"),
|
||||
REGISTRATION("/io/bitsquare/gui/main/account/content/registration/RegistrationView.fxml"),
|
||||
FIAT_ACCOUNT("/io/bitsquare/gui/main/account/content/fiat/FiatAccountView.fxml"),
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Popups
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// arbitrator
|
||||
ARBITRATOR_PROFILE("/io/bitsquare/gui/main/arbitrators/profile/ArbitratorProfileView.fxml"),
|
||||
ARBITRATOR_BROWSER("/io/bitsquare/gui/main/arbitrators/browser/ArbitratorBrowserView.fxml"),
|
||||
ARBITRATOR_REGISTRATION("/io/bitsquare/gui/main/arbitrators/registration/ArbitratorRegistrationView.fxml");
|
||||
|
||||
|
||||
private final String fxmlUrl;
|
||||
private String icon;
|
||||
private String activeIcon;
|
||||
|
||||
/**
|
||||
* @param fxmlUrl
|
||||
* @param icon
|
||||
* @param activeIcon
|
||||
*/
|
||||
NavigationItem(String fxmlUrl, String icon, String activeIcon) {
|
||||
this.fxmlUrl = fxmlUrl;
|
||||
this.icon = icon;
|
||||
this.activeIcon = activeIcon;
|
||||
}
|
||||
|
||||
NavigationItem(String fxmlUrl) {
|
||||
this.fxmlUrl = fxmlUrl;
|
||||
}
|
||||
|
||||
public String getFxmlUrl() {
|
||||
return fxmlUrl;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public String getActiveIcon() {
|
||||
return activeIcon;
|
||||
}
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class NavigationManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(NavigationManager.class);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Interface
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public interface Listener {
|
||||
void onNavigationRequested(NavigationItem... navigationItems);
|
||||
}
|
||||
|
||||
// New listeners can be added during iteration so we use CopyOnWriteArrayList to prevent invalid array
|
||||
// modification
|
||||
private List<Listener> listeners = new CopyOnWriteArrayList<>();
|
||||
private Persistence persistence;
|
||||
private NavigationItem[] currentNavigationItems;
|
||||
|
||||
// Used for returning to the last important view
|
||||
// After setup is done we want to return to the last opened view (e.g. sell/buy)
|
||||
private NavigationItem[] navigationItemsForReturning;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public NavigationManager(Persistence persistence) {
|
||||
this.persistence = persistence;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Public methods
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void navigationTo(NavigationItem... navigationItems) {
|
||||
log.trace("navigationTo " + Arrays.asList(navigationItems).toString());
|
||||
List<NavigationItem> temp = new ArrayList<>();
|
||||
for (int i = 0; i < navigationItems.length; i++) {
|
||||
NavigationItem item = navigationItems[i];
|
||||
temp.add(item);
|
||||
if (currentNavigationItems == null ||
|
||||
(currentNavigationItems != null &&
|
||||
currentNavigationItems.length > i &&
|
||||
item != currentNavigationItems[i] &&
|
||||
i != navigationItems.length - 1)) {
|
||||
List<NavigationItem> temp2 = new ArrayList<>(temp);
|
||||
for (int n = i + 1; n < navigationItems.length; n++) {
|
||||
NavigationItem[] newTemp = new NavigationItem[i + 1];
|
||||
currentNavigationItems = temp2.toArray(newTemp);
|
||||
navigationTo(currentNavigationItems);
|
||||
item = navigationItems[n];
|
||||
temp2.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
currentNavigationItems = navigationItems;
|
||||
|
||||
persistence.write(this, "navigationItems", navigationItems);
|
||||
log.trace("navigationTo notify listeners " + Arrays.asList(navigationItems).toString() + " / " + listeners
|
||||
.size());
|
||||
listeners.stream().forEach((e) -> e.onNavigationRequested(navigationItems));
|
||||
}
|
||||
|
||||
public void navigateToLastStoredItem() {
|
||||
NavigationItem[] navigationItems = (NavigationItem[]) persistence.read(this, "navigationItems");
|
||||
if (navigationItems == null || navigationItems.length == 0)
|
||||
navigationItems = new NavigationItem[]{NavigationItem.MAIN, NavigationItem.HOME};
|
||||
|
||||
navigationTo(navigationItems);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Listeners
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void addListener(Listener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(Listener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public NavigationItem[] getNavigationItemsForReturning() {
|
||||
return navigationItemsForReturning;
|
||||
}
|
||||
|
||||
public NavigationItem[] getCurrentNavigationItems() {
|
||||
return currentNavigationItems;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Setters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void setNavigationItemsForReturning(NavigationItem[] navigationItemsForReturning) {
|
||||
this.navigationItemsForReturning = navigationItemsForReturning;
|
||||
}
|
||||
|
||||
}
|
|
@ -83,7 +83,7 @@ public class ViewCB<T extends PresentationModel> implements Initializable {
|
|||
* @param navigationItem NavigationItem to be loaded.
|
||||
* @return The ViewController of the loaded view.
|
||||
*/
|
||||
protected Initializable loadView(NavigationItem navigationItem) {
|
||||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
log.trace("Lifecycle: loadViewAndGetChildController " + this.getClass().getSimpleName() + " / navigationItem " +
|
||||
"= " + navigationItem);
|
||||
return null;
|
||||
|
|
|
@ -84,12 +84,12 @@ public abstract class ViewController implements Initializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param navigationItem NavigationItem to be loaded.
|
||||
* @param item NavigationItem to be loaded.
|
||||
* @return The ViewController of the loaded view.
|
||||
*/
|
||||
public Initializable loadViewAndGetChildController(NavigationItem navigationItem) {
|
||||
public Initializable loadViewAndGetChildController(Navigation.Item item) {
|
||||
log.trace("Lifecycle: loadViewAndGetChildController " + this.getClass().getSimpleName() + " / navigationItem " +
|
||||
"= " + navigationItem);
|
||||
"= " + item);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@ package io.bitsquare.gui.main;
|
|||
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.gui.AWTSystemTray;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.NavigationManager;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.OverlayManager;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.components.NetworkSyncPane;
|
||||
|
@ -53,7 +52,7 @@ import org.slf4j.LoggerFactory;
|
|||
public class MainViewCB extends ViewCB<MainPM> {
|
||||
private static final Logger log = LoggerFactory.getLogger(MainViewCB.class);
|
||||
|
||||
private final NavigationManager navigationManager;
|
||||
private final Navigation navigation;
|
||||
private final OverlayManager overlayManager;
|
||||
|
||||
private final ToggleGroup navButtonsGroup = new ToggleGroup();
|
||||
|
@ -73,11 +72,11 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private MainViewCB(MainPM presentationModel, NavigationManager navigationManager,
|
||||
private MainViewCB(MainPM presentationModel, Navigation navigation,
|
||||
OverlayManager overlayManager) {
|
||||
super(presentationModel);
|
||||
|
||||
this.navigationManager = navigationManager;
|
||||
this.navigation = navigation;
|
||||
this.overlayManager = overlayManager;
|
||||
}
|
||||
|
||||
|
@ -95,9 +94,9 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
// just temp. ugly hack... Popups will be removed
|
||||
Popups.setOverlayManager(overlayManager);
|
||||
|
||||
navigationManager.addListener(navigationItems -> {
|
||||
navigation.addListener(navigationItems -> {
|
||||
if (navigationItems != null && navigationItems.length == 2) {
|
||||
if (navigationItems[0] == NavigationItem.MAIN) {
|
||||
if (navigationItems[0] == Navigation.Item.MAIN) {
|
||||
loadView(navigationItems[1]);
|
||||
selectMainMenuButton(navigationItems[1]);
|
||||
}
|
||||
|
@ -131,7 +130,7 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected Initializable loadView(NavigationItem navigationItem) {
|
||||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
super.loadView((navigationItem));
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
|
||||
try {
|
||||
|
@ -193,16 +192,16 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
alertButton.setId("nav-alert-button");
|
||||
alertButton.relocate(36, 19);
|
||||
alertButton.setOnAction((e) ->
|
||||
navigationManager.navigationTo(NavigationItem.MAIN,
|
||||
NavigationItem.ORDERS,
|
||||
NavigationItem.PENDING_TRADE));
|
||||
navigation.navigationTo(Navigation.Item.MAIN,
|
||||
Navigation.Item.ORDERS,
|
||||
Navigation.Item.PENDING_TRADE));
|
||||
Tooltip.install(alertButton, new Tooltip("Your offer has been accepted"));
|
||||
ordersButtonButtonPane.getChildren().add(alertButton);
|
||||
|
||||
AWTSystemTray.setAlert();
|
||||
});
|
||||
|
||||
navigationManager.navigateToLastStoredItem();
|
||||
navigation.navigateToLastStoredItem();
|
||||
onContentAdded();
|
||||
}
|
||||
|
||||
|
@ -216,8 +215,8 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
// Private
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void selectMainMenuButton(NavigationItem navigationItem) {
|
||||
switch (navigationItem) {
|
||||
private void selectMainMenuButton(Navigation.Item item) {
|
||||
switch (item) {
|
||||
case HOME:
|
||||
homeButton.setSelected(true);
|
||||
break;
|
||||
|
@ -243,7 +242,7 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
accountButton.setSelected(true);
|
||||
break;
|
||||
default:
|
||||
log.error(navigationItem.getFxmlUrl() + " is no main navigation item");
|
||||
log.error(item.getFxmlUrl() + " is no main navigation item");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -338,32 +337,32 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
}
|
||||
|
||||
private void addMainNavigation() {
|
||||
homeButton = addNavButton(leftNavPane, "Overview", NavigationItem.HOME);
|
||||
buyButton = addNavButton(leftNavPane, "Buy BTC", NavigationItem.BUY);
|
||||
sellButton = addNavButton(leftNavPane, "Sell BTC", NavigationItem.SELL);
|
||||
homeButton = addNavButton(leftNavPane, "Overview", Navigation.Item.HOME);
|
||||
buyButton = addNavButton(leftNavPane, "Buy BTC", Navigation.Item.BUY);
|
||||
sellButton = addNavButton(leftNavPane, "Sell BTC", Navigation.Item.SELL);
|
||||
|
||||
ordersButtonButtonPane = new Pane();
|
||||
ordersButton = addNavButton(ordersButtonButtonPane, "Orders", NavigationItem.ORDERS);
|
||||
ordersButton = addNavButton(ordersButtonButtonPane, "Orders", Navigation.Item.ORDERS);
|
||||
leftNavPane.getChildren().add(ordersButtonButtonPane);
|
||||
|
||||
fundsButton = addNavButton(leftNavPane, "Funds", NavigationItem.FUNDS);
|
||||
fundsButton = addNavButton(leftNavPane, "Funds", Navigation.Item.FUNDS);
|
||||
|
||||
final Pane msgButtonHolder = new Pane();
|
||||
msgButton = addNavButton(msgButtonHolder, "Message", NavigationItem.MSG);
|
||||
msgButton = addNavButton(msgButtonHolder, "Message", Navigation.Item.MSG);
|
||||
leftNavPane.getChildren().add(msgButtonHolder);
|
||||
|
||||
addBalanceInfo(rightNavPane);
|
||||
|
||||
addBankAccountComboBox(rightNavPane);
|
||||
|
||||
settingsButton = addNavButton(rightNavPane, "Settings", NavigationItem.SETTINGS);
|
||||
accountButton = addNavButton(rightNavPane, "Account", NavigationItem.ACCOUNT);
|
||||
settingsButton = addNavButton(rightNavPane, "Settings", Navigation.Item.SETTINGS);
|
||||
accountButton = addNavButton(rightNavPane, "Account", Navigation.Item.ACCOUNT);
|
||||
|
||||
onMainNavigationAdded();
|
||||
}
|
||||
|
||||
private ToggleButton addNavButton(Pane parent, String title, NavigationItem navigationItem) {
|
||||
ImageView icon = ImageUtil.getIconImageView(navigationItem.getIcon());
|
||||
private ToggleButton addNavButton(Pane parent, String title, Navigation.Item item) {
|
||||
ImageView icon = ImageUtil.getIconImageView(item.getIcon());
|
||||
icon.setFitWidth(32);
|
||||
icon.setFitHeight(32);
|
||||
|
||||
|
@ -382,16 +381,16 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
toggleButton.setMaxSize(50, 50);
|
||||
toggleButton.setGraphicTextGap(newValue ? -1 : 0);
|
||||
if (newValue) {
|
||||
Image activeIcon = ImageUtil.getIconImage(navigationItem.getActiveIcon());
|
||||
Image activeIcon = ImageUtil.getIconImage(item.getActiveIcon());
|
||||
((ImageView) toggleButton.getGraphic()).setImage(activeIcon);
|
||||
}
|
||||
else {
|
||||
Image activeIcon = ImageUtil.getIconImage(navigationItem.getIcon());
|
||||
Image activeIcon = ImageUtil.getIconImage(item.getIcon());
|
||||
((ImageView) toggleButton.getGraphic()).setImage(activeIcon);
|
||||
}
|
||||
});
|
||||
|
||||
toggleButton.setOnAction(e -> navigationManager.navigationTo(NavigationItem.MAIN, navigationItem));
|
||||
toggleButton.setOnAction(e -> navigation.navigationTo(Navigation.Item.MAIN, item));
|
||||
|
||||
parent.getChildren().add(toggleButton);
|
||||
return toggleButton;
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
package io.bitsquare.gui.main.account;
|
||||
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.NavigationManager;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
|
@ -43,8 +42,8 @@ public class AccountViewCB extends CachedViewCB<AccountPM> {
|
|||
private static final Logger log = LoggerFactory.getLogger(AccountViewCB.class);
|
||||
|
||||
public Tab tab;
|
||||
private NavigationManager navigationManager;
|
||||
private NavigationManager.Listener listener;
|
||||
private Navigation navigation;
|
||||
private Navigation.Listener listener;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -52,10 +51,10 @@ public class AccountViewCB extends CachedViewCB<AccountPM> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private AccountViewCB(AccountPM presentationModel, NavigationManager navigationManager) {
|
||||
private AccountViewCB(AccountPM presentationModel, Navigation navigation) {
|
||||
super(presentationModel);
|
||||
|
||||
this.navigationManager = navigationManager;
|
||||
this.navigation = navigation;
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,7 +68,7 @@ public class AccountViewCB extends CachedViewCB<AccountPM> {
|
|||
listener = navigationItems -> {
|
||||
if (navigationItems != null &&
|
||||
navigationItems.length == 3 &&
|
||||
navigationItems[1] == NavigationItem.ACCOUNT)
|
||||
navigationItems[1] == Navigation.Item.ACCOUNT)
|
||||
loadView(navigationItems[2]);
|
||||
};
|
||||
|
||||
|
@ -80,16 +79,16 @@ public class AccountViewCB extends CachedViewCB<AccountPM> {
|
|||
public void activate() {
|
||||
super.activate();
|
||||
|
||||
navigationManager.addListener(listener);
|
||||
navigation.addListener(listener);
|
||||
|
||||
if (navigationManager.getCurrentNavigationItems().length == 2 &&
|
||||
navigationManager.getCurrentNavigationItems()[1] == NavigationItem.ACCOUNT) {
|
||||
if (navigation.getCurrentItems().length == 2 &&
|
||||
navigation.getCurrentItems()[1] == Navigation.Item.ACCOUNT) {
|
||||
if (presentationModel.getNeedRegistration())
|
||||
navigationManager.navigationTo(NavigationItem.MAIN, NavigationItem.ACCOUNT,
|
||||
NavigationItem.ACCOUNT_SETUP);
|
||||
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT,
|
||||
Navigation.Item.ACCOUNT_SETUP);
|
||||
else
|
||||
navigationManager.navigationTo(NavigationItem.MAIN, NavigationItem.ACCOUNT,
|
||||
NavigationItem.ACCOUNT_SETTINGS);
|
||||
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT,
|
||||
Navigation.Item.ACCOUNT_SETTINGS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +96,7 @@ public class AccountViewCB extends CachedViewCB<AccountPM> {
|
|||
public void deactivate() {
|
||||
super.deactivate();
|
||||
|
||||
navigationManager.removeListener(listener);
|
||||
navigation.removeListener(listener);
|
||||
}
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
|
@ -112,10 +111,10 @@ public class AccountViewCB extends CachedViewCB<AccountPM> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected Initializable loadView(NavigationItem navigationItem) {
|
||||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
super.loadView(navigationItem);
|
||||
|
||||
tab.setText((navigationItem == NavigationItem.ACCOUNT_SETUP) ? "Account setup" : "Account settings");
|
||||
tab.setText((navigationItem == Navigation.Item.ACCOUNT_SETUP) ? "Account setup" : "Account settings");
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
|
||||
try {
|
||||
AnchorPane view = loader.load();
|
||||
|
@ -124,7 +123,7 @@ public class AccountViewCB extends CachedViewCB<AccountPM> {
|
|||
((ViewCB) childController).setParent(this);
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("Loading view failed. FxmlUrl = " + NavigationItem.ACCOUNT_SETUP.getFxmlUrl());
|
||||
log.error("Loading view failed. FxmlUrl = " + Navigation.Item.ACCOUNT_SETUP.getFxmlUrl());
|
||||
e.getStackTrace();
|
||||
}
|
||||
return childController;
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bitsquare.gui.main.account.content.restrictions;
|
|||
import io.bitsquare.BitSquare;
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.main.account.MultiStepNavigation;
|
||||
import io.bitsquare.gui.main.account.content.ContextAware;
|
||||
import io.bitsquare.gui.main.help.Help;
|
||||
|
@ -154,7 +154,7 @@ public class RestrictionsViewCB extends CachedViewCB<RestrictionsPM> implements
|
|||
|
||||
@FXML
|
||||
private void onOpenArbitratorScreen() {
|
||||
loadView(NavigationItem.ARBITRATOR_BROWSER);
|
||||
loadView(Navigation.Item.ARBITRATOR_BROWSER);
|
||||
}
|
||||
|
||||
|
||||
|
@ -185,7 +185,7 @@ public class RestrictionsViewCB extends CachedViewCB<RestrictionsPM> implements
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected Initializable loadView(NavigationItem navigationItem) {
|
||||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
// TODO caching causes exception
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()), false);
|
||||
try {
|
||||
|
@ -208,7 +208,7 @@ public class RestrictionsViewCB extends CachedViewCB<RestrictionsPM> implements
|
|||
Scene scene = new Scene((Parent) view, 800, 600);
|
||||
stage.setScene(scene);
|
||||
stage.setOnHidden(windowEvent -> {
|
||||
if (navigationItem == NavigationItem.ARBITRATOR_BROWSER)
|
||||
if (navigationItem == Navigation.Item.ARBITRATOR_BROWSER)
|
||||
updateArbitratorList();
|
||||
});
|
||||
stage.show();
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
package io.bitsquare.gui.main.account.settings;
|
||||
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.NavigationManager;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.PresentationModel;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.main.account.content.ContextAware;
|
||||
|
@ -51,8 +50,8 @@ public class AccountSettingsViewCB extends CachedViewCB<AccountSettingsPM> {
|
|||
private static final Logger log = LoggerFactory.getLogger(AccountSettingsViewCB.class);
|
||||
|
||||
private MenuItem seedWords, password, restrictions, fiatAccount, registration;
|
||||
private NavigationManager navigationManager;
|
||||
private NavigationManager.Listener listener;
|
||||
private Navigation navigation;
|
||||
private Navigation.Listener listener;
|
||||
|
||||
@FXML VBox leftVBox;
|
||||
@FXML AnchorPane content;
|
||||
|
@ -63,10 +62,10 @@ public class AccountSettingsViewCB extends CachedViewCB<AccountSettingsPM> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private AccountSettingsViewCB(AccountSettingsPM presentationModel, NavigationManager navigationManager) {
|
||||
private AccountSettingsViewCB(AccountSettingsPM presentationModel, Navigation navigation) {
|
||||
super(presentationModel);
|
||||
|
||||
this.navigationManager = navigationManager;
|
||||
this.navigation = navigation;
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,23 +78,23 @@ public class AccountSettingsViewCB extends CachedViewCB<AccountSettingsPM> {
|
|||
listener = navigationItems -> {
|
||||
if (navigationItems != null &&
|
||||
navigationItems.length == 4 &&
|
||||
navigationItems[2] == NavigationItem.ACCOUNT_SETTINGS) {
|
||||
navigationItems[2] == Navigation.Item.ACCOUNT_SETTINGS) {
|
||||
loadView(navigationItems[3]);
|
||||
selectMainMenuButton(navigationItems[3]);
|
||||
}
|
||||
};
|
||||
|
||||
ToggleGroup toggleGroup = new ToggleGroup();
|
||||
seedWords = new MenuItem(navigationManager, "Wallet seed",
|
||||
NavigationItem.SEED_WORDS, toggleGroup);
|
||||
password = new MenuItem(navigationManager, "Wallet password",
|
||||
NavigationItem.CHANGE_PASSWORD, toggleGroup);
|
||||
restrictions = new MenuItem(navigationManager, "Trading restrictions",
|
||||
NavigationItem.RESTRICTIONS, toggleGroup);
|
||||
fiatAccount = new MenuItem(navigationManager, "Payments account(s)",
|
||||
NavigationItem.FIAT_ACCOUNT, toggleGroup);
|
||||
registration = new MenuItem(navigationManager, "Renew your account",
|
||||
NavigationItem.REGISTRATION, toggleGroup);
|
||||
seedWords = new MenuItem(navigation, "Wallet seed",
|
||||
Navigation.Item.SEED_WORDS, toggleGroup);
|
||||
password = new MenuItem(navigation, "Wallet password",
|
||||
Navigation.Item.CHANGE_PASSWORD, toggleGroup);
|
||||
restrictions = new MenuItem(navigation, "Trading restrictions",
|
||||
Navigation.Item.RESTRICTIONS, toggleGroup);
|
||||
fiatAccount = new MenuItem(navigation, "Payments account(s)",
|
||||
Navigation.Item.FIAT_ACCOUNT, toggleGroup);
|
||||
registration = new MenuItem(navigation, "Renew your account",
|
||||
Navigation.Item.REGISTRATION, toggleGroup);
|
||||
|
||||
registration.setDisable(true);
|
||||
|
||||
|
@ -109,17 +108,17 @@ public class AccountSettingsViewCB extends CachedViewCB<AccountSettingsPM> {
|
|||
public void activate() {
|
||||
super.activate();
|
||||
|
||||
navigationManager.addListener(listener);
|
||||
NavigationItem[] items = navigationManager.getCurrentNavigationItems();
|
||||
navigation.addListener(listener);
|
||||
Navigation.Item[] items = navigation.getCurrentItems();
|
||||
if (items.length == 3 &&
|
||||
items[2] == NavigationItem.ACCOUNT_SETTINGS) {
|
||||
navigationManager.navigationTo(NavigationItem.MAIN, NavigationItem.ACCOUNT,
|
||||
NavigationItem.ACCOUNT_SETTINGS, NavigationItem.SEED_WORDS);
|
||||
items[2] == Navigation.Item.ACCOUNT_SETTINGS) {
|
||||
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT,
|
||||
Navigation.Item.ACCOUNT_SETTINGS, Navigation.Item.SEED_WORDS);
|
||||
}
|
||||
else {
|
||||
if (items != null &&
|
||||
items.length == 4 &&
|
||||
items[2] == NavigationItem.ACCOUNT_SETTINGS) {
|
||||
items[2] == Navigation.Item.ACCOUNT_SETTINGS) {
|
||||
loadView(items[3]);
|
||||
selectMainMenuButton(items[3]);
|
||||
}
|
||||
|
@ -130,7 +129,7 @@ public class AccountSettingsViewCB extends CachedViewCB<AccountSettingsPM> {
|
|||
public void deactivate() {
|
||||
super.deactivate();
|
||||
|
||||
navigationManager.removeListener(listener);
|
||||
navigation.removeListener(listener);
|
||||
}
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
|
@ -145,7 +144,7 @@ public class AccountSettingsViewCB extends CachedViewCB<AccountSettingsPM> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected Initializable loadView(NavigationItem navigationItem) {
|
||||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
|
||||
try {
|
||||
final Pane view = loader.load();
|
||||
|
@ -166,8 +165,8 @@ public class AccountSettingsViewCB extends CachedViewCB<AccountSettingsPM> {
|
|||
// Private
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void selectMainMenuButton(NavigationItem navigationItem) {
|
||||
switch (navigationItem) {
|
||||
private void selectMainMenuButton(Navigation.Item item) {
|
||||
switch (item) {
|
||||
case SEED_WORDS:
|
||||
seedWords.setSelected(true);
|
||||
break;
|
||||
|
@ -184,7 +183,7 @@ public class AccountSettingsViewCB extends CachedViewCB<AccountSettingsPM> {
|
|||
registration.setSelected(true);
|
||||
break;
|
||||
default:
|
||||
log.error(navigationItem.getFxmlUrl() + " is invalid");
|
||||
log.error(item.getFxmlUrl() + " is invalid");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +192,7 @@ public class AccountSettingsViewCB extends CachedViewCB<AccountSettingsPM> {
|
|||
class MenuItem extends ToggleButton {
|
||||
private static final Logger log = LoggerFactory.getLogger(MenuItem.class);
|
||||
|
||||
MenuItem(NavigationManager navigationManager, String title, NavigationItem navigationItem,
|
||||
MenuItem(Navigation navigation, String title, Navigation.Item navigationItem,
|
||||
ToggleGroup toggleGroup) {
|
||||
|
||||
setToggleGroup(toggleGroup);
|
||||
|
@ -205,17 +204,17 @@ class MenuItem extends ToggleButton {
|
|||
|
||||
Label icon = new Label();
|
||||
icon.setTextFill(Paint.valueOf("#999"));
|
||||
if (navigationItem.equals(NavigationItem.SEED_WORDS))
|
||||
if (navigationItem.equals(Navigation.Item.SEED_WORDS))
|
||||
AwesomeDude.setIcon(icon, AwesomeIcon.INFO_SIGN);
|
||||
else if (navigationItem.equals(NavigationItem.REGISTRATION))
|
||||
else if (navigationItem.equals(Navigation.Item.REGISTRATION))
|
||||
AwesomeDude.setIcon(icon, AwesomeIcon.BRIEFCASE);
|
||||
else
|
||||
AwesomeDude.setIcon(icon, AwesomeIcon.EDIT_SIGN);
|
||||
|
||||
setGraphic(icon);
|
||||
|
||||
setOnAction((event) -> navigationManager.navigationTo(NavigationItem.MAIN, NavigationItem.ACCOUNT,
|
||||
NavigationItem.ACCOUNT_SETTINGS, navigationItem));
|
||||
setOnAction((event) -> navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT,
|
||||
Navigation.Item.ACCOUNT_SETTINGS, navigationItem));
|
||||
|
||||
selectedProperty().addListener((ov, oldValue, newValue) -> {
|
||||
if (newValue) {
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
package io.bitsquare.gui.main.account.setup;
|
||||
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.NavigationManager;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.PresentationModel;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.main.account.MultiStepNavigation;
|
||||
|
@ -55,8 +54,8 @@ public class AccountSetupViewCB extends CachedViewCB<AccountSetupPM> implements
|
|||
private static final Logger log = LoggerFactory.getLogger(AccountSetupViewCB.class);
|
||||
|
||||
private WizardItem seedWords, password, fiatAccount, restrictions, registration;
|
||||
private NavigationManager navigationManager;
|
||||
private NavigationManager.Listener listener;
|
||||
private Navigation navigation;
|
||||
private Navigation.Listener listener;
|
||||
|
||||
@FXML VBox leftVBox;
|
||||
@FXML AnchorPane content;
|
||||
|
@ -67,9 +66,9 @@ public class AccountSetupViewCB extends CachedViewCB<AccountSetupPM> implements
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private AccountSetupViewCB(AccountSetupPM presentationModel, NavigationManager navigationManager) {
|
||||
private AccountSetupViewCB(AccountSetupPM presentationModel, Navigation navigation) {
|
||||
super(presentationModel);
|
||||
this.navigationManager = navigationManager;
|
||||
this.navigation = navigation;
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,24 +81,24 @@ public class AccountSetupViewCB extends CachedViewCB<AccountSetupPM> implements
|
|||
listener = navigationItems -> {
|
||||
if (navigationItems != null &&
|
||||
navigationItems.length == 4 &&
|
||||
navigationItems[2] == NavigationItem.ACCOUNT_SETUP) {
|
||||
navigationItems[2] == Navigation.Item.ACCOUNT_SETUP) {
|
||||
loadView(navigationItems[3]);
|
||||
}
|
||||
};
|
||||
|
||||
seedWords = new WizardItem(navigationManager, "Backup wallet seed", "Write down the seed word for your wallet",
|
||||
NavigationItem.SEED_WORDS);
|
||||
password = new WizardItem(navigationManager, "Setup password", "Protect your wallet with a password",
|
||||
NavigationItem.ADD_PASSWORD);
|
||||
restrictions = new WizardItem(navigationManager, "Setup your preferences",
|
||||
seedWords = new WizardItem(navigation, "Backup wallet seed", "Write down the seed word for your wallet",
|
||||
Navigation.Item.SEED_WORDS);
|
||||
password = new WizardItem(navigation, "Setup password", "Protect your wallet with a password",
|
||||
Navigation.Item.ADD_PASSWORD);
|
||||
restrictions = new WizardItem(navigation, "Setup your preferences",
|
||||
"Define your preferences with whom you want to trade",
|
||||
NavigationItem.RESTRICTIONS);
|
||||
fiatAccount = new WizardItem(navigationManager, " Setup Payments account(s)",
|
||||
Navigation.Item.RESTRICTIONS);
|
||||
fiatAccount = new WizardItem(navigation, " Setup Payments account(s)",
|
||||
"You need to add a payments account to your trading account",
|
||||
NavigationItem.FIAT_ACCOUNT);
|
||||
registration = new WizardItem(navigationManager, "Register your account",
|
||||
Navigation.Item.FIAT_ACCOUNT);
|
||||
registration = new WizardItem(navigation, "Register your account",
|
||||
"Pay in the registration fee of 0.0002 BTC and store your account in the BTC block chain",
|
||||
NavigationItem.REGISTRATION);
|
||||
Navigation.Item.REGISTRATION);
|
||||
|
||||
leftVBox.getChildren().addAll(seedWords, password, restrictions, fiatAccount, registration);
|
||||
|
||||
|
@ -111,7 +110,7 @@ public class AccountSetupViewCB extends CachedViewCB<AccountSetupPM> implements
|
|||
public void activate() {
|
||||
super.activate();
|
||||
|
||||
navigationManager.addListener(listener);
|
||||
navigation.addListener(listener);
|
||||
|
||||
// triggers navigationTo
|
||||
childController = seedWords.show();
|
||||
|
@ -121,7 +120,7 @@ public class AccountSetupViewCB extends CachedViewCB<AccountSetupPM> implements
|
|||
public void deactivate() {
|
||||
super.deactivate();
|
||||
|
||||
navigationManager.removeListener(listener);
|
||||
navigation.removeListener(listener);
|
||||
}
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
|
@ -156,7 +155,7 @@ public class AccountSetupViewCB extends CachedViewCB<AccountSetupPM> implements
|
|||
registration.onCompleted();
|
||||
childController = null;
|
||||
|
||||
navigationManager.navigationTo(navigationManager.getNavigationItemsForReturning());
|
||||
navigation.navigationTo(navigation.getItemsForReturning());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +165,7 @@ public class AccountSetupViewCB extends CachedViewCB<AccountSetupPM> implements
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected Initializable loadView(NavigationItem navigationItem) {
|
||||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
|
||||
try {
|
||||
final Pane view = loader.load();
|
||||
|
@ -191,12 +190,12 @@ class WizardItem extends HBox {
|
|||
private final ImageView imageView;
|
||||
private final Label titleLabel;
|
||||
private final Label subTitleLabel;
|
||||
private final NavigationItem navigationItem;
|
||||
private final NavigationManager navigationManager;
|
||||
private final Navigation.Item navigationItem;
|
||||
private final Navigation navigation;
|
||||
|
||||
WizardItem(NavigationManager navigationManager, String title, String subTitle,
|
||||
NavigationItem navigationItem) {
|
||||
this.navigationManager = navigationManager;
|
||||
WizardItem(Navigation navigation, String title, String subTitle,
|
||||
Navigation.Item navigationItem) {
|
||||
this.navigation = navigation;
|
||||
this.navigationItem = navigationItem;
|
||||
|
||||
setId("wizard-item-background-deactivated");
|
||||
|
@ -233,7 +232,8 @@ class WizardItem extends HBox {
|
|||
}
|
||||
|
||||
ViewCB<? extends PresentationModel> show() {
|
||||
navigationManager.navigationTo(NavigationItem.MAIN, NavigationItem.ACCOUNT, NavigationItem.ACCOUNT_SETUP,
|
||||
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT, Navigation
|
||||
.Item.ACCOUNT_SETUP,
|
||||
navigationItem);
|
||||
|
||||
setId("wizard-item-background-active");
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bitsquare.gui.main.arbitrators.browser;
|
|||
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.gui.CachedViewController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.main.arbitrators.profile.ArbitratorProfileController;
|
||||
import io.bitsquare.locale.LanguageUtil;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
|
@ -91,7 +91,7 @@ public class ArbitratorBrowserController extends CachedViewController implements
|
|||
public void initialize(URL url, ResourceBundle rb) {
|
||||
super.initialize(url, rb);
|
||||
|
||||
loadViewAndGetChildController(NavigationItem.ARBITRATOR_PROFILE);
|
||||
loadViewAndGetChildController(Navigation.Item.ARBITRATOR_PROFILE);
|
||||
checkButtonState();
|
||||
}
|
||||
|
||||
|
@ -121,8 +121,8 @@ public class ArbitratorBrowserController extends CachedViewController implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public Initializable loadViewAndGetChildController(NavigationItem navigationItem) {
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
|
||||
public Initializable loadViewAndGetChildController(Navigation.Item item) {
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(item.getFxmlUrl()));
|
||||
try {
|
||||
final Node view = loader.load();
|
||||
arbitratorProfileController = loader.getController();
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bitsquare.gui.main.arbitrators.profile;
|
|||
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.gui.CachedViewController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
|
@ -99,7 +99,7 @@ public class ArbitratorProfileController extends CachedViewController {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Initializable loadViewAndGetChildController(NavigationItem navigationItem) {
|
||||
public Initializable loadViewAndGetChildController(Navigation.Item item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import io.bitsquare.arbitrator.Arbitrator;
|
|||
import io.bitsquare.arbitrator.Reputation;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.gui.CachedViewController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.components.ConfidenceDisplay;
|
||||
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||
import io.bitsquare.gui.main.arbitrators.profile.ArbitratorProfileController;
|
||||
|
@ -224,7 +224,7 @@ public class ArbitratorRegistrationController extends CachedViewController {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Initializable loadViewAndGetChildController(NavigationItem navigationItem) {
|
||||
public Initializable loadViewAndGetChildController(Navigation.Item item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bitsquare.gui.main.funds;
|
||||
|
||||
import io.bitsquare.gui.CachedViewController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.ViewController;
|
||||
import io.bitsquare.gui.components.CachingTabPane;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
|
@ -59,8 +59,8 @@ public class FundsController extends CachedViewController {
|
|||
super.initialize(url, rb);
|
||||
|
||||
((CachingTabPane) root).initialize(
|
||||
this, persistence, NavigationItem.DEPOSIT.getFxmlUrl(), NavigationItem.WITHDRAWAL.getFxmlUrl(),
|
||||
NavigationItem.TRANSACTIONS.getFxmlUrl());
|
||||
this, persistence, Navigation.Item.DEPOSIT.getFxmlUrl(), Navigation.Item.WITHDRAWAL.getFxmlUrl(),
|
||||
Navigation.Item.TRANSACTIONS.getFxmlUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,8 +79,8 @@ public class FundsController extends CachedViewController {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public Initializable loadViewAndGetChildController(NavigationItem navigationItem) {
|
||||
childController = ((CachingTabPane) root).loadViewAndGetChildController(navigationItem.getFxmlUrl());
|
||||
public Initializable loadViewAndGetChildController(Navigation.Item item) {
|
||||
childController = ((CachingTabPane) root).loadViewAndGetChildController(item.getFxmlUrl());
|
||||
return childController;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bitsquare.gui.main.home;
|
|||
|
||||
import io.bitsquare.BitSquare;
|
||||
import io.bitsquare.gui.CachedViewController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.main.arbitrators.registration.ArbitratorRegistrationController;
|
||||
import io.bitsquare.util.ViewLoader;
|
||||
|
||||
|
@ -70,9 +70,9 @@ public class HomeController extends CachedViewController {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public Initializable loadViewAndGetChildController(NavigationItem navigationItem) {
|
||||
public Initializable loadViewAndGetChildController(Navigation.Item item) {
|
||||
// don't use caching here, cause exc. -> need to investigate and is rarely called so no caching is better
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()), false);
|
||||
final ViewLoader loader = new ViewLoader(getClass().getResource(item.getFxmlUrl()), false);
|
||||
try {
|
||||
final Parent view = loader.load();
|
||||
arbitratorRegistrationController = loader.getController();
|
||||
|
@ -107,12 +107,12 @@ public class HomeController extends CachedViewController {
|
|||
|
||||
@FXML
|
||||
public void onArbitratorRegistration() {
|
||||
loadViewAndGetChildController(NavigationItem.ARBITRATOR_REGISTRATION);
|
||||
loadViewAndGetChildController(Navigation.Item.ARBITRATOR_REGISTRATION);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void onArbitratorEdit() {
|
||||
loadViewAndGetChildController(NavigationItem.ARBITRATOR_REGISTRATION);
|
||||
loadViewAndGetChildController(Navigation.Item.ARBITRATOR_REGISTRATION);
|
||||
arbitratorRegistrationController.setEditMode(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bitsquare.gui.main.msg;
|
||||
|
||||
import io.bitsquare.gui.CachedViewController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class MsgController extends CachedViewController {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public Initializable loadViewAndGetChildController(NavigationItem navigationItem) {
|
||||
public Initializable loadViewAndGetChildController(Navigation.Item item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bitsquare.gui.main.orders;
|
||||
|
||||
import io.bitsquare.gui.CachedViewController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.components.CachingTabPane;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
|
||||
|
@ -61,8 +61,8 @@ public class OrdersController extends CachedViewController {
|
|||
public void initialize(URL url, ResourceBundle rb) {
|
||||
super.initialize(url, rb);
|
||||
|
||||
((CachingTabPane) root).initialize(this, persistence, NavigationItem.OFFER.getFxmlUrl(),
|
||||
NavigationItem.PENDING_TRADE.getFxmlUrl(), NavigationItem.CLOSED_TRADE.getFxmlUrl());
|
||||
((CachingTabPane) root).initialize(this, persistence, Navigation.Item.OFFER.getFxmlUrl(),
|
||||
Navigation.Item.PENDING_TRADE.getFxmlUrl(), Navigation.Item.CLOSED_TRADE.getFxmlUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,8 +81,8 @@ public class OrdersController extends CachedViewController {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public Initializable loadViewAndGetChildController(NavigationItem navigationItem) {
|
||||
childController = ((CachingTabPane) root).loadViewAndGetChildController(navigationItem.getFxmlUrl());
|
||||
public Initializable loadViewAndGetChildController(Navigation.Item item) {
|
||||
childController = ((CachingTabPane) root).loadViewAndGetChildController(item.getFxmlUrl());
|
||||
return childController;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package io.bitsquare.gui.main.settings;
|
||||
|
||||
import io.bitsquare.gui.CachedViewController;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -68,8 +68,8 @@ public class SettingsController extends CachedViewController {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public Initializable loadViewAndGetChildController(NavigationItem navigationItem) {
|
||||
return super.loadViewAndGetChildController(navigationItem);
|
||||
public Initializable loadViewAndGetChildController(Navigation.Item item) {
|
||||
return super.loadViewAndGetChildController(item);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
|
||||
package io.bitsquare.gui.main.trade;
|
||||
|
||||
import io.bitsquare.gui.NavigationManager;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class BuyViewCB extends TradeViewCB {
|
||||
|
||||
@Inject
|
||||
public BuyViewCB(NavigationManager navigationManager) {
|
||||
super(navigationManager);
|
||||
public BuyViewCB(Navigation navigation) {
|
||||
super(navigation);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
|
||||
package io.bitsquare.gui.main.trade;
|
||||
|
||||
import io.bitsquare.gui.NavigationManager;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class SellViewCB extends TradeViewCB {
|
||||
|
||||
@Inject
|
||||
public SellViewCB(NavigationManager navigationManager) {
|
||||
super(navigationManager);
|
||||
public SellViewCB(Navigation navigation) {
|
||||
super(navigation);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
package io.bitsquare.gui.main.trade;
|
||||
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.NavigationManager;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.components.InputTextField;
|
||||
import io.bitsquare.gui.main.trade.createoffer.CreateOfferViewCB;
|
||||
import io.bitsquare.gui.main.trade.orderbook.OrderBookViewCB;
|
||||
|
@ -51,19 +50,19 @@ public class TradeViewCB extends CachedViewCB {
|
|||
private CreateOfferViewCB createOfferViewCB;
|
||||
private TakeOfferController takeOfferController;
|
||||
private Node createOfferView;
|
||||
private NavigationManager navigationManager;
|
||||
private NavigationManager.Listener listener;
|
||||
private NavigationItem tradeNavigationItem;
|
||||
private Navigation navigation;
|
||||
private Navigation.Listener listener;
|
||||
private Navigation.Item navigationItem;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
protected TradeViewCB(NavigationManager navigationManager) {
|
||||
protected TradeViewCB(Navigation navigation) {
|
||||
super();
|
||||
|
||||
this.navigationManager = navigationManager;
|
||||
this.navigation = navigation;
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,14 +73,14 @@ public class TradeViewCB extends CachedViewCB {
|
|||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
listener = navigationItems -> {
|
||||
if (navigationItems != null && navigationItems.length == 3 && navigationItems[1] == tradeNavigationItem) {
|
||||
if (navigationItems != null && navigationItems.length == 3 && navigationItems[1] == navigationItem) {
|
||||
loadView(navigationItems[2]);
|
||||
}
|
||||
};
|
||||
|
||||
Direction direction = (this instanceof BuyViewCB) ? Direction.BUY : Direction.SELL;
|
||||
orderBookInfo.setDirection(direction);
|
||||
tradeNavigationItem = (direction == Direction.BUY) ? NavigationItem.BUY : NavigationItem.SELL;
|
||||
navigationItem = (direction == Direction.BUY) ? Navigation.Item.BUY : Navigation.Item.SELL;
|
||||
|
||||
super.initialize(url, rb);
|
||||
}
|
||||
|
@ -108,8 +107,8 @@ public class TradeViewCB extends CachedViewCB {
|
|||
}
|
||||
});
|
||||
|
||||
navigationManager.addListener(listener);
|
||||
navigationManager.navigationTo(NavigationItem.MAIN, tradeNavigationItem, NavigationItem.ORDER_BOOK);
|
||||
navigation.addListener(listener);
|
||||
navigation.navigationTo(Navigation.Item.MAIN, navigationItem, Navigation.Item.ORDER_BOOK);
|
||||
}
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
|
@ -131,11 +130,11 @@ public class TradeViewCB extends CachedViewCB {
|
|||
|
||||
// @Override
|
||||
|
||||
protected Initializable loadView(NavigationItem navigationItem) {
|
||||
protected Initializable loadView(Navigation.Item navigationItem) {
|
||||
super.loadView(navigationItem);
|
||||
TabPane tabPane = (TabPane) root;
|
||||
if (navigationItem == NavigationItem.ORDER_BOOK && orderBookViewCB == null) {
|
||||
// Orderbook must not be cached by GuiceFXMLLoader as we use 2 instances for sell and buy screens.
|
||||
if (navigationItem == Navigation.Item.ORDER_BOOK && orderBookViewCB == null) {
|
||||
// Orderbook must not be cached by ViewLoader as we use 2 instances for sell and buy screens.
|
||||
ViewLoader orderBookLoader =
|
||||
new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()), false);
|
||||
try {
|
||||
|
@ -154,8 +153,8 @@ public class TradeViewCB extends CachedViewCB {
|
|||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
else if (navigationItem == NavigationItem.CREATE_OFFER && createOfferViewCB == null) {
|
||||
// CreateOffer and TakeOffer must not be cached by GuiceFXMLLoader as we cannot use a view multiple times
|
||||
else if (navigationItem == Navigation.Item.CREATE_OFFER && createOfferViewCB == null) {
|
||||
// CreateOffer and TakeOffer must not be cached by ViewLoader as we cannot use a view multiple times
|
||||
// in different graphs
|
||||
ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()), false);
|
||||
try {
|
||||
|
@ -173,8 +172,8 @@ public class TradeViewCB extends CachedViewCB {
|
|||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
else if (navigationItem == NavigationItem.TAKE_OFFER && takeOfferController == null) {
|
||||
// CreateOffer and TakeOffer must not be cached by GuiceFXMLLoader as we cannot use a view multiple times
|
||||
else if (navigationItem == Navigation.Item.TAKE_OFFER && takeOfferController == null) {
|
||||
// CreateOffer and TakeOffer must not be cached by ViewLoader as we cannot use a view multiple times
|
||||
// in different graphs
|
||||
ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()), false);
|
||||
try {
|
||||
|
@ -219,7 +218,7 @@ public class TradeViewCB extends CachedViewCB {
|
|||
orderBookViewCB.enableCreateOfferButton();
|
||||
|
||||
// update the navigation state
|
||||
navigationManager.navigationTo(NavigationItem.MAIN, tradeNavigationItem, NavigationItem.ORDER_BOOK);
|
||||
navigation.navigationTo(Navigation.Item.MAIN, navigationItem, Navigation.Item.ORDER_BOOK);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@ package io.bitsquare.gui.main.trade.createoffer;
|
|||
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.CloseListener;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.NavigationManager;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.OverlayManager;
|
||||
import io.bitsquare.gui.components.InfoDisplay;
|
||||
import io.bitsquare.gui.components.InputTextField;
|
||||
|
@ -74,7 +73,7 @@ import static javafx.beans.binding.Bindings.createStringBinding;
|
|||
public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
|
||||
private static final Logger log = LoggerFactory.getLogger(CreateOfferViewCB.class);
|
||||
|
||||
private NavigationManager navigationManager;
|
||||
private Navigation navigation;
|
||||
private OverlayManager overlayManager;
|
||||
private CloseListener closeListener;
|
||||
|
||||
|
@ -109,10 +108,10 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private CreateOfferViewCB(CreateOfferPM presentationModel, NavigationManager navigationManager,
|
||||
private CreateOfferViewCB(CreateOfferPM presentationModel, Navigation navigation,
|
||||
OverlayManager overlayManager) {
|
||||
super(presentationModel);
|
||||
this.navigationManager = navigationManager;
|
||||
this.navigation = navigation;
|
||||
this.overlayManager = overlayManager;
|
||||
}
|
||||
|
||||
|
@ -237,10 +236,10 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void openAccountSettings() {
|
||||
navigationManager.navigationTo(NavigationItem.MAIN,
|
||||
NavigationItem.ACCOUNT,
|
||||
NavigationItem.ACCOUNT_SETTINGS,
|
||||
NavigationItem.RESTRICTIONS);
|
||||
navigation.navigationTo(Navigation.Item.MAIN,
|
||||
Navigation.Item.ACCOUNT,
|
||||
Navigation.Item.ACCOUNT_SETTINGS,
|
||||
Navigation.Item.RESTRICTIONS);
|
||||
}
|
||||
|
||||
private void close() {
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
package io.bitsquare.gui.main.trade.orderbook;
|
||||
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.NavigationItem;
|
||||
import io.bitsquare.gui.NavigationManager;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.OverlayManager;
|
||||
import io.bitsquare.gui.components.InputTextField;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
|
@ -62,8 +61,8 @@ import static javafx.beans.binding.Bindings.createStringBinding;
|
|||
public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
|
||||
private static final Logger log = LoggerFactory.getLogger(OrderBookViewCB.class);
|
||||
|
||||
private NavigationManager navigationManager;
|
||||
private NavigationItem tradeNavigationItem;
|
||||
private Navigation navigation;
|
||||
private Navigation.Item navigationItem;
|
||||
private OverlayManager overlayManager;
|
||||
private OptionalBtcValidator optionalBtcValidator;
|
||||
private OptionalFiatValidator optionalFiatValidator;
|
||||
|
@ -92,13 +91,13 @@ public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
|
|||
|
||||
@Inject
|
||||
private OrderBookViewCB(OrderBookPM presentationModel,
|
||||
NavigationManager navigationManager,
|
||||
Navigation navigation,
|
||||
OverlayManager overlayManager,
|
||||
OptionalBtcValidator optionalBtcValidator,
|
||||
OptionalFiatValidator optionalFiatValidator) {
|
||||
super(presentationModel);
|
||||
|
||||
this.navigationManager = navigationManager;
|
||||
this.navigation = navigation;
|
||||
this.overlayManager = overlayManager;
|
||||
this.optionalBtcValidator = optionalBtcValidator;
|
||||
this.optionalFiatValidator = optionalFiatValidator;
|
||||
|
@ -177,8 +176,8 @@ public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
|
|||
|
||||
public void setOrderBookInfo(OrderBookInfo orderBookInfo) {
|
||||
presentationModel.setOrderBookInfo(orderBookInfo);
|
||||
tradeNavigationItem = (orderBookInfo.getDirection() == Direction.BUY) ? NavigationItem.BUY : NavigationItem
|
||||
.SELL;
|
||||
navigationItem = (orderBookInfo.getDirection() == Direction.BUY) ?
|
||||
Navigation.Item.BUY : Navigation.Item.SELL;
|
||||
|
||||
}
|
||||
|
||||
|
@ -191,11 +190,8 @@ public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
|
|||
void createOffer() {
|
||||
if (presentationModel.isRegistered()) {
|
||||
createOfferButton.setDisable(true);
|
||||
if (presentationModel.getOrderBookInfo().getDirection() == Direction.BUY)
|
||||
navigationManager.navigationTo(NavigationItem.MAIN, NavigationItem.BUY, NavigationItem.CREATE_OFFER);
|
||||
else
|
||||
navigationManager.navigationTo(NavigationItem.MAIN, NavigationItem.SELL, NavigationItem.CREATE_OFFER);
|
||||
|
||||
navigation.navigationTo(Navigation.Item.MAIN, navigationItem,
|
||||
Navigation.Item.CREATE_OFFER);
|
||||
}
|
||||
else {
|
||||
openSetupScreen();
|
||||
|
@ -231,9 +227,9 @@ public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
|
|||
public void handle(ActionEvent actionEvent) {
|
||||
Dialog.Actions.OK.handle(actionEvent);
|
||||
overlayManager.removeBlurContent();
|
||||
navigationManager.setNavigationItemsForReturning(navigationManager.getCurrentNavigationItems());
|
||||
navigationManager.navigationTo(NavigationItem.MAIN, NavigationItem.ACCOUNT,
|
||||
NavigationItem.ACCOUNT_SETUP);
|
||||
navigation.setItemsForReturning(navigation.getCurrentItems());
|
||||
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT,
|
||||
Navigation.Item.ACCOUNT_SETUP);
|
||||
}
|
||||
});
|
||||
Popups.openInfo("You need to setup your trading account before you can trade.",
|
||||
|
@ -243,13 +239,9 @@ public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
|
|||
//TODO not updated yet
|
||||
private void takeOffer(Offer offer) {
|
||||
if (presentationModel.isRegistered()) {
|
||||
|
||||
presentationModel.getOrderBookInfo().setOffer(offer);
|
||||
|
||||
if (presentationModel.getOrderBookInfo().getDirection() == Direction.BUY)
|
||||
navigationManager.navigationTo(NavigationItem.MAIN, NavigationItem.BUY, NavigationItem.TAKE_OFFER);
|
||||
else
|
||||
navigationManager.navigationTo(NavigationItem.MAIN, NavigationItem.SELL, NavigationItem.TAKE_OFFER);
|
||||
navigation.navigationTo(Navigation.Item.MAIN, navigationItem,
|
||||
Navigation.Item.TAKE_OFFER);
|
||||
}
|
||||
else {
|
||||
openSetupScreen();
|
||||
|
@ -267,8 +259,9 @@ public class OrderBookViewCB extends CachedViewCB<OrderBookPM> {
|
|||
actions);
|
||||
|
||||
if (response == Dialog.Actions.YES)
|
||||
navigationManager.navigationTo(NavigationItem.MAIN, NavigationItem.ACCOUNT, NavigationItem.ACCOUNT_SETTINGS,
|
||||
NavigationItem.RESTRICTIONS);
|
||||
navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.ACCOUNT,
|
||||
Navigation.Item.ACCOUNT_SETTINGS,
|
||||
Navigation.Item.RESTRICTIONS);
|
||||
else
|
||||
orderBookTable.getSelectionModel().clearSelection();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue