Implement retained target sessions, runtime sizing and Component navigation
This commit is contained in:
+11
@@ -13,6 +13,7 @@ public final class DesignerApplication extends Application {
|
||||
private HostLaunch launch;
|
||||
private StandaloneHost host;
|
||||
private int windows;
|
||||
private final java.util.Map<Path, Stage> editors = new java.util.HashMap<>();
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws Exception {
|
||||
@@ -75,6 +76,14 @@ public final class DesignerApplication extends Application {
|
||||
}
|
||||
|
||||
private void open(Stage stage, Path file) throws Exception {
|
||||
Path identity = file.toRealPath();
|
||||
var existing = editors.get(identity);
|
||||
if (existing != null) {
|
||||
existing.show();
|
||||
existing.toFront();
|
||||
existing.requestFocus();
|
||||
return;
|
||||
}
|
||||
if (host == null)
|
||||
host =
|
||||
new StandaloneHost(
|
||||
@@ -97,6 +106,7 @@ public final class DesignerApplication extends Application {
|
||||
stage.setTitle("Neitzel FX Designer — " + file.getFileName());
|
||||
stage.setScene(new Scene(pane, 1300, 850));
|
||||
windows++;
|
||||
editors.put(identity, stage);
|
||||
boolean[] closing = {false};
|
||||
stage.setOnCloseRequest(
|
||||
event -> {
|
||||
@@ -181,6 +191,7 @@ public final class DesignerApplication extends Application {
|
||||
});
|
||||
stage.setOnHidden(
|
||||
e -> {
|
||||
editors.remove(identity, stage);
|
||||
pane.close();
|
||||
if (--windows == 0) host.close();
|
||||
});
|
||||
|
||||
@@ -17,6 +17,14 @@ public final class FileDocuments implements HostServices.Documents, AutoCloseabl
|
||||
private final java.util.concurrent.CopyOnWriteArrayList<java.util.function.Consumer<URI>>
|
||||
changes = new java.util.concurrent.CopyOnWriteArrayList<>();
|
||||
|
||||
private final java.util.List<java.util.function.Consumer<URI>> saves =
|
||||
new java.util.concurrent.CopyOnWriteArrayList<>();
|
||||
|
||||
public AutoCloseable onSave(java.util.function.Consumer<URI> listener) {
|
||||
saves.add(listener);
|
||||
return () -> saves.remove(listener);
|
||||
}
|
||||
|
||||
public AutoCloseable onChange(java.util.function.Consumer<URI> listener) {
|
||||
changes.add(listener);
|
||||
return () -> changes.remove(listener);
|
||||
@@ -186,6 +194,7 @@ public final class FileDocuments implements HostServices.Documents, AutoCloseabl
|
||||
Files.deleteIfExists(temp);
|
||||
}
|
||||
s.saved = s.text;
|
||||
saves.forEach(listener -> listener.accept(s.file.toUri()));
|
||||
return FileDocuments.snapshot(s);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user