Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » How to programmatically Center a MWindow and Access his Rendering Tag.(Accessing and Modifying Login View)
How to programmatically Center a MWindow and Access his Rendering Tag. [message #1128245] Mon, 07 October 2013 09:46 Go to next message
Ghislain Mustermann is currently offline Ghislain Mustermann
Messages: 24
Registered: April 2013
Junior Member
I want to build a e(fx)clipse E4 Application which has a Login (MTrimmeredWindow) as start Window. But although i used Rendering Tag like "shellMaximized" my E4xmi dont center itself. I saw in E4 Forum a Post from Thomas.

I wanted to used it so like described in Forum but i couldnt. I cant see no Display and no Monitor.

How can i then programmatically access the Display and Monitor like in E4?

Can i access Rendering Tags like :

  • efx.window.scene.3d
  • efx.window.undecorated
  • efx.window.decoration.fxml

programmatically from a Addon for Example?


Thanks

[Updated on: Wed, 09 October 2013 05:18]

Report message to a moderator

Re: How to programmatically Center a MWindow and Access his Rendering Tag. [message #1128302 is a reply to message #1128245] Mon, 07 October 2013 10:53 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5227
Registered: July 2009
Senior Member
On 07.10.13 15:46, Ghislain Mustermann wrote:
> I want to build a e(fx)clipse E4 Application which has a Login
> (MTrimmeredWindow) as start Window. But although i used Rendering Tag

I'd not do the login in a TrimmedWindow but using a lifecycleHook popup
a JavaFX-Stage

> like "shellMaximized" my E4xmi dont center itself. I saw in E4 Forum a

Why should shellMaximized center something? I guess we are not currently
honoring the shellMaximized (IIRC this is only available in FX8)

Although I would not use a TrimmedWindow it might make sense to center a
window so we could introduce a tag centering the window. File a bugzilla
if you want it.

> http://www.eclipse.org/forums/index.php/t/198222/ from Thomas.
> I wanted to used it so like described in Forum but i couldnt. I cant see
> no Display and no Monitor.
>
> How can i then programmatically access the Display and Monitor like in E4?

Display & Monitor are SWT concepts. You need to find the JavaFX counter
parts. Screen.getPrimary() provides you with the primary monitor on your
system.

>
> Can i access Rendering Tags like :
>
> efx.window.scene.3d
> efx.window.undecorated efx.window.decoration.fxml
>
> programmatically from a Addon for Example?
>

Why do you want to access them? Anyways, those are part of the
M(Trimmed)Window so yes you can access them in an Addon.

Tom
Re: How to programmatically Center a MWindow and Access his Rendering Tag. [message #1128626 is a reply to message #1128302] Mon, 07 October 2013 18:10 Go to previous messageGo to next message
Ghislain Mustermann is currently offline Ghislain Mustermann
Messages: 24
Registered: April 2013
Junior Member
Hallo Tom,

Thank you for the Answers.
First of all i misuse "shellMaximized", i wanted to FullScreen my Window. But thats another Story.

You said that i better use LifeCycleHook. Well i saw a tutorial from Vogella, and with my newbie knowledge about E4 i tried to transpose it to e(fx)clipse E4 like this :

1. I added into my plugin.xml an Extension with name lifeCycleURI with a Value pointing to a Class.
2. The Class look like this where i got a warning about restrictive use of PostContextCreate :

import java.io.IOException;

import org.eclipse.e4.ui.workbench.lifecycle.PostContextCreate;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.fx.ui.di.FXMLBuilder;
import org.eclipse.fx.ui.di.FXMLLoader;
import org.eclipse.fx.ui.di.FXMLLoaderFactory;

import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

@SuppressWarnings("restriction")
public class StartupLifeCycleHandler {

	@PostContextCreate
	void postContextCreate(IApplicationContext appContext, Stage primaryStage,
			@FXMLLoader FXMLLoaderFactory factory) {

		System.out.println("Enter PostContextCreate");

		FXMLBuilder<AnchorPane> builder = factory
				.loadRequestorRelative("LoginScreenView.fxml");
		try {
			AnchorPane anchorPane = builder.load();
			primaryStage.centerOnScreen();
			primaryStage.setScene(anchorPane.getScene());

		} catch (IOException e) {
			e.printStackTrace();
		}

		// close the static splash screen
		appContext.applicationRunning();
	}
}


While compiling i got no Errors but i can't see my LoginScreen, the sysout i wrote cant either be shown. Is something missing in my approach or i really dont get the point?

Thanks
Re: How to programmatically Center a MWindow and Access his Rendering Tag. [message #1129027 is a reply to message #1128626] Tue, 08 October 2013 04:04 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5227
Registered: July 2009
Senior Member
That can't work, there's no stage at this point, the handler should look
like this:

public class StartupLifeCycleHandler {
private boolean ok;

@PostContextCreate
boolean login(@FXMLLoader FXMLLoaderFactory factory) {
Stage s = new Stage();
// ...
s.showAndWait();
return ok;
}
}

I think will work as well but you need to give it a try, in case you
are not called come back here.

Tom

On 08.10.13 00:10, Ghislain Mustermann wrote:
> Hallo Tom,
>
> Thank you for the Answers.
> First of all i misuse "shellMaximized", i wanted to FullScreen my
> Window. But thats another Story.
>
> You said that i better use LifeCycleHook. Well i saw a tutorial from
> http://www.vogella.com/articles/Eclipse4LifeCycle/article.html, and with
> my newbie knowledge about E4 i tried to transpose it to e(fx)clipse E4
> like this :
> 1. I added into my plugin.xml an Extension with name lifeCycleURI with a
> Value pointing to a Class.
> 2. The Class look like this where i got a warning about restrictive use
> of PostContextCreate :
>
>
> import java.io.IOException;
>
> import org.eclipse.e4.ui.workbench.lifecycle.PostContextCreate;
> import org.eclipse.equinox.app.IApplicationContext;
> import org.eclipse.fx.ui.di.FXMLBuilder;
> import org.eclipse.fx.ui.di.FXMLLoader;
> import org.eclipse.fx.ui.di.FXMLLoaderFactory;
>
> import javafx.scene.layout.AnchorPane;
> import javafx.stage.Stage;
>
> @SuppressWarnings("restriction")
> public class StartupLifeCycleHandler {
>
> @PostContextCreate
> void postContextCreate(IApplicationContext appContext, Stage
> primaryStage,
> @FXMLLoader FXMLLoaderFactory factory) {
>
> System.out.println("Enter PostContextCreate");
>
> FXMLBuilder<AnchorPane> builder = factory
> .loadRequestorRelative("LoginScreenView.fxml");
> try {
> AnchorPane anchorPane = builder.load();
> primaryStage.centerOnScreen();
> primaryStage.setScene(anchorPane.getScene());
>
> } catch (IOException e) {
> e.printStackTrace();
> }
>
> // close the static splash screen
> appContext.applicationRunning();
> }
> }
>
>
> While compiling i got no Errors but i can't see my LoginScreen, the
> sysout i wrote cant either be shown. Is something missing in my approach
> or i really dont get the point?
>
> Thanks
Re: How to programmatically Center a MWindow and Access his Rendering Tag. [message #1129688 is a reply to message #1129027] Tue, 08 October 2013 18:21 Go to previous messageGo to next message
Ghislain Mustermann is currently offline Ghislain Mustermann
Messages: 24
Registered: April 2013
Junior Member
Hi Tom,

i cant obviously cant see the Login. I try it like u show :

@SuppressWarnings("restriction")
public class StartupLifeCycleHandler {

	private boolean ok;

	@PostContextCreate
	boolean login(@FXMLLoader FXMLLoaderFactory factory) {

		Stage primaryStage = new Stage();
		FXMLBuilder<AnchorPane> builder = factory
				.loadRequestorRelative("LoginScreenView.fxml");
		try {
			AnchorPane anchorPane = builder.load();
			primaryStage.centerOnScreen();
			primaryStage.setScene(anchorPane.getScene());

		} catch (IOException e) {
			e.printStackTrace();
		}

		primaryStage.showAndWait();
		return ok;
	}
}

Re: How to programmatically Center a MWindow and Access his Rendering Tag. [message #1129712 is a reply to message #1129688] Tue, 08 October 2013 18:52 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5227
Registered: July 2009
Senior Member
So is the method called?

Tom

On 09.10.13 00:21, Ghislain Mustermann wrote:
> Hi Tom,
>
> i cant obviously cant see the Login. I try it like u show :
>
> @SuppressWarnings("restriction")
> public class StartupLifeCycleHandler {
>
> private boolean ok;
>
> @PostContextCreate
> boolean login(@FXMLLoader FXMLLoaderFactory factory) {
>
> Stage primaryStage = new Stage();
> FXMLBuilder<AnchorPane> builder = factory
> .loadRequestorRelative("LoginScreenView.fxml");
> try {
> AnchorPane anchorPane = builder.load();
> primaryStage.centerOnScreen();
> primaryStage.setScene(anchorPane.getScene());
>
> } catch (IOException e) {
> e.printStackTrace();
> }
>
> primaryStage.showAndWait();
> return ok;
> }
> }
>
>
Re: How to programmatically Center a MWindow and Access his Rendering Tag. [message #1130162 is a reply to message #1129712] Wed, 09 October 2013 05:16 Go to previous messageGo to next message
Ghislain Mustermann is currently offline Ghislain Mustermann
Messages: 24
Registered: April 2013
Junior Member
Is called!!

i forgot to set my fxml as Scene before send it to stage.

			Scene myScene = new Scene(anchorPane);
			primaryStage.centerOnScreen();
			primaryStage.setScene(myScene);


Now its shown. Thank you for that.

So my last Question, Now that i see my Login, which BEST Practices should i use to come to my MWindow and Perspective after a successful Login? From LoginController go through the Database connection and Authentication or should i use command and so on?

Thanks

[Updated on: Wed, 09 October 2013 05:16]

Report message to a moderator

Re: How to programmatically Center a MWindow and Access his Rendering Tag. [message #1130170 is a reply to message #1130162] Wed, 09 October 2013 05:25 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5227
Registered: July 2009
Senior Member
On 09.10.13 11:16, Ghislain Mustermann wrote:
> Is called i forgot to set my fxml as Scene before send it to stage. Now
> its shown. Thank you for that.
>
> So my last Question, Now that i see my Login, which BEST Practices
> should i use to come to my MWindow and Perspective after a successful
> Login? From LoginController go through the Database connection and
> Authentication or should i use command and so on?

This does not make sense. You stop in the launch process and if you
close the window the process goes on and the initial window will open
itself.

If you wanted to ask how to pass the logged in user, credentials, ...
I'd suggest you push them to the IEclipseContext.

Tom
Previous Topic:(no subject)
Next Topic:Accessing the controller instance when using FXMLLoaderFactory
Goto Forum:
  


Current Time: Wed Jul 23 01:50:41 EDT 2014

Powered by FUDForum. Page generated in 0.02722 seconds