mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-26 14:31:02 -04:00
fixed an issue concerning keeping the main file at "save as" operation.
This commit is contained in:
parent
e52ea13573
commit
c1c9130c4f
@ -110,6 +110,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
private final ScheduledThreadPoolExecutor timerExecutor = new ScheduledThreadPoolExecutor(1);
|
||||
private final WindowPosManager windowPosManager = new WindowPosManager();
|
||||
private final InsertHistory insertHistory;
|
||||
private final boolean keepPrefMainFile;
|
||||
|
||||
private ToolTipAction doStep;
|
||||
private ToolTipAction runToBreakAction;
|
||||
@ -140,6 +141,8 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
setIconImages(IconCreator.createImages("icon32.png", "icon64.png", "icon128.png"));
|
||||
|
||||
keepPrefMainFile = builder.keepPrefMainFile;
|
||||
|
||||
if (builder.library != null) library = builder.library;
|
||||
else library = new ElementLibrary();
|
||||
|
||||
@ -348,6 +351,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
.setLibrary(library)
|
||||
.setCircuit(new Circuit())
|
||||
.setBaseFileName(getBaseFileName())
|
||||
.keepPrefMainFile()
|
||||
.build()
|
||||
.setVisible(true);
|
||||
}
|
||||
@ -391,7 +395,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
saveAsHelper.checkOverwrite(
|
||||
file -> {
|
||||
if (library.isFileAccessible(file))
|
||||
saveFile(file, false);
|
||||
saveFile(file, !keepPrefMainFile);
|
||||
else {
|
||||
Object[] options = {Lang.get("btn_saveAnyway"), Lang.get("btn_newName"), Lang.get("cancel")};
|
||||
int res = JOptionPane.showOptionDialog(Main.this,
|
||||
@ -548,6 +552,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
.setLibrary(library)
|
||||
.setCircuit(circuit)
|
||||
.setBaseFileName(getBaseFileName())
|
||||
.keepPrefMainFile()
|
||||
.build()
|
||||
.setVisible(true);
|
||||
}
|
||||
@ -1201,6 +1206,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
private Circuit circuit;
|
||||
private boolean allowAllFileActions = true;
|
||||
private File baseFileName;
|
||||
private boolean keepPrefMainFile;
|
||||
|
||||
/**
|
||||
* @param fileToOpen the file to open
|
||||
@ -1258,6 +1264,16 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps the main file defined in the preferences
|
||||
*
|
||||
* @return this for chained calls
|
||||
*/
|
||||
public MainBuilder keepPrefMainFile() {
|
||||
this.keepPrefMainFile = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Main instance
|
||||
*
|
||||
@ -1273,5 +1289,6 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
public void openLater() {
|
||||
SwingUtilities.invokeLater(() -> build().setVisible(true));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -612,6 +612,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
.setFileToOpen(((ElementLibrary.ElementTypeDescriptionCustom) elementType).getFile())
|
||||
.setLibrary(library)
|
||||
.denyMostFileActions()
|
||||
.keepPrefMainFile()
|
||||
.openLater();
|
||||
}
|
||||
}.setToolTip(Lang.get("attr_openCircuit_tt")));
|
||||
|
Loading…
x
Reference in New Issue
Block a user