mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-05-24 01:11:34 -04:00
Rename gui.GuiceControllerFactory => viewfx...GuiceViewFactory
This commit is contained in:
parent
318bfc5fb0
commit
5a75a1aa10
19 changed files with 51 additions and 26 deletions
|
@ -19,7 +19,6 @@ package io.bitsquare.app.gui;
|
|||
|
||||
import io.bitsquare.BitsquareException;
|
||||
import io.bitsquare.account.AccountSettings;
|
||||
import io.bitsquare.gui.GuiceControllerFactory;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.SystemTray;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
|
@ -41,6 +40,7 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
|
||||
import viewfx.view.View;
|
||||
import viewfx.view.support.guice.GuiceViewFactory;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.*;
|
||||
|
@ -66,7 +66,7 @@ public class BitsquareApp extends Application {
|
|||
public void start(Stage primaryStage) throws IOException {
|
||||
bitsquareAppModule = new BitsquareAppModule(env, primaryStage);
|
||||
injector = Guice.createInjector(bitsquareAppModule);
|
||||
injector.getInstance(GuiceControllerFactory.class).setInjector(injector);
|
||||
injector.getInstance(GuiceViewFactory.class).setInjector(injector);
|
||||
|
||||
|
||||
// route uncaught exceptions to a user-facing dialog
|
||||
|
|
|
@ -31,6 +31,8 @@ import io.bitsquare.gui.util.validation.PasswordValidator;
|
|||
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
import viewfx.view.support.guice.GuiceViewFactory;
|
||||
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import org.springframework.core.env.Environment;
|
||||
|
@ -46,7 +48,7 @@ public class GuiModule extends BitsquareModule {
|
|||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(GuiceControllerFactory.class).asEagerSingleton();
|
||||
bind(GuiceViewFactory.class).asEagerSingleton();
|
||||
bind(ViewLoader.class).asEagerSingleton();
|
||||
|
||||
bind(OfferBook.class).asEagerSingleton();
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Map;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import viewfx.view.View;
|
||||
import viewfx.view.support.guice.GuiceViewFactory;
|
||||
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.JavaFXBuilderFactory;
|
||||
|
@ -40,10 +41,10 @@ public class ViewLoader {
|
|||
|
||||
private final Map<URL, View> cache = new HashMap<>();
|
||||
private final BuilderFactory builderFactory = new JavaFXBuilderFactory();
|
||||
private final GuiceControllerFactory controllerFactory;
|
||||
private final GuiceViewFactory controllerFactory;
|
||||
|
||||
@Inject
|
||||
public ViewLoader(GuiceControllerFactory controllerFactory) {
|
||||
public ViewLoader(GuiceViewFactory controllerFactory) {
|
||||
this.controllerFactory = controllerFactory;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ import com.google.inject.Inject;
|
|||
|
||||
import java.util.Currency;
|
||||
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
import viewfx.model.ViewModel;
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
|
|
|
@ -27,8 +27,8 @@ import com.google.inject.Inject;
|
|||
|
||||
import java.util.Currency;
|
||||
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
import viewfx.model.ViewModel;
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
|
|
|
@ -30,9 +30,9 @@ import java.util.Locale;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import viewfx.view.support.ActivatableViewAndModel;
|
||||
import viewfx.view.View;
|
||||
import viewfx.view.Wizard;
|
||||
import viewfx.view.support.ActivatableViewAndModel;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.*;
|
||||
|
|
|
@ -25,8 +25,8 @@ import com.google.inject.Inject;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
import viewfx.model.ViewModel;
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
|
|
|
@ -21,8 +21,8 @@ import io.bitsquare.gui.util.BSFormatter;
|
|||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
import viewfx.model.ViewModel;
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ import io.bitsquare.gui.util.BSFormatter;
|
|||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
import viewfx.model.ViewModel;
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ import com.google.inject.Inject;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
import viewfx.model.ViewModel;
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
|
||||
import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
|
|
|
@ -19,8 +19,8 @@ package io.bitsquare.gui.main.settings.application;
|
|||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
import viewfx.model.ViewModel;
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
|
|
@ -31,8 +31,8 @@ import org.bitcoinj.utils.Fiat;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import viewfx.view.support.ActivatableView;
|
||||
import viewfx.view.View;
|
||||
import viewfx.view.support.ActivatableView;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.collections.ListChangeListener;
|
||||
|
|
|
@ -31,8 +31,8 @@ import org.bitcoinj.utils.Fiat;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
import viewfx.model.ViewModel;
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
|
||||
import javafx.beans.Observable;
|
||||
import javafx.beans.binding.Bindings;
|
||||
|
|
|
@ -30,8 +30,8 @@ import org.bitcoinj.utils.Fiat;
|
|||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
import viewfx.model.ViewModel;
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
|
|
@ -30,8 +30,8 @@ import org.bitcoinj.core.Coin;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
import viewfx.model.ViewModel;
|
||||
import viewfx.model.support.ActivatableWithDelegate;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
package viewfx.view;
|
||||
|
||||
import viewfx.view.View;
|
||||
|
||||
public interface ChildView<Parent extends View> extends View {
|
||||
void setParent(Parent parent);
|
||||
}
|
||||
|
|
23
src/main/java/viewfx/view/ViewFactory.java
Normal file
23
src/main/java/viewfx/view/ViewFactory.java
Normal 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> {
|
||||
}
|
|
@ -15,23 +15,23 @@
|
|||
* 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.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
|
||||
* {@link javafx.fxml.FXMLLoader#setControllerFactory(javafx.util.Callback)}.
|
||||
* <p>
|
||||
* Once set, make sure you do <b>not</b> use the static methods on
|
||||
* {@link javafx.fxml.FXMLLoader} when creating your JavaFX node.
|
||||
*/
|
||||
public class GuiceControllerFactory implements Callback<Class<?>, Object> {
|
||||
public class GuiceViewFactory implements ViewFactory {
|
||||
|
||||
private Injector injector;
|
||||
|
|
@ -19,7 +19,6 @@ package io.bitsquare.app.gui;
|
|||
|
||||
import io.bitsquare.BitsquareException;
|
||||
import io.bitsquare.app.BitsquareEnvironment;
|
||||
import io.bitsquare.gui.GuiceControllerFactory;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
|
||||
|
@ -28,6 +27,8 @@ import com.google.inject.Injector;
|
|||
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
import viewfx.view.support.guice.GuiceViewFactory;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
|
@ -61,14 +62,14 @@ public class ViewLoaderTests {
|
|||
Thread.sleep(10);
|
||||
}
|
||||
|
||||
private GuiceControllerFactory controllerFactory;
|
||||
private GuiceViewFactory controllerFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
OptionParser parser = new OptionParser();
|
||||
BitsquareEnvironment env = new BitsquareEnvironment(parser.parse(new String[]{}));
|
||||
Injector injector = Guice.createInjector(new BitsquareAppModule(env, TestApp.primaryStage));
|
||||
controllerFactory = injector.getInstance(GuiceControllerFactory.class);
|
||||
controllerFactory = injector.getInstance(GuiceViewFactory.class);
|
||||
controllerFactory.setInjector(injector);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue