0

I am trying to add GraniteDS Framework to Javafx E4 application. I already osgify GraniteDS Javafx libraries to bundles, which i was able to initialize in JavaFX OSGi application (osgi app has jfxStart method with parameters i need).
But in Javafx E4 application (created using e(fx)clipse wizard) there no classes with start function. In osgi app code was:

protected void jfxStart(IApplicationContext applicationContext, Application jfxApplication, Stage primaryStage) {
        contextManager = new SimpleContextManager(new JavaFXApplication(jfxApplication, primaryStage));
        contextManager.initModules(App.class);  
        Context context = contextManager.getContext();
        context.set(this);
    .......
}

The question is - how to get jfxApplication and primaryStage instances in Javafx E4 application and where(when) to execute initialization (in Activator start method probably?)

Y Borys
  • 543
  • 1
  • 5
  • 21

1 Answers1

2

Both are available through DI:

class MyComponent {
  @Inject
  public MyComponent(Application app, @Named("primaryStage") Stage primaryStage) {

  }
}

Please note that primaryStage is NEVER shown in an e4+JavaFX application so you maybe really want to have is the stage you are shown in - so most likely what you really want is

class MyComponent {
  @Inject
  public MyComponent(Application app, Stage primaryStage) {

  }
}
tomsontom
  • 5,856
  • 2
  • 23
  • 21
  • Thanks. This works. But i used it in life Cycle manager class, when stage is not in context yet. Fortunately GraniteDS can be initialized with stage parameter as null. – Y Borys Mar 25 '15 at 10:35