asset workspace progress
This commit is contained in:
parent
165be76128
commit
126788bd5d
@ -3,9 +3,14 @@ package p.packer.messages;
|
||||
import java.util.Objects;
|
||||
|
||||
public record ListAssetsRequest(
|
||||
PackerProjectContext project) {
|
||||
PackerProjectContext project,
|
||||
boolean deepSync) {
|
||||
|
||||
public ListAssetsRequest {
|
||||
Objects.requireNonNull(project, "project");
|
||||
}
|
||||
|
||||
public ListAssetsRequest(PackerProjectContext project) {
|
||||
this(project, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +82,9 @@ public final class FileSystemPackerWorkspaceService implements PackerWorkspaceSe
|
||||
@Override
|
||||
public ListAssetsResult listAssets(ListAssetsRequest request) {
|
||||
final PackerProjectContext project = Objects.requireNonNull(request, "request").project();
|
||||
final PackerRuntimeSnapshot snapshot = runtimeRegistry.getOrLoad(project).snapshot();
|
||||
final PackerRuntimeSnapshot snapshot = request.deepSync()
|
||||
? runtimeRegistry.refresh(project).snapshot()
|
||||
: runtimeRegistry.getOrLoad(project).snapshot();
|
||||
final PackerOperationEventEmitter events = new PackerOperationEventEmitter(project, eventSink);
|
||||
final PackerRegistryState registry = snapshot.registry();
|
||||
final Map<Path, PackerRegistryEntry> registryByRoot = new HashMap<>();
|
||||
|
||||
@ -175,6 +175,22 @@ final class FileSystemPackerWorkspaceServiceTest {
|
||||
assertEquals(1, loader.loadCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
void listAssetsOnlyReloadsSnapshotWhenHardRefreshIsRequested() throws Exception {
|
||||
final Path projectRoot = copyFixture("workspaces/read-mixed", tempDir.resolve("hard-refresh"));
|
||||
final CountingLoader loader = countingLoader();
|
||||
final FileSystemPackerWorkspaceService service = service(ignored -> { }, loader);
|
||||
|
||||
service.listAssets(new ListAssetsRequest(project(projectRoot)));
|
||||
assertEquals(1, loader.loadCount());
|
||||
|
||||
service.listAssets(new ListAssetsRequest(project(projectRoot)));
|
||||
assertEquals(1, loader.loadCount());
|
||||
|
||||
service.listAssets(new ListAssetsRequest(project(projectRoot), true));
|
||||
assertEquals(2, loader.loadCount());
|
||||
}
|
||||
|
||||
@Test
|
||||
void exposesRegisterActionForValidUnregisteredAsset() throws Exception {
|
||||
final Path projectRoot = copyFixture("workspaces/orphan-valid", tempDir.resolve("orphan-actions"));
|
||||
|
||||
@ -98,7 +98,7 @@ public final class AssetWorkspace extends Workspace {
|
||||
}
|
||||
|
||||
private void refreshAssets() {
|
||||
workspaceEventBus.publish(new StudioAssetsRefreshRequestedEvent());
|
||||
workspaceEventBus.publish(new StudioAssetsRefreshRequestedEvent(null, true));
|
||||
}
|
||||
|
||||
private Button createAddAssetButton() {
|
||||
|
||||
@ -294,9 +294,6 @@ public final class AssetDetailsControl extends VBox implements StudioEventAware
|
||||
button.setDisable(actionRunning || !action.enabled());
|
||||
button.setOnAction(ignored -> executeAction(action));
|
||||
nodes.add(button);
|
||||
if (action.reason() != null) {
|
||||
nodes.add(AssetDetailsUiSupport.createSectionMessage(action.reason()));
|
||||
}
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ public final class AssetListControl extends VBox implements StudioEventAware {
|
||||
@Override
|
||||
public void registerEventSubscriptions() {
|
||||
eventBindings.listen(workspaceBus, StudioAssetsRefreshRequestedEvent.class).handle(event -> {
|
||||
requestRefresh(event.preferredAssetReference());
|
||||
requestRefresh(event.preferredAssetReference(), event.deepSync());
|
||||
});
|
||||
eventBindings.listen(workspaceBus, StudioAssetsNavigatorViewStateChangedEvent.class).handle(event -> {
|
||||
viewState = event.viewState();
|
||||
@ -136,9 +136,9 @@ public final class AssetListControl extends VBox implements StudioEventAware {
|
||||
preloadFilterButton.setOnAction(ignored -> rebuildProjection());
|
||||
}
|
||||
|
||||
private void requestRefresh(AssetReference preferredAssetReference) {
|
||||
private void requestRefresh(AssetReference preferredAssetReference, boolean deepSync) {
|
||||
if (!Platform.isFxApplicationThread()) {
|
||||
Platform.runLater(() -> requestRefresh(preferredAssetReference));
|
||||
Platform.runLater(() -> requestRefresh(preferredAssetReference, deepSync));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -154,17 +154,18 @@ public final class AssetListControl extends VBox implements StudioEventAware {
|
||||
Container.i18n().text(I18n.ASSETS_STATE_LOADING)));
|
||||
workspaceBus.publish(new StudioAssetsWorkspaceRefreshStartedEvent());
|
||||
|
||||
Container.backgroundTasks().submit(() -> loadAssets(generation, assetReference));
|
||||
Container.backgroundTasks().submit(() -> loadAssets(generation, assetReference, deepSync));
|
||||
}
|
||||
|
||||
private void loadAssets(
|
||||
long generation,
|
||||
AssetReference preferredAssetReference) {
|
||||
AssetReference preferredAssetReference,
|
||||
boolean deepSync) {
|
||||
try {
|
||||
final var projectContext = projectReference.toPackerProjectContext();
|
||||
final var response = Container.packer()
|
||||
.workspaceService()
|
||||
.listAssets(new ListAssetsRequest(projectContext));
|
||||
.listAssets(new ListAssetsRequest(projectContext, deepSync));
|
||||
final List<AssetWorkspaceAssetSummary> assets = response.assets().stream()
|
||||
.map(this::mapAsset)
|
||||
.toList();
|
||||
|
||||
@ -4,8 +4,13 @@ import p.packer.messages.AssetReference;
|
||||
import p.studio.events.StudioEvent;
|
||||
|
||||
public record StudioAssetsRefreshRequestedEvent(
|
||||
AssetReference preferredAssetReference) implements StudioEvent {
|
||||
AssetReference preferredAssetReference,
|
||||
boolean deepSync) implements StudioEvent {
|
||||
public StudioAssetsRefreshRequestedEvent() {
|
||||
this(null);
|
||||
this(null, false);
|
||||
}
|
||||
|
||||
public StudioAssetsRefreshRequestedEvent(AssetReference preferredAssetReference) {
|
||||
this(preferredAssetReference, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -549,6 +549,10 @@
|
||||
|
||||
.assets-details-action-button {
|
||||
-fx-max-width: Infinity;
|
||||
-fx-padding: 6 10 6 10;
|
||||
-fx-background-radius: 8;
|
||||
-fx-border-radius: 8;
|
||||
-fx-font-size: 12px;
|
||||
}
|
||||
|
||||
.assets-details-section {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"schema_version" : 1,
|
||||
"next_asset_id" : 13,
|
||||
"next_asset_id" : 14,
|
||||
"assets" : [ {
|
||||
"asset_id" : 3,
|
||||
"asset_uuid" : "21953cb8-4101-4790-9e5e-d95f5fbc9b5a",
|
||||
@ -21,11 +21,6 @@
|
||||
"asset_uuid" : "b23fd13b-9a52-4a76-9e8a-9286f59757b2",
|
||||
"root" : "ui/test",
|
||||
"included_in_build" : true
|
||||
}, {
|
||||
"asset_id" : 10,
|
||||
"asset_uuid" : "c025c9bd-7fc0-4a9f-8f00-0fd673c2a9d3",
|
||||
"root" : "recovered/new asset",
|
||||
"included_in_build" : true
|
||||
}, {
|
||||
"asset_id" : 11,
|
||||
"asset_uuid" : "64147d33-e8bf-4272-bb5c-b4c07c0276b3",
|
||||
@ -36,5 +31,10 @@
|
||||
"asset_uuid" : "b15b319f-5cab-4254-93ea-d83f4742d204",
|
||||
"root" : "recovered/atlas2",
|
||||
"included_in_build" : true
|
||||
}, {
|
||||
"asset_id" : 13,
|
||||
"asset_uuid" : "4d9847b0-5a23-421f-8b78-bf3909ca2281",
|
||||
"root" : "recovered/one-more-atlas",
|
||||
"included_in_build" : true
|
||||
} ]
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
{
|
||||
"schema_version" : 1,
|
||||
"asset_uuid" : "c025c9bd-7fc0-4a9f-8f00-0fd673c2a9d3",
|
||||
"name" : "Novo Asset",
|
||||
"type" : "image_bank",
|
||||
"inputs" : { },
|
||||
"output" : {
|
||||
"format" : "TILES/indexed_v1",
|
||||
"codec" : "NONE"
|
||||
},
|
||||
"preload" : {
|
||||
"enabled" : false
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user