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

View File

@ -38,7 +38,7 @@ final class OSXSetup {
*/
public static final OpenFilesHandler OPEN_FILE_HANDLER = (e) -> {
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() {
@Override
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);
}
});
@ -216,6 +214,9 @@ public class SwingStartup {
((SwingPreferences) Application.getPreferences()).loadDefaultUnits();
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)
log.info("Opening main application window");