GP-4270: Minor fixes

This commit is contained in:
dragonmacher 2024-01-26 16:18:05 -05:00 committed by Ryan Kurtz
parent b9f914d57c
commit 1cf7803d88
22 changed files with 295 additions and 183 deletions

View file

@ -633,7 +633,7 @@ public abstract class PluginTool extends AbstractDockingTool {
}
winMgr.restoreWindowDataFromXml(root);
winMgr.setToolName(fullName);
updateTitle();
return hasErrors;
}

View file

@ -225,21 +225,37 @@ public abstract class StandAloneApplication implements GenericStandAloneApplicat
}
private Element getSavedToolElement() {
File savedToolFile = new File(Application.getUserSettingsDirectory(), SAVED_TOOL_FILE);
if (!savedToolFile.exists()) {
return null;
File userSettingsDir = Application.getUserSettingsDirectory();
File savedToolFile = new File(userSettingsDir, SAVED_TOOL_FILE);
if (savedToolFile.exists()) {
return loadToolXml(savedToolFile);
}
Msg.debug(this, "No saved tool found in " + userSettingsDir);
List<File> dirs = GenericRunInfo.getPreviousApplicationSettingsDirsByTime();
for (File dir : dirs) {
savedToolFile = new File(dir, SAVED_TOOL_FILE);
Msg.debug(this, "Checking for previous tool in " + dir);
if (savedToolFile.exists()) {
Msg.debug(this, "Using previous tool " + savedToolFile);
return loadToolXml(savedToolFile);
}
}
return null;
}
private Element loadToolXml(File file) {
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(savedToolFile.getAbsolutePath());
fileInputStream = new FileInputStream(file.getAbsolutePath());
SAXBuilder sax = XmlUtilities.createSecureSAXBuilder(false, false);
Element root = sax.build(fileInputStream).getRootElement();
return root;
}
catch (Exception e) {
Msg.showError(getClass(), null, "Error Reading Tool",
"Could not read tool: " + savedToolFile, e);
Msg.showError(getClass(), null, "Error Reading Tool", "Could not read tool: " + file,
e);
}
finally {
if (fileInputStream != null) {
@ -251,7 +267,6 @@ public abstract class StandAloneApplication implements GenericStandAloneApplicat
}
}
}
return null;
}