Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » FXML include didn't bring the css along
FXML include didn't bring the css along [message #1726829] Wed, 16 March 2016 17:29 Go to next message
John Bodkin is currently offline John BodkinFriend
Messages: 39
Registered: November 2011
Member
Is there a procedure to have a plugins css files visible throughout the e4 application or do I need to add them to the main FXML file?

I'm breaking up my GUI into plugins so that each plugin contributes a unique UI control.

I have an e4 app that loads an FXML (generated by FXGraph) file (1) successfully. That FXML file (1) includes an FXML (also generated by FXGraph) file (2) that comes from a different plugin I created. The problem is the css file that the included FXML file (2) uses to style controls isn't visible when included in the FXML file (1). Therefore the controls contributed by FXML file (2) are not styled by its css file.

I attached an example set of projects. I created the app project through the wizard:
File->New-Project... JavaFX->OSGI->e4 Application projects

I created the contribution project through the wizard:
File->New->Plugin Project...

I then added the contribution project to the app feature dependencies and the plugin.xml dependencies.
Re: FXML include didn't bring the css along [message #1726841 is a reply to message #1726829] Wed, 16 March 2016 20:28 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6363
Registered: July 2009
Senior Member
Hi,

The css-Files in fxgraph and fxml are soley for the preview (hence their
name).

e4 on JavaFX applications have to have a theme
(org.eclipse.fx.ui.services.theme.Theme) who is made up from the base
css-File and is registered as an OSGi-Service.

If you want a plugin to contribute a CSS you need to register an
OSGi-Service of type org.eclipse.fx.ui.services.theme.Stylesheet which
could look like this:

@Component
public class MyStylesheet implements Stylesheet {

public boolean appliesToTheme(Theme t) {
return true;
}

public URL getURL(Theme t) {
return getClass().getClassloader().getResource("css/mycustom.css");
}
}

The @Component annotation assumes you have the DS-Annotation-Processor
plugin installed, if not you can use the PDE-Editor (who is buggy so we
propose to use the annotations!)

Tom

On 16.03.16 18:29, John Bodkin wrote:
> Is there a procedure to have a plugins css files visible throughout the e4 application or do I need to add them to the main FXML file?
>
> I'm breaking up my GUI into plugins so that each plugin contributes a unique UI control.
>
> I have an e4 app that loads an FXML (generated by FXGraph) file (1) successfully. That FXML file (1) includes an FXML (also generated by FXGraph) file (2) that comes from a different plugin I created. The problem is the css file that the included FXML file (2) uses to style controls isn't visible when included in the FXML file (1). Therefore the controls contributed by FXML file (2) are not styled by its css file.
>
> I attached an example set of projects. I created the app project through the wizard:
> File->New-Project... JavaFX->OSGI->e4 Application projects
>
> I created the contribution project through the wizard:
> File->New->Plugin Project...
>
> I then added the contribution project to the app feature dependencies and the plugin.xml dependencies.
>
Re: FXML include didn't bring the css along [message #1726965 is a reply to message #1726841] Thu, 17 March 2016 18:40 Go to previous messageGo to next message
John Bodkin is currently offline John BodkinFriend
Messages: 39
Registered: November 2011
Member
Thank you for your help.
The addition of the component provided the desired result in the running application. However it does not produce a result in the JavaFX Preview part. Is that expected?

I attached the changes as an eclipse project export archive. I verified that it does in fact run sorry if the previous one did not.

Is this the DS-Annotation-Processor you were referring to? https://marketplace.eclipse.org/content/declarative-services-annotations-support
That particular plugin's update site is blocked by the corporate filter and I wanted to verify that is the plugin before going through the process of getting the site unblocked.



Re: FXML include didn't bring the css along [message #1726979 is a reply to message #1726965] Thu, 17 March 2016 22:50 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6363
Registered: July 2009
Senior Member
On 17.03.16 19:40, John Bodkin wrote:
> Thank you for your help.
> The addition of the component provided the desired result in the running application. However it does not produce a result in the JavaFX Preview part. Is that expected?

Not sure I can follow. You tell me that now that you added the
stylesheet stuff the preview is not applying the CSS anymore while you
are coding?

>
> I attached the changes as an eclipse project export archive. I verified that it does in fact run sorry if the previous one did not.
>
> Is this the DS-Annotation-Processor you were referring to? https://marketplace.eclipse.org/content/declarative-services-annotations-support

