Fix missing CachingViewLoader

This commit is contained in:
Manfred Karrer 2014-11-27 00:37:04 +01:00
parent 3f5d82f8b0
commit ea98a15406
8 changed files with 30 additions and 16 deletions

View File

@ -28,8 +28,8 @@ import javax.inject.Inject;
import viewfx.view.FxmlView;
import viewfx.view.View;
import viewfx.view.ViewLoader;
import viewfx.view.ViewPath;
import viewfx.view.support.ActivatableView;
import viewfx.view.support.CachingViewLoader;
import javafx.beans.value.ChangeListener;
import javafx.fxml.FXML;
@ -45,9 +45,11 @@ public class AccountView extends ActivatableView<TabPane, AccountViewModel> {
private final ViewLoader viewLoader;
private final Navigation navigation;
private View accountSetupWizardView;
private Tab tab;
@Inject
private AccountView(AccountViewModel model, ViewLoader viewLoader, Navigation navigation) {
private AccountView(AccountViewModel model, CachingViewLoader viewLoader, Navigation navigation) {
super(model);
this.viewLoader = viewLoader;
this.navigation = navigation;
@ -73,8 +75,7 @@ public class AccountView extends ActivatableView<TabPane, AccountViewModel> {
navigation.addListener(navigationListener);
root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener);
if (navigation.getCurrentPath().size() == 2 &&
navigation.getCurrentPath().get(1) == AccountView.class) {
if (navigation.getCurrentPath().size() == 2 && navigation.getCurrentPath().get(1) == AccountView.class) {
if (model.getNeedRegistration()) {
navigation.navigateTo(MainView.class, AccountView.class, AccountSetupWizard.class);
}
@ -91,10 +92,12 @@ public class AccountView extends ActivatableView<TabPane, AccountViewModel> {
public void deactivate() {
navigation.removeListener(navigationListener);
root.getSelectionModel().selectedItemProperty().removeListener(tabChangeListener);
if (accountSetupWizardView != null)
tab.setContent(null);
}
private void loadView(Class<? extends View> viewClass) {
Tab tab;
View view = viewLoader.load(viewClass);
if (view instanceof AccountSettingsView) {
@ -106,6 +109,7 @@ public class AccountView extends ActivatableView<TabPane, AccountViewModel> {
tab = accountSettingsTab;
tab.setText("Account setup");
arbitratorSettingsTab.setDisable(true);
accountSetupWizardView = view;
}
else if (view instanceof ArbitratorSettingsView) {
tab = arbitratorSettingsTab;

View File

@ -34,6 +34,7 @@ import viewfx.view.FxmlView;
import viewfx.view.View;
import viewfx.view.ViewLoader;
import viewfx.view.support.ActivatableView;
import viewfx.view.support.CachingViewLoader;
import javafx.fxml.FXML;
import javafx.scene.control.*;
@ -58,7 +59,7 @@ public class ArbitratorBrowserView extends ActivatableView<Pane, Void> implement
private final MessageService messageService;
@Inject
public ArbitratorBrowserView(ViewLoader viewLoader, AccountSettings accountSettings, Persistence persistence,
public ArbitratorBrowserView(CachingViewLoader viewLoader, AccountSettings accountSettings, Persistence persistence,
MessageService messageService) {
this.viewLoader = viewLoader;
this.accountSettings = accountSettings;

View File

@ -64,7 +64,7 @@ public class ChangePasswordView extends InitializableView<GridPane, ChangePasswo
@FXML
private void onSaved() {
if (model.requestSavePassword())
if (wizard != null && model.requestSavePassword())
wizard.nextStep(this);
else
log.debug(model.getErrorMessage()); // TODO use validating TF
@ -77,7 +77,8 @@ public class ChangePasswordView extends InitializableView<GridPane, ChangePasswo
@FXML
private void onSkipped() {
wizard.nextStep(this);
if (wizard != null)
wizard.nextStep(this);
}
}

View File

@ -36,6 +36,7 @@ import viewfx.view.ViewLoader;
import viewfx.view.ViewPath;
import viewfx.view.Wizard;
import viewfx.view.support.ActivatableViewAndModel;
import viewfx.view.support.CachingViewLoader;
import javafx.fxml.FXML;
import javafx.geometry.Pos;
@ -59,7 +60,7 @@ public class AccountSettingsView extends ActivatableViewAndModel {
@FXML private AnchorPane content;
@Inject
private AccountSettingsView(ViewLoader viewLoader, Navigation navigation) {
private AccountSettingsView(CachingViewLoader viewLoader, Navigation navigation) {
this.viewLoader = viewLoader;
this.navigation = navigation;
}

View File

@ -33,6 +33,7 @@ import viewfx.view.View;
import viewfx.view.ViewLoader;
import viewfx.view.Wizard;
import viewfx.view.support.ActivatableView;
import viewfx.view.support.CachingViewLoader;
import javafx.fxml.FXML;
import javafx.geometry.Insets;
@ -53,7 +54,7 @@ public class AccountSetupWizard extends ActivatableView implements Wizard {
private final Navigation navigation;
@Inject
private AccountSetupWizard(ViewLoader viewLoader, Navigation navigation) {
private AccountSetupWizard(CachingViewLoader viewLoader, Navigation navigation) {
this.viewLoader = viewLoader;
this.navigation = navigation;
}

View File

@ -29,6 +29,7 @@ import viewfx.view.FxmlView;
import viewfx.view.View;
import viewfx.view.ViewLoader;
import viewfx.view.support.ActivatableViewAndModel;
import viewfx.view.support.CachingViewLoader;
import javafx.beans.value.ChangeListener;
import javafx.fxml.FXML;
@ -47,7 +48,7 @@ public class FundsView extends ActivatableViewAndModel<TabPane, Activatable> {
private final Navigation navigation;
@Inject
public FundsView(ViewLoader viewLoader, Navigation navigation) {
public FundsView(CachingViewLoader viewLoader, Navigation navigation) {
this.viewLoader = viewLoader;
this.navigation = navigation;
}
@ -75,13 +76,14 @@ public class FundsView extends ActivatableViewAndModel<TabPane, Activatable> {
if (root.getSelectionModel().getSelectedItem() == transactionsTab)
navigation.navigateTo(MainView.class, FundsView.class, TransactionsView.class);
else
navigation.navigateTo(MainView.class, FundsView.class, WithdrawalView.class);
navigation.navigateTo(MainView.class, FundsView.class, WithdrawalView.class);
}
@Override
public void doDeactivate() {
root.getSelectionModel().selectedItemProperty().removeListener(tabChangeListener);
navigation.removeListener(navigationListener);
currentTab = null;
}
private void loadView(Class<? extends View> viewClass) {
@ -91,8 +93,10 @@ public class FundsView extends ActivatableViewAndModel<TabPane, Activatable> {
View view = viewLoader.load(viewClass);
if (view instanceof WithdrawalView) currentTab = withdrawalTab;
else if (view instanceof TransactionsView) currentTab = transactionsTab;
if (view instanceof WithdrawalView)
currentTab = withdrawalTab;
else if (view instanceof TransactionsView)
currentTab = transactionsTab;
currentTab.setContent(view.getRoot());
root.getSelectionModel().select(currentTab);

View File

@ -31,6 +31,7 @@ import viewfx.view.FxmlView;
import viewfx.view.View;
import viewfx.view.ViewLoader;
import viewfx.view.support.ActivatableViewAndModel;
import viewfx.view.support.CachingViewLoader;
import javafx.beans.value.ChangeListener;
import javafx.fxml.FXML;
@ -50,7 +51,7 @@ public class PortfolioView extends ActivatableViewAndModel<TabPane, Activatable>
private final TradeManager tradeManager;
@Inject
public PortfolioView(ViewLoader viewLoader, Navigation navigation, TradeManager tradeManager) {
public PortfolioView(CachingViewLoader viewLoader, Navigation navigation, TradeManager tradeManager) {
this.viewLoader = viewLoader;
this.navigation = navigation;
this.tradeManager = tradeManager;

View File

@ -30,6 +30,7 @@ import viewfx.view.FxmlView;
import viewfx.view.View;
import viewfx.view.ViewLoader;
import viewfx.view.support.ActivatableViewAndModel;
import viewfx.view.support.CachingViewLoader;
import javafx.beans.value.ChangeListener;
import javafx.fxml.FXML;
@ -48,7 +49,7 @@ public class SettingsView extends ActivatableViewAndModel<TabPane, Activatable>
private final Navigation navigation;
@Inject
public SettingsView(ViewLoader viewLoader, Navigation navigation, Preferences preferences) {
public SettingsView(CachingViewLoader viewLoader, Navigation navigation, Preferences preferences) {
this.viewLoader = viewLoader;
this.navigation = navigation;
this.preferences = preferences;