diff --git a/src/main/java/io/bitsquare/gui/CachedViewController.java b/src/main/java/io/bitsquare/gui/CachedViewController.java
deleted file mode 100644
index bda37e639e..0000000000
--- a/src/main/java/io/bitsquare/gui/CachedViewController.java
+++ /dev/null
@@ -1,88 +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 .
- */
-
-package io.bitsquare.gui;
-
-import java.net.URL;
-
-import java.util.ResourceBundle;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * If caching is used for loader we use the CachedViewController for turning the controller into sleep mode if not
- * active and awake it at reactivation.
- */
-// for new PM pattern use CachedCodeBehind
-@Deprecated
-public abstract class CachedViewController extends ViewController {
- private static final Logger log = LoggerFactory.getLogger(CachedViewController.class);
-
- public CachedViewController() {
- }
-
- /**
- * Get called form GUI framework when the UI is ready.
- * In caching controllers the initialize is only used for static UI setup.
- * The activate() method is called to start resources like.
- *
- * @param url
- * @param rb
- */
- @Override
- public void initialize(URL url, ResourceBundle rb) {
- log.trace("Lifecycle: initialize " + this.getClass().getSimpleName());
- root.sceneProperty().addListener((ov, oldValue, newValue) -> {
- // we got removed from the scene
- // lets terminate
- log.trace("Lifecycle: sceneProperty changed: " + this.getClass().getSimpleName() + " / oldValue=" +
- oldValue + " / newValue=" + newValue);
- if (oldValue == null && newValue != null) activate();
- else if (oldValue != null && newValue == null) deactivate();
- });
- }
-
- /**
- * In caching controllers the terminate calls the deactivate method.
- */
- @Override
- public void terminate() {
- log.trace("Lifecycle: terminate " + this.getClass().getSimpleName());
- super.terminate();
-
- deactivate();
- }
-
- /**
- * Used for deactivating resources (removing listeners, stopping timers or animations,...)
- */
- public void deactivate() {
- log.trace("Lifecycle: deactivate " + this.getClass().getSimpleName());
- if (childController instanceof CachedViewController) ((CachedViewController) childController).deactivate();
- }
-
- /**
- * Used to activate resources (adding listeners, starting timers or animations,...)
- */
- public void activate() {
- log.trace("Lifecycle: activate " + this.getClass().getSimpleName());
- if (childController instanceof CachedViewController) ((CachedViewController) childController).activate();
- }
-
-
-}
diff --git a/src/main/java/io/bitsquare/gui/ViewController.java b/src/main/java/io/bitsquare/gui/ViewController.java
deleted file mode 100644
index 91234f8a50..0000000000
--- a/src/main/java/io/bitsquare/gui/ViewController.java
+++ /dev/null
@@ -1,96 +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 .
- */
-
-package io.bitsquare.gui;
-
-import java.net.URL;
-
-import java.util.ResourceBundle;
-
-import javafx.fxml.FXML;
-import javafx.fxml.Initializable;
-import javafx.scene.*;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Base class for all controllers.
- */
-// for new PM pattern use CodeBehind
-@Deprecated
-public abstract class ViewController implements Initializable {
- private static final Logger log = LoggerFactory.getLogger(ViewController.class);
-
- protected Initializable childController;
- protected Initializable parentController;
-
- @FXML protected Parent root;
-
- /**
- * Get called form GUI framework when the UI is ready.
- *
- * @param url
- * @param rb
- */
- @Override
- public void initialize(URL url, ResourceBundle rb) {
- log.trace("Lifecycle: initialize " + this.getClass().getSimpleName());
- root.sceneProperty().addListener((ov, oldValue, newValue) -> {
- // we got removed from the scene
- // lets terminate
- if (oldValue != null && newValue == null) terminate();
- });
- }
-
- /**
- * Called automatically when view gets removed. Used for house keeping (removing listeners,
- * stopping timers or animations,...).
- */
- public void terminate() {
- log.trace("Lifecycle: terminate " + this.getClass().getSimpleName());
-
- if (childController != null) {
- if (childController instanceof ViewController)
- ((ViewController) childController).terminate();
- else if (childController instanceof ViewCB)
- ((ViewCB) childController).terminate();
- }
-
- }
-
- /**
- * @param parentController Controller who has created this.getClass().getSimpleName() instance (via
- * navigateToView/FXMLLoader).
- */
- public void setParentController(Initializable parentController) {
- log.trace("Lifecycle: setParentController " + this.getClass().getSimpleName() + " / parent = " +
- parentController);
- this.parentController = parentController;
- }
-
- /**
- * @param item NavigationItem to be loaded.
- * @return The ViewController of the loaded view.
- */
- public Initializable loadViewAndGetChildController(Navigation.Item item) {
- log.trace("Lifecycle: loadViewAndGetChildController " + this.getClass().getSimpleName() + " / navigationItem " +
- "= " + item);
- return null;
- }
-
-}
diff --git a/src/main/java/io/bitsquare/gui/components/CachingTabPane.java b/src/main/java/io/bitsquare/gui/components/CachingTabPane.java
deleted file mode 100644
index 006f364077..0000000000
--- a/src/main/java/io/bitsquare/gui/components/CachingTabPane.java
+++ /dev/null
@@ -1,125 +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 .
- */
-
-package io.bitsquare.gui.components;
-
-import io.bitsquare.gui.ViewController;
-import io.bitsquare.persistence.Persistence;
-import io.bitsquare.util.ViewLoader;
-
-import java.io.IOException;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javafx.scene.*;
-import javafx.scene.control.*;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * That class caches the already created views in a tab pane.
- * So when switching back to an already opened tab it is faster as no fxml loading is needed anymore.
- */
-
-public class CachingTabPane extends TabPane {
- private static final Logger log = LoggerFactory.getLogger(CachingTabPane.class);
-
- private final List tabInfoList = new ArrayList<>();
- private ViewController parentController;
- private Persistence persistence;
- private int selectedTabIndex;
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- // Public methods
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- public void initialize(ViewController parentController, Persistence persistence, String... tabContentFXMLUrls) {
- if (tabContentFXMLUrls.length == 0) {
- throw new IllegalArgumentException("No tabContentFXMLUrls defined");
- }
-
- this.parentController = parentController;
- this.persistence = persistence;
-
- for (String tabContentFXMLUrl : tabContentFXMLUrls) tabInfoList.add(new TabInfo(tabContentFXMLUrl));
-
- getSelectionModel().selectedItemProperty().addListener((observableValue, oldTab, newTab) -> loadView());
-
- // use parent to read selectedTabIndex
- Object indexObject = persistence.read(parentController, "selectedTabIndex");
- selectedTabIndex = (indexObject == null) ? 0 : (int) indexObject;
-
- // if selectedTabIndex = 0 the the change listener will not fire so we load it manually
- if (selectedTabIndex == 0) loadView();
-
- getSelectionModel().select(selectedTabIndex);
- }
-
- public ViewController loadViewAndGetChildController(String fxmlView) {
- for (int i = 0; i < tabInfoList.size(); i++) {
- if (tabInfoList.get(i).url.equals(fxmlView)) {
- // selection will cause loadView() call
- getSelectionModel().select(i);
- return currentController();
- }
- }
- throw new IllegalArgumentException("fxmlView not defined in tabContentFXMLUrlMap.");
- }
-
- public void setSelectedTabIndex(int selectedTabIndex) {
- getSelectionModel().select(selectedTabIndex);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- // Private methods
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- private void loadView() {
- selectedTabIndex = getSelectionModel().getSelectedIndex();
- TabInfo selectedTabInfo = tabInfoList.get(selectedTabIndex);
-
- final ViewLoader loader = new ViewLoader(getClass().getResource(selectedTabInfo.url));
- try {
- Node view = loader.load();
- selectedTabInfo.controller = loader.getController();
- getSelectionModel().getSelectedItem().setContent(view);
- } catch (IOException e) {
- log.error(e.getMessage());
- }
-
- selectedTabInfo.controller.setParentController(parentController);
- // use parent to write selectedTabIndex
- persistence.write(parentController, "selectedTabIndex", selectedTabIndex);
- }
-
- private ViewController currentController() {
- return tabInfoList.get(selectedTabIndex).controller;
- }
-}
-
-class TabInfo {
- ViewController controller;
- final String url;
-
- TabInfo(String url) {
- this.url = url;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/io/bitsquare/gui/main/arbitrators/browser/ArbitratorBrowserView.fxml b/src/main/java/io/bitsquare/gui/main/arbitrators/browser/ArbitratorBrowserView.fxml
index 98e995b04b..359625dc02 100644
--- a/src/main/java/io/bitsquare/gui/main/arbitrators/browser/ArbitratorBrowserView.fxml
+++ b/src/main/java/io/bitsquare/gui/main/arbitrators/browser/ArbitratorBrowserView.fxml
@@ -18,7 +18,7 @@
-
diff --git a/src/main/java/io/bitsquare/gui/main/arbitrators/browser/ArbitratorBrowserController.java b/src/main/java/io/bitsquare/gui/main/arbitrators/browser/ArbitratorBrowserViewCB.java
similarity index 74%
rename from src/main/java/io/bitsquare/gui/main/arbitrators/browser/ArbitratorBrowserController.java
rename to src/main/java/io/bitsquare/gui/main/arbitrators/browser/ArbitratorBrowserViewCB.java
index 661e756cd9..2b9d2fe030 100644
--- a/src/main/java/io/bitsquare/gui/main/arbitrators/browser/ArbitratorBrowserController.java
+++ b/src/main/java/io/bitsquare/gui/main/arbitrators/browser/ArbitratorBrowserViewCB.java
@@ -18,9 +18,10 @@
package io.bitsquare.gui.main.arbitrators.browser;
import io.bitsquare.arbitrator.Arbitrator;
-import io.bitsquare.gui.CachedViewController;
+import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.Navigation;
-import io.bitsquare.gui.main.arbitrators.profile.ArbitratorProfileController;
+import io.bitsquare.gui.ViewCB;
+import io.bitsquare.gui.main.arbitrators.profile.ArbitratorProfileViewCB;
import io.bitsquare.locale.LanguageUtil;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.listeners.ArbitratorListener;
@@ -51,15 +52,15 @@ import org.slf4j.LoggerFactory;
/**
* Arbitration is not much developed yet
*/
-public class ArbitratorBrowserController extends CachedViewController implements ArbitratorListener {
- private static final Logger log = LoggerFactory.getLogger(ArbitratorBrowserController.class);
+public class ArbitratorBrowserViewCB extends CachedViewCB implements ArbitratorListener {
+ private static final Logger log = LoggerFactory.getLogger(ArbitratorBrowserViewCB.class);
private final Settings settings;
private final Persistence persistence;
private final List allArbitrators = new ArrayList<>();
private Arbitrator currentArbitrator;
- private ArbitratorProfileController arbitratorProfileController;
+ private ArbitratorProfileViewCB arbitratorProfileViewCB;
private int index = -1;
@FXML Button prevButton, nextButton, selectButton, closeButton;
@@ -70,7 +71,7 @@ public class ArbitratorBrowserController extends CachedViewController implements
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
- public ArbitratorBrowserController(Settings settings, Persistence persistence, MessageFacade messageFacade) {
+ public ArbitratorBrowserViewCB(Settings settings, Persistence persistence, MessageFacade messageFacade) {
this.settings = settings;
this.persistence = persistence;
@@ -88,23 +89,26 @@ public class ArbitratorBrowserController extends CachedViewController implements
public void initialize(URL url, ResourceBundle rb) {
super.initialize(url, rb);
- loadViewAndGetChildController(Navigation.Item.ARBITRATOR_PROFILE);
+ loadView(Navigation.Item.ARBITRATOR_PROFILE);
checkButtonState();
}
+ @SuppressWarnings("EmptyMethod")
@Override
- public void terminate() {
- super.terminate();
+ public void activate() {
+ super.activate();
}
+ @SuppressWarnings("EmptyMethod")
@Override
public void deactivate() {
super.deactivate();
}
+ @SuppressWarnings("EmptyMethod")
@Override
- public void activate() {
- super.activate();
+ public void terminate() {
+ super.terminate();
}
@@ -112,28 +116,44 @@ public class ArbitratorBrowserController extends CachedViewController implements
// Navigation
///////////////////////////////////////////////////////////////////////////////////////////
- @Override
- public void setParentController(Initializable parentController) {
- super.setParentController(parentController);
- }
-
- @Override
- public Initializable loadViewAndGetChildController(Navigation.Item item) {
+ /* public Initializable loadViewAndGetChildController(Navigation.Item item) {
final ViewLoader loader = new ViewLoader(getClass().getResource(item.getFxmlUrl()));
try {
final Node view = loader.load();
- arbitratorProfileController = loader.getController();
- arbitratorProfileController.setParentController(this);
+ arbitratorProfileViewCB = loader.getController();
+ arbitratorProfileViewCB.setParentController(this);
((Pane) root).getChildren().set(0, view);
- return arbitratorProfileController;
+ return arbitratorProfileViewCB;
} catch (IOException e) {
e.printStackTrace();
}
return null;
- }
+ }*/
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ // Navigation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+
+ @Override
+ protected Initializable loadView(Navigation.Item navigationItem) {
+ super.loadView(navigationItem);
+
+ final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
+ try {
+ Node view = loader.load();
+ ((Pane) root).getChildren().set(0, view);
+ Initializable childController = arbitratorProfileViewCB = loader.getController();
+ ((ViewCB) childController).setParent(this);
+
+ } catch (IOException e) {
+ log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
+ e.printStackTrace();
+ }
+ return childController;
+ }
+
///////////////////////////////////////////////////////////////////////////////////////////
// Interface implementation: ArbitratorListener
///////////////////////////////////////////////////////////////////////////////////////////
@@ -150,7 +170,7 @@ public class ArbitratorBrowserController extends CachedViewController implements
if (!allArbitrators.isEmpty()) {
index = 0;
currentArbitrator = allArbitrators.get(index);
- arbitratorProfileController.applyArbitrator(currentArbitrator);
+ arbitratorProfileViewCB.applyArbitrator(currentArbitrator);
checkButtonState();
}
}
@@ -169,7 +189,7 @@ public class ArbitratorBrowserController extends CachedViewController implements
if (index > 0) {
index--;
currentArbitrator = allArbitrators.get(index);
- arbitratorProfileController.applyArbitrator(currentArbitrator);
+ arbitratorProfileViewCB.applyArbitrator(currentArbitrator);
}
checkButtonState();
}
@@ -179,7 +199,7 @@ public class ArbitratorBrowserController extends CachedViewController implements
if (index < allArbitrators.size() - 1) {
index++;
currentArbitrator = allArbitrators.get(index);
- arbitratorProfileController.applyArbitrator(currentArbitrator);
+ arbitratorProfileViewCB.applyArbitrator(currentArbitrator);
}
checkButtonState();
}
diff --git a/src/main/java/io/bitsquare/gui/main/arbitrators/profile/ArbitratorProfileView.fxml b/src/main/java/io/bitsquare/gui/main/arbitrators/profile/ArbitratorProfileView.fxml
index fe29d14cad..5212c0a70b 100644
--- a/src/main/java/io/bitsquare/gui/main/arbitrators/profile/ArbitratorProfileView.fxml
+++ b/src/main/java/io/bitsquare/gui/main/arbitrators/profile/ArbitratorProfileView.fxml
@@ -19,7 +19,7 @@
-
diff --git a/src/main/java/io/bitsquare/gui/main/arbitrators/profile/ArbitratorProfileController.java b/src/main/java/io/bitsquare/gui/main/arbitrators/profile/ArbitratorProfileViewCB.java
similarity index 85%
rename from src/main/java/io/bitsquare/gui/main/arbitrators/profile/ArbitratorProfileController.java
rename to src/main/java/io/bitsquare/gui/main/arbitrators/profile/ArbitratorProfileViewCB.java
index 70318861bd..282e7e002d 100644
--- a/src/main/java/io/bitsquare/gui/main/arbitrators/profile/ArbitratorProfileController.java
+++ b/src/main/java/io/bitsquare/gui/main/arbitrators/profile/ArbitratorProfileViewCB.java
@@ -18,8 +18,7 @@
package io.bitsquare.gui.main.arbitrators.profile;
import io.bitsquare.arbitrator.Arbitrator;
-import io.bitsquare.gui.CachedViewController;
-import io.bitsquare.gui.Navigation;
+import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.settings.Settings;
@@ -31,11 +30,10 @@ import java.util.ResourceBundle;
import javax.inject.Inject;
import javafx.fxml.FXML;
-import javafx.fxml.Initializable;
import javafx.scene.control.*;
// Arbitration is not much developed yet
-public class ArbitratorProfileController extends CachedViewController {
+public class ArbitratorProfileViewCB extends CachedViewCB {
private final Settings settings;
@@ -56,7 +54,7 @@ public class ArbitratorProfileController extends CachedViewController {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
- public ArbitratorProfileController(Settings settings, Persistence persistence, BSFormatter formatter) {
+ public ArbitratorProfileViewCB(Settings settings, Persistence persistence, BSFormatter formatter) {
this.settings = settings;
this.persistence = persistence;
@@ -70,39 +68,28 @@ public class ArbitratorProfileController extends CachedViewController {
// Lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
+ @SuppressWarnings("EmptyMethod")
@Override
public void initialize(URL url, ResourceBundle rb) {
super.initialize(url, rb);
}
- @Override
- public void terminate() {
- super.terminate();
- }
-
- @Override
- public void deactivate() {
- super.deactivate();
- }
-
+ @SuppressWarnings("EmptyMethod")
@Override
public void activate() {
super.activate();
}
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- // Navigation
- ///////////////////////////////////////////////////////////////////////////////////////////
-
+ @SuppressWarnings("EmptyMethod")
@Override
- public void setParentController(Initializable parentController) {
- super.setParentController(parentController);
+ public void deactivate() {
+ super.deactivate();
}
+ @SuppressWarnings("EmptyMethod")
@Override
- public Initializable loadViewAndGetChildController(Navigation.Item item) {
- return null;
+ public void terminate() {
+ super.terminate();
}
diff --git a/src/main/java/io/bitsquare/gui/main/arbitrators/registration/ArbitratorRegistrationView.fxml b/src/main/java/io/bitsquare/gui/main/arbitrators/registration/ArbitratorRegistrationView.fxml
index ef747a1430..b3dd7677f8 100644
--- a/src/main/java/io/bitsquare/gui/main/arbitrators/registration/ArbitratorRegistrationView.fxml
+++ b/src/main/java/io/bitsquare/gui/main/arbitrators/registration/ArbitratorRegistrationView.fxml
@@ -20,7 +20,7 @@
-
diff --git a/src/main/java/io/bitsquare/gui/main/arbitrators/registration/ArbitratorRegistrationController.java b/src/main/java/io/bitsquare/gui/main/arbitrators/registration/ArbitratorRegistrationViewCB.java
similarity index 94%
rename from src/main/java/io/bitsquare/gui/main/arbitrators/registration/ArbitratorRegistrationController.java
rename to src/main/java/io/bitsquare/gui/main/arbitrators/registration/ArbitratorRegistrationViewCB.java
index f646113ad7..65ad15941c 100644
--- a/src/main/java/io/bitsquare/gui/main/arbitrators/registration/ArbitratorRegistrationController.java
+++ b/src/main/java/io/bitsquare/gui/main/arbitrators/registration/ArbitratorRegistrationViewCB.java
@@ -20,10 +20,9 @@ package io.bitsquare.gui.main.arbitrators.registration;
import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.arbitrator.Reputation;
import io.bitsquare.btc.WalletFacade;
-import io.bitsquare.gui.CachedViewController;
-import io.bitsquare.gui.Navigation;
+import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
-import io.bitsquare.gui.main.arbitrators.profile.ArbitratorProfileController;
+import io.bitsquare.gui.main.arbitrators.profile.ArbitratorProfileViewCB;
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.locale.BSResources;
import io.bitsquare.locale.LanguageUtil;
@@ -51,7 +50,6 @@ import javax.inject.Inject;
import javafx.collections.FXCollections;
import javafx.fxml.FXML;
-import javafx.fxml.Initializable;
import javafx.scene.control.*;
import javafx.scene.input.*;
import javafx.stage.Stage;
@@ -64,8 +62,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// Arbitration is not much developed yet
-public class ArbitratorRegistrationController extends CachedViewController {
- private static final Logger log = LoggerFactory.getLogger(ArbitratorRegistrationController.class);
+public class ArbitratorRegistrationViewCB extends CachedViewCB {
+ private static final Logger log = LoggerFactory.getLogger(ArbitratorRegistrationViewCB.class);
private final Persistence persistence;
private final WalletFacade walletFacade;
@@ -73,7 +71,7 @@ public class ArbitratorRegistrationController extends CachedViewController {
private final User user;
private BSFormatter formatter;
private Arbitrator arbitrator = new Arbitrator();
- private ArbitratorProfileController arbitratorProfileController;
+ private ArbitratorProfileViewCB arbitratorProfileViewCB;
private boolean isEditMode;
private List languageList = new ArrayList<>();
@@ -104,8 +102,8 @@ public class ArbitratorRegistrationController extends CachedViewController {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
- private ArbitratorRegistrationController(Persistence persistence, WalletFacade walletFacade,
- MessageFacade messageFacade, User user, BSFormatter formatter) {
+ private ArbitratorRegistrationViewCB(Persistence persistence, WalletFacade walletFacade,
+ MessageFacade messageFacade, User user, BSFormatter formatter) {
this.persistence = persistence;
this.walletFacade = walletFacade;
this.messageFacade = messageFacade;
@@ -197,37 +195,24 @@ public class ArbitratorRegistrationController extends CachedViewController {
});
}
- @Override
- public void terminate() {
- super.terminate();
- }
-
- @Override
- public void deactivate() {
- super.deactivate();
- }
-
+ @SuppressWarnings("EmptyMethod")
@Override
public void activate() {
super.activate();
}
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- // Navigation
- ///////////////////////////////////////////////////////////////////////////////////////////
-
+ @SuppressWarnings("EmptyMethod")
@Override
- public void setParentController(Initializable parentController) {
- super.setParentController(parentController);
+ public void deactivate() {
+ super.deactivate();
}
+ @SuppressWarnings("EmptyMethod")
@Override
- public Initializable loadViewAndGetChildController(Navigation.Item item) {
- return null;
+ public void terminate() {
+ super.terminate();
}
-
///////////////////////////////////////////////////////////////////////////////////////////
// Public Methods
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/io/bitsquare/gui/main/funds/FundsController.java b/src/main/java/io/bitsquare/gui/main/funds/FundsController.java
deleted file mode 100644
index 3921f1de24..0000000000
--- a/src/main/java/io/bitsquare/gui/main/funds/FundsController.java
+++ /dev/null
@@ -1,88 +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 .
- */
-
-package io.bitsquare.gui.main.funds;
-
-import io.bitsquare.gui.CachedViewController;
-import io.bitsquare.gui.Navigation;
-import io.bitsquare.gui.ViewController;
-import io.bitsquare.gui.components.CachingTabPane;
-import io.bitsquare.persistence.Persistence;
-
-import java.net.URL;
-
-import java.util.ResourceBundle;
-
-import javax.inject.Inject;
-
-import javafx.fxml.Initializable;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class FundsController extends CachedViewController {
- private static final Logger log = LoggerFactory.getLogger(FundsController.class);
- private final Persistence persistence;
- private ViewController childController;
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- // Constructor
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- @Inject
- private FundsController(Persistence persistence) {
- this.persistence = persistence;
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- // Lifecycle
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- @Override
- public void initialize(URL url, ResourceBundle rb) {
- super.initialize(url, rb);
-
- ((CachingTabPane) root).initialize(
- this, persistence, Navigation.Item.WITHDRAWAL.getFxmlUrl(),
- Navigation.Item.TRANSACTIONS.getFxmlUrl());
- }
-
- @Override
- public void deactivate() {
- super.deactivate();
- }
-
- @Override
- public void activate() {
- super.activate();
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- // Navigation
- ///////////////////////////////////////////////////////////////////////////////////////////
-
- @Override
- public Initializable loadViewAndGetChildController(Navigation.Item item) {
- childController = ((CachingTabPane) root).loadViewAndGetChildController(item.getFxmlUrl());
- return childController;
- }
-
-}
-
diff --git a/src/main/java/io/bitsquare/gui/main/funds/FundsView.fxml b/src/main/java/io/bitsquare/gui/main/funds/FundsView.fxml
index 67ee6c8fff..0706fa4cce 100644
--- a/src/main/java/io/bitsquare/gui/main/funds/FundsView.fxml
+++ b/src/main/java/io/bitsquare/gui/main/funds/FundsView.fxml
@@ -16,15 +16,14 @@
~ along with Bitsquare. If not, see .
-->
-
-
+
-
-
+
+
-
+
\ No newline at end of file
diff --git a/src/main/java/io/bitsquare/gui/main/funds/FundsViewCB.java b/src/main/java/io/bitsquare/gui/main/funds/FundsViewCB.java
new file mode 100644
index 0000000000..b5c635f63c
--- /dev/null
+++ b/src/main/java/io/bitsquare/gui/main/funds/FundsViewCB.java
@@ -0,0 +1,148 @@
+/*
+ * 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 .
+ */
+
+package io.bitsquare.gui.main.funds;
+
+import io.bitsquare.gui.CachedViewCB;
+import io.bitsquare.gui.Navigation;
+import io.bitsquare.gui.ViewCB;
+import io.bitsquare.util.ViewLoader;
+
+import java.io.IOException;
+
+import java.net.URL;
+
+import java.util.ResourceBundle;
+
+import javax.inject.Inject;
+
+import javafx.beans.value.ChangeListener;
+import javafx.fxml.FXML;
+import javafx.fxml.Initializable;
+import javafx.scene.*;
+import javafx.scene.control.*;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FundsViewCB extends CachedViewCB {
+ private static final Logger log = LoggerFactory.getLogger(FundsViewCB.class);
+
+ private final Navigation navigation;
+
+ private Navigation.Listener navigationListener;
+ private ChangeListener tabChangeListener;
+
+ @FXML Tab withdrawalTab, transactionsTab;
+
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ // Constructor
+ ///////////////////////////////////////////////////////////////////////////////////////////
+
+ @Inject
+ FundsViewCB(Navigation navigation) {
+ super();
+
+ this.navigation = navigation;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ // Lifecycle
+ ///////////////////////////////////////////////////////////////////////////////////////////
+
+ @Override
+ public void initialize(URL url, ResourceBundle rb) {
+ navigationListener = navigationItems -> {
+ if (navigationItems != null && navigationItems.length == 3
+ && navigationItems[1] == Navigation.Item.FUNDS)
+ loadView(navigationItems[2]);
+ };
+
+ tabChangeListener = (ov, oldValue, newValue) -> {
+ if (newValue == withdrawalTab)
+ navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.FUNDS, Navigation.Item.WITHDRAWAL);
+ else if (newValue == transactionsTab)
+ navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.FUNDS, Navigation.Item.TRANSACTIONS);
+ };
+
+ super.initialize(url, rb);
+ }
+
+ @Override
+ public void activate() {
+ super.activate();
+
+ ((TabPane) root).getSelectionModel().selectedItemProperty().addListener(tabChangeListener);
+ navigation.addListener(navigationListener);
+
+ if (((TabPane) root).getSelectionModel().getSelectedItem() == transactionsTab)
+ navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.FUNDS, Navigation.Item.TRANSACTIONS);
+ else
+ navigation.navigationTo(Navigation.Item.MAIN, Navigation.Item.FUNDS, Navigation.Item.WITHDRAWAL);
+ }
+
+ @Override
+ public void deactivate() {
+ super.deactivate();
+
+ ((TabPane) root).getSelectionModel().selectedItemProperty().removeListener(tabChangeListener);
+ navigation.removeListener(navigationListener);
+ }
+
+ @SuppressWarnings("EmptyMethod")
+ @Override
+ public void terminate() {
+ super.terminate();
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////////////////////////
+ // Navigation
+ ///////////////////////////////////////////////////////////////////////////////////////////
+
+ @Override
+ protected Initializable loadView(Navigation.Item navigationItem) {
+ super.loadView(navigationItem);
+
+ final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()));
+ try {
+ Node view = loader.load();
+ Tab tab = null;
+ switch (navigationItem) {
+ case WITHDRAWAL:
+ tab = withdrawalTab;
+ break;
+ case TRANSACTIONS:
+ tab = transactionsTab;
+ break;
+ }
+ tab.setContent(view);
+ ((TabPane) root).getSelectionModel().select(tab);
+ Initializable childController = loader.getController();
+ ((ViewCB) childController).setParent(this);
+
+ } catch (IOException e) {
+ log.error("Loading view failed. FxmlUrl = " + navigationItem.getFxmlUrl());
+ e.printStackTrace();
+ }
+ return childController;
+ }
+
+}
+
diff --git a/src/main/java/io/bitsquare/gui/main/funds/transactions/TransactionsView.fxml b/src/main/java/io/bitsquare/gui/main/funds/transactions/TransactionsView.fxml
index ab492d6a7e..406bf6ca5f 100644
--- a/src/main/java/io/bitsquare/gui/main/funds/transactions/TransactionsView.fxml
+++ b/src/main/java/io/bitsquare/gui/main/funds/transactions/TransactionsView.fxml
@@ -21,7 +21,7 @@
-
diff --git a/src/main/java/io/bitsquare/gui/main/funds/transactions/TransactionsController.java b/src/main/java/io/bitsquare/gui/main/funds/transactions/TransactionsViewCB.java
similarity index 95%
rename from src/main/java/io/bitsquare/gui/main/funds/transactions/TransactionsController.java
rename to src/main/java/io/bitsquare/gui/main/funds/transactions/TransactionsViewCB.java
index 8a8d3fe92e..245caefcba 100644
--- a/src/main/java/io/bitsquare/gui/main/funds/transactions/TransactionsController.java
+++ b/src/main/java/io/bitsquare/gui/main/funds/transactions/TransactionsViewCB.java
@@ -18,7 +18,7 @@
package io.bitsquare.gui.main.funds.transactions;
import io.bitsquare.btc.WalletFacade;
-import io.bitsquare.gui.CachedViewController;
+import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.util.BSFormatter;
import com.google.bitcoin.core.Transaction;
@@ -41,8 +41,8 @@ import javafx.util.Callback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class TransactionsController extends CachedViewController {
- private static final Logger log = LoggerFactory.getLogger(TransactionsController.class);
+public class TransactionsViewCB extends CachedViewCB {
+ private static final Logger log = LoggerFactory.getLogger(TransactionsViewCB.class);
private final WalletFacade walletFacade;
private BSFormatter formatter;
@@ -58,7 +58,7 @@ public class TransactionsController extends CachedViewController {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
- private TransactionsController(WalletFacade walletFacade, BSFormatter formatter) {
+ private TransactionsViewCB(WalletFacade walletFacade, BSFormatter formatter) {
this.walletFacade = walletFacade;
this.formatter = formatter;
}
@@ -98,6 +98,12 @@ public class TransactionsController extends CachedViewController {
tableView.setItems(transactionsListItems);
}
+ @SuppressWarnings("EmptyMethod")
+ @Override
+ public void terminate() {
+ super.terminate();
+ }
+
///////////////////////////////////////////////////////////////////////////////////////////
// UI handlers
diff --git a/src/main/java/io/bitsquare/gui/main/funds/withdrawal/WithdrawalView.fxml b/src/main/java/io/bitsquare/gui/main/funds/withdrawal/WithdrawalView.fxml
index 29e041021f..4c4138585c 100644
--- a/src/main/java/io/bitsquare/gui/main/funds/withdrawal/WithdrawalView.fxml
+++ b/src/main/java/io/bitsquare/gui/main/funds/withdrawal/WithdrawalView.fxml
@@ -21,7 +21,7 @@
-
diff --git a/src/main/java/io/bitsquare/gui/main/funds/withdrawal/WithdrawalController.java b/src/main/java/io/bitsquare/gui/main/funds/withdrawal/WithdrawalViewCB.java
similarity index 97%
rename from src/main/java/io/bitsquare/gui/main/funds/withdrawal/WithdrawalController.java
rename to src/main/java/io/bitsquare/gui/main/funds/withdrawal/WithdrawalViewCB.java
index 3d983b5436..7148672f75 100644
--- a/src/main/java/io/bitsquare/gui/main/funds/withdrawal/WithdrawalController.java
+++ b/src/main/java/io/bitsquare/gui/main/funds/withdrawal/WithdrawalViewCB.java
@@ -21,7 +21,7 @@ import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.FeePolicy;
import io.bitsquare.btc.Restrictions;
import io.bitsquare.btc.WalletFacade;
-import io.bitsquare.gui.CachedViewController;
+import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.components.Popups;
import io.bitsquare.gui.util.BSFormatter;
@@ -59,8 +59,8 @@ import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class WithdrawalController extends CachedViewController {
- private static final Logger log = LoggerFactory.getLogger(WithdrawalController.class);
+public class WithdrawalViewCB extends CachedViewCB {
+ private static final Logger log = LoggerFactory.getLogger(WithdrawalViewCB.class);
private final WalletFacade walletFacade;
@@ -79,7 +79,7 @@ public class WithdrawalController extends CachedViewController {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
- private WithdrawalController(WalletFacade walletFacade, BSFormatter formatter) {
+ private WithdrawalViewCB(WalletFacade walletFacade, BSFormatter formatter) {
this.walletFacade = walletFacade;
this.formatter = formatter;
}
@@ -90,14 +90,14 @@ public class WithdrawalController extends CachedViewController {
@Override
public void initialize(URL url, ResourceBundle rb) {
- super.initialize(url, rb);
-
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
setLabelColumnCellFactory();
setBalanceColumnCellFactory();
setCopyColumnCellFactory();
setConfidenceColumnCellFactory();
+
+ super.initialize(url, rb);
}
@Override
@@ -137,6 +137,12 @@ public class WithdrawalController extends CachedViewController {
tableView.setItems(addressList);
}
+ @SuppressWarnings("EmptyMethod")
+ @Override
+ public void terminate() {
+ super.terminate();
+ }
+
///////////////////////////////////////////////////////////////////////////////////////////
// UI handlers
diff --git a/src/main/java/io/bitsquare/gui/main/home/HomeView.fxml b/src/main/java/io/bitsquare/gui/main/home/HomeView.fxml
index a18df0bb86..701690e39c 100644
--- a/src/main/java/io/bitsquare/gui/main/home/HomeView.fxml
+++ b/src/main/java/io/bitsquare/gui/main/home/HomeView.fxml
@@ -20,7 +20,7 @@
-
diff --git a/src/main/java/io/bitsquare/gui/main/home/HomeController.java b/src/main/java/io/bitsquare/gui/main/home/HomeViewCB.java
similarity index 90%
rename from src/main/java/io/bitsquare/gui/main/home/HomeController.java
rename to src/main/java/io/bitsquare/gui/main/home/HomeViewCB.java
index e9b4ac4535..9e43c36a8e 100644
--- a/src/main/java/io/bitsquare/gui/main/home/HomeController.java
+++ b/src/main/java/io/bitsquare/gui/main/home/HomeViewCB.java
@@ -20,7 +20,7 @@ package io.bitsquare.gui.main.home;
import io.bitsquare.BitSquare;
import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.Navigation;
-import io.bitsquare.gui.main.arbitrators.registration.ArbitratorRegistrationController;
+import io.bitsquare.gui.main.arbitrators.registration.ArbitratorRegistrationViewCB;
import io.bitsquare.util.ViewLoader;
import java.io.IOException;
@@ -40,10 +40,10 @@ import org.slf4j.LoggerFactory;
// home is just hosting the arbiters buttons yet, but that's just for dev, not clear yet what will be in home,
// probably overview, event history, news, charts,... -> low prio
-public class HomeController extends CachedViewCB {
- private static final Logger log = LoggerFactory.getLogger(HomeController.class);
+public class HomeViewCB extends CachedViewCB {
+ private static final Logger log = LoggerFactory.getLogger(HomeViewCB.class);
- private ArbitratorRegistrationController arbitratorRegistrationController;
+ private ArbitratorRegistrationViewCB arbitratorRegistrationViewCB;
///////////////////////////////////////////////////////////////////////////////////////////
// Lifecycle
@@ -84,8 +84,7 @@ public class HomeController extends CachedViewCB {
final ViewLoader loader = new ViewLoader(getClass().getResource(navigationItem.getFxmlUrl()), false);
try {
final Parent view = loader.load();
- arbitratorRegistrationController = loader.getController();
- arbitratorRegistrationController.setParentController(this);
+ arbitratorRegistrationViewCB = loader.getController();
final Stage rootStage = BitSquare.getPrimaryStage();
final Stage stage = new Stage();
@@ -102,7 +101,7 @@ public class HomeController extends CachedViewCB {
stage.setScene(scene);
stage.show();
- return arbitratorRegistrationController;
+ return arbitratorRegistrationViewCB;
} catch (IOException e) {
e.printStackTrace();
}
@@ -122,7 +121,7 @@ public class HomeController extends CachedViewCB {
@FXML
public void onArbitratorEdit() {
loadView(Navigation.Item.ARBITRATOR_REGISTRATION);
- arbitratorRegistrationController.setEditMode(true);
+ arbitratorRegistrationViewCB.setEditMode(true);
}
diff --git a/src/main/java/io/bitsquare/gui/main/msg/MsgView.fxml b/src/main/java/io/bitsquare/gui/main/msg/MsgView.fxml
index 6bd3ddea1f..1ab8c0331f 100644
--- a/src/main/java/io/bitsquare/gui/main/msg/MsgView.fxml
+++ b/src/main/java/io/bitsquare/gui/main/msg/MsgView.fxml
@@ -20,7 +20,7 @@
-
diff --git a/src/main/java/io/bitsquare/gui/main/msg/MsgController.java b/src/main/java/io/bitsquare/gui/main/msg/MsgViewCB.java
similarity index 96%
rename from src/main/java/io/bitsquare/gui/main/msg/MsgController.java
rename to src/main/java/io/bitsquare/gui/main/msg/MsgViewCB.java
index 9fe4eef3e4..7d169e08e6 100644
--- a/src/main/java/io/bitsquare/gui/main/msg/MsgController.java
+++ b/src/main/java/io/bitsquare/gui/main/msg/MsgViewCB.java
@@ -34,8 +34,8 @@ import org.slf4j.LoggerFactory;
// will be probably only used for arbitration communication, will be renamed and the icon changed
-public class MsgController extends CachedViewCB {
- private static final Logger log = LoggerFactory.getLogger(MsgController.class);
+public class MsgViewCB extends CachedViewCB {
+ private static final Logger log = LoggerFactory.getLogger(MsgViewCB.class);
///////////////////////////////////////////////////////////////////////////////////////////
@@ -43,7 +43,7 @@ public class MsgController extends CachedViewCB {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
- private MsgController() {
+ private MsgViewCB() {
}
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/io/bitsquare/gui/main/orders/OrdersViewCB.java b/src/main/java/io/bitsquare/gui/main/orders/OrdersViewCB.java
index 9d776c933a..79f709ec0d 100644
--- a/src/main/java/io/bitsquare/gui/main/orders/OrdersViewCB.java
+++ b/src/main/java/io/bitsquare/gui/main/orders/OrdersViewCB.java
@@ -45,10 +45,11 @@ public class OrdersViewCB extends CachedViewCB {
private final Navigation navigation;
private final TradeManager tradeManager;
+
private Navigation.Listener navigationListener;
+ private ChangeListener tabChangeListener;
@FXML Tab offersTab, pendingTradesTab, closedTradesTab;
- private ChangeListener tabChangeListener;
///////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/test/java/io/bitsquare/gui/main/orders/pending/uimock/PendingTradesControllerUIMock.java b/src/test/java/io/bitsquare/gui/main/orders/pending/uimock/PendingTradesControllerUIMock.java
index 94b6d5448d..bf568cd604 100644
--- a/src/test/java/io/bitsquare/gui/main/orders/pending/uimock/PendingTradesControllerUIMock.java
+++ b/src/test/java/io/bitsquare/gui/main/orders/pending/uimock/PendingTradesControllerUIMock.java
@@ -17,7 +17,7 @@
package io.bitsquare.gui.main.orders.pending.uimock;
-import io.bitsquare.gui.CachedViewController;
+import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.components.processbar.ProcessStepBar;
import io.bitsquare.gui.components.processbar.ProcessStepItem;
@@ -32,7 +32,7 @@ import javax.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class PendingTradesControllerUIMock extends CachedViewController {
+public class PendingTradesControllerUIMock extends CachedViewCB {
private static final Logger log = LoggerFactory.getLogger(PendingTradesControllerUIMock.class);
public ProcessStepBar processBar;