kelemen / netbeans-gradle-project

This project is a NetBeans plugin able to open Gradle based Java projects. The implementation is based on Geertjan Wielenga's plugin.
171 stars 57 forks source link

JavaFX support is not functional in Gradle projects #160

Open swpalmer opened 10 years ago

swpalmer commented 10 years ago

When I select New File... FXML is not an available selection. When I have FXML files in my project, launching Scene Builder to edit them is not an option. This is despite having both the "JavaFX 2 Support" and "JavaFX 2 Scene Builder" and even "Monet - SceneBuildre Designer" plugins active.

I'm using Gradle Support 1.3.1, Gradle 2.1, NetBeans 8.0.1, and Java 8u20.

kelemen commented 10 years ago

I don't really know what those plugins need to work but will try to look it up in the sources of NB.

shevek commented 9 years ago

I wonder if this is related to Matisse not working in my projects since I switched to Gradle.

WillBDaniels commented 9 years ago

I've just finished migrating all of our netbeans projects over to gradle, and 80% of them are large ( > 50 files) javafx desktop applications. Besides having to manually add .fxml files, every other functionality (when used in conjunction with the gradle-javafx plugin) work without issue. Including being able to edit .fxml in scene builder. That being said, for me with scene builder, if I double click the .fxml, It edits with scene builder (no right-click explicit option for 'open with scene builder', simply 'open'), and if I select 'edit' of course it opens in netbeans. Perhaps try setting your default program association for .fxml files to scene builder, and then when you double-click in netbeans project manager, I bet it'll open right up in scene builder.

Hope that helps!

Specifically with java 8, netbeans 8, gradle 2.1-rc2

swpalmer commented 9 years ago

Does SceneBuilder know where to find your controller classes as well?

On Wed, Dec 3, 2014 at 1:29 AM, WillBDaniels notifications@github.com wrote:

I've just finished migrating all of our netbeans projects over to gradle, and 80% of them are large ( > 50 files) javafx desktop applications. Besides having to manually add .fxml files, every other functionality (when used in conjunction with the gradle-javafx plugin) work without issue. Including being able to edit .fxml in scene builder. That being said, for me with scene builder, if I double click the .fxml, It edits with scene builder (no right-click explicit option for 'open with scene builder', simply 'open'), and if I select 'edit' of course it opens in netbeans. Perhaps try setting your default program association for .fxml files to scene builder, and then when you double-click in netbeans project manager, I bet it'll open right up in scene builder.

Hope that helps!

Specifically with java 8, netbeans 8, gradle 2.1-rc2

— Reply to this email directly or view it on GitHub https://github.com/kelemen/netbeans-gradle-project/issues/160#issuecomment-65361672 .

WillBDaniels commented 9 years ago

Yes, so long as I give it the fully qualified package name. For example, my hierarchy looks like the following:

src ---- main 
               |
               |---Java
               |      |--------com
               |                   |-------magvar
               |                                |---------mvgm
               |                                                |------{All top level .java controllers, sub-packages, etc.)
               |---Resources
               |      |--------com
               |                   |-------magvar
               |                                |---------mvgm
               |                                                |--------CSS
               |                                                |              |---------*.css
               |                                                |--------FXML
               |                                                |              |---------*.fxml

etc. etc. with images, and everything else. Now, that being said, in my FXML files, if I want to reference some controller, lets say controller1.java, all I have to put In Scene Builder under ' controller' is: com.magvar.mvgm.controller1 That's it, it'll recognize it no problem. For all .css through scene builder I simply give it ../css/whatever.css and it finds it without issue. The gradle netbeans plugin also picks up this hierarchy without issue.

JustGregory-zz commented 9 years ago

So, does this mean the FXML must be in the resource packages? they cannot be in the main packages, alongside their controller classes?

WillBDaniels commented 9 years ago

You know, I have absolutely no idea. I haven't tried putting .fxml anywhere else while using the gradle plugin with netbeans. If it is indeed one of the requirements that it be in the resource folder... that's arguably a good thing!

JustGregory-zz commented 9 years ago

Well, I'm presuming that it is the case, because in my case I'm building a multi-project hierarchy, with FXML and controllers in the same packages, and it won't run. Sure, it compiles just fine, but I noticed the built jar does not have the FXML files anywhere that they should be.

WillBDaniels commented 9 years ago

Does it create the proper jar if you run it from the command line? (just native, plain old gradle?)

On Mon, Feb 16, 2015 at 9:34 PM, Gregory notifications@github.com wrote:

Well, I'm presuming that it is the case, because in my case I'm building a multi-project hierarchy, with FXML and controllers in the same packages, and it won't run. Sure, it compiles just fine, but I noticed the built jar does not have the FXML files anywhere that they should be.

— Reply to this email directly or view it on GitHub https://github.com/kelemen/netbeans-gradle-project/issues/160#issuecomment-74615993 .

    -William Bryant Daniels
JustGregory-zz commented 9 years ago

I can try it, just to be certain, but I don't recall it running either way.

Edit: Nope, cannot run when they are in the same path.

:Editor:run
Exception in Application start method
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:363)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:303)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:875)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(LauncherImpl.java:157)
        at com.sun.javafx.application.LauncherImpl$$Lambda$48/1732398722.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: Location is required.
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3201)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3169)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3142)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3118)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3098)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3091)
        at brm.editor.Editor.start(Editor.java:32)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
        at com.sun.javafx.application.LauncherImpl$$Lambda$51/284981984.run(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
        at com.sun.javafx.application.PlatformImpl$$Lambda$45/1051754451.run(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
        at com.sun.javafx.application.PlatformImpl$$Lambda$47/817637177.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
        at com.sun.javafx.application.PlatformImpl$$Lambda$46/1775282465.run(Unknown Source)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
        at com.sun.glass.ui.win.WinApplication$$Lambda$37/1109371569.run(Unknown Source)
        ... 1 more
Exception running application brm.editor.Editor
:Editor:run FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Editor:run'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 1
swpalmer commented 9 years ago

You must place resources in the resource folder or they don't get included in the jar or class path. That is normal. The source folder is for source code only, imagine files, film, etc. must go in the resources folder. You should match the package structure of the controller class so it is placed "beside" it.

Scott

On Feb 16, 2015, at 11:34 PM, Gregory notifications@github.com wrote:

Well, I'm presuming that it is the case, because in my case I'm building a multi-project hierarchy, with FXML and controllers in the same packages, and it won't run. Sure, it compiles just fine, but I noticed the built jar does not have the FXML files anywhere that they should be.

— Reply to this email directly or view it on GitHub.

JustGregory-zz commented 9 years ago

Ah, then it's the semantics of the issue that's at stake; because I have always viewed FXML as "source" files, regardless of whether it's a "markup" format.