Rename View => BasicView and extract View interface

This commit is contained in:
Chris Beams 2014-11-23 04:59:53 +01:00
parent 55036b04c6
commit 961ec9b317
No known key found for this signature in database
GPG Key ID: 3D214F8F5BC5ED73
10 changed files with 63 additions and 45 deletions

View File

@ -0,0 +1,44 @@
/*
* 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 javafx.fxml.FXML;
import javafx.scene.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class BasicView<M> implements View {
protected final Logger log = LoggerFactory.getLogger(this.getClass());
protected final M model;
protected @FXML Parent root;
public BasicView(M model) {
this.model = model;
}
public BasicView() {
this(null);
}
protected View loadView(Navigation.Item navigationItem) {
throw new UnsupportedOperationException("loadView not implemented");
}
}

View File

@ -17,6 +17,6 @@
package io.bitsquare.gui; package io.bitsquare.gui;
public interface ChildOf<Parent> { public interface ChildOf<Parent extends View> extends View {
void setParent(Parent parent); void setParent(Parent parent);
} }

View File

@ -23,7 +23,7 @@ import java.util.ResourceBundle;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
public class InitializableView<M> extends View<M> implements Initializable { public class InitializableView<M> extends BasicView<M> implements Initializable {
public InitializableView(M model) { public InitializableView(M model) {
super(model); super(model);

View File

@ -17,28 +17,5 @@
package io.bitsquare.gui; package io.bitsquare.gui;
import javafx.fxml.FXML; public interface View {
import javafx.scene.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class View<M> {
protected final Logger log = LoggerFactory.getLogger(this.getClass());
protected final M model;
protected @FXML Parent root;
public View(M model) {
this.model = model;
}
public View() {
this(null);
}
protected View loadView(Navigation.Item navigationItem) {
throw new UnsupportedOperationException("loadView not implemented");
}
} }

View File

@ -17,8 +17,8 @@
package io.bitsquare.gui; package io.bitsquare.gui;
public interface Wizard { public interface Wizard extends View {
void nextStep(View current); void nextStep(Step currentStep);
public interface Step extends ChildOf<Wizard> { public interface Step extends ChildOf<Wizard> {
void hideWizardNavigation(); void hideWizardNavigation();

View File

@ -17,6 +17,7 @@
package io.bitsquare.gui.main.account.arbitrator; package io.bitsquare.gui.main.account.arbitrator;
import io.bitsquare.gui.BasicView;
import io.bitsquare.gui.Navigation; import io.bitsquare.gui.Navigation;
import io.bitsquare.gui.View; import io.bitsquare.gui.View;
import io.bitsquare.gui.ViewLoader; import io.bitsquare.gui.ViewLoader;
@ -30,7 +31,7 @@ import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
// TODO Arbitration is very basic yet // TODO Arbitration is very basic yet
public class ArbitratorSettingsView extends View { public class ArbitratorSettingsView extends BasicView {
private final ViewLoader viewLoader; private final ViewLoader viewLoader;
private final Navigation navigation; private final Navigation navigation;

View File

@ -18,7 +18,7 @@
package io.bitsquare.gui.main.account.arbitrator.profile; package io.bitsquare.gui.main.account.arbitrator.profile;
import io.bitsquare.arbitrator.Arbitrator; import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.gui.View; import io.bitsquare.gui.BasicView;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.persistence.Persistence; import io.bitsquare.persistence.Persistence;
import io.bitsquare.settings.Preferences; import io.bitsquare.settings.Preferences;
@ -29,7 +29,7 @@ import javafx.fxml.FXML;
import javafx.scene.control.*; import javafx.scene.control.*;
// TODO Arbitration is very basic yet // TODO Arbitration is very basic yet
public class ArbitratorProfileView extends View { public class ArbitratorProfileView extends BasicView {
private final Preferences preferences; private final Preferences preferences;

View File

@ -142,29 +142,25 @@ public class AccountSetupWizard extends ActivatableView implements Wizard {
} }
///////////////////////////////////////////////////////////////////////////////////////////
// MultiStepNavigation implementation
///////////////////////////////////////////////////////////////////////////////////////////
@Override @Override
public void nextStep(View childView) { public void nextStep(Step currentStep) {
if (childView instanceof SeedWordsView) { if (currentStep instanceof SeedWordsView) {
seedWords.onCompleted(); seedWords.onCompleted();
password.show(); password.show();
} }
else if (childView instanceof PasswordView) { else if (currentStep instanceof PasswordView) {
password.onCompleted(); password.onCompleted();
restrictions.show(); restrictions.show();
} }
else if (childView instanceof RestrictionsView) { else if (currentStep instanceof RestrictionsView) {
restrictions.onCompleted(); restrictions.onCompleted();
fiatAccount.show(); fiatAccount.show();
} }
else if (childView instanceof IrcAccountView) { else if (currentStep instanceof IrcAccountView) {
fiatAccount.onCompleted(); fiatAccount.onCompleted();
registration.show(); registration.show();
} }
else if (childView instanceof RegistrationView) { else if (currentStep instanceof RegistrationView) {
registration.onCompleted(); registration.onCompleted();
if (navigation.getItemsForReturning() != null) if (navigation.getItemsForReturning() != null)

View File

@ -17,9 +17,9 @@
package io.bitsquare.gui.main.home; package io.bitsquare.gui.main.home;
import io.bitsquare.gui.View; import io.bitsquare.gui.BasicView;
// home is just hosting the arbiters buttons yet, but that's just for dev, not clear yet what will be in home, // 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 // probably overview, event history, news, charts,... -> low prio
public class HomeView extends View { public class HomeView extends BasicView {
} }

View File

@ -17,7 +17,7 @@
package io.bitsquare.gui.main.msg; package io.bitsquare.gui.main.msg;
import io.bitsquare.gui.View; import io.bitsquare.gui.BasicView;
import javax.inject.Inject; import javax.inject.Inject;
@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory;
// will be probably only used for arbitration communication, will be renamed and the icon changed // will be probably only used for arbitration communication, will be renamed and the icon changed
public class MsgView extends View { public class MsgView extends BasicView {
private static final Logger log = LoggerFactory.getLogger(MsgView.class); private static final Logger log = LoggerFactory.getLogger(MsgView.class);