Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0dacc1d
Design Import: engine pipeline, live preview and GUI Builder round-tr…
shai-almog Nov 27, 2026
ea3b359
Design Import: compile what it emits, hold the docs files out, PMD clean
shai-almog Nov 27, 2026
1d11c1b
Design Import: MCP tools, headless CLI, run script
shai-almog Nov 27, 2026
0ff2b03
Design Import: example gallery, adaptive pair, device skin, flattened…
shai-almog Nov 27, 2026
f904bfa
Design Import: the desktop workbench
shai-almog Nov 27, 2026
5db4498
Design Import: CI workflow, developer guide chapter, skill pointer
shai-almog Nov 27, 2026
e115dd2
Design Import: copyright headers
shai-almog Nov 27, 2026
086a4f2
Design Import: run the generated tests, neutral screenshot path
shai-almog Nov 27, 2026
801bd66
JavaSE port: stop recreating the screen buffer of a canvas never shown
shai-almog Nov 27, 2026
e20ac8c
Design Import: cn1:import-design and importDesign run the tool from a…
shai-almog Nov 27, 2026
8a089a3
Design Import: the import wizard, from cn1:import-design and importDe…
shai-almog Nov 27, 2026
0cdbc16
Design Import: several screens per import, a guided review, text size
shai-almog Nov 27, 2026
ae4d1f1
Design Import: readable issues, alternative fixes, device-size form p…
shai-almog Nov 28, 2026
b2508c7
Sketch symbols are laid out, not scaled; wizard steps and scrollbars
shai-almog Nov 28, 2026
9969d90
Design Import: a live, resizable form preview and desktop size classes
shai-almog Nov 28, 2026
cbf8262
Design Import: React/HTML prototypes, rendered in headless Chrome
shai-almog Nov 28, 2026
24f238f
Design Import: popups, long scrolling screens, a code card and a refi…
shai-almog Nov 28, 2026
0309ff0
Design Import: WorkbenchTest sizes the live view, not the removed siz…
shai-almog Nov 28, 2026
5012b72
Design Import: the workbench's Open button shows the file dialog
shai-almog Nov 28, 2026
87624bf
Design Import: the app opens the wizard, a spotlight selection and a …
shai-almog Nov 28, 2026
2c0be81
Design Import: a compact screen picker, one status line, a conversion…
shai-almog Nov 28, 2026
e42fd03
Design Import: highlighted code, one size bar over both panes, radio …
shai-almog Nov 28, 2026
472f61c
Design Import: one toolbar, steps in the status bar, forms checked ag…
shai-almog Nov 28, 2026
a302587
Design Import: drawings stay pictures, mark an element as converted w…
shai-almog Nov 28, 2026
5b402d7
Design Import: the bottom bar keeps its height on the write step
shai-almog Nov 29, 2026
1027508
Design Import: always in a project, grids above a button, centred sym…
shai-almog Nov 29, 2026
059750a
Design Import: a new screen filter shows its results from the top
shai-almog Nov 29, 2026
7118359
Design Import: import from a Figma link, a coach mark tour of every step
shai-almog Nov 29, 2026
cc8697b
Figma groups land where their boxes say; centred title bars; how to g…
shai-almog Nov 29, 2026
f7b00d1
CoachMarks: a tour opened by a button starts at its first step, wrapp…
shai-almog Nov 29, 2026
b29cd13
Design Import: a refused Figma read opens the last copy, multi-line f…
shai-almog Nov 29, 2026
44e7b1f
FigmaReader: a child at its group's corner decides nothing, without a…
shai-almog Nov 29, 2026
b341dc8
Merge remote-tracking branch 'origin/master' into design-import-tool
shai-almog Nov 30, 2026
9fdfe48
Design Import: document Figma links, the tours and the saved copy; a …
shai-almog Nov 30, 2026
5709bcd
Design Import: review fixes - Java names checked, the Figma copy only…
shai-almog Nov 30, 2026
c1170f3
Design Import: round 2 review fixes
shai-almog Nov 30, 2026
13e9194
Design Import: the launcher keeps a working JAVA_HOME instead of sour…
shai-almog Nov 30, 2026
b448cdc
Design Import: WizardTest creates the gallery directory instead of th…
shai-almog Nov 30, 2026
7de0627
Design Import CI: the MCP smoke reads the repository Maven installed …
shai-almog Nov 30, 2026
e62988b
Merge remote-tracking branch 'origin/master' into design-import-tool
shai-almog Nov 30, 2026
eb3ae03
Design Import guide: the shell examples are included from docs/demos,…
shai-almog Dec 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions .github/workflows/designimport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Design Import

