Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK 11 / OpenJFX 11 no CSS autocomplete and “Unknown property” warning #75

Open
mininotallarines opened this issue May 1, 2020 · 5 comments

Comments

@mininotallarines
Copy link

My css autocomplete doesn't work and I get "unknown property" warnings. I've tried a lot already but nothing seems to work. I even reinstalled eclipse, removed all the plugins, and reinstalled all of them. I created new workspaces, new projects, ... Nothing works.

My Environment

Eclipse 2020-03 (4.15.0)

Windows 10 (1903)

Java JDK 11.0.7

What I did

  1. Created a new Maven project (JavaSE-11)

  2. Added OpenJFX as dependency in the pom file

  3. Made sure the Maven dependencies are on the classpath since I don't want to use the module system

  4. Added the JavaFX SDK library to the classpath

  5. Downloaded the OpenJFX libraries and point JavaFX 11 + SDK path in preferences to the path I installed it to (C:\Program Files\OpenJFX\javafx-sdk-11.0.2\lib)

  6. Write a test class using the JavaFX libraries (which works)

  7. Create a css file to style my application which adds the xtext nature (and open it with the e(fx)clipse css editor)

So I can use the JavaFX libraries and I can launch my application without any errors. But I can't use the css autocomplete feature because all properties are unknown and this causes warnings.

My POM file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.company</groupId>
  <artifactId>FXProject</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
      <resource>
        <directory>src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <release>11</release>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
  	<dependency>
  		<groupId>org.openjfx</groupId>
  		<artifactId>javafx-controls</artifactId>
  		<version>11.0.1</version>
  	</dependency>
  </dependencies>
</project>

My CSS file (application.css)

.root {
	-fx-background-color: red;
}

Launcher class (main class)

import javafx.application.Application;

public class Launcher {
	
	public static void main(String[] args) {
		Application.launch(TestApp.class);
	}
	
}

TestApp class

import javafx.application.Application;
import javafx.stage.Stage;

public class TestApp extends Application {
	
	@Override
    public void start(Stage primaryStage) {
	    try {
		    BorderPane root = new BorderPane();
		    Scene scene = new Scene(root,400,400);
		    scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
		    primaryStage.setScene(scene);
		    primaryStage.show();
	    } catch(Exception e) {
		    e.printStackTrace();
	    }
    }
	
}
@ghost
Copy link

ghost commented Jun 1, 2020

I have this issue too, but in nun-modular project. I asked at stackoverflow.com - https://stackoverflow.com/questions/62123931/eclipse-doesnt-see-javafx-properties-in-css-file-unknown-property?noredirect=1#comment109877393_62123931, but nobody answer me.

@mininotallarines
Copy link
Author

@4n4h3l I also posted a question on stack about this topic, but never got any answer as well. The developers of e(fx)clipse have a development repository that seems to "work". By that I mean, it does the trick for now but it needs a lot of work done, that's why this issue is still open.

Try removing your current e(fx)clipse and instead use the following repositories:
http://download.eclipse.org/efxclipse/updates-released/3.6.0/site
https://download.eclipse.org/efxclipse/updates-nightly/site

@ghost
Copy link

ghost commented Jun 1, 2020

@laica10 Thank you fellow, you directed me on the right path. I will not do it again so as not to break anything, but it seems I did it. So, I deleted the old version of e (fx) clipse and tried to install the new one of those repositories that you gave me. But I saw a message that installing version 3.6.0 or a night build is impossible due to unsatisfied dependencies (and version automatically downgraded, probably I just didn't read this earlier). I looked at the message and saw that m2e is required. I decided to search m2e in the same repositories and found. After that, the installation went smoothly and auto-completion works perfectly.
shot

@mininotallarines
Copy link
Author

@4n4h3l I'm very glad I could be of help. This issue was very frustrating for me too because I lost about a week of development not being able to fix this and no replies whatsoever. I looked into it and there are 2 maven (m2e) packages installed in my Eclipse installation. Should have mentioned them, but glad you found it.

@brett-smith
Copy link

I know it's been a while, and maybe things have changed, but the above solutions do not work. I have tried with multiple versions from version 3.6.0 up to the current 3.10.0 nightly builds, but the results are always the same.

It appears that some properties do work, for example -fx-background, but the more specific -fx-background-color does not.

CssDslJavaValidator.java seems to be where all of this happens, and that led me to the @SuppressWarning "annotation" you can add to the CSS. This works, but adding this to 100s of styles is not practical. This same class has a PREDEFINED_VAR_PROPS that contains a list of -fx-* properties it considers valid. Somehow this contains nearly none of the properties I actually use.

It would be useful maybe if efx could just consider anything that starts with -fx-* as a valid property, or have some configurable pattern. At the very least, the ability to turn off validation entirely would be better than the status quo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants