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

Codename One Style-Sheet Needs Constant Libraries Refreshing #2974

Closed
rainer2208 opened this issue Dec 27, 2019 · 6 comments
Closed

Codename One Style-Sheet Needs Constant Libraries Refreshing #2974

rainer2208 opened this issue Dec 27, 2019 · 6 comments
Assignees
Milestone

Comments

@rainer2208
Copy link

I have a new Android application, that uses CSS styling.

The style sheet is added through the CN1-settings. This has always worked in the past.

Today, whenever I make changes to the style of a component in the style-sheet, they don't reflect, unless I refresh the CN1-Libraries.

I am using Eclipse on Ubuntu Budgie 19.10.

For the console output, after changing the CSS file and saving it, the print output is as follows:

-cn1-compile-css:
[java] Retina Scale: 1.0
[java] Updating merge file /home/xxxxxx/eclipse-workspace/Test_A1/css/theme.css.merged
[java] Input: /home/xxxxxx/eclipse-workspace/Test_A1/css/theme.css
[java] Output: /home/xxxxxx/eclipse-workspace/Test_A1/src/theme.res
[java] Acquiring lock on CSS checksums file /home/xxxxx/eclipse-workspace/Test_A1/.cn1_css_checksums...
[java] Lock obtained
[java] Releasing lock
[java] CSS file successfully compiled. /home/xxxxxx/eclipse-workspace/Test_A1/src/theme.res

jar:
[echo] Compile is forcing compliance to the supported API's/features for maximum device compatibility. This allows smaller
[echo] code size and wider device support
[copy] Copying 1 file to /home/xxxxxx/eclipse-workspace/Test_A1/build/tmp
Trying to override old definition of task javac
[javac] Compiling 2 source files to /home/xxxxxx/eclipse-workspace/Test_A1/build/tmp
[jar] Building jar: /home/xxxxxx/eclipse-workspace/Test_A1/dist/Test_A1.jar
BUILD SUCCESSFUL
Total time: 1 second

This is the console output when I run the simulator:

Found theme.css file. Watching for changes...
Retina Scale: 1.0
CSS> Retina Scale: 1.0
CSS> Updating merge file /home/xxxxxx/eclipse-workspace/Test_A1/css/theme.css.merged
CSS> Input: /home/xxxxxxx/eclipse-workspace/Test_A1/css/theme.css
CSS> Output: /home/xxxxxxx/eclipse-workspace/Test_A1/src/theme.res
CSS> Acquiring lock on CSS checksums file /home/xxxxxx/eclipse-workspace/Test_A1/.cn1_css_checksums...
CSS> Lock obtained
CSS> File has not changed since last compile.
CSS> Releasing lock
CSS> CSS file successfully compiled. /home/xxxxxx/eclipse-workspace/Test_A1/src/theme.res
CSS> null

What called my attention is that the output says : CSS> File has not changed since last compile. even though it has.

@codenameone codenameone added this to the Version 7.0 milestone Dec 28, 2019
@shannah
Copy link
Collaborator

shannah commented Dec 28, 2019

I can't reproduce this. Can you post a test project that I can try out? Are you sure you're changing the theme.css file, and not the theme.css.merged file?

@shannah
Copy link
Collaborator

shannah commented Dec 30, 2019

What kinds of style changes are you making? The message "File has not changed since last compile." indicates that the CSS compiler thinks that no style changes have been made. This is not a simple file timestamp check, it is actually comparing the style rules in the css file to the compiled .res file. It is possible that it is missing a change. Please provide a specific test case, including which stylesheet changes you made, so that I can try to reproduce.

@rainer2208
Copy link
Author

rainer2208 commented Dec 30, 2019

I have generated a new (bare bone) project and activated the CSS support in the CN1 settings. After simulating the the project, no CSS folder gets generated.

Going back to css settings, there is warning message in the dialog box: css is enabled in the project properties, but it may not be working correctly, because some the project's configuration files appear to be out of date.

I press the button: "Activate css Now", and then "Open CSS File for Editing".

After running the application, the css folder appears.

In the application's generated main class, I change the code to the following:

    Form hi = new Form("Hi World", BoxLayout.y());
    Label label = new Label("Test");
    label.setUIID("MyLabel");
    hi.add(label);
    hi.show();

Inside the generated css folder, I open the file "theme.css", and add the following code:

    MyLabel {
         background-color: green;
    }

In the running the application, the color of the label's background does not change.

When changing the css attribute and save the files (Crtl+S), I get the following console output:

-cn1-compile-css:
        [java] Retina Scale: 1.0
        [java] Updating merge file /home/rainer/eclipse-workspace/CSS_Test/css/theme.css.merged
        [java] Input: /home/rainer/eclipse-workspace/CSS_Test/css/theme.css
        [java] Output: /home/rainer/eclipse-workspace/CSS_Test/src/theme.res
        [java] Acquiring lock on CSS checksums file /home/rainer/eclipse-workspace/CSS_Test/.cn1_css_checksums...
        [java] Lock obtained
        [java] Releasing lock
        [java] CSS file successfully compiled.  /home/rainer/eclipse-workspace/CSS_Test/src/theme.res

jar:
        [echo] Compile is forcing compliance to the supported API's/features for maximum device compatibility. This allows smaller
        [echo] 	        code size and wider device support
        [copy] Copying 1 file to /home/rainer/eclipse-workspace/CSS_Test/build/tmp
       [javac] /home/rainer/eclipse-workspace/CSS_Test/build.xml:105: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
       [javac] Compiling 1 source file to /home/rainer/eclipse-workspace/CSS_Test/build/tmp
         [jar] Building jar: /home/rainer/eclipse-workspace/CSS_Test/dist/CSS_Test.jar
       [javac] /home/rainer/eclipse-workspace/CSS_Test/build.xml:129: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
BUILD SUCCESSFUL

When I finally refresh the CN1 libraries , the css changes bocome visible.

Screenshot from 2019-12-30 13:31:49

Screenshot from 2019-12-30 13:17:07

Screenshot from 2019-12-30 13:36:00

Screenshot from 2019-12-30 13:41:55

@shannah
Copy link
Collaborator

shannah commented Dec 30, 2019

Thanks. I see the issue. It is eclipse-specific. I'll have a fix shortly.

shannah added a commit that referenced this issue Dec 30, 2019
…sent. This fixes issues with CSS not being loaded properly in eclipse. #2974
@shannah
Copy link
Collaborator

shannah commented Dec 30, 2019

The reason it refreshing libs worked is because it forces the "jar" target to run, which reloads the theme.res. I have made a change so that the simulator will prefer to load the theme.res file from the src directory if it is present, which will fix this issue.

The fix will be available in the next update on Friday.

@shannah shannah closed this as completed Dec 30, 2019
@rainer2208
Copy link
Author

Many thanks for looking into this ...

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