Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » css file doesn't load for app handlers
css file doesn't load for app handlers [message #1731710] Mon, 09 May 2016 12:45 Go to next message
Matthew Montgomery is currently offline Matthew MontgomeryFriend
Messages: 5
Registered: May 2016
Junior Member
Good morning. I am currently working on an e4 application project that implements e(fx)clipse plug-ins. One plugin implements a .css file as a styleclass. When I add the plugin to the main e4 application window, all the changes of the .css file make it just fine. I grab the plugin with the following code:

public class ProjectPart {
@PostConstruct
public void postConstruct(IEclipseContext context, BorderPane parent) {
try {
InjectingFXMLLoader<Node> loader = InjectingFXMLLoader.create(context, ProjectPart.class, "Project.fxml");
parent.setCenter(loader.load());
} catch (IOException e) {
e.printStackTrace();
}
}
}


I added a menu drop down (File->Open) to the e4 window that opens the same plugin in a new window. When I open the plugin through this method however, the changes of the .css file do not make it over to the new window. Right now this is how I'm bringing in the plugin in the handler class:

public class Open {

@Execute
public void execute(IEclipseContext context, BorderPane parent ) {
try {
Stage stage = new Stage();
VBox root = (VBox)FXMLLoader.load(getClass().getResource("Open.fxml"));
Scene scene = new Scene(root,355,530);
stage.setScene(scene);
stage.show();
}

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


Both Project.fxml and Open.fxml just contain a VBox that includes the plugin I need.
I'm not sure why the e4 application class can bring in the .css changes, but the handler class cannot. Are there any other steps needed to bring in the .css class?

Thanks.
Re: css file doesn't load for app handlers [message #1731736 is a reply to message #1731710] Mon, 09 May 2016 16:52 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6363
Registered: July 2009
Senior Member
Because the renderers setup the stage scene appropriately, loading the
CSS-Files using the current theme setting.

To make that work in your new stage as well you need to:

@Execute
void execute(ThemeManager mgr) {
...
Scene scene = new Scene(root,355,530);
Registration r = mgr.registerScene(scene);
stage.setOnClose( e -> r.dispose())
}

Tom

On 09.05.16 14:49, Matthew Montgomery wrote:
> Good morning. I am currently working on an e4 application project that
> implements e(fx)clipse plug-ins. One plugin implements a .css file as a
> styleclass. When I add the plugin to the main e4 application window, all
> the changes of the .css file make it just fine. I grab the plugin with
> the following code:
>
> public class ProjectPart {
> @PostConstruct
> public void postConstruct(IEclipseContext context, BorderPane parent) {
> try {
> InjectingFXMLLoader<Node> loader =
> InjectingFXMLLoader.create(context, ProjectPart.class, "Project.fxml");
> parent.setCenter(loader.load());
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
> }
>
>
> I added a menu drop down (File->Open) to the e4 window that opens the
> same plugin in a new window. When I open the plugin through this method
> however, the changes of the .css file do not make it over to the new
> window. Right now this is how I'm bringing in the plugin in the handler
> class:
>
> public class Open {
>
> @Execute
> public void execute(IEclipseContext context, BorderPane parent ) {
> try {
> Stage stage = new Stage();
> VBox root =
> (VBox)FXMLLoader.load(getClass().getResource("Open.fxml"));
> Scene scene = new Scene(root,355,530);
> stage.setScene(scene);
> stage.show();
> }
>
> catch(Exception e) {
> e.printStackTrace();
> }
> }
> }
>
>
> Both Project.fxml and Open.fxml just contain a VBox that includes the
> plugin I need.
> I'm not sure why the e4 application class can bring in the .css changes,
> but the handler class cannot. Are there any other steps needed to bring
> in the .css class?
>
> Thanks.
Re: css file doesn't load for app handlers [message #1731738 is a reply to message #1731736] Mon, 09 May 2016 17:07 Go to previous message
Matthew Montgomery is currently offline Matthew MontgomeryFriend
Messages: 5
Registered: May 2016
Junior Member
Your solution worked. Thanks a lot!
Previous Topic:Can't Send Email using SMTP in JavaFX
Next Topic:Maven build problem
Goto Forum:
  


Current Time: Tue Oct 24 02:42:27 GMT 2017

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

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