JavaFX + GEF5 + E4 RCP Application troubles [message #1764188] |
Fri, 26 May 2017 14:12  |
|
I want to build GEF5 based sentence visualiser, interface of which will have 2 parts:
the input part - where you can put your sentence,
the output part, which will be showing GEF5 graph
The easiest way of organising these parts is to use E4 RCP as they can have individual javafx..Panes
Here is the deal, E4 RCP uses parts as separated javafx..BorderPanes
public class DictionaryPart {
@PostConstruct
void initUI(BorderPane pane) {
try {
TextArea textbox = new TextArea();
pane.setCenter(textbox);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
However,GEF5 examples include simple app realisation using javafx..Stage and IViewer interface.
public void start(final Stage primaryStage) throws Exception {
// create graph
graph = createGraph();
// configure application
Injector injector = Guice.createInjector(createModule());
domain = injector.getInstance(IDomain.class);
viewer = domain.getAdapter(
AdapterKey.get(IViewer.class, IDomain.CONTENT_VIEWER_ROLE));
primaryStage.setScene(createScene(viewer));
primaryStage.setResizable(true);
primaryStage.setWidth(getStageWidth());
primaryStage.setHeight(getStageHeight());
primaryStage.setTitle(title);
primaryStage.show();
// activate domain only after viewers have been hooked
domain.activate();
// set contents in the JavaFX application thread because it alters the
// scene graph
Platform.runLater(new Runnable() {
@Override
public void run() {
viewer.getContents().setAll(Collections.singletonList(graph));
}
});
}
protected Scene createScene(IViewer viewer) {
return new Scene(((IViewer) viewer).getCanvas());
}
This code from my second Part brings up Stage in front of my application, when i need just a Pane.
I just dont understand how do i implement GEF5 to E4 correctly? Is there any tutorials exept GEF documentation?
UPD: Found a Conversion of the GEF4 MVC Logo example to an e4 RCP application,But it is outdated.
|
|
|
Re: JavaFX + GEF5 + E4 RCP Application troubles [message #1764313 is a reply to message #1764188] |
Sun, 28 May 2017 07:42   |
|
IViewer is a central concept in GEF. It is what renders contents (IViewer.contentsProperty()). Multiple viewers are contained in an IDomain, which is the central entry point (also for dependency injection). Each viewer provides a JavaFX Parent (IViewer.getCanvas()) as its 'control', which has to be 'hooked' into a JavaFX scene. While in the standalone example, we use a JavaFX Stage for creating the scene, in an SWT-based e4 application you will have to embed the scene into an FXCanvas (or better FXCanvasEx). You can simply transfer the logic within AbstractFXView.createPartControl(Composite) for creating an FXCanvasEx and hooking the viewer controls. Use Guice-injection for creating an IDomain, then traverse the viewers and hook their controls. That's it.
|
|
|
|
Re: JavaFX + GEF5 + E4 RCP Application troubles [message #1766134 is a reply to message #1766010] |
Fri, 16 June 2017 10:16   |
|
Hi Ken,
FWIW there is a small tutorial series available for E(fx)clipse that covers E4 RCP with pure JavaFX rendering [1]. It should be straightforward to put GEF into the mix as well, i.e. take the #getCanvas() of your IViewer(s) and put them into the BorderPane. The IDomain needs to be #activate()d to start the application.
Other than that, can you list your most significant problems when migrating a GEF-Legacy application? Maybe we can find a good solution here.
[1] https://wiki.eclipse.org/Efxclipse/Tutorials/Tutorial3
Best regards,
Matthias
|
|
|
Re: JavaFX + GEF5 + E4 RCP Application troubles [message #1766702 is a reply to message #1766134] |
Mon, 26 June 2017 09:43   |
|
Matthias Wienand wrote on Fri, 16 June 2017 10:16...
take the #getCanvas() of your IViewer(s) and put them into the BorderPane. The IDomain needs to be #activate()d to start the application.
...
Like that?
void initUIPane(BorderPane pane){
graph = createGraph();
// configure application
Injector injector = Guice.createInjector(createModule());
domain = injector.getInstance(IDomain.class);
viewer = domain.getAdapter(AdapterKey.get(IViewer.class, IDomain.CONTENT_VIEWER_ROLE));
pane.setCenter(((IViewer)viewer).getCanvas());
domain.activate();
Platform.runLater(new Runnable() {
@Override
public void run() {
viewer.getContents().setAll(Collections.singletonList(graph));
}
});
}
If that is so, i get the " Viewer controls have to be hooked (to scene) before activation. " IllegalStateException
|
|
|
Re: JavaFX + GEF5 + E4 RCP Application troubles [message #1766725 is a reply to message #1766702] |
Mon, 26 June 2017 14:04   |
|
Forced it to work like that:
@PostConstruct
void initUIPane(BorderPane pane){
graph = createGraph();
// configure application
Injector injector = Guice.createInjector(createModule());
domain = injector.getInstance(IDomain.class);
viewer = domain.getAdapter(AdapterKey.get(IViewer.class, IDomain.CONTENT_VIEWER_ROLE));
InfiniteCanvas canvas = (InfiniteCanvas)viewer.getCanvas();
pane.setCenter(canvas);
canvas.sceneProperty().addListener((observable, oldValue, newValue) -> {
if (canvas.getScene() != null) {
domain.activate();
try {
viewer.getContents().setAll(Collections.singletonList(graph));
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
|
|
|
Re: JavaFX + GEF5 + E4 RCP Application troubles [message #1766794 is a reply to message #1766725] |
Tue, 27 June 2017 11:12  |
|
Yes, that is exactly how I imagined it. I think it is OK to listen for the scene change. However, when using multiple viewers within the same domain, all of them have to be hooked before activiation. Maybe we can provide that functionality within Domain, i.e. activateWhenReady(Node...) that waits for the sceneProperty of the individual Nodes to be set before activating the domain. Another interesting scenario would be multiple viewers within one domain, but split among multiple views.
If you encounter any problems with your code, feel free to open a new thread to discuss the issue.
Best regards,
Matthias
|
|
|
Powered by
FUDForum. Page generated in 0.01802 seconds