Yes

> That particular plugin's update site is blocked by the corporate filter and I wanted to verify that is the plugin before going through the process of getting the site unblocked.
>

It is not strictly needed but makes your life 100% easier! It's also
contained in our all-in-one build but i guess you can't download that
either.

Eclipse Neon will have it built-in.

Tom
Re: FXML include didn't bring the css along [message #1726980 is a reply to message #1726979] Thu, 17 March 2016 23:29 Go to previous messageGo to next message
John Bodkin is currently offline John BodkinFriend
Messages: 39
Registered: November 2011
Member
The application project has "FXML file 1" which includes "FXML file 2" from plugin 2. When editing the FXGraph file for FXML file 1 that includes the FXML file 2 the css for FXML file 2 does not get applied. If you run the application the css is applied to the included FXML file 2 that is housed in plugin 2. So the addition of the Stylesheet component to plugin 2 provides the desired result when the application is running but not when you are editing the FXGraph file in the application project.

You can see this in the attached zip file.

I can get to Neon and will work on getting the DS annotation plugin from that.

Also: The documentation on https://wiki.eclipse.org/Efxclipse/Tooling/FXGraph#Referencing_other_FXGraph_files also states:
"Furthermore, the WorldController can be referenced from the HelloWorldController using the implied worldController variable: ". This is not working for me. The variable for WorldController in what would be the equivalent of HelloWorldController is never initialized and gives me a NullPointerException. I've attached another project archive that demonstrates this issue. Is this functionality no longer included in the latest version of e(fx)clipse?
Re: FXML include didn't bring the css along [message #1727066 is a reply to message #1726980] Fri, 18 March 2016 14:37 Go to previous messageGo to next message
John Bodkin is currently offline John BodkinFriend
Messages: 39
Registered: November 2011
Member
I'm still having the issue with the css as described above but I did figure out the controller issue:

John Bodkin wrote on Thu, 17 March 2016 19:29

Also: The documentation on https://wiki.eclipse.org/Efxclipse/Tooling/FXGraph#Referencing_other_FXGraph_files also states:
"Furthermore, the WorldController can be referenced from the HelloWorldController using the implied worldController variable: ". This is not working for me. The variable for WorldController in what would be the equivalent of HelloWorldController is never initialized and gives me a NullPointerException. I've attached another project archive that demonstrates this issue. Is this functionality no longer included in the latest version of e(fx)clipse?


The documentation is not 100% accurate or it is accurate and I just misunderstood it . I was able to get the included FXML controller to initialize by naming the variable differently.

If you do an include in your FXGraph like the following:
include Contribution as world

and that contributions controller class is named ContributionController the "implied variable" is not contributionController the "implied variable" is "worldController"

[Updated on: Fri, 18 March 2016 14:39]

Report message to a moderator

Re: FXML include didn't bring the css along [message #1727068 is a reply to message #1727066] Fri, 18 March 2016 14:41 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6363
Registered: July 2009
Senior Member
Simply include both css-files into the master fxgraph-file - you may
want to file a bug requesting the tooling to do this automatically.

Tom

On 18.03.16 15:37, John Bodkin wrote:
> I'm still having the issue with the css as described above but I did
> figure out the controller issue:
>
> John Bodkin wrote on Thu, 17 March 2016 19:29
>> Also: The documentation on
>> https://wiki.eclipse.org/Efxclipse/Tooling/FXGraph#Referencing_other_FXGraph_files
>> also states:
>> "Furthermore, the WorldController can be referenced from the
>> HelloWorldController using the implied worldController variable: ".
>> This is not working for me. The variable for WorldController in what
>> would be the equivalent of HelloWorldController is never initialized
>> and gives me a NullPointerException. I've attached another project
>> archive that demonstrates this issue. Is this functionality no longer
>> included in the latest version of e(fx)clipse?
>
>
> The documentation is not 100% accurate. I was able to get the included
> FXML controller to initialize by naming the variable differently.
>
> If you do an include in your FXGraph like the following:
> include Contribution as world
>
> and that contributions controller class is name ContributionController
> the "implied variable" is not contributionController the "implied
> variable" is "worldController"
>
Previous Topic:Plug-in org.eclipse.xtext.ui.shared was unable to load class
Next Topic:Can a JavaFX program run in JWS and access a database?
Goto Forum:
  


Current Time: Mon Nov 20 09:56:14 GMT 2017

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

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