# Design Import: the engine and its command line are the reactor module maven/design-import,
# which cn1:import-design and the Gradle importDesign task resolve and fork; the desktop
# workbench app is scripts/designimport. The tests import the GUI Builder demo forms and the
# developer guide's Sketch files through the core design readers, so a change to any of those
# is what can break it.
# Per the nightly policy it runs on a pull request only when its own inputs change.

on:
workflow_dispatch:
schedule:
- cron: '11 0 * * *'
pull_request:
branches:
- master
paths:
- 'scripts/ci/retry.sh'
- '.github/workflows/designimport.yml'
- 'scripts/designimport/**'
- 'maven/design-import/**'
- 'maven/codenameone-maven-plugin/src/main/java/com/codename1/maven/ImportDesignMojo.java'
- 'maven/codenameone-gradle-plugin/src/main/java/com/codename1/gradle/tasks/ImportDesignTask.java'
- 'maven/codenameone-gradle-plugin/src/main/java/com/codename1/gradle/AppSupport.java'
- 'CodenameOne/src/com/codename1/components/CoachMarks.java'
- '!scripts/designimport/**/*.md'
- 'scripts/guibuilder/demo-project/**'
- 'docs/developer-guide/sketch/**'
- 'CodenameOne/src/com/codename1/art/**'

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
golden-plan:
uses: ./.github/workflows/golden-plan.yml
permissions:
contents: read

designimport:
needs: golden-plan
if: needs.golden-plan.outputs.run == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 60
container: ghcr.io/codenameone/codenameone/pr-ci-container:latest
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v6

- name: Cache Maven dependencies
uses: actions/cache@v5
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2

- name: Use Google's copy of Maven Central first
uses: ./.github/actions/maven-central-mirror

- name: Prepare Codename One binaries
# The JavaSE port needs jfxrt.jar from cn1-binaries; without it the
# build fails with a large, misleading set of missing javafx.* errors.
run: |
set -euo pipefail
rm -rf maven/target/cn1-binaries
mkdir -p maven/target
cp -r /opt/cn1-binaries maven/target/cn1-binaries

- name: Install Codename One artifacts (JDK 8)
# JAVA_HOME_8 / JAVA_HOME_17 are container image environment variables,
# so they are expanded by the shell rather than the env context.
run: |
set -euo pipefail
export JAVA_HOME="${JAVA_HOME_8}"
export PATH="${JAVA_HOME}/bin:${PATH}"
cd maven
# Retried: Central has been answering 403 on this runner pool, and Maven treats a
# failed build-extension resolution as permanent -- the job dies in setup having
# proved nothing. Same rationale as setup-workspace.sh's mvn_retry.
bash ../scripts/ci/retry.sh mvn -B install -Plocal-dev-javase -DskipTests \
-Darchetype.test.skip=true -Dmaven.javadoc.skip=true \
-Dcn1.binaries="${GITHUB_WORKSPACE}/maven/target/cn1-binaries"

- name: Run Design Import tests (JDK 8)
# Headless: the workbench test paints the window into an image, nothing needs a display.
run: |
set -euo pipefail
export JAVA_HOME="${JAVA_HOME_8}"
export PATH="${JAVA_HOME}/bin:${PATH}"
(cd maven && mvn -B test -pl design-import \
-Ddesignimport.argLine="-Ddesignimport.examples=${GITHUB_WORKSPACE}/scripts/designimport/target/examples")
cd scripts/designimport
# No clean: the gallery the tests above wrote lives in this target and is uploaded below.
mvn -B install -Dcodename1.platform=javase -DargLine="-Djava.awt.headless=true"

