Use last BasicFrame as parent in macOS OpenFileHandler

This ensures the newly opened file replaces a (replaceable) already opened design file
This commit is contained in:
SiboVG 2022-06-16 03:21:16 +02:00
parent 9e73f6e4e2
commit 6bfaaf907b
3 changed files with 7 additions and 3 deletions

View File

@ -139,6 +139,8 @@ public class BasicFrame extends JFrame {
private SimulationPanel simulationPanel; private SimulationPanel simulationPanel;
public static BasicFrame lastFrameInstance = null; // Latest BasicFrame that was created
/** /**
* Sole constructor. Creates a new frame based on the supplied document * Sole constructor. Creates a new frame based on the supplied document
@ -152,6 +154,7 @@ public class BasicFrame extends JFrame {
this.document = document; this.document = document;
this.rocket = document.getRocket(); this.rocket = document.getRocket();
this.rocket.getSelectedConfiguration().setAllStages(); this.rocket.getSelectedConfiguration().setAllStages();
BasicFrame.lastFrameInstance = this;
// Create the component tree selection model that will be used // Create the component tree selection model that will be used
componentSelectionModel = new DefaultTreeSelectionModel(); componentSelectionModel = new DefaultTreeSelectionModel();

View File

@ -38,7 +38,7 @@ final class OSXSetup {
*/ */
public static final OpenFilesHandler OPEN_FILE_HANDLER = (e) -> { public static final OpenFilesHandler OPEN_FILE_HANDLER = (e) -> {
log.info("Opening file from association: " + e.getFiles().get(0)); log.info("Opening file from association: " + e.getFiles().get(0));
BasicFrame.open(e.getFiles().get(0), null); BasicFrame.open(e.getFiles().get(0), BasicFrame.lastFrameInstance);
}; };
/** /**

View File

@ -85,8 +85,6 @@ public class SwingStartup {
SwingUtilities.invokeAndWait(new Runnable() { SwingUtilities.invokeAndWait(new Runnable() {
@Override @Override
public void run() { public void run() {
// Set up the OSX file open handler here so that it can handle files that are opened when OR is not yet running.
OSXSetup.setupOSXOpenFileHandler();
runner.runInEDT(args); runner.runInEDT(args);
} }
}); });
@ -217,6 +215,9 @@ public class SwingStartup {
Databases.fakeMethod(); Databases.fakeMethod();
// Set up the OSX file open handler here so that it can handle files that are opened when OR is not yet running.
OSXSetup.setupOSXOpenFileHandler();
// Starting action (load files or open new document) // Starting action (load files or open new document)
log.info("Opening main application window"); log.info("Opening main application window");
if (!handleCommandLine(args)) { if (!handleCommandLine(args)) {