implements PR-07e assets refactor cleanup and regression coverage

This commit is contained in:
bQUARKz 2026-03-12 09:40:09 +00:00
parent 288178c44e
commit 4c8190cc31
Signed by: bquarkz
SSH Key Fingerprint: SHA256:Z7dgqoglWwoK6j6u4QC87OveEq74WOhFN+gitsxtkf8
3 changed files with 0 additions and 134 deletions

View File

@ -1,11 +0,0 @@
package p.studio.events;
import p.studio.projects.ProjectReference;
import java.util.Objects;
public record StudioAssetsDetailsRedrawRequestedEvent(ProjectReference project) implements StudioEvent {
public StudioAssetsDetailsRedrawRequestedEvent {
Objects.requireNonNull(project, "project");
}
}

View File

@ -1,11 +0,0 @@
package p.studio.events;
import p.studio.projects.ProjectReference;
import java.util.Objects;
public record StudioAssetsNavigatorRedrawRequestedEvent(ProjectReference project) implements StudioEvent {
public StudioAssetsNavigatorRedrawRequestedEvent {
Objects.requireNonNull(project, "project");
}
}

View File

@ -746,51 +746,6 @@ public final class AssetWorkspace implements Workspace, AssetWorkspaceInteractio
workspaceBus.publish(new StudioAssetsAssetSummaryPatchedEvent(projectReference, updatedSummary)); workspaceBus.publish(new StudioAssetsAssetSummaryPatchedEvent(projectReference, updatedSummary));
} }
private Node createStagedMutationPanel(AssetWorkspaceMutationPreview preview) {
final VBox panel = new VBox(10);
panel.getStyleClass().add("assets-mutation-panel");
final Label title = new Label(Container.i18n().format(I18n.ASSETS_MUTATION_PREVIEW_TITLE, actionLabel(preview.action())));
title.getStyleClass().add("assets-mutation-panel-title");
panel.getChildren().add(title);
panel.getChildren().add(createMutationSection(
Container.i18n().text(I18n.ASSETS_MUTATION_SECTION_AFFECTED_ASSET),
createAffectedAssetContent(preview)));
final AssetWorkspaceMutationImpactViewModel impacts = AssetWorkspaceMutationImpactViewModel.from(preview);
panel.getChildren().add(createMutationSection(
Container.i18n().text(I18n.ASSETS_MUTATION_SECTION_REGISTRY_IMPACT),
createMutationChangesContent(impacts.registryChanges(), Container.i18n().text(I18n.ASSETS_MUTATION_EMPTY_REGISTRY_IMPACT))));
panel.getChildren().add(createMutationSection(
Container.i18n().text(I18n.ASSETS_MUTATION_SECTION_WORKSPACE_IMPACT),
createMutationChangesContent(impacts.workspaceChanges(), Container.i18n().text(I18n.ASSETS_MUTATION_EMPTY_WORKSPACE_IMPACT))));
panel.getChildren().add(createMutationSection(
Container.i18n().text(I18n.ASSETS_MUTATION_SECTION_BLOCKERS),
createMutationMessages(preview.blockers(), "assets-mutation-message-blocker", Container.i18n().text(I18n.ASSETS_MUTATION_EMPTY_BLOCKERS))));
panel.getChildren().add(createMutationSection(
Container.i18n().text(I18n.ASSETS_MUTATION_SECTION_WARNINGS),
createMutationMessages(preview.warnings(), "assets-mutation-message-warning", Container.i18n().text(I18n.ASSETS_MUTATION_EMPTY_WARNINGS))));
panel.getChildren().add(createMutationSection(
Container.i18n().text(I18n.ASSETS_MUTATION_SECTION_SAFE_FIXES),
createMutationMessages(preview.safeFixes(), "assets-mutation-message-safe-fix", Container.i18n().text(I18n.ASSETS_MUTATION_EMPTY_SAFE_FIXES))));
final HBox actions = new HBox(8);
final Button cancel = new Button(Container.i18n().text(I18n.ASSETS_MUTATION_CANCEL));
cancel.getStyleClass().addAll("studio-button", "studio-button-cancel");
cancel.setOnAction(event -> {
stagedMutationPreview = null;
requestDetailsRedraw();
});
final Button apply = new Button(Container.i18n().text(I18n.ASSETS_MUTATION_APPLY));
apply.getStyleClass().addAll("studio-button", "studio-button-primary");
apply.setDisable(!preview.canApply());
apply.setOnAction(event -> applyStagedMutation(preview));
actions.getChildren().addAll(cancel, apply);
panel.getChildren().add(actions);
return panel;
}
private Node createMutationSection(String title, Node content) { private Node createMutationSection(String title, Node content) {
final VBox section = new VBox(6); final VBox section = new VBox(6);
final Label label = new Label(title); final Label label = new Label(title);
@ -918,10 +873,6 @@ public final class AssetWorkspace implements Workspace, AssetWorkspaceInteractio
.orElse(null); .orElse(null);
} }
private boolean containsInput(AssetWorkspaceAssetDetails details, Path input) {
return details.inputsByRole().values().stream().flatMap(List::stream).anyMatch(input::equals);
}
static String readPreviewText(Path input) { static String readPreviewText(Path input) {
try { try {
final String text = Files.readString(input); final String text = Files.readString(input);
@ -931,40 +882,6 @@ public final class AssetWorkspace implements Workspace, AssetWorkspaceInteractio
} }
} }
private String extensionOf(Path input) {
final String fileName = input.getFileName().toString();
final int dot = fileName.lastIndexOf('.');
if (dot < 0 || dot == fileName.length() - 1) {
return "";
}
return fileName.substring(dot + 1).toLowerCase();
}
private boolean isImage(String extension) {
return extension.equals("png")
|| extension.equals("jpg")
|| extension.equals("jpeg")
|| extension.equals("gif")
|| extension.equals("bmp");
}
private boolean isText(String extension) {
return extension.equals("json")
|| extension.equals("txt")
|| extension.equals("pal")
|| extension.equals("csv")
|| extension.equals("yaml")
|| extension.equals("yml")
|| extension.equals("xml")
|| extension.equals("pbs");
}
private boolean isAudio(String extension) {
return extension.equals("wav")
|| extension.equals("ogg")
|| extension.equals("mp3");
}
private Node createSectionMessage(String text) { private Node createSectionMessage(String text) {
final Label label = new Label(text); final Label label = new Label(text);
label.setWrapText(true); label.setWrapText(true);
@ -993,35 +910,6 @@ public final class AssetWorkspace implements Workspace, AssetWorkspaceInteractio
return value ? Container.i18n().text(I18n.ASSETS_VALUE_YES) : Container.i18n().text(I18n.ASSETS_VALUE_NO); return value ? Container.i18n().text(I18n.ASSETS_VALUE_YES) : Container.i18n().text(I18n.ASSETS_VALUE_NO);
} }
private String assetRowToneClass(String assetFamily) {
return "assets-workspace-asset-row-tone-" + assetFamilyTone(assetFamily);
}
private String assetNameToneClass(String assetFamily) {
return "assets-workspace-asset-name-tone-" + assetFamilyTone(assetFamily);
}
private String assetFamilyTone(String assetFamily) {
final String family = assetFamily == null ? "" : assetFamily.toLowerCase(Locale.ROOT);
if (family.contains("image") || family.contains("sprite") || family.contains("tile")) {
return "image";
}
if (family.contains("sound") || family.contains("audio") || family.contains("music")) {
return "audio";
}
if (family.contains("palette") || family.contains("color")) {
return "palette";
}
if (family.contains("font") || family.contains("text") || family.contains("script")) {
return "text";
}
return "generic";
}
private Path assetsRoot() {
return projectReference.rootPath().resolve("assets").toAbsolutePath().normalize();
}
private Path projectRoot() { private Path projectRoot() {
return projectReference.rootPath().toAbsolutePath().normalize(); return projectReference.rootPath().toAbsolutePath().normalize();
} }