diff --git a/src/studio/kdb/config/ActionOnExit.java b/src/studio/kdb/config/ActionOnExit.java index 8fa974ce..4a4faa67 100644 --- a/src/studio/kdb/config/ActionOnExit.java +++ b/src/studio/kdb/config/ActionOnExit.java @@ -3,7 +3,7 @@ public enum ActionOnExit { NOTHING("Don't ask to save and keep workspace as is"), SAVE("Ask to save all modified tabs"), - CLOSE_ANONYMOUS_NOT_SAVED("Ask to save and close all anonymous not-saved tabs"); + CLOSE_ANONYMOUS_NOT_SAVED("Ask to save and close all anonymous tabs"); private final String description; diff --git a/src/studio/ui/EditorTab.java b/src/studio/ui/EditorTab.java index 7b7a2f57..b2c65afd 100644 --- a/src/studio/ui/EditorTab.java +++ b/src/studio/ui/EditorTab.java @@ -433,6 +433,10 @@ public EditorsPanel getEditorsPanel() { return (EditorsPanel) getPane().getParent().getParent(); } + public void selectEditor() { + getEditorsPanel().selectTab(this); + } + public boolean isAddedToPanel() { return getPane().getParent() != null; } diff --git a/src/studio/ui/EditorsPanel.java b/src/studio/ui/EditorsPanel.java index 379de04e..164d37b9 100644 --- a/src/studio/ui/EditorsPanel.java +++ b/src/studio/ui/EditorsPanel.java @@ -296,6 +296,7 @@ public static boolean saveEditor(EditorTab editor) { public static boolean checkAndSaveTab(EditorTab editor) { if (! editor.isModified()) return true; + editor.selectEditor(); int choice = StudioOptionPane.showYesNoCancelDialog(editor.getPane(), editor.getTitle() + " is changed. Save changes?","Save changes?"); @@ -308,13 +309,16 @@ public static boolean checkAndSaveTab(EditorTab editor) { return true; } - public boolean closeTab(EditorTab editorTab) { - if (!checkAndSaveTab(editorTab)) return false; - + public void closeTabForced(EditorTab editorTab) { editorTab.closing(); tabbedEditors.remove(editorTab.getPane()); closeIfEmpty(); + } + + public boolean closeTab(EditorTab editorTab) { + if (!checkAndSaveTab(editorTab)) return false; + closeTabForced(editorTab); return true; } @@ -341,6 +345,17 @@ public void selectNextTab(boolean forward) { tabbedEditors.setSelectedIndex(index); } + public void selectTab(EditorTab editorTab) { + int count = tabbedEditors.getTabCount(); + for (int index = 0; index {}", tmpFile.toString(), filename); } }; } diff --git a/src/studio/utils/PropertiesConfig.java b/src/studio/utils/PropertiesConfig.java index cd941386..afccca4b 100644 --- a/src/studio/utils/PropertiesConfig.java +++ b/src/studio/utils/PropertiesConfig.java @@ -96,6 +96,8 @@ public void saveToDisk() { ByteArrayOutputStream buffer = getStreamToSave(); if (buffer == null) return; + log.info("Saving config to file {} with number of properties {}", filename, size()); + try (OutputStream out = FilesBackup.getInstance().newFileOutputStream(filename)) { byte[] lineSeparator = System.getProperty("line.separator").getBytes(CHARSET); @@ -119,6 +121,8 @@ public void saveToDisk() { out.write(line.getBytes(CHARSET)); out.write(lineSeparator); } + + propertiesToSave = null; } catch (IOException e) { log.error("Error in saving config to the file {}", filename, e); }