- name: cn1:import-design in a new application
# The goal resolves the tool at the plugin's version and forks it; the form it writes
# has to build with the application, stylesheet and generated test included.
run: |
set -euo pipefail
export JAVA_HOME="${JAVA_HOME_8}"
export PATH="${JAVA_HOME}/bin:${PATH}"
APPS="${RUNNER_TEMP}/designimport-app"
rm -rf "$APPS" && mkdir -p "$APPS" && cd "$APPS"
VERSION=$(cd "${GITHUB_WORKSPACE}/maven" && mvn -B -q help:evaluate -Dexpression=project.version -DforceStdout)
mvn -B -q archetype:generate -DarchetypeGroupId=com.codenameone -DarchetypeArtifactId=cn1app-archetype \
-DarchetypeVersion="$VERSION" -DgroupId=com.acme -DartifactId=shop -Dversion=1.0 -DmainName=Shop \
-Dpackage=com.acme.shop -DinteractiveMode=false
cd shop
mvn -B cn1:import-design -Dcn1.design="${GITHUB_WORKSPACE}/docs/developer-guide/sketch/new-gui-builder-property-sheet.sketch" \
-Dcn1.design.class=SheetForm | tee import.log
grep -q '\[design-import\] emit:' import.log
test -f common/src/main/java/com/acme/shop/SheetFormBase.java
mvn -B test-compile

- name: MCP smoke session
run: |
set -euo pipefail
export JAVA_HOME="${JAVA_HOME_8}"
export PATH="${JAVA_HOME}/bin:${PATH}"
# Maven's own answer: in this container HOME is /github/home, while Maven writes to /root/.m2.
REPO=$(cd maven && mvn -B -q help:evaluate -Dexpression=settings.localRepository -DforceStdout)
MAVEN_REPO_LOCAL="$REPO" DESIGNIMPORT_MVN_OFFLINE= DESIGNIMPORT_SKIP_BUILD=1 \
scripts/designimport/design-import.sh --mcp-smoke

