Skip to content

Add advanced theme CSS editing with live preview in Initializr#4601

Open
shai-almog wants to merge 5 commits intomasterfrom
codex/add-advanced-theme-mode-with-live-preview
Open

Add advanced theme CSS editing with live preview in Initializr#4601
shai-almog wants to merge 5 commits intomasterfrom
codex/add-advanced-theme-mode-with-live-preview

Conversation

@shai-almog
Copy link
Collaborator

Motivation

  • Provide an "Advanced Theme Mode" in the Initializr UI so users can edit the CSS that would be generated for their project and see changes immediately in the preview.
  • Reuse existing CSS compilation/runtime plumbing (MutableResource + CSSThemeCompiler) to apply edits into the running preview without requiring a full regenerate.

Description

  • Added a customThemeCss field and an overloaded constructor to ProjectOptions so custom CSS is carried through generation and preview via ProjectOptions.
  • Extended the Initializr UI (createThemeOptionsPanel) with an Advanced Theme Mode checkbox and a TextArea editor for custom CSS, and threaded the advanced CSS into ProjectOptions used for generation/preview.
  • Refactored theme override generation in GeneratorModel into a reusable entry point buildThemeOverrides(ProjectOptions) (and a small buildThemeCss() adapter) so generated zip output and live preview share the same logic and advanced CSS is appended to common/src/main/css/theme.css when present.
  • Implemented live preview application in TemplatePreviewPanel via MutableResource + CSSThemeCompiler by compiling generated CSS into a theme Hashtable and applying it to the preview form with UIManager.addThemeProps, plus restoring defaults before applying changes.
  • Added a unit test validateAdvancedThemeCssGeneration to GeneratorModelMatrixTest that verifies advanced CSS is emitted into common/src/main/css/theme.css in generated zips.

Testing

  • Attempted to run module tests with Java 8 using export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 && export PATH="$JAVA_HOME/bin:$PATH" && cd scripts/initializr && mvn -pl common -am test -DskipTests=false, but the build is blocked by environment/bootstrap steps (the CN1 bootstrap expected /root/.codenameone/CodeNameOneBuildClient.jar).
  • A non--am invocation (mvn -pl common test) failed due to missing reactor dependency when not building the dependent modules first, so a full reactor build is required to validate end-to-end.
  • Copied the bundled maven/UpdateCodenameOne.jar into /root/UpdateCodenameOne.jar to bypass the downloader in this environment, which allowed Maven to progress further, but the CN1 plugin still requires /root/.codenameone/CodeNameOneBuildClient.jar and/or network access for full plugin bootstrap; as a result automated tests could not complete successfully here.
  • The new unit test was added to the suite and should pass once the repository is built in an environment that satisfies the CN1 bootstrap requirements and builds the reactor modules together.

Codex Task

@github-actions
Copy link

Cloudflare Preview

@shai-almog
Copy link
Collaborator Author

shai-almog commented Mar 10, 2026

Compared 32 screenshots: 32 matched.

Native Android coverage

  • 📊 Line coverage: 7.31% (3716/50864 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 5.66% (18086/319675), branch 2.75% (856/31113), complexity 3.40% (1011/29741), method 5.98% (829/13853), class 9.63% (176/1827)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/712 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 7.31% (3716/50864 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 5.66% (18086/319675), branch 2.75% (856/31113), complexity 3.40% (1011/29741), method 5.98% (829/13853), class 9.63% (176/1827)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/712 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

@github-actions
Copy link

✅ Continuous Quality Report

Test & Coverage

Static Analysis

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Collaborator Author

shai-almog commented Mar 10, 2026

iOS screenshot updates

Compared 32 screenshots: 31 matched, 1 updated.

  • landscape — updated screenshot. Screenshot differs (2556x1179 px, bit depth 8).

    landscape
    Preview info: Preview provided by instrumentation.
    Full-resolution PNG saved as landscape.png in workflow artifacts.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 115 seconds

Detailed Performance Metrics

Metric Duration
Simulator Boot 1000 ms
Simulator Boot (Run) 1000 ms
App Install 3000 ms
App Launch 3000 ms
Test Execution 166000 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant