Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » JavaFX + GEF5 + E4 RCP Application troubles(Having trouble coding a GEF5 based sentence visualiser on E4 RCP)
JavaFX + GEF5 + E4 RCP Application troubles [message #1764188] Fri, 26 May 2017 14:12 Go to next message
Mike Shimko is currently offline Mike ShimkoFriend
Messages: 9
Registered: May 2017
Location: Moscow
Junior Member
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 Go to previous messageGo to next message
Alexander Nyssen is currently offline Alexander NyssenFriend
Messages: 230
Registered: July 2009
Location: L√ľnen
Senior Member
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 #1766010 is a reply to message #1764188] Wed, 14 June 2017 18:20 Go to previous messageGo to next message
Ken Keefe is currently offline Ken KeefeFriend
Messages: 23
Registered: April 2012
Junior Member
I would echo the real desire for an E4 + GEF 5 example. I keep trying to get my old E3 + GEF application ported and failing miserably. I would love to see the old Shapes GEF example built as an E4 + GEF 5 application.
Re: JavaFX + GEF5 + E4 RCP Application troubles [message #1766134 is a reply to message #1766010] Fri, 16 June 2017 10:16 Go to previous messageGo to next message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 128
Registered: March 2015
Senior Member
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 Go to previous messageGo to next message
Mike Shimko is currently offline Mike ShimkoFriend
Messages: 9
Registered: May 2017
Location: Moscow
Junior Member
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 Go to previous messageGo to next message
Mike Shimko is currently offline Mike ShimkoFriend
Messages: 9
Registered: May 2017
Location: Moscow
Junior Member
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 Go to previous message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 128
Registered: March 2015
Senior Member
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
Previous Topic:JavaFX + GEF5: Trouble with display of Pie
Next Topic:GEF5 Node building
Goto Forum:
  


Current Time: Sat Jan 20 05:31:48 GMT 2018

Powered by FUDForum. Page generated in 0.02132 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software