diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 3b1d201c1..ae4ef991d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -547,6 +547,15 @@ public final class SWF implements SWFContainerItem, Timelined { } } + public boolean isModified() { + for (Tag tag : tags) { + if (tag.isModified()) { + return true; + } + } + return false; + } + public void clearModified() { for (Tag tag : tags) { if (tag.isModified()) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 56bc751f0..ac6406445 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -366,6 +366,10 @@ public class Configuration { @ConfigurationCategory("ui") public static final ConfigurationItem autoLoadEmbeddedSwfs = null; + @ConfigurationDefaultBoolean(true) + @ConfigurationCategory("ui") + public static final ConfigurationItem showCloseConfirmation = null; + private enum OSId { WINDOWS, OSX, UNIX diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 6335c7d94..83d8dc7de 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -657,6 +657,21 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec } public void closeAll() { + boolean modified = false; + for (SWFList swfList: swfs) { + for (SWF swf : swfList) { + if (swf.isModified()) { + modified = true; + } + } + } + + if (modified) { + if (View.showConfirmDialog(this, translate("message.confirm.closeAll"), translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, Configuration.showCloseConfirmation, JOptionPane.OK_OPTION) == JOptionPane.CANCEL_OPTION) { + return; + } + } + swfs.clear(); oldItem = null; previewPanel.clear(); @@ -672,6 +687,19 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec } public void close(SWFList swfList) { + boolean modified = false; + for (SWF swf : swfList) { + if (swf.isModified()) { + modified = true; + } + } + + if (modified) { + if (View.showConfirmDialog(this, translate("message.confirm.close").replace("{swfName}",swfList.name), translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, Configuration.showCloseConfirmation, JOptionPane.CANCEL_OPTION) == JOptionPane.CANCEL_OPTION) { + return; + } + } + swfs.remove(swfList); if (abcPanel != null) { for (SWF swf : swfList) { diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties index ec9ec97b0..295ae8fb6 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog.properties @@ -305,3 +305,6 @@ config.group.description.import = Configuration of imports config.name.textImportResizeTextBoundsMode = Text bounds resize mode config.description.textImportResizeTextBoundsMode = Text bounds resize mode after text editing. + +config.name.showCloseConfirmation = Show again SWF close confirmation +config.description.showCloseConfirmation = Show again SWF close confirmation for modified files. diff --git a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_hu.properties b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_hu.properties index db9dda4fb..a060e62ba 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_hu.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/AdvancedSettingsDialog_hu.properties @@ -305,3 +305,6 @@ config.group.description.import = Import\u00e1l\u00e1s be\u00e1ll\u00edt\u00e1sa config.name.textImportResizeTextBoundsMode = Sz\u00f6veg hat\u00e1r \u00e1tm\u00e9retez\u00e9se config.description.textImportResizeTextBoundsMode = Sz\u00f6veg hat\u00e1r \u00e1tm\u00e9retez\u00e9se sz\u00f6veg m\u00f3dos\u00edt\u00e1sa ut\u00e1n. + +config.name.showCloseConfirmation = SWF bez\u00e1r\u00e1si meger\u0151s\u00edt\u00e9s \u00fajb\u00f3li mutat\u00e1sa +config.description.showCloseConfirmation = SWF bez\u00e1r\u00e1si meger\u0151s\u00edt\u00e9s \u00fajb\u00f3li mutat\u00e1sa m\u00f3dosult f\u00e1jlok eset\u00e9n. diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 3959ba114..6491a4c06 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -545,3 +545,6 @@ fit = fit button.setAdvanceValues = Set advance values menu.tools.replace = Text Replace + +message.confirm.close = There are unsaved changes. Do you really want to close {swfName}? +message.confirm.closeAll = There are unsaved changes. Do you really want to close all SWFs? diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties index 980a4311e..152e2ba62 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_hu.properties @@ -545,3 +545,6 @@ fit = kit\u00f6lt button.setAdvanceValues = Halad\u00e1si \u00e9rt\u00e9kek be\u00e1ll\u00edt\u00e1sa menu.tools.replace = Sz\u00f6veg csere + +message.confirm.close = Mentetlen v\u00e1ltoz\u00e1sok vannak. Szeretm\u00e9 m\u00e9gis bez\u00e9rni a k\u00f6vetkez\u0151t: {swfName}? +message.confirm.closeAll = Mentetlen v\u00e1ltoz\u00e1sok vannak. Szeretn\u00e9 bez\u00e1rni az \u00f6sszes SWF-t ?