Remove static access to BitsquareUI#getPrimaryStage

- Bind BitsquareUI#start's primaryStage for DI
 - Statically inject primaryStage directly into Help and Popups
This commit is contained in:
Chris Beams 2014-11-04 18:55:17 +01:00
parent f6368754b9
commit 6f27c5ce29
No known key found for this signature in database
GPG key ID: 3D214F8F5BC5ED73
9 changed files with 54 additions and 43 deletions

View file

@ -35,13 +35,15 @@ import org.junit.Test;
public class ViewLoaderTest {
public static class TestApp extends Application {
static Stage primaryStage;
@Override
public void start(Stage primaryStage) throws Exception {
TestApp.primaryStage = primaryStage;
}
}
@BeforeClass
public static void initJavaFX() {
public static void initJavaFX() throws InterruptedException {
Thread t = new Thread("JavaFX Init Thread") {
public void run() {
Application.launch(TestApp.class);
@ -49,12 +51,14 @@ public class ViewLoaderTest {
};
t.setDaemon(true);
t.start();
while (TestApp.primaryStage == null)
Thread.sleep(10);
}
@Before
public void setUp() {
Injector injector = Guice.createInjector(new BitsquareModule());
Injector injector = Guice.createInjector(new BitsquareModule(TestApp.primaryStage));
ViewLoader.setInjector(injector);
}