Rename gui.GuiceControllerFactory => viewfx...GuiceViewFactory

This commit is contained in:
Chris Beams 2014-11-23 20:05:32 +01:00
parent 318bfc5fb0
commit 5a75a1aa10
No known key found for this signature in database
GPG key ID: 3D214F8F5BC5ED73
19 changed files with 51 additions and 26 deletions

View file

@ -19,7 +19,6 @@ package io.bitsquare.app.gui;
import io.bitsquare.BitsquareException; import io.bitsquare.BitsquareException;
import io.bitsquare.account.AccountSettings; import io.bitsquare.account.AccountSettings;
import io.bitsquare.gui.GuiceControllerFactory;
import io.bitsquare.gui.Navigation; import io.bitsquare.gui.Navigation;
import io.bitsquare.gui.SystemTray; import io.bitsquare.gui.SystemTray;
import io.bitsquare.gui.ViewLoader; import io.bitsquare.gui.ViewLoader;
@ -41,6 +40,7 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import viewfx.view.View; import viewfx.view.View;
import viewfx.view.support.guice.GuiceViewFactory;
import javafx.application.Application; import javafx.application.Application;
import javafx.scene.*; import javafx.scene.*;
@ -66,7 +66,7 @@ public class BitsquareApp extends Application {
public void start(Stage primaryStage) throws IOException { public void start(Stage primaryStage) throws IOException {
bitsquareAppModule = new BitsquareAppModule(env, primaryStage); bitsquareAppModule = new BitsquareAppModule(env, primaryStage);
injector = Guice.createInjector(bitsquareAppModule); injector = Guice.createInjector(bitsquareAppModule);
injector.getInstance(GuiceControllerFactory.class).setInjector(injector); injector.getInstance(GuiceViewFactory.class).setInjector(injector);
// route uncaught exceptions to a user-facing dialog // route uncaught exceptions to a user-facing dialog

View file

@ -31,6 +31,8 @@ import io.bitsquare.gui.util.validation.PasswordValidator;
import com.google.inject.name.Names; import com.google.inject.name.Names;
import viewfx.view.support.guice.GuiceViewFactory;
import javafx.stage.Stage; import javafx.stage.Stage;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
@ -46,7 +48,7 @@ public class GuiModule extends BitsquareModule {
@Override @Override
protected void configure() { protected void configure() {
bind(GuiceControllerFactory.class).asEagerSingleton(); bind(GuiceViewFactory.class).asEagerSingleton();
bind(ViewLoader.class).asEagerSingleton(); bind(ViewLoader.class).asEagerSingleton();
bind(OfferBook.class).asEagerSingleton(); bind(OfferBook.class).asEagerSingleton();

View file

@ -27,6 +27,7 @@ import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import viewfx.view.View; import viewfx.view.View;
import viewfx.view.support.guice.GuiceViewFactory;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.fxml.JavaFXBuilderFactory; import javafx.fxml.JavaFXBuilderFactory;
@ -40,10 +41,10 @@ public class ViewLoader {
private final Map<URL, View> cache = new HashMap<>(); private final Map<URL, View> cache = new HashMap<>();
private final BuilderFactory builderFactory = new JavaFXBuilderFactory(); private final BuilderFactory builderFactory = new JavaFXBuilderFactory();
private final GuiceControllerFactory controllerFactory; private final GuiceViewFactory controllerFactory;
@Inject @Inject
public ViewLoader(GuiceControllerFactory controllerFactory) { public ViewLoader(GuiceViewFactory controllerFactory) {
this.controllerFactory = controllerFactory; this.controllerFactory = controllerFactory;
} }

View file

@ -29,8 +29,8 @@ import com.google.inject.Inject;
import java.util.Currency; import java.util.Currency;
import viewfx.model.support.ActivatableWithDelegate;
import viewfx.model.ViewModel; import viewfx.model.ViewModel;
import viewfx.model.support.ActivatableWithDelegate;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty; import javafx.beans.property.ObjectProperty;

View file

@ -27,8 +27,8 @@ import com.google.inject.Inject;
import java.util.Currency; import java.util.Currency;
import viewfx.model.support.ActivatableWithDelegate;
import viewfx.model.ViewModel; import viewfx.model.ViewModel;
import viewfx.model.support.ActivatableWithDelegate;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty; import javafx.beans.property.ObjectProperty;

View file

@ -30,9 +30,9 @@ import java.util.Locale;
import javax.inject.Inject; import javax.inject.Inject;
import viewfx.view.support.ActivatableViewAndModel;
import viewfx.view.View; import viewfx.view.View;
import viewfx.view.Wizard; import viewfx.view.Wizard;
import viewfx.view.support.ActivatableViewAndModel;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.*; import javafx.scene.*;

View file

@ -25,8 +25,8 @@ import com.google.inject.Inject;
import java.util.Locale; import java.util.Locale;
import viewfx.model.support.ActivatableWithDelegate;
import viewfx.model.ViewModel; import viewfx.model.ViewModel;
import viewfx.model.support.ActivatableWithDelegate;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleBooleanProperty;

View file

@ -21,8 +21,8 @@ import io.bitsquare.gui.util.BSFormatter;
import com.google.inject.Inject; import com.google.inject.Inject;
import viewfx.model.support.ActivatableWithDelegate;
import viewfx.model.ViewModel; import viewfx.model.ViewModel;
import viewfx.model.support.ActivatableWithDelegate;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;

View file

@ -21,8 +21,8 @@ import io.bitsquare.gui.util.BSFormatter;
import com.google.inject.Inject; import com.google.inject.Inject;
import viewfx.model.support.ActivatableWithDelegate;
import viewfx.model.ViewModel; import viewfx.model.ViewModel;
import viewfx.model.support.ActivatableWithDelegate;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;

View file

@ -30,8 +30,8 @@ import com.google.inject.Inject;
import java.util.Date; import java.util.Date;
import viewfx.model.support.ActivatableWithDelegate;
import viewfx.model.ViewModel; import viewfx.model.ViewModel;
import viewfx.model.support.ActivatableWithDelegate;
import javafx.beans.InvalidationListener; import javafx.beans.InvalidationListener;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;

View file

@ -19,8 +19,8 @@ package io.bitsquare.gui.main.settings.application;
import com.google.inject.Inject; import com.google.inject.Inject;
import viewfx.model.support.ActivatableWithDelegate;
import viewfx.model.ViewModel; import viewfx.model.ViewModel;
import viewfx.model.support.ActivatableWithDelegate;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;

View file

@ -31,8 +31,8 @@ import org.bitcoinj.utils.Fiat;
import java.util.List; import java.util.List;
import viewfx.view.support.ActivatableView;
import viewfx.view.View; import viewfx.view.View;
import viewfx.view.support.ActivatableView;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.collections.ListChangeListener; import javafx.collections.ListChangeListener;

View file

@ -31,8 +31,8 @@ import org.bitcoinj.utils.Fiat;
import javax.inject.Inject; import javax.inject.Inject;
import viewfx.model.support.ActivatableWithDelegate;
import viewfx.model.ViewModel; import viewfx.model.ViewModel;
import viewfx.model.support.ActivatableWithDelegate;
import javafx.beans.Observable; import javafx.beans.Observable;
import javafx.beans.binding.Bindings; import javafx.beans.binding.Bindings;

View file

@ -30,8 +30,8 @@ import org.bitcoinj.utils.Fiat;
import com.google.inject.Inject; import com.google.inject.Inject;
import viewfx.model.support.ActivatableWithDelegate;
import viewfx.model.ViewModel; import viewfx.model.ViewModel;
import viewfx.model.support.ActivatableWithDelegate;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;

View file

@ -30,8 +30,8 @@ import org.bitcoinj.core.Coin;
import javax.inject.Inject; import javax.inject.Inject;
import viewfx.model.support.ActivatableWithDelegate;
import viewfx.model.ViewModel; import viewfx.model.ViewModel;
import viewfx.model.support.ActivatableWithDelegate;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty; import javafx.beans.property.ObjectProperty;

View file

@ -17,8 +17,6 @@
package viewfx.view; package viewfx.view;
import viewfx.view.View;
public interface ChildView<Parent extends View> extends View { public interface ChildView<Parent extends View> extends View {
void setParent(Parent parent); void setParent(Parent parent);
} }

View file

@ -0,0 +1,23 @@
/*
* 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 viewfx.view;
import javafx.util.Callback;
public interface ViewFactory extends Callback<Class<?>, Object> {
}

View file

@ -15,23 +15,23 @@
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>. * along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/ */
package io.bitsquare.gui; package viewfx.view.support.guice;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.inject.Injector; import com.google.inject.Injector;
import javafx.util.Callback; import viewfx.view.ViewFactory;
/** /**
* A JavaFX controller factory for constructing controllers via Guice DI. To * A JavaFX controller factory for constructing viewfx Views using Guice. To
* install this in the {@link javafx.fxml.FXMLLoader}, pass it as a parameter to * install this in the {@link javafx.fxml.FXMLLoader}, pass it as a parameter to
* {@link javafx.fxml.FXMLLoader#setControllerFactory(javafx.util.Callback)}. * {@link javafx.fxml.FXMLLoader#setControllerFactory(javafx.util.Callback)}.
* <p> * <p>
* Once set, make sure you do <b>not</b> use the static methods on * Once set, make sure you do <b>not</b> use the static methods on
* {@link javafx.fxml.FXMLLoader} when creating your JavaFX node. * {@link javafx.fxml.FXMLLoader} when creating your JavaFX node.
*/ */
public class GuiceControllerFactory implements Callback<Class<?>, Object> { public class GuiceViewFactory implements ViewFactory {
private Injector injector; private Injector injector;

View file

@ -19,7 +19,6 @@ package io.bitsquare.app.gui;
import io.bitsquare.BitsquareException; import io.bitsquare.BitsquareException;
import io.bitsquare.app.BitsquareEnvironment; import io.bitsquare.app.BitsquareEnvironment;
import io.bitsquare.gui.GuiceControllerFactory;
import io.bitsquare.gui.Navigation; import io.bitsquare.gui.Navigation;
import io.bitsquare.gui.ViewLoader; import io.bitsquare.gui.ViewLoader;
@ -28,6 +27,8 @@ import com.google.inject.Injector;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import viewfx.view.support.guice.GuiceViewFactory;
import javafx.application.Application; import javafx.application.Application;
import javafx.stage.Stage; import javafx.stage.Stage;
@ -61,14 +62,14 @@ public class ViewLoaderTests {
Thread.sleep(10); Thread.sleep(10);
} }
private GuiceControllerFactory controllerFactory; private GuiceViewFactory controllerFactory;
@Before @Before
public void setUp() { public void setUp() {
OptionParser parser = new OptionParser(); OptionParser parser = new OptionParser();
BitsquareEnvironment env = new BitsquareEnvironment(parser.parse(new String[]{})); BitsquareEnvironment env = new BitsquareEnvironment(parser.parse(new String[]{}));
Injector injector = Guice.createInjector(new BitsquareAppModule(env, TestApp.primaryStage)); Injector injector = Guice.createInjector(new BitsquareAppModule(env, TestApp.primaryStage));
controllerFactory = injector.getInstance(GuiceControllerFactory.class); controllerFactory = injector.getInstance(GuiceViewFactory.class);
controllerFactory.setInjector(injector); controllerFactory.setInjector(injector);
} }