- name: Upload reports and the regenerated gallery
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
name: designimport-reports
path: |
scripts/designimport/javase/target/surefire-reports
scripts/designimport/target/examples
if-no-files-found: warn
retention-days: 14
9 changes: 5 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ jobs:
-Dcn1.binaries="${CN1_BINARIES}" \
-Pcompile-android \
-DbackendAnalysis \
-pl android,ios,project-model,build-engine,codenameone-maven-plugin,codenameone-gradle-plugin,backend,backend-test,backend-parparvm,javac,code-model,android-res-compiler,android-compat,swing-compat,javafx-compat,compose-compat,rive-runtime,fxml-compiler,desktop-compat-runtime,cn1-app-kit/backend,cn1-app-kit/common,python-transpiler -am verify
-pl android,ios,project-model,build-engine,codenameone-maven-plugin,codenameone-gradle-plugin,backend,backend-test,backend-parparvm,javac,code-model,android-res-compiler,android-compat,swing-compat,javafx-compat,compose-compat,rive-runtime,fxml-compiler,design-import,desktop-compat-runtime,cn1-app-kit/backend,cn1-app-kit/common,python-transpiler -am verify
# The step above skips tests, so the Android port's pure-Java unit tests
# (maven/android/src/test) run here, against the classes it just built.
- name: Run Android port unit tests
Expand Down Expand Up @@ -516,7 +516,7 @@ jobs:
- name: Generate static analysis HTML summaries
if: ${{ !cancelled() && matrix.java-version == 8 }}
env:
QUALITY_REPORT_TARGET_DIRS: maven/core-unittests/target:maven/android/target:maven/ios/target:vm/ByteCodeTranslator/target:maven/codenameone-maven-plugin/target:maven/build-engine/target:maven/project-model/target:maven/codenameone-gradle-plugin/target:maven/build-hint-catalog/target:maven/build-hint-tools/target:maven/backend/target:maven/backend-test/target:maven/backend-parparvm/target:maven/javac/target:maven/code-model/target:maven/android-res-compiler/target:maven/android-compat/target:maven/swing-compat/target:maven/javafx-compat/target:maven/compose-compat/target:maven/fxml-compiler/target:maven/desktop-compat-runtime/target:maven/python-transpiler/target:maven/python-runtime/target:maven/rive-runtime/target
QUALITY_REPORT_TARGET_DIRS: maven/core-unittests/target:maven/android/target:maven/ios/target:vm/ByteCodeTranslator/target:maven/codenameone-maven-plugin/target:maven/build-engine/target:maven/project-model/target:maven/codenameone-gradle-plugin/target:maven/build-hint-catalog/target:maven/build-hint-tools/target:maven/backend/target:maven/backend-test/target:maven/backend-parparvm/target:maven/javac/target:maven/code-model/target:maven/android-res-compiler/target:maven/android-compat/target:maven/swing-compat/target:maven/javafx-compat/target:maven/compose-compat/target:maven/fxml-compiler/target:maven/design-import/target:maven/desktop-compat-runtime/target:maven/python-transpiler/target:maven/python-runtime/target:maven/rive-runtime/target
QUALITY_REPORT_SERVER_URL: ${{ github.server_url }}
QUALITY_REPORT_REPOSITORY: ${{ github.repository }}
QUALITY_REPORT_REF: ${{ github.event.pull_request.head.sha || github.sha }}
Expand All @@ -543,6 +543,7 @@ jobs:
"compose-compat:maven/compose-compat/target" \
"rive-runtime:maven/rive-runtime/target" \
"fxml-compiler:maven/fxml-compiler/target" \
"design-import:maven/design-import/target" \
"desktop-compat-runtime:maven/desktop-compat-runtime/target" \
"project-model:maven/project-model/target" \
"gradle-plugin:maven/codenameone-gradle-plugin/target" \
Expand Down Expand Up @@ -675,11 +676,11 @@ jobs:
- name: Generate quality report summary
if: ${{ !cancelled() && matrix.java-version == 8 }}
env:
QUALITY_REPORT_TARGET_DIRS: maven/core-unittests/target:maven/android/target:maven/ios/target:vm/ByteCodeTranslator/target:maven/codenameone-maven-plugin/target:maven/build-engine/target:maven/project-model/target:maven/codenameone-gradle-plugin/target:maven/build-hint-catalog/target:maven/build-hint-tools/target:maven/backend/target:maven/backend-test/target:maven/backend-parparvm/target:maven/javac/target:maven/code-model/target:maven/android-res-compiler/target:maven/android-compat/target:maven/swing-compat/target:maven/javafx-compat/target:maven/compose-compat/target:maven/fxml-compiler/target:maven/desktop-compat-runtime/target:maven/python-transpiler/target:maven/python-runtime/target:maven/rive-runtime/target
QUALITY_REPORT_TARGET_DIRS: maven/core-unittests/target:maven/android/target:maven/ios/target:vm/ByteCodeTranslator/target:maven/codenameone-maven-plugin/target:maven/build-engine/target:maven/project-model/target:maven/codenameone-gradle-plugin/target:maven/build-hint-catalog/target:maven/build-hint-tools/target:maven/backend/target:maven/backend-test/target:maven/backend-parparvm/target:maven/javac/target:maven/code-model/target:maven/android-res-compiler/target:maven/android-compat/target:maven/swing-compat/target:maven/javafx-compat/target:maven/compose-compat/target:maven/fxml-compiler/target:maven/design-import/target:maven/desktop-compat-runtime/target:maven/python-transpiler/target:maven/python-runtime/target:maven/rive-runtime/target
# Every project listed here must produce a SpotBugs report and that
# report must be empty. A missing report fails the gate too, so a
# SpotBugs run that silently stops running is not mistaken for clean.
QUALITY_REPORT_REQUIRED_SPOTBUGS: core-unittests:android:ios:ByteCodeTranslator:codenameone-maven-plugin:build-engine:project-model:codenameone-gradle-plugin:build-hint-catalog:build-hint-tools:backend:backend-test:javac:code-model:android-res-compiler:android-compat:swing-compat:javafx-compat:compose-compat:fxml-compiler:desktop-compat-runtime:python-transpiler:python-runtime:rive-runtime
QUALITY_REPORT_REQUIRED_SPOTBUGS: core-unittests:android:ios:ByteCodeTranslator:codenameone-maven-plugin:build-engine:project-model:codenameone-gradle-plugin:build-hint-catalog:build-hint-tools:backend:backend-test:javac:code-model:android-res-compiler:android-compat:swing-compat:javafx-compat:compose-compat:fxml-compiler:design-import:desktop-compat-runtime:python-transpiler:python-runtime:rive-runtime
# PMD and Checkstyle run on the core, the backend runtime and the Python
# transpiler and runtime, and each must produce its report: without one,
# the PMD gate below it has nothing to read and passes.
Expand Down
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ PR CI (`.github/workflows/pr.yml`, Java 8 leg) runs SpotBugs over
`core-unittests`, `android`, `ios`, `ByteCodeTranslator`,
`codenameone-maven-plugin`, `build-engine` (the Maven-free build logic both
build plugins share), `project-model` (the project-layout API),
`design-import` (the Design Import engine),
`android-res-compiler` and `android-compat` (the Android compatibility
runtime), `codenameone-gradle-plugin`, `javac` (the in-tree Java compiler,
`vm/JavaCompiler`), `code-model` (the code visualizer's analyzer) and `python-transpiler`, plus `python-runtime` in a step of
Expand All @@ -131,7 +132,7 @@ it runs only when the Unity tree itself changes, so a change to the core's
- **Record intentional exceptions in the project's `spotbugs-exclude.xml`**
(`maven/core-unittests/`, `Ports/Android/`, `Ports/iOSPort/`,
`vm/ByteCodeTranslator/`, `maven/codenameone-maven-plugin/`,
`maven/build-engine/`, `maven/project-model/`,
`maven/build-engine/`, `maven/project-model/`, `maven/design-import/`,
`maven/android-res-compiler/`, `maven/android-compat/`,
`maven/codenameone-gradle-plugin/`, `maven/javac/`, `maven/code-model/`,
`maven/python-transpiler/`, `maven/python-runtime/`,
Expand Down
49 changes: 49 additions & 0 deletions CodenameOne/src/com/codename1/art/ArtNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
import com.codename1.ui.geom.GeneralPath;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/// One element of an artwork: a group, shape, text, image or adjustment layer.
///
Expand All @@ -45,6 +48,49 @@ public abstract class ArtNode {
private boolean luminanceMask;
private boolean knockout;
private final List<Effect> effects = new ArrayList<Effect>();
private Map<String, String> attributes;

/// A source attribute the reader kept, or null.
///
/// Readers keep facts the rendering model has no field for, so that tools reading
/// the document as a design can still see them: Figma's auto-layout
/// (`layoutMode`, `itemSpacing`, `paddingLeft`...), resizing constraints
/// (`constraints.horizontal`), component instances (`componentId`), and the
/// source's own node type (`sourceType`). Rendering never reads them.
///
/// #### Parameters
///
/// - `key`: the attribute name
public String getAttribute(String key) {
return attributes == null ? null : attributes.get(key);
}

/// Sets a source attribute; null removes it.
///
/// #### Parameters
///
/// - `key`: the attribute name
/// - `value`: the value, or null
public void setAttribute(String key, String value) {
if (value == null) {
if (attributes != null) {
attributes.remove(key);
}
return;
}
if (attributes == null) {
attributes = new LinkedHashMap<String, String>();
}
attributes.put(key, value);
}

/// Every source attribute, in the order they were set; read only.
public Map<String, String> getAttributes() {
if (attributes == null) {
return Collections.emptyMap();
}
return Collections.unmodifiableMap(attributes);
}

/// The node's id, unique within a document when set.
public String getId() {
Expand Down Expand Up @@ -226,6 +272,9 @@ protected ArtNode copyBase(ArtNode n) {
n.mask = mask == null ? null : mask.copy();
n.luminanceMask = luminanceMask;
n.knockout = knockout;
if (attributes != null) {
n.attributes = new LinkedHashMap<String, String>(attributes);
}
for (int i = 0; i < effects.size(); i++) { // NOPMD ForLoopCanBeForeach - indexed: no iterator allocation
n.effects.add(effects.get(i).copy());
}
Expand Down
53 changes: 50 additions & 3 deletions CodenameOne/src/com/codename1/art/FigmaClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,25 @@ public FigmaClient setOAuth(boolean oauth) {
///
/// - `fileKey`: the key in the file's URL, `figma.com/design/KEY/...`
public ArtDocument fetch(String fileKey) throws IOException {
Map<String, byte[]> images = new HashMap<String, byte[]>();
byte[] json = fetchJson(fileKey, images);
return FigmaReader.read(json, images);
}

/// Downloads a file without reading it: its JSON is returned and the pictures its fills
/// name are put in `images`, keyed by image ref. `FigmaReader.read(json, images)` turns the
/// pair into the same document `fetch` returns, so a caller can keep a copy of a file and
/// read it again without asking Figma, whose quota on whole-file reads is small.
///
/// #### Parameters
///
/// - `fileKey`: the key in the file's URL, `figma.com/design/KEY/...`
///
/// - `images`: receives the pictures the file uses
public byte[] fetchJson(String fileKey, Map<String, byte[]> images) throws IOException {
checkKey(fileKey);
byte[] json = get(API + "files/" + fileKey + "?geometry=paths");
Map<String, Object> parsed = JSONParser.parseJSON(json);
Map<String, byte[]> images = new HashMap<String, byte[]>();
List<String> refs = FigmaReader.imageRefs(parsed);
if (!refs.isEmpty()) {
Map<String, Object> fills = JSONParser.parseJSON(get(API + "files/" + fileKey + "/images"));
Expand All @@ -108,7 +123,7 @@ public ArtDocument fetch(String fileKey) throws IOException {
}
}
}
return FigmaReader.read(json, images);
return json;
}

/// The raw JSON of any API path, such as `files/KEY/nodes?ids=1:2&geometry=paths`.
Expand Down Expand Up @@ -167,16 +182,48 @@ private byte[] request(String url, boolean auth) throws IOException {
throw new IOException("Figma file not found (404)");
}
if (code == 429) {
throw new IOException("Figma rate limit reached (429); try again later");
throw new IOException("Figma rate limit reached (429); " + retryAfter(r.retryAfter));
}
if (code < 200 || code >= 300 || data == null) {
throw new IOException("Figma request failed with HTTP " + code);
}
return data;
}

/// How long Figma asks a refused caller to wait, from its `Retry-After` seconds. On the
/// Starter plan that is days, not seconds, and "try again later" hides it.
static String retryAfter(String seconds) {
long s = -1;
if (seconds != null) {
try {
s = Long.parseLong(seconds.trim());
} catch (NumberFormatException e) {
s = -1;
}
}
if (s < 0) {
return "try again later";
}
if (s < 120) {
return "Figma asks to wait " + s + " seconds";
}
if (s < 2 * 3600) {
return "Figma asks to wait " + (s / 60) + " minutes";
}
if (s < 2 * 86400) {
return "Figma asks to wait " + (s / 3600) + " hours";
}
return "Figma asks to wait " + (s / 86400) + " days";
}

private static final class Request extends ConnectionRequest {
private Exception failure;
private String retryAfter;

@Override
protected void readHeaders(Object connection) throws IOException {
retryAfter = getHeader(connection, "Retry-After");
}

@Override
protected void handleException(Exception err) {
Expand Down
Loading
Loading