From a7989d2d02b544bfee6e1a6e951fa0021f3bcae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 27 Mar 2021 09:11:00 +0100 Subject: [PATCH] Fixed: #1670 Parent component/window of dialogs not properly set --- CHANGELOG.md | 2 + .../decompiler/flash/gui/AboutDialog.java | 4 +- .../flash/gui/AdvancedSettingsDialog.java | 6 +- .../jpexs/decompiler/flash/gui/AppDialog.java | 4 +- .../decompiler/flash/gui/DebugLogDialog.java | 4 +- .../decompiler/flash/gui/DebugPanel.java | 6 +- .../decompiler/flash/gui/DebuggerHandler.java | 2 +- .../decompiler/flash/gui/ExportDialog.java | 4 +- .../flash/gui/FilesChangedDialog.java | 2 +- .../decompiler/flash/gui/FontEmbedDialog.java | 4 +- .../jpexs/decompiler/flash/gui/FontPanel.java | 10 +- .../flash/gui/FontPreviewDialog.java | 2 +- .../flash/gui/GuiAbortRetryIgnoreHandler.java | 8 +- .../flash/gui/LoadFromCacheFrame.java | 2 +- .../flash/gui/LoadFromMemoryFrame.java | 2 +- .../decompiler/flash/gui/LoadingDialog.java | 5 +- src/com/jpexs/decompiler/flash/gui/Main.java | 50 ++++--- .../decompiler/flash/gui/MainFrameMenu.java | 32 ++-- .../flash/gui/MainFrameRibbonMenu.java | 6 +- .../jpexs/decompiler/flash/gui/MainPanel.java | 74 +++++----- .../flash/gui/NewVersionDialog.java | 6 +- .../decompiler/flash/gui/RenameDialog.java | 4 +- .../flash/gui/ReplaceCharacterDialog.java | 4 +- .../flash/gui/ReplaceTraceDialog.java | 4 +- .../decompiler/flash/gui/SearchDialog.java | 2 +- .../flash/gui/SelectLanguageDialog.java | 4 +- src/com/jpexs/decompiler/flash/gui/View.java | 105 -------------- .../decompiler/flash/gui/ViewMessages.java | 137 ++++++++++++++++++ .../decompiler/flash/gui/abc/ABCPanel.java | 15 +- .../flash/gui/abc/ASMSourceEditorPane.java | 5 +- .../flash/gui/abc/DeobfuscationDialog.java | 4 +- .../decompiler/flash/gui/abc/DetailPanel.java | 3 +- .../gui/abc/DialogMissingSymbolHandler.java | 10 +- .../flash/gui/abc/NewTraitDialog.java | 7 +- .../gui/abc/SlotConstTraitDetailPanel.java | 5 +- .../flash/gui/action/ActionPanel.java | 15 +- .../flash/gui/action/AddScriptDialog.java | 4 +- .../flash/gui/debugger/DebuggerTools.java | 2 +- .../generictageditors/Amf3ValueEditor.java | 3 +- .../flash/gui/hexview/GotoAddressDialog.java | 4 +- .../decompiler/flash/gui/hexview/HexView.java | 5 +- .../flash/gui/pipes/FirstInstance.java | 2 +- .../flash/gui/player/PlayerControls.java | 5 +- .../flash/gui/proxy/ProxyFrame.java | 9 +- .../flash/gui/tagtree/TagTreeContextMenu.java | 11 +- 45 files changed, 351 insertions(+), 253 deletions(-) create mode 100644 src/com/jpexs/decompiler/flash/gui/ViewMessages.java diff --git a/CHANGELOG.md b/CHANGELOG.md index f56764424..bbed18eac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. - [#1660] Empty thumbnail view on remove item - [#1669] FILLSTYLE color handling in DefineShape3/4 - [#1668] Not removing SymbolClass/ExportAssets entry on character remove +- [#1670] Parent component/window of dialogs not properly set ## [14.3.1] - 2021-03-25 ### Fixed @@ -2166,6 +2167,7 @@ All notable changes to this project will be documented in this file. [#1660]: https://www.free-decompiler.com/flash/issues/1660 [#1669]: https://www.free-decompiler.com/flash/issues/1669 [#1668]: https://www.free-decompiler.com/flash/issues/1668 +[#1670]: https://www.free-decompiler.com/flash/issues/1670 [#1665]: https://www.free-decompiler.com/flash/issues/1665 [#1661]: https://www.free-decompiler.com/flash/issues/1661 [#1435]: https://www.free-decompiler.com/flash/issues/1435 diff --git a/src/com/jpexs/decompiler/flash/gui/AboutDialog.java b/src/com/jpexs/decompiler/flash/gui/AboutDialog.java index 88a18e724..5adfad0ec 100644 --- a/src/com/jpexs/decompiler/flash/gui/AboutDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/AboutDialog.java @@ -22,6 +22,7 @@ import java.awt.Color; import java.awt.Container; import java.awt.FlowLayout; import java.awt.Font; +import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; @@ -50,7 +51,8 @@ public class AboutDialog extends AppDialog { private static final String AUTHOR = "JPEXS"; - public AboutDialog() { + public AboutDialog(Window owner) { + super(owner); setDefaultCloseOperation(HIDE_ON_CLOSE); setTitle(translate("dialog.title")); diff --git a/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java b/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java index 35d721b45..e149265bc 100644 --- a/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/AdvancedSettingsDialog.java @@ -33,6 +33,7 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; import java.awt.RenderingHints; +import java.awt.Window; import java.awt.event.ActionEvent; import java.io.File; import java.lang.reflect.Field; @@ -91,7 +92,8 @@ public class AdvancedSettingsDialog extends AppDialog { private JButton resetButton; - public AdvancedSettingsDialog(String selectedCategory) { + public AdvancedSettingsDialog(Window owner, String selectedCategory) { + super(owner); initComponents(selectedCategory); View.centerScreen(this); View.setWindowIcon(this); @@ -491,7 +493,7 @@ public class AdvancedSettingsDialog extends AppDialog { } private void showRestartConfirmDialog() { - if (View.showConfirmDialog(this, translate("advancedSettings.restartConfirmation"), AppStrings.translate("message.warning"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { + if (ViewMessages.showConfirmDialog(this, translate("advancedSettings.restartConfirmation"), AppStrings.translate("message.warning"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { try { // todo: honfika: why? Thread.sleep(1000); diff --git a/src/com/jpexs/decompiler/flash/gui/AppDialog.java b/src/com/jpexs/decompiler/flash/gui/AppDialog.java index eb598e0ff..fc9e32fb6 100644 --- a/src/com/jpexs/decompiler/flash/gui/AppDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/AppDialog.java @@ -36,12 +36,12 @@ public abstract class AppDialog extends JDialog { private ResourceBundle resourceBundle = ResourceBundle.getBundle(AppStrings.getResourcePath(getClass())); - public AppDialog() { + /*public AppDialog() { View.installEscapeCloseOperation(this); if (Configuration.useRibbonInterface.get()) { getRootPane().setWindowDecorationStyle(JRootPane.FRAME); } - } + }*/ public AppDialog(Window owner) { super(owner); diff --git a/src/com/jpexs/decompiler/flash/gui/DebugLogDialog.java b/src/com/jpexs/decompiler/flash/gui/DebugLogDialog.java index 596c7ed6e..423a6ff84 100644 --- a/src/com/jpexs/decompiler/flash/gui/DebugLogDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/DebugLogDialog.java @@ -23,6 +23,7 @@ import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.FlowLayout; +import java.awt.Window; import java.awt.event.ActionEvent; import javax.swing.JButton; import javax.swing.JPanel; @@ -41,7 +42,8 @@ public class DebugLogDialog extends AppDialog { private final Debugger debug; - public DebugLogDialog(Debugger debug) { + public DebugLogDialog(Window owner, Debugger debug) { + super(owner); setSize(800, 600); this.debug = debug; setTitle(translate("dialog.title")); diff --git a/src/com/jpexs/decompiler/flash/gui/DebugPanel.java b/src/com/jpexs/decompiler/flash/gui/DebugPanel.java index d5a585de5..c651ce0c5 100644 --- a/src/com/jpexs/decompiler/flash/gui/DebugPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/DebugPanel.java @@ -186,19 +186,19 @@ public class DebugPanel extends JPanel { JMenuItem watchReadMenuItem = new JMenuItem(AppStrings.translate("debug.watch.add.read")); watchReadMenuItem.addActionListener((ActionEvent e1) -> { if (!Main.addWatch(v, watchParentId, true, false)) { - View.showMessageDialog(DebugPanel.this, AppStrings.translate("error.debug.watch.add"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(DebugPanel.this, AppStrings.translate("error.debug.watch.add"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); } }); JMenuItem watchWriteMenuItem = new JMenuItem(AppStrings.translate("debug.watch.add.write")); watchWriteMenuItem.addActionListener((ActionEvent e1) -> { if (!Main.addWatch(v, watchParentId, false, true)) { - View.showMessageDialog(DebugPanel.this, AppStrings.translate("error.debug.watch.add"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(DebugPanel.this, AppStrings.translate("error.debug.watch.add"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); } }); JMenuItem watchReadWriteMenuItem = new JMenuItem(AppStrings.translate("debug.watch.add.readwrite")); watchReadWriteMenuItem.addActionListener((ActionEvent e1) -> { if (!Main.addWatch(v, watchParentId, true, true)) { - View.showMessageDialog(DebugPanel.this, AppStrings.translate("error.debug.watch.add"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(DebugPanel.this, AppStrings.translate("error.debug.watch.add"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); } }); diff --git a/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java b/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java index 82a0e98c7..df11ee308 100644 --- a/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java +++ b/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java @@ -500,7 +500,7 @@ public class DebuggerHandler implements DebugConnectionListener { disconnect(); Main.stopRun(); Main.stopWork(); - View.showMessageDialog(Main.getMainFrame().getPanel(), AppStrings.translate("error.debug.listen").replace("%port%", "" + Debugger.DEBUG_PORT)); + ViewMessages.showMessageDialog(Main.getMainFrame().getPanel(), AppStrings.translate("error.debug.listen").replace("%port%", "" + Debugger.DEBUG_PORT)); Main.getMainFrame().getPanel().updateMenu(); } }); diff --git a/src/com/jpexs/decompiler/flash/gui/ExportDialog.java b/src/com/jpexs/decompiler/flash/gui/ExportDialog.java index d9fded7c8..f2ad455b5 100644 --- a/src/com/jpexs/decompiler/flash/gui/ExportDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/ExportDialog.java @@ -51,6 +51,7 @@ import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; import java.awt.FlowLayout; +import java.awt.Window; import java.awt.event.ActionEvent; import java.util.Arrays; import java.util.List; @@ -199,7 +200,8 @@ public class ExportDialog extends AppDialog { return false; } - public ExportDialog(List exportables) { + public ExportDialog(Window owner, List exportables) { + super(owner); setTitle(translate("dialog.title")); setResizable(false); diff --git a/src/com/jpexs/decompiler/flash/gui/FilesChangedDialog.java b/src/com/jpexs/decompiler/flash/gui/FilesChangedDialog.java index 2b279af04..7905fad9f 100644 --- a/src/com/jpexs/decompiler/flash/gui/FilesChangedDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/FilesChangedDialog.java @@ -99,7 +99,7 @@ public class FilesChangedDialog extends AppDialog { @Override public void setVisible(boolean b) { if (b && !onTopInited) { - Main.getMainFrame().getWindow().addWindowListener(new WindowAdapter() { + Main.getDefaultDialogsOwner().addWindowListener(new WindowAdapter() { @Override public void windowDeactivated(WindowEvent e) { Window wnd = e.getOppositeWindow(); diff --git a/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java b/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java index 781e415eb..e6ca1e590 100644 --- a/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java @@ -27,6 +27,7 @@ import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import java.awt.FontFormatException; +import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; @@ -134,7 +135,8 @@ public class FontEmbedDialog extends AppDialog { faceSelection.setModel(FontPanel.getFaceModel((FontFamily) familyNamesSelection.getSelectedItem())); } - public FontEmbedDialog(boolean hasLayout, FontFace selectedFace, String selectedChars) { + public FontEmbedDialog(Window owner, boolean hasLayout, FontFace selectedFace, String selectedChars) { + super(owner); setSize(900, 600); setDefaultCloseOperation(HIDE_ON_CLOSE); setTitle(translate("dialog.title")); diff --git a/src/com/jpexs/decompiler/flash/gui/FontPanel.java b/src/com/jpexs/decompiler/flash/gui/FontPanel.java index 1419df49d..80c94196f 100644 --- a/src/com/jpexs/decompiler/flash/gui/FontPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/FontPanel.java @@ -170,7 +170,7 @@ public class FontPanel extends JPanel { if (!font.canDisplay(c)) { String msg = translate("error.font.nocharacter").replace("%char%", "" + c); Logger.getLogger(FontPanel.class.getName()).log(Level.SEVERE, msg); - View.showMessageDialog(null, msg, translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(FontPanel.this, msg, translate("error"), JOptionPane.ERROR_MESSAGE); return; } } @@ -185,7 +185,7 @@ public class FontPanel extends JPanel { if (oldchars.indexOf((int) c) > -1) { int opt = -1; if (!(yestoall || notoall)) { - opt = View.showOptionDialog(null, translate("message.font.add.exists").replace("%char%", "" + c), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, yesno, translate("button.yes")); + opt = ViewMessages.showOptionDialog(FontPanel.this, translate("message.font.add.exists").replace("%char%", "" + c), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, yesno, translate("button.yes")); if (opt == 2) { yestoall = true; } @@ -212,7 +212,7 @@ public class FontPanel extends JPanel { } if (replaced) { - if (View.showConfirmDialog(null, translate("message.font.replace.updateTexts"), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION) { + if (ViewMessages.showConfirmDialog(FontPanel.this, translate("message.font.replace.updateTexts"), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION) { int fontId = ft.getFontId(); SWF swf = ft.getSwf(); for (Tag tag : swf.getTags()) { @@ -603,7 +603,7 @@ public class FontPanel extends JPanel { TreeItem item = mainPanel.tagTree.getCurrentTreeItem(); if (item instanceof FontTag) { FontTag ft = (FontTag) item; - FontEmbedDialog fed = new FontEmbedDialog(ft.hasLayout() || ft.getCharacterCount() == 0, (FontFace) fontFaceSelection.getSelectedItem(), fontAddCharactersField.getText()); + FontEmbedDialog fed = new FontEmbedDialog(Main.getDefaultDialogsOwner(), ft.hasLayout() || ft.getCharacterCount() == 0, (FontFace) fontFaceSelection.getSelectedItem(), fontAddCharactersField.getText()); if (fed.showDialog() == AppDialog.OK_OPTION) { Set selChars = fed.getSelectedChars(); if (!selChars.isEmpty() || fed.isImportAscentDescentLeading()) { @@ -721,7 +721,7 @@ public class FontPanel extends JPanel { } private void buttonSetAdvanceValuesActionPerformed(ActionEvent evt) { - if (View.showConfirmDialog(null, AppStrings.translate("message.font.setadvancevalues"), AppStrings.translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, Configuration.showSetAdvanceValuesMessage, JOptionPane.OK_OPTION) == JOptionPane.OK_OPTION) { + if (ViewMessages.showConfirmDialog(FontPanel.this, AppStrings.translate("message.font.setadvancevalues"), AppStrings.translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, Configuration.showSetAdvanceValuesMessage, JOptionPane.OK_OPTION) == JOptionPane.OK_OPTION) { fontTag.setAdvanceValues(((FontFace) fontFaceSelection.getSelectedItem()).font); } } diff --git a/src/com/jpexs/decompiler/flash/gui/FontPreviewDialog.java b/src/com/jpexs/decompiler/flash/gui/FontPreviewDialog.java index 5726c8c54..2250551a2 100644 --- a/src/com/jpexs/decompiler/flash/gui/FontPreviewDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/FontPreviewDialog.java @@ -43,7 +43,7 @@ public class FontPreviewDialog extends AppDialog { * @param modal Will show as modal? */ public FontPreviewDialog(java.awt.Frame parent, boolean modal, Font font) { - super(); + super(parent); setModal(true); initComponents(); View.setWindowIcon(this); diff --git a/src/com/jpexs/decompiler/flash/gui/GuiAbortRetryIgnoreHandler.java b/src/com/jpexs/decompiler/flash/gui/GuiAbortRetryIgnoreHandler.java index 13e9e1a86..79a83d00e 100644 --- a/src/com/jpexs/decompiler/flash/gui/GuiAbortRetryIgnoreHandler.java +++ b/src/com/jpexs/decompiler/flash/gui/GuiAbortRetryIgnoreHandler.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; +import java.awt.Component; import javax.swing.JOptionPane; /** @@ -53,7 +54,12 @@ public class GuiAbortRetryIgnoreHandler implements AbortRetryIgnoreHandler { msg = ""; } - int result = View.showOptionDialog(null, AppStrings.translate("error.occured").replace("%error%", msg), AppStrings.translate("error"), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, options, ""); + MainFrame mf = Main.getMainFrame(); + Component cmp = null; + if (mf != null) { + cmp = mf.getPanel(); + } + int result = ViewMessages.showOptionDialog(cmp, AppStrings.translate("error.occured").replace("%error%", msg), AppStrings.translate("error"), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, options, ""); if (result == AbortRetryIgnoreHandler.IGNORE_ALL) { ignoreAll = true; result = AbortRetryIgnoreHandler.IGNORE; diff --git a/src/com/jpexs/decompiler/flash/gui/LoadFromCacheFrame.java b/src/com/jpexs/decompiler/flash/gui/LoadFromCacheFrame.java index 1ec005912..23482b3e4 100644 --- a/src/com/jpexs/decompiler/flash/gui/LoadFromCacheFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/LoadFromCacheFrame.java @@ -276,7 +276,7 @@ public class LoadFromCacheFrame extends AppFrame { } Configuration.lastSaveDir.set(file.getParentFile().getAbsolutePath()); } catch (IOException ex) { - View.showMessageDialog(null, translate("error.file.write")); + ViewMessages.showMessageDialog(this, translate("error.file.write")); } } } diff --git a/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java b/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java index e3f753da6..15ae15e46 100644 --- a/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/LoadFromMemoryFrame.java @@ -418,7 +418,7 @@ public class LoadFromMemoryFrame extends AppFrame { } Configuration.lastSaveDir.set(file.getParentFile().getAbsolutePath()); } catch (IOException ex) { - View.showMessageDialog(null, translate("error.file.write")); + ViewMessages.showMessageDialog(this, translate("error.file.write")); } } } diff --git a/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java b/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java index 7a1b5d2d6..09f26a9b9 100644 --- a/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java @@ -22,6 +22,7 @@ import com.jpexs.helpers.Helper; import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; +import java.awt.Window; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; @@ -70,8 +71,8 @@ public class LoadingDialog extends AppDialog { * Constructor * */ - public LoadingDialog() { - super(); + public LoadingDialog(Window owner) { + super(owner); setResizable(false); setTitle(ApplicationInfo.shortApplicationVerName); Container cntp = getContentPane(); diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index 55ebe321f..3dadd32ed 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -63,12 +63,14 @@ import com.sun.jna.platform.win32.Advapi32Util; import com.sun.jna.platform.win32.Kernel32; import com.sun.jna.platform.win32.WinReg; import java.awt.AWTException; +import java.awt.Component; import java.awt.Frame; import java.awt.GraphicsEnvironment; import java.awt.MenuItem; import java.awt.PopupMenu; import java.awt.SystemTray; import java.awt.TrayIcon; +import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -469,7 +471,7 @@ public class Main { String flashVars = "";//key=val&key2=val2 String playerLocation = Configuration.playerLocation.get(); if (playerLocation.isEmpty() || (!new File(playerLocation).exists())) { - View.showMessageDialog(null, AppStrings.translate("message.playerpath.notset"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(getDefaultMessagesComponent(), AppStrings.translate("message.playerpath.notset"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); advancedSettings("paths"); return; } @@ -505,7 +507,7 @@ public class Main { String flashVars = "";//key=val&key2=val2 String playerLocation = Configuration.playerDebugLocation.get(); if (playerLocation.isEmpty() || (!new File(playerLocation).exists())) { - View.showMessageDialog(null, AppStrings.translate("message.playerpath.debug.notset"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(getDefaultMessagesComponent(), AppStrings.translate("message.playerpath.debug.notset"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); Main.advancedSettings("paths"); return; } @@ -628,6 +630,20 @@ public class Main { return mainFrame; } + public static Component getDefaultMessagesComponent() { + if (mainFrame != null) { + return mainFrame.getPanel(); + } + return null; + } + + public static Window getDefaultDialogsOwner() { + if (mainFrame != null) { + return mainFrame.getWindow(); + } + return null; + } + public static void loadFromCache() { if (loadFromCacheFrame == null) { loadFromCacheFrame = new LoadFromCacheFrame(); @@ -805,7 +821,7 @@ public class Main { public SWF resolveUrl(final String url) { int opt = -1; if (!(yestoall || notoall)) { - opt = View.showOptionDialog(null, AppStrings.translate("message.imported.swf").replace("%url%", url), AppStrings.translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, yesno, AppStrings.translate("button.yes")); + opt = ViewMessages.showOptionDialog(getDefaultMessagesComponent(), AppStrings.translate("message.imported.swf").replace("%url%", url), AppStrings.translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, yesno, AppStrings.translate("button.yes")); if (opt == 2) { yestoall = true; } @@ -847,7 +863,7 @@ public class Main { @Override public void run() { - while (JOptionPane.YES_OPTION == View.showConfirmDialog(null, AppStrings.translate("message.imported.swf.manually").replace("%url%", url), AppStrings.translate("error"), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE)) { + while (JOptionPane.YES_OPTION == ViewMessages.showConfirmDialog(getDefaultMessagesComponent(), AppStrings.translate("message.imported.swf.manually").replace("%url%", url), AppStrings.translate("error"), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE)) { JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(Configuration.lastOpenDir.get())); @@ -1160,15 +1176,15 @@ public class Main { } } catch (OutOfMemoryError ex) { logger.log(Level.SEVERE, null, ex); - View.showMessageDialog(null, "Cannot load SWF file. Out of memory."); + ViewMessages.showMessageDialog(getDefaultMessagesComponent(), "Cannot load SWF file. Out of memory."); continue; } catch (SwfOpenException ex) { logger.log(Level.SEVERE, null, ex); - View.showMessageDialog(null, ex.getMessage()); + ViewMessages.showMessageDialog(getDefaultMessagesComponent(), ex.getMessage()); continue; } catch (Exception ex) { logger.log(Level.SEVERE, null, ex); - View.showMessageDialog(null, "Cannot load SWF file."); + ViewMessages.showMessageDialog(getDefaultMessagesComponent(), "Cannot load SWF file."); continue; } @@ -1300,7 +1316,7 @@ public class Main { try { File file = new File(swfFile); if (!file.exists()) { - View.showMessageDialog(null, AppStrings.translate("open.error.fileNotFound"), AppStrings.translate("open.error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(getDefaultMessagesComponent(), AppStrings.translate("open.error.fileNotFound"), AppStrings.translate("open.error"), JOptionPane.ERROR_MESSAGE); return OpenFileResult.NOT_FOUND; } swfFile = file.getCanonicalPath(); @@ -1308,7 +1324,7 @@ public class Main { OpenFileResult openResult = openFile(sourceInfo); return openResult; } catch (IOException ex) { - View.showMessageDialog(null, AppStrings.translate("open.error.cannotOpen"), AppStrings.translate("open.error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(getDefaultMessagesComponent(), AppStrings.translate("open.error.cannotOpen"), AppStrings.translate("open.error"), JOptionPane.ERROR_MESSAGE); return OpenFileResult.ERROR; } } @@ -1564,9 +1580,9 @@ public class Main { } errorMessage += "\n"; errorMessage += AppStrings.translate("error.outOfMemory.64bit"); - View.showMessageDialog(null, errorMessage, AppStrings.translate("error.outOfMemory.title"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(getDefaultMessagesComponent(), errorMessage, AppStrings.translate("error.outOfMemory.title"), JOptionPane.ERROR_MESSAGE); } else { - View.showMessageDialog(null, AppStrings.translate("error.file.save") + ": " + ex.getLocalizedMessage(), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(getDefaultMessagesComponent(), AppStrings.translate("error.file.save") + ": " + ex.getLocalizedMessage(), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); } } @@ -1756,7 +1772,7 @@ public class Main { autoCheckForUpdates(); offerAssociation(); - loadingDialog = new LoadingDialog(); + loadingDialog = new LoadingDialog(getDefaultDialogsOwner()); if (Configuration.checkForModifications.get()) { try { @@ -1934,7 +1950,7 @@ public class Main { boolean offered = Configuration.offeredAssociation.get(); if (!offered) { if (Platform.isWindows()) { - if ((!ContextMenuTools.isAddedToContextMenu()) && View.showConfirmDialog(null, "Do you want to add FFDec to context menu of SWF files?\n(Can be changed later from main menu)", "Context menu", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { + if ((!ContextMenuTools.isAddedToContextMenu()) && ViewMessages.showConfirmDialog(getDefaultMessagesComponent(), "Do you want to add FFDec to context menu of SWF files?\n(Can be changed later from main menu)", "Context menu", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { ContextMenuTools.addToContextMenu(true, false); } } @@ -2343,7 +2359,7 @@ public class Main { } public static void about() { - (new AboutDialog()).setVisible(true); + (new AboutDialog(mainFrame.getWindow())).setVisible(true); } public static void advancedSettings() { @@ -2351,7 +2367,7 @@ public class Main { } public static void advancedSettings(String category) { - (new AdvancedSettingsDialog(category)).setVisible(true); + (new AdvancedSettingsDialog(mainFrame.getWindow(), category)).setVisible(true); } public static void autoCheckForUpdates() { @@ -2464,7 +2480,7 @@ public class Main { if (!versions.isEmpty()) { View.execInEventDispatch(() -> { - NewVersionDialog newVersionDialog = new NewVersionDialog(versions); + NewVersionDialog newVersionDialog = new NewVersionDialog(mainFrame.getWindow(), versions); newVersionDialog.setVisible(true); Configuration.lastUpdatesCheckDate.set(Calendar.getInstance()); }); @@ -2529,7 +2545,7 @@ public class Main { public void uncaughtException(Thread t, Throwable e) { logger.log(Level.SEVERE, "Uncaught exception in thread: " + t.getName(), e); if (e instanceof OutOfMemoryError && !Helper.is64BitJre() && Helper.is64BitOs()) { - View.showMessageDialog(null, AppStrings.translate("message.warning.outOfMemory32BitJre"), AppStrings.translate("message.warning"), JOptionPane.WARNING_MESSAGE); + ViewMessages.showMessageDialog(getDefaultMessagesComponent(), AppStrings.translate("message.warning.outOfMemory32BitJre"), AppStrings.translate("message.warning"), JOptionPane.WARNING_MESSAGE); } } }); diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java index 871d940c1..1ebd50d97 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java @@ -420,7 +420,7 @@ public abstract class MainFrameMenu implements MenuBuilder { } protected void debuggerReplaceTraceCallsActionPerformed(ActionEvent evt) { - ReplaceTraceDialog rtd = new ReplaceTraceDialog(Configuration.lastDebuggerReplaceFunction.get()); + ReplaceTraceDialog rtd = new ReplaceTraceDialog(Main.getDefaultDialogsOwner(), Configuration.lastDebuggerReplaceFunction.get()); rtd.setVisible(true); if (rtd.getValue() != null) { String fname = rtd.getValue(); @@ -507,7 +507,7 @@ public abstract class MainFrameMenu implements MenuBuilder { } if (!Main.checkForUpdates()) { - View.showMessageDialog(null, translate("update.check.nonewversion"), translate("update.check.title"), JOptionPane.INFORMATION_MESSAGE); + ViewMessages.showMessageDialog(Main.getDefaultMessagesComponent(), translate("update.check.nonewversion"), translate("update.check.title"), JOptionPane.INFORMATION_MESSAGE); } } @@ -518,7 +518,7 @@ public abstract class MainFrameMenu implements MenuBuilder { String helpUsURL = ApplicationInfo.PROJECT_PAGE; if (!View.navigateUrl(helpUsURL)) { - View.showMessageDialog(null, translate("message.helpus").replace("%url%", helpUsURL)); + ViewMessages.showMessageDialog(Main.getDefaultMessagesComponent(), translate("message.helpus").replace("%url%", helpUsURL)); } } @@ -529,7 +529,7 @@ public abstract class MainFrameMenu implements MenuBuilder { String homePageURL = ApplicationInfo.PROJECT_PAGE; if (!View.navigateUrl(homePageURL)) { - View.showMessageDialog(null, translate("message.homepage").replace("%url%", homePageURL)); + ViewMessages.showMessageDialog(Main.getDefaultMessagesComponent(), translate("message.homepage").replace("%url%", homePageURL)); } } @@ -543,7 +543,7 @@ public abstract class MainFrameMenu implements MenuBuilder { protected boolean reloadActionPerformed(ActionEvent evt) { if (swf != null) { - if (!Configuration.showCloseConfirmation.get() || View.showConfirmDialog(null, translate("message.confirm.reload"), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { + if (!Configuration.showCloseConfirmation.get() || ViewMessages.showConfirmDialog(Main.getDefaultMessagesComponent(), translate("message.confirm.reload"), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { Main.reloadFile(swf.swfList); } } @@ -552,7 +552,7 @@ public abstract class MainFrameMenu implements MenuBuilder { protected boolean reloadAllActionPerformed(ActionEvent evt) { if (swf != null) { - if (!Configuration.showCloseConfirmation.get() || View.showConfirmDialog(null, translate("message.confirm.reloadAll"), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { + if (!Configuration.showCloseConfirmation.get() || ViewMessages.showConfirmDialog(Main.getDefaultMessagesComponent(), translate("message.confirm.reloadAll"), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { Main.reloadApp(); } @@ -608,7 +608,7 @@ public abstract class MainFrameMenu implements MenuBuilder { } }*/ protected void setLanguageActionPerformed(ActionEvent evt) { - new SelectLanguageDialog().display(); + new SelectLanguageDialog(Main.getDefaultDialogsOwner()).display(); } protected void disableDecompilationActionPerformed(ActionEvent evt) { @@ -651,7 +651,7 @@ public abstract class MainFrameMenu implements MenuBuilder { } else { confStr += " " + translate("message.confirm.off"); } - if (View.showConfirmDialog(null, confStr, translate("message.parallel"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { + if (ViewMessages.showConfirmDialog(Main.getDefaultMessagesComponent(), confStr, translate("message.parallel"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { Configuration.parallelSpeedUp.set(selected); } else { button.setSelected(Configuration.parallelSpeedUp.get()); @@ -678,7 +678,7 @@ public abstract class MainFrameMenu implements MenuBuilder { AbstractButton button = (AbstractButton) evt.getSource(); boolean selected = button.isSelected(); - if (View.showConfirmDialog(mainFrame.getPanel(), translate("message.confirm.autodeobfuscate") + "\r\n" + (selected ? translate("message.confirm.on") : translate("message.confirm.off")), translate("message.confirm"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { + if (ViewMessages.showConfirmDialog(Main.getDefaultMessagesComponent(), translate("message.confirm.autodeobfuscate") + "\r\n" + (selected ? translate("message.confirm.on") : translate("message.confirm.off")), translate("message.confirm"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { Configuration.autoDeobfuscate.set(selected); mainFrame.getPanel().autoDeobfuscateChanged(); } else { @@ -1079,7 +1079,7 @@ public abstract class MainFrameMenu implements MenuBuilder { + "Max: " + (runtime.maxMemory() / 1024 / 1024) + "MB" + Helper.newLine + "Used: " + (runtime.totalMemory() / 1024 / 1024) + "MB" + Helper.newLine + "Free: " + (runtime.freeMemory() / 1024 / 1024) + "MB"; - View.showMessageDialog(null, info); + ViewMessages.showMessageDialog(Main.getDefaultMessagesComponent(), info); SWF nswf = mainFrame.getPanel().getCurrentSwf(); if (nswf != null) { nswf.clearAllCache(); @@ -1134,7 +1134,7 @@ public abstract class MainFrameMenu implements MenuBuilder { Configuration.dumpView.set(true); MainPanel mainPanel = mainFrame.getPanel(); if (mainPanel.isModified()) { - View.showMessageDialog(null, translate("message.warning.hexViewNotUpToDate"), translate("message.warning"), JOptionPane.WARNING_MESSAGE, Configuration.warningHexViewNotUpToDate); + ViewMessages.showMessageDialog(Main.getDefaultMessagesComponent(), translate("message.warning.hexViewNotUpToDate"), translate("message.warning"), JOptionPane.WARNING_MESSAGE, Configuration.warningHexViewNotUpToDate); } mainPanel.showView(MainPanel.VIEW_DUMP); @@ -1144,7 +1144,7 @@ public abstract class MainFrameMenu implements MenuBuilder { private void debuggerSwitchActionPerformed(ActionEvent evt) { boolean debuggerOn = isMenuChecked("/tools/debugger/debuggerSwitch"); - if (!debuggerOn || View.showConfirmDialog((Component) mainFrame, translate("message.debugger"), translate("dialog.message.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, Configuration.displayDebuggerInfo, JOptionPane.OK_OPTION) == JOptionPane.OK_OPTION) { + if (!debuggerOn || ViewMessages.showConfirmDialog(Main.getDefaultMessagesComponent(), translate("message.debugger"), translate("dialog.message.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, Configuration.displayDebuggerInfo, JOptionPane.OK_OPTION) == JOptionPane.OK_OPTION) { switchDebugger(); mainFrame.getPanel().refreshDecompiled(); } else { @@ -1188,10 +1188,10 @@ public abstract class MainFrameMenu implements MenuBuilder { listeners.add(Main.getMainFrame().getPanel().getActionPanel()); if (swf.isAS3()) { - sr = new SearchResultsDialog<>(Main.getMainFrame().getWindow(), searched, Main.searchResultsStorage.isIgnoreCaseAt(fi), Main.searchResultsStorage.isRegExpAt(fi), listeners); + sr = new SearchResultsDialog<>(Main.getDefaultDialogsOwner(), searched, Main.searchResultsStorage.isIgnoreCaseAt(fi), Main.searchResultsStorage.isRegExpAt(fi), listeners); } else { - sr = new SearchResultsDialog<>(Main.getMainFrame().getWindow(), searched, Main.searchResultsStorage.isIgnoreCaseAt(fi), Main.searchResultsStorage.isRegExpAt(fi), listeners); + sr = new SearchResultsDialog<>(Main.getDefaultDialogsOwner(), searched, Main.searchResultsStorage.isIgnoreCaseAt(fi), Main.searchResultsStorage.isRegExpAt(fi), listeners); } sr.setResults(Main.searchResultsStorage.getSearchResultsAt(mainFrame.getPanel().getAllSwfs(), fi)); sr.setVisible(true); @@ -1209,7 +1209,7 @@ public abstract class MainFrameMenu implements MenuBuilder { } protected void clearRecentSearchesForCurrentSwfActionPerformed(ActionEvent evt) { - if (View.showConfirmDialog(mainFrame.getPanel(), translate("message.confirm.recentSearches.clear"), translate("message.confirm"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { + if (ViewMessages.showConfirmDialog(Main.getDefaultMessagesComponent(), translate("message.confirm.recentSearches.clear"), translate("message.confirm"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { Main.searchResultsStorage.clearForSwf(swf); } } @@ -1223,7 +1223,7 @@ public abstract class MainFrameMenu implements MenuBuilder { final String f = recentFiles.get(i); ActionListener a = (ActionEvent e) -> { if (Main.openFile(f, null) == OpenFileResult.NOT_FOUND) { - if (View.showConfirmDialog(null, translate("message.confirm.recentFileNotFound"), translate("message.confirm"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_NO_OPTION) { + if (ViewMessages.showConfirmDialog(Main.getDefaultMessagesComponent(), translate("message.confirm.recentFileNotFound"), translate("message.confirm"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_NO_OPTION) { Configuration.removeRecentFile(f); } } diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java index dd93fc4bc..831065668 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameRibbonMenu.java @@ -190,9 +190,9 @@ public class MainFrameRibbonMenu extends MainFrameMenu { listeners.add(Main.getMainFrame().getPanel().getActionPanel()); SearchResultsDialog sr; if (swf.isAS3()) { - sr = new SearchResultsDialog<>(Main.getMainFrame().getWindow(), searched, Main.searchResultsStorage.isIgnoreCaseAt(fi), Main.searchResultsStorage.isRegExpAt(fi), listeners); + sr = new SearchResultsDialog<>(Main.getDefaultDialogsOwner(), searched, Main.searchResultsStorage.isIgnoreCaseAt(fi), Main.searchResultsStorage.isRegExpAt(fi), listeners); } else { - sr = new SearchResultsDialog<>(Main.getMainFrame().getWindow(), searched, Main.searchResultsStorage.isIgnoreCaseAt(fi), Main.searchResultsStorage.isRegExpAt(fi), listeners); + sr = new SearchResultsDialog<>(Main.getDefaultDialogsOwner(), searched, Main.searchResultsStorage.isIgnoreCaseAt(fi), Main.searchResultsStorage.isRegExpAt(fi), listeners); } sr.setResults(Main.searchResultsStorage.getSearchResultsAt(Main.getMainFrame().getPanel().getAllSwfs(), fi)); sr.setVisible(true); @@ -251,7 +251,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu { historyButton.addActionListener((ActionEvent ae) -> { RecentFilesButton source = (RecentFilesButton) ae.getSource(); if (Main.openFile(source.fileName, null) == OpenFileResult.NOT_FOUND) { - if (View.showConfirmDialog(null, translate("message.confirm.recentFileNotFound"), translate("message.confirm"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_NO_OPTION) { + if (ViewMessages.showConfirmDialog(Main.getDefaultMessagesComponent(), translate("message.confirm.recentFileNotFound"), translate("message.confirm"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_NO_OPTION) { Configuration.removeRecentFile(source.fileName); } } diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index bf02f1850..7c52d2790 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -602,7 +602,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se Path.createDirectorySafe(fTempDir); File ftemp = new File(tempDir); - ExportDialog exd = new ExportDialog(null); + ExportDialog exd = new ExportDialog(Main.getDefaultDialogsOwner(), null); try { files = exportSelection(new GuiAbortRetryIgnoreHandler(), tempDir, exd); } catch (InterruptedException ex) { @@ -751,7 +751,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se boolean valid; int characterId = -1; do { - val = View.showInputDialog(MainPanel.this, translate("message.input.gotoCharacter"), translate("message.input.gotoCharacter.title"), val); + val = ViewMessages.showInputDialog(MainPanel.this, translate("message.input.gotoCharacter"), translate("message.input.gotoCharacter.title"), val); if (val == null) { break; } @@ -765,7 +765,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (characterId > 0) { CharacterTag tag = swf.getCharacter(characterId); if (tag == null) { - View.showMessageDialog(MainPanel.this, translate("message.character.notfound").replace("%characterid%", "" + characterId), translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(MainPanel.this, translate("message.character.notfound").replace("%characterid%", "" + characterId), translate("error"), JOptionPane.ERROR_MESSAGE); } else { TreePath path = tagTree.getModel().getTreePath(tag); if (path != null) { @@ -958,7 +958,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se ? translate("message.confirm.closeAll") : translate("message.confirm.close").replace("{swfName}", swfList.toString()); - return View.showConfirmDialog(this, message, translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, Configuration.showCloseConfirmation, JOptionPane.OK_OPTION) == JOptionPane.OK_OPTION; + return ViewMessages.showConfirmDialog(this, message, translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, Configuration.showCloseConfirmation, JOptionPane.OK_OPTION) == JOptionPane.OK_OPTION; } public boolean isModified() { @@ -1132,11 +1132,11 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se public void renameIdentifier(SWF swf, String identifier) throws InterruptedException { String oldName = identifier; - String newName = View.showInputDialog(translate("rename.enternew"), oldName); + String newName = ViewMessages.showInputDialog(this, translate("rename.enternew"), oldName); if (newName != null) { if (!oldName.equals(newName)) { swf.renameAS2Identifier(oldName, newName); - View.showMessageDialog(null, translate("rename.finished.identifier")); + ViewMessages.showMessageDialog(this, translate("rename.finished.identifier")); updateClassesList(); reload(true); } @@ -1150,7 +1150,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se oldName = constants.getString(constants.getMultiname(multiNameIndex).name_index); } - String newName = View.showInputDialog(translate("rename.enternew"), oldName); + String newName = ViewMessages.showInputDialog(this, translate("rename.enternew"), oldName); if (newName != null) { if (!oldName.equals(newName)) { int mulCount = 0; @@ -1171,7 +1171,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se int fmulCount = mulCount; View.execInEventDispatch(() -> { - View.showMessageDialog(null, translate("rename.finished.multiname").replace("%count%", Integer.toString(fmulCount))); + ViewMessages.showMessageDialog(this, translate("rename.finished.multiname").replace("%count%", Integer.toString(fmulCount))); if (abcPanel != null) { abcPanel.reload(); } @@ -1212,7 +1212,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se public boolean confirmExperimental() { View.checkAccess(); - return View.showConfirmDialog(null, translate("message.confirm.experimental"), translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION; + return ViewMessages.showConfirmDialog(this, translate("message.confirm.experimental"), translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION; } public List exportSelection(AbortRetryIgnoreHandler handler, String selFile, ExportDialog export) throws IOException, InterruptedException { @@ -2001,7 +2001,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se sr.setVisible(true); searchResultsDialogs.add(sr); if (!found) { - View.showMessageDialog(null, translate("message.search.notfound").replace("%searchtext%", txt), translate("message.search.notfound.title"), JOptionPane.INFORMATION_MESSAGE); + ViewMessages.showMessageDialog(MainPanel.this, translate("message.search.notfound").replace("%searchtext%", txt), translate("message.search.notfound.title"), JOptionPane.INFORMATION_MESSAGE); } Main.stopWork(); @@ -2033,7 +2033,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se textSearchPanel.setSearchText(txt); boolean found = textSearchPanel.setResults(fTextResult); if (!found) { - View.showMessageDialog(null, translate("message.search.notfound").replace("%searchtext%", txt), translate("message.search.notfound.title"), JOptionPane.INFORMATION_MESSAGE); + ViewMessages.showMessageDialog(MainPanel.this, translate("message.search.notfound").replace("%searchtext%", txt), translate("message.search.notfound.title"), JOptionPane.INFORMATION_MESSAGE); } Main.stopWork(); @@ -2210,7 +2210,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se try { int cnt = get(); Main.stopWork(); - View.showMessageDialog(null, translate("message.rename.renamed").replace("%count%", Integer.toString(cnt))); + ViewMessages.showMessageDialog(MainPanel.this, translate("message.rename.renamed").replace("%count%", Integer.toString(cnt))); swf.assignClassesToSymbols(); swf.clearScriptCache(); if (abcPanel != null) { @@ -2221,7 +2221,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } catch (Exception ex) { logger.log(Level.SEVERE, "Error during renaming identifiers", ex); Main.stopWork(); - View.showMessageDialog(null, translate("error.occured").replace("%error%", ex.getClass().getSimpleName())); + ViewMessages.showMessageDialog(MainPanel.this, translate("error.occured").replace("%error%", ex.getClass().getSimpleName())); } }); } @@ -2260,7 +2260,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se }.execute(); } else { - View.showMessageDialog(null, translate("message.rename.notfound.multiname"), translate("message.rename.notfound.title"), JOptionPane.INFORMATION_MESSAGE); + ViewMessages.showMessageDialog(MainPanel.this, translate("message.rename.notfound.multiname"), translate("message.rename.notfound.title"), JOptionPane.INFORMATION_MESSAGE); } } else { final String identifier = getActionPanel().getStringUnderCursor(); @@ -2287,7 +2287,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } }.execute(); } else { - View.showMessageDialog(null, translate("message.rename.notfound.identifier"), translate("message.rename.notfound.title"), JOptionPane.INFORMATION_MESSAGE); + ViewMessages.showMessageDialog(MainPanel.this, translate("message.rename.notfound.identifier"), translate("message.rename.notfound.title"), JOptionPane.INFORMATION_MESSAGE); } } } @@ -2377,7 +2377,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } } catch (Exception ex) { logger.log(Level.SEVERE, "FLA export error", ex); - View.showMessageDialog(null, translate("error.export") + ": " + ex.getClass().getName() + " " + ex.getLocalizedMessage(), translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(MainPanel.this, translate("error.export") + ": " + ex.getClass().getName() + " " + ex.getLocalizedMessage(), translate("error"), JOptionPane.ERROR_MESSAGE); } Helper.freeMem(); return null; @@ -2432,14 +2432,14 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se public boolean handle(TextTag textTag) { String msg = translate("error.text.import"); logger.log(Level.SEVERE, "{0}{1}", new Object[]{msg, getTextTagInfo(textTag)}); - return View.showConfirmDialog(MainPanel.this, msg, translate("error"), JOptionPane.OK_CANCEL_OPTION, showAgainImportError, JOptionPane.OK_OPTION) != JOptionPane.OK_OPTION; + return ViewMessages.showConfirmDialog(MainPanel.this, msg, translate("error"), JOptionPane.OK_CANCEL_OPTION, showAgainImportError, JOptionPane.OK_OPTION) != JOptionPane.OK_OPTION; } @Override public boolean handle(TextTag textTag, String message, long line) { String msg = translate("error.text.invalid.continue").replace("%text%", message).replace("%line%", Long.toString(line)); logger.log(Level.SEVERE, "{0}{1}", new Object[]{msg, getTextTagInfo(textTag)}); - return View.showConfirmDialog(MainPanel.this, msg, translate("error"), JOptionPane.OK_CANCEL_OPTION, showAgainInvalidText, JOptionPane.OK_OPTION) != JOptionPane.OK_OPTION; + return ViewMessages.showConfirmDialog(MainPanel.this, msg, translate("error"), JOptionPane.OK_CANCEL_OPTION, showAgainInvalidText, JOptionPane.OK_OPTION) != JOptionPane.OK_OPTION; } }); @@ -2465,16 +2465,16 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se As3ScriptReplacerInterface r = As3ScriptReplacerFactory.createByConfig(); if (!r.isAvailable()) { if (r instanceof MxmlcAs3ScriptReplacer) { - if (View.showConfirmDialog(null, AppStrings.translate("message.flexpath.notset"), AppStrings.translate("error"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { + if (ViewMessages.showConfirmDialog(this, AppStrings.translate("message.flexpath.notset"), AppStrings.translate("error"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { Main.advancedSettings("paths"); } } else if (r instanceof FFDecAs3ScriptReplacer) { - if (View.showConfirmDialog(this, AppStrings.translate("message.playerpath.lib.notset"), AppStrings.translate("message.action.playerglobal.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { + if (ViewMessages.showConfirmDialog(this, AppStrings.translate("message.playerpath.lib.notset"), AppStrings.translate("message.action.playerglobal.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { Main.advancedSettings("paths"); } } else { //Not translated yet - just in case there are more Script replacers in the future. Unused now. - View.showConfirmDialog(this, "Current script replacer is not available", "Script replacer not available", JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE); + ViewMessages.showConfirmDialog(this, "Current script replacer is not available", "Script replacer not available", JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE); } return null; } @@ -2503,7 +2503,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se updateClassesList(); } - View.showMessageDialog(this, translate("import.script.result").replace("%count%", Integer.toString(countAs2 + countAs3))); + ViewMessages.showMessageDialog(this, translate("import.script.result").replace("%count%", Integer.toString(countAs2 + countAs3))); if (countAs2 != 0 || countAs3 != 0) { reload(true); } @@ -2551,7 +2551,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } else if (sel.isEmpty()) { return; } - final ExportDialog export = new ExportDialog(sel); + final ExportDialog export = new ExportDialog(Main.getDefaultDialogsOwner(), sel); if (export.showExportDialog() == AppDialog.OK_OPTION) { final String selFile = selectExportDir(); if (selFile != null) { @@ -2569,7 +2569,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } } catch (Exception ex) { logger.log(Level.SEVERE, "Error during export", ex); - View.showMessageDialog(null, translate("error.export") + ": " + ex.getClass().getName() + " " + ex.getLocalizedMessage()); + ViewMessages.showMessageDialog(null, translate("error.export") + ": " + ex.getClass().getName() + " " + ex.getLocalizedMessage()); } return null; } @@ -2678,7 +2678,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se return; } if (confirmExperimental()) { - RenameDialog renameDialog = new RenameDialog(); + RenameDialog renameDialog = new RenameDialog(Main.getDefaultDialogsOwner()); if (renameDialog.showRenameDialog() == AppDialog.OK_OPTION) { final RenameType renameType = renameDialog.getRenameType(); new CancellableWorker() { @@ -2699,7 +2699,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se try { int cnt = get(); Main.stopWork(); - View.showMessageDialog(null, translate("message.rename.renamed").replace("%count%", Integer.toString(cnt))); + ViewMessages.showMessageDialog(MainPanel.this, translate("message.rename.renamed").replace("%count%", Integer.toString(cnt))); swf.assignClassesToSymbols(); swf.clearScriptCache(); if (abcPanel != null) { @@ -2710,7 +2710,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } catch (Exception ex) { logger.log(Level.SEVERE, "Error during renaming identifiers", ex); Main.stopWork(); - View.showMessageDialog(null, translate("error.occured").replace("%error%", ex.getClass().getSimpleName())); + ViewMessages.showMessageDialog(MainPanel.this, translate("error.occured").replace("%error%", ex.getClass().getSimpleName())); } }); } @@ -2722,7 +2722,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se public void deobfuscate() { View.checkAccess(); - DeobfuscationDialog deobfuscationDialog = new DeobfuscationDialog(); + DeobfuscationDialog deobfuscationDialog = new DeobfuscationDialog(Main.getDefaultDialogsOwner()); if (deobfuscationDialog.showDialog() == AppDialog.OK_OPTION) { DeobfuscationLevel level = DeobfuscationLevel.getByLevel(deobfuscationDialog.codeProcessingLevel.getValue()); new CancellableWorker() { @@ -2762,7 +2762,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se protected void done() { View.execInEventDispatch(() -> { Main.stopWork(); - View.showMessageDialog(null, translate("work.deobfuscating.complete")); + ViewMessages.showMessageDialog(MainPanel.this, translate("work.deobfuscating.complete")); clearAllScriptCache(); getABCPanel().reload(); @@ -2915,7 +2915,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (f == null || !f.canDisplay(character)) { String msg = translate("error.font.nocharacter").replace("%char%", "" + character); logger.log(Level.SEVERE, "{0} FontId: {1} TextId: {2}", new Object[]{msg, font.getCharacterId(), textTag.getCharacterId()}); - ignoreMissingCharacters = View.showConfirmDialog(null, msg, translate("error"), + ignoreMissingCharacters = ViewMessages.showConfirmDialog(MainPanel.this, msg, translate("error"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE, showAgainIgnoreMissingCharacters, ignoreMissingCharacters ? JOptionPane.OK_OPTION : JOptionPane.CANCEL_OPTION) == JOptionPane.OK_OPTION; @@ -2940,7 +2940,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se editor.markError(); } - View.showMessageDialog(null, translate("error.text.invalid").replace("%text%", ex.text).replace("%line%", Long.toString(ex.line)), translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(MainPanel.this, translate("error.text.invalid").replace("%text%", ex.text).replace("%line%", Long.toString(ex.line)), translate("error"), JOptionPane.ERROR_MESSAGE); } return false; @@ -3033,7 +3033,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } if (!ok) { - View.showMessageDialog(null, translate("error.sound.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(this, translate("error.sound.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE); } else { reload(true); } @@ -3053,7 +3053,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se swf.clearImageCache(); } catch (IOException ex) { logger.log(Level.SEVERE, "Invalid image", ex); - View.showMessageDialog(null, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(this, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE); } reload(true); @@ -3081,7 +3081,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se swf.clearImageCache(); } catch (IOException ex) { logger.log(Level.SEVERE, "Invalid image", ex); - View.showMessageDialog(null, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(MainPanel.this, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE); } reload(true); } @@ -3136,7 +3136,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se swf.clearImageCache(); } catch (IOException ex) { logger.log(Level.SEVERE, "Invalid image", ex); - View.showMessageDialog(null, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(this, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE); } reload(true); } @@ -3144,7 +3144,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } private void showSvgImportWarning() { - View.showMessageDialog(null, AppStrings.translate("message.warning.svgImportExperimental"), AppStrings.translate("message.warning"), JOptionPane.WARNING_MESSAGE, Configuration.warningSvgImport); + ViewMessages.showMessageDialog(this, AppStrings.translate("message.warning.svgImportExperimental"), AppStrings.translate("message.warning"), JOptionPane.WARNING_MESSAGE, Configuration.warningSvgImport); } public void replaceAlphaButtonActionPerformed(ActionEvent evt) { @@ -3166,7 +3166,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se swf.clearImageCache(); } catch (IOException ex) { logger.log(Level.SEVERE, "Invalid alpha channel data", ex); - View.showMessageDialog(null, translate("error.image.alpha.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(this, translate("error.image.alpha.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE); } reload(true); diff --git a/src/com/jpexs/decompiler/flash/gui/NewVersionDialog.java b/src/com/jpexs/decompiler/flash/gui/NewVersionDialog.java index 429c37e1a..7d1590e02 100644 --- a/src/com/jpexs/decompiler/flash/gui/NewVersionDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/NewVersionDialog.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.Version; import java.awt.Container; import java.awt.Dimension; import java.awt.FlowLayout; +import java.awt.Window; import java.awt.event.ActionEvent; import java.text.DateFormat; import java.text.ParseException; @@ -46,7 +47,8 @@ public class NewVersionDialog extends AppDialog { private Version latestVersion; - public NewVersionDialog(List versions) { + public NewVersionDialog(Window owner, List versions) { + super(owner); setSize(new Dimension(300, 150)); Container cnt = getContentPane(); cnt.setLayout(new BoxLayout(cnt, BoxLayout.PAGE_AXIS)); @@ -146,7 +148,7 @@ public class NewVersionDialog extends AppDialog { if (View.navigateUrl(url)) { Main.exit(); } else { - View.showMessageDialog(null, translate("newvermessage").replace("%oldAppName%", ApplicationInfo.SHORT_APPLICATION_NAME).replace("%newAppName%", latestVersion.versionName).replace("%projectPage%", ApplicationInfo.PROJECT_PAGE), translate("newversion"), JOptionPane.INFORMATION_MESSAGE); + ViewMessages.showMessageDialog(this, translate("newvermessage").replace("%oldAppName%", ApplicationInfo.SHORT_APPLICATION_NAME).replace("%newAppName%", latestVersion.versionName).replace("%projectPage%", ApplicationInfo.PROJECT_PAGE), translate("newversion"), JOptionPane.INFORMATION_MESSAGE); } setVisible(false); diff --git a/src/com/jpexs/decompiler/flash/gui/RenameDialog.java b/src/com/jpexs/decompiler/flash/gui/RenameDialog.java index 1405ad490..7a7bdb320 100644 --- a/src/com/jpexs/decompiler/flash/gui/RenameDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/RenameDialog.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.RenameType; import com.jpexs.decompiler.flash.configuration.Configuration; import java.awt.BorderLayout; import java.awt.FlowLayout; +import java.awt.Window; import java.awt.event.ActionEvent; import javax.swing.BoxLayout; import javax.swing.ButtonGroup; @@ -45,7 +46,8 @@ public class RenameDialog extends AppDialog { private int result = ERROR_OPTION; - public RenameDialog() { + public RenameDialog(Window owner) { + super(owner); setSize(300, 150); setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); int renameType = Configuration.lastRenameType.get(); diff --git a/src/com/jpexs/decompiler/flash/gui/ReplaceCharacterDialog.java b/src/com/jpexs/decompiler/flash/gui/ReplaceCharacterDialog.java index 8c5f0e612..c2b7a754b 100644 --- a/src/com/jpexs/decompiler/flash/gui/ReplaceCharacterDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/ReplaceCharacterDialog.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.tags.base.CharacterTag; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; +import java.awt.Window; import java.awt.event.ActionEvent; import java.util.Map; import javax.swing.JButton; @@ -43,7 +44,8 @@ public class ReplaceCharacterDialog extends AppDialog { private int result = ERROR_OPTION; - public ReplaceCharacterDialog() { + public ReplaceCharacterDialog(Window owner) { + super(owner); setSize(400, 150); setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); setLayout(new BorderLayout()); diff --git a/src/com/jpexs/decompiler/flash/gui/ReplaceTraceDialog.java b/src/com/jpexs/decompiler/flash/gui/ReplaceTraceDialog.java index 9b892cb28..0fd388fef 100644 --- a/src/com/jpexs/decompiler/flash/gui/ReplaceTraceDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/ReplaceTraceDialog.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.gui; import java.awt.Container; import java.awt.FlowLayout; +import java.awt.Window; import java.awt.event.ActionEvent; import javax.swing.BoxLayout; import javax.swing.ButtonGroup; @@ -60,7 +61,8 @@ public class ReplaceTraceDialog extends AppDialog { return value; } - public ReplaceTraceDialog(String defaultVal) { + public ReplaceTraceDialog(Window owner, String defaultVal) { + super(owner); setTitle(translate("dialog.title")); Container cnt = getContentPane(); cnt.setLayout(new BoxLayout(cnt, BoxLayout.Y_AXIS)); diff --git a/src/com/jpexs/decompiler/flash/gui/SearchDialog.java b/src/com/jpexs/decompiler/flash/gui/SearchDialog.java index 7bb8a447f..cfa488ca2 100644 --- a/src/com/jpexs/decompiler/flash/gui/SearchDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/SearchDialog.java @@ -201,7 +201,7 @@ public class SearchDialog extends AppDialog { try { Pattern pat = Pattern.compile(searchField.getText()); } catch (PatternSyntaxException ex) { - View.showMessageDialog(null, translate("error.invalidregexp"), translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(this, translate("error.invalidregexp"), translate("error"), JOptionPane.ERROR_MESSAGE); return; } } diff --git a/src/com/jpexs/decompiler/flash/gui/SelectLanguageDialog.java b/src/com/jpexs/decompiler/flash/gui/SelectLanguageDialog.java index 67ae799db..408872fdb 100644 --- a/src/com/jpexs/decompiler/flash/gui/SelectLanguageDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/SelectLanguageDialog.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.configuration.Configuration; import java.awt.BorderLayout; import java.awt.Container; import java.awt.FlowLayout; +import java.awt.Window; import java.awt.event.ActionEvent; import java.util.Locale; import java.util.ResourceBundle; @@ -43,7 +44,8 @@ public class SelectLanguageDialog extends AppDialog { protected static final String[] languages = new String[]{"en", "ca", "cs", "zh", "de", "es", "fr", "hu", "it", "ja", "nl", "pl", "pt", "pt-BR", "ru", "sv", "tr", "uk"}; - public SelectLanguageDialog() { + public SelectLanguageDialog(Window owner) { + super(owner); setSize(350, 130); Container cnt1 = getContentPane(); JPanel cnt = new JPanel(); diff --git a/src/com/jpexs/decompiler/flash/gui/View.java b/src/com/jpexs/decompiler/flash/gui/View.java index abaa91aeb..16c3d9e2e 100644 --- a/src/com/jpexs/decompiler/flash/gui/View.java +++ b/src/com/jpexs/decompiler/flash/gui/View.java @@ -475,111 +475,6 @@ public class View { } } - public static int showOptionDialog(final Component parentComponent, final Object message, final String title, final int optionType, final int messageType, final Icon icon, final Object[] options, final Object initialValue) { - final int[] ret = new int[1]; - execInEventDispatch(() -> { - ret[0] = JOptionPane.showOptionDialog(parentComponent, message, title, optionType, messageType, icon, options, initialValue); - }); - return ret[0]; - } - - public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType) { - return showConfirmDialog(parentComponent, message, title, optionType, JOptionPane.PLAIN_MESSAGE); - } - - public static int showConfirmDialog(final Component parentComponent, final Object message, final String title, final int optionType, final int messageTyp) { - final int[] ret = new int[1]; - execInEventDispatch(() -> { - ret[0] = JOptionPane.showConfirmDialog(parentComponent, message, title, optionType, messageTyp); - }); - return ret[0]; - } - - public static int showConfirmDialog(Component parentComponent, String message, String title, int optionType, ConfigurationItem showAgainConfig, int defaultOption) { - return showConfirmDialog(parentComponent, message, title, optionType, JOptionPane.PLAIN_MESSAGE, showAgainConfig, defaultOption); - } - - public static int showConfirmDialog(final Component parentComponent, String message, final String title, final int optionType, final int messageType, ConfigurationItem showAgainConfig, int defaultOption) { - - JCheckBox donotShowAgainCheckBox = null; - JPanel warPanel = null; - if (showAgainConfig != null) { - if (!showAgainConfig.get()) { - return defaultOption; - } - - JLabel warLabel = new JLabel("" + message.replace("\r\n", "
") + ""); - warPanel = new JPanel(new BorderLayout()); - warPanel.add(warLabel, BorderLayout.CENTER); - donotShowAgainCheckBox = new JCheckBox(AppStrings.translate("message.confirm.donotshowagain")); - warPanel.add(donotShowAgainCheckBox, BorderLayout.SOUTH); - } - - final int[] ret = new int[1]; - final Object messageObj = warPanel == null ? message : warPanel; - execInEventDispatch(() -> { - ret[0] = JOptionPane.showConfirmDialog(parentComponent, messageObj, title, optionType, messageType); - }); - - if (donotShowAgainCheckBox != null) { - showAgainConfig.set(!donotShowAgainCheckBox.isSelected()); - } - - return ret[0]; - } - - public static void showMessageDialog(final Component parentComponent, final String message, final String title, final int messageType) { - showMessageDialog(parentComponent, message, title, messageType, null); - } - - public static void showMessageDialog(final Component parentComponent, final String message, final String title, final int messageType, ConfigurationItem showAgainConfig) { - - execInEventDispatch(() -> { - Object msg = message; - JCheckBox donotShowAgainCheckBox = null; - if (showAgainConfig != null) { - if (!showAgainConfig.get()) { - return; - } - - JLabel warLabel = new JLabel("" + message.replace("\r\n", "
") + ""); - final JPanel warPanel = new JPanel(new BorderLayout()); - warPanel.add(warLabel, BorderLayout.CENTER); - donotShowAgainCheckBox = new JCheckBox(AppStrings.translate("message.confirm.donotshowagain")); - warPanel.add(donotShowAgainCheckBox, BorderLayout.SOUTH); - msg = warPanel; - } - final Object fmsg = msg; - - JOptionPane.showMessageDialog(parentComponent, fmsg, title, messageType); - if (donotShowAgainCheckBox != null) { - showAgainConfig.set(!donotShowAgainCheckBox.isSelected()); - } - }); - } - - public static void showMessageDialog(final Component parentComponent, final Object message) { - execInEventDispatch(() -> { - JOptionPane.showMessageDialog(parentComponent, message); - }); - } - - public static String showInputDialog(final Object message, final Object initialSelection) { - final String[] ret = new String[1]; - execInEventDispatch(() -> { - ret[0] = JOptionPane.showInputDialog(message, initialSelection); - }); - return ret[0]; - } - - public static String showInputDialog(Component parentComponent, final Object message, final String title, final Object initialSelection) { - final String[] ret = new String[1]; - execInEventDispatch(() -> { - ret[0] = (String) JOptionPane.showInputDialog(parentComponent, message, title, JOptionPane.QUESTION_MESSAGE, null, null, initialSelection); - }); - return ret[0]; - } - public static SubstanceColorScheme getColorScheme() { return SubstanceColorSchemeUtilities.getActiveColorScheme(new JButton(), ComponentState.ENABLED); } diff --git a/src/com/jpexs/decompiler/flash/gui/ViewMessages.java b/src/com/jpexs/decompiler/flash/gui/ViewMessages.java new file mode 100644 index 000000000..fb8132710 --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/ViewMessages.java @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2021 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui; + +import com.jpexs.decompiler.flash.configuration.ConfigurationItem; +import java.awt.BorderLayout; +import java.awt.Component; +import javax.swing.Icon; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; + +/** + * + * @author JPEXS + */ +public class ViewMessages { + public static int showOptionDialog(final Component parentComponent, final Object message, final String title, final int optionType, final int messageType, final Icon icon, final Object[] options, final Object initialValue) { + final int[] ret = new int[1]; + View.execInEventDispatch(() -> { + ret[0] = JOptionPane.showOptionDialog(parentComponent, message, title, optionType, messageType, icon, options, initialValue); + }); + return ret[0]; + } + + public static int showConfirmDialog(Component parentComponent, Object message, String title, int optionType) { + return showConfirmDialog(parentComponent, message, title, optionType, JOptionPane.PLAIN_MESSAGE); + } + + public static int showConfirmDialog(final Component parentComponent, final Object message, final String title, final int optionType, final int messageTyp) { + final int[] ret = new int[1]; + View.execInEventDispatch(() -> { + ret[0] = JOptionPane.showConfirmDialog(parentComponent, message, title, optionType, messageTyp); + }); + return ret[0]; + } + + public static int showConfirmDialog(Component parentComponent, String message, String title, int optionType, ConfigurationItem showAgainConfig, int defaultOption) { + return showConfirmDialog(parentComponent, message, title, optionType, JOptionPane.PLAIN_MESSAGE, showAgainConfig, defaultOption); + } + + public static int showConfirmDialog(final Component parentComponent, String message, final String title, final int optionType, final int messageType, ConfigurationItem showAgainConfig, int defaultOption) { + + JCheckBox donotShowAgainCheckBox = null; + JPanel warPanel = null; + if (showAgainConfig != null) { + if (!showAgainConfig.get()) { + return defaultOption; + } + + JLabel warLabel = new JLabel("" + message.replace("\r\n", "
") + ""); + warPanel = new JPanel(new BorderLayout()); + warPanel.add(warLabel, BorderLayout.CENTER); + donotShowAgainCheckBox = new JCheckBox(AppStrings.translate("message.confirm.donotshowagain")); + warPanel.add(donotShowAgainCheckBox, BorderLayout.SOUTH); + } + + final int[] ret = new int[1]; + final Object messageObj = warPanel == null ? message : warPanel; + View.execInEventDispatch(() -> { + ret[0] = JOptionPane.showConfirmDialog(parentComponent, messageObj, title, optionType, messageType); + }); + + if (donotShowAgainCheckBox != null) { + showAgainConfig.set(!donotShowAgainCheckBox.isSelected()); + } + + return ret[0]; + } + + public static void showMessageDialog(final Component parentComponent, final String message, final String title, final int messageType) { + showMessageDialog(parentComponent, message, title, messageType, null); + } + + public static void showMessageDialog(final Component parentComponent, final String message, final String title, final int messageType, ConfigurationItem showAgainConfig) { + + View.execInEventDispatch(() -> { + Object msg = message; + JCheckBox donotShowAgainCheckBox = null; + if (showAgainConfig != null) { + if (!showAgainConfig.get()) { + return; + } + + JLabel warLabel = new JLabel("" + message.replace("\r\n", "
") + ""); + final JPanel warPanel = new JPanel(new BorderLayout()); + warPanel.add(warLabel, BorderLayout.CENTER); + donotShowAgainCheckBox = new JCheckBox(AppStrings.translate("message.confirm.donotshowagain")); + warPanel.add(donotShowAgainCheckBox, BorderLayout.SOUTH); + msg = warPanel; + } + final Object fmsg = msg; + + JOptionPane.showMessageDialog(parentComponent, fmsg, title, messageType); + if (donotShowAgainCheckBox != null) { + showAgainConfig.set(!donotShowAgainCheckBox.isSelected()); + } + }); + } + + public static void showMessageDialog(final Component parentComponent, final Object message) { + View.execInEventDispatch(() -> { + JOptionPane.showMessageDialog(parentComponent, message); + }); + } + + public static String showInputDialog(final Component parentComponent, final Object message, final Object initialSelection) { + final String[] ret = new String[1]; + View.execInEventDispatch(() -> { + ret[0] = JOptionPane.showInputDialog(parentComponent, message, initialSelection); + }); + return ret[0]; + } + + public static String showInputDialog(Component parentComponent, final Object message, final String title, final Object initialSelection) { + final String[] ret = new String[1]; + View.execInEventDispatch(() -> { + ret[0] = (String) JOptionPane.showInputDialog(parentComponent, message, title, JOptionPane.QUESTION_MESSAGE, null, null, initialSelection); + }); + return ret[0]; + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index db8256435..a1f9cecbb 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -58,6 +58,7 @@ import com.jpexs.decompiler.flash.gui.SearchListener; import com.jpexs.decompiler.flash.gui.SearchPanel; import com.jpexs.decompiler.flash.gui.TagEditorPanel; import com.jpexs.decompiler.flash.gui.View; +import com.jpexs.decompiler.flash.gui.ViewMessages; import com.jpexs.decompiler.flash.gui.abc.tablemodels.DecimalTableModel; import com.jpexs.decompiler.flash.gui.abc.tablemodels.DoubleTableModel; import com.jpexs.decompiler.flash.gui.abc.tablemodels.IntTableModel; @@ -1439,7 +1440,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener())); int int_type = abc.constants.getPublicQnameId("int", true); //abc.constants.forceGetMultinameId(new Multiname(Multiname.QNAME, abc.constants.forceGetStringId("int"), abc.constants.forceGetNamespaceId(new Namespace(Namespace.KIND_PACKAGE, abc.constants.forceGetStringId("")), 0), -1, -1, new ArrayList())); @@ -1614,7 +1615,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener existingClasses = new ArrayList<>(); private List spriteIdsWithDoInitAction; - public AddScriptDialog(SWF swf) { + public AddScriptDialog(Window owner, SWF swf) { + super(owner); setDefaultCloseOperation(HIDE_ON_CLOSE); setTitle(translate("dialog.title")); diff --git a/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java b/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java index 1553dfde9..ab3e3561b 100644 --- a/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java +++ b/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java @@ -240,7 +240,7 @@ public class DebuggerTools { public static void debuggerShowLog() { initDebugger(); if (Main.debugDialog == null) { - Main.debugDialog = new DebugLogDialog(debugger); + Main.debugDialog = new DebugLogDialog(Main.getDefaultDialogsOwner(), debugger); } Main.debugDialog.setVisible(true); } diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java index 58d9a5abf..36cc223b2 100644 --- a/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.exporters.amf.amf3.Amf3Exporter; import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.gui.FasterScrollPane; import com.jpexs.decompiler.flash.gui.View; +import com.jpexs.decompiler.flash.gui.ViewMessages; import com.jpexs.decompiler.flash.gui.editor.LineMarkedEditorPane; import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer; import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3ParseException; @@ -144,7 +145,7 @@ public class Amf3ValueEditor extends JPanel implements GenericTagEditor, FullSiz txthelp.setText(AppStrings.translate("generic.editor.amf3.help").replace("%scalar_samples%", SCALAR_SAMPLES).replace("%nonscalar_samples%", NONSCALAR_SAMPLES).replace("%reference_sample%", REFERENCE_SAMPLE)); txthelp.setEditable(false); helpButton.addActionListener((ActionEvent e) -> { - View.showMessageDialog(null, txthelp); + ViewMessages.showMessageDialog(this, txthelp); }); titlePanel.add(helpButton, BorderLayout.EAST); add(titlePanel, BorderLayout.NORTH); diff --git a/src/com/jpexs/decompiler/flash/gui/hexview/GotoAddressDialog.java b/src/com/jpexs/decompiler/flash/gui/hexview/GotoAddressDialog.java index 49af6e262..7ecdf548b 100644 --- a/src/com/jpexs/decompiler/flash/gui/hexview/GotoAddressDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/hexview/GotoAddressDialog.java @@ -22,6 +22,7 @@ import java.awt.BorderLayout; import java.awt.Container; import java.awt.FlowLayout; import java.awt.Font; +import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; @@ -43,7 +44,8 @@ public class GotoAddressDialog extends AppDialog { private final JCheckBox hexCheckBox; private boolean okPressed = false; - public GotoAddressDialog() { + public GotoAddressDialog(Window owner) { + super(owner); setDefaultCloseOperation(HIDE_ON_CLOSE); setTitle(translate("dialog.title")); lineTextField = new JTextField(10); diff --git a/src/com/jpexs/decompiler/flash/gui/hexview/HexView.java b/src/com/jpexs/decompiler/flash/gui/hexview/HexView.java index aa605308b..eefbfa8e1 100644 --- a/src/com/jpexs/decompiler/flash/gui/hexview/HexView.java +++ b/src/com/jpexs/decompiler/flash/gui/hexview/HexView.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.gui.hexview; import com.jpexs.decompiler.flash.gui.AppDialog; +import com.jpexs.decompiler.flash.gui.Main; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; @@ -164,7 +165,7 @@ public class HexView extends JTable { gotoAddressMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - Long value = new GotoAddressDialog().showDialog(); + Long value = new GotoAddressDialog(Main.getDefaultDialogsOwner()).showDialog(); if (value != null) { selectByte(value); } @@ -253,7 +254,7 @@ public class HexView extends JTable { @Override public void keyReleased(KeyEvent e) { if (e.isControlDown() && e.getKeyCode() == 'G') { - Long value = new GotoAddressDialog().showDialog(); + Long value = new GotoAddressDialog(Main.getDefaultDialogsOwner()).showDialog(); if (value != null) { selectByte(value); } diff --git a/src/com/jpexs/decompiler/flash/gui/pipes/FirstInstance.java b/src/com/jpexs/decompiler/flash/gui/pipes/FirstInstance.java index 7dc0fe244..63d37e958 100644 --- a/src/com/jpexs/decompiler/flash/gui/pipes/FirstInstance.java +++ b/src/com/jpexs/decompiler/flash/gui/pipes/FirstInstance.java @@ -94,7 +94,7 @@ public class FirstInstance { View.execInEventDispatch(new Runnable() { @Override public void run() { - Window wnd = Main.getMainFrame().getWindow(); + Window wnd = Main.getDefaultDialogsOwner(); wnd.setAlwaysOnTop(true); wnd.toFront(); wnd.requestFocus(); diff --git a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java index f57ea12e3..73d3fdc6d 100644 --- a/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java +++ b/src/com/jpexs/decompiler/flash/gui/player/PlayerControls.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.gui.MainPanel; import com.jpexs.decompiler.flash.gui.View; +import com.jpexs.decompiler.flash.gui.ViewMessages; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Cursor; @@ -461,7 +462,7 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { } }); - if (View.showConfirmDialog(this, gotoPanel, AppStrings.translate("preview.gotoframe.dialog.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) == JOptionPane.OK_OPTION) { + if (ViewMessages.showConfirmDialog(this, gotoPanel, AppStrings.translate("preview.gotoframe.dialog.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) == JOptionPane.OK_OPTION) { int frame = -1; try { frame = Integer.parseInt(frameField.getText()); @@ -469,7 +470,7 @@ public class PlayerControls extends JPanel implements MediaDisplayListener { //handled as -1 } if (frame <= 0 || frame > display.getTotalFrames()) { - View.showMessageDialog(this, AppStrings.translate("preview.gotoframe.dialog.frame.error").replace("%min%", "1").replace("%max%", "" + display.getTotalFrames()), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(this, AppStrings.translate("preview.gotoframe.dialog.frame.error").replace("%min%", "1").replace("%max%", "" + display.getTotalFrames()), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); return; } display.gotoFrame(frame - 1); diff --git a/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java b/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java index 16b22a717..e40206ec5 100644 --- a/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java @@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.gui.GuiAbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.gui.Main; import com.jpexs.decompiler.flash.gui.MainFrame; import com.jpexs.decompiler.flash.gui.View; +import com.jpexs.decompiler.flash.gui.ViewMessages; import com.jpexs.decompiler.flash.helpers.SWFDecompilerPlugin; import com.jpexs.helpers.Helper; import com.jpexs.helpers.utf8.Utf8InputStreamReader; @@ -420,7 +421,7 @@ public class ProxyFrame extends AppFrame implements CatchedListener, MouseListen try { Files.copy(new File(r.targetFile).toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING); } catch (IOException ex) { - View.showMessageDialog(this, translate("error.save.as") + "\r\n" + ex.getLocalizedMessage(), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(this, translate("error.save.as") + "\r\n" + ex.getLocalizedMessage(), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); } } } else { @@ -492,7 +493,7 @@ public class ProxyFrame extends AppFrame implements CatchedListener, MouseListen Files.copy(file.toPath(), new File(r.targetFile).toPath(), StandardCopyOption.REPLACE_EXISTING); tableModel.fireTableCellUpdated(sel[0], 1/*size*/); } catch (IOException ex) { - View.showMessageDialog(f, translate("error.replace") + "\r\n" + ex.getLocalizedMessage(), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(f, translate("error.replace") + "\r\n" + ex.getLocalizedMessage(), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE); } } } @@ -520,7 +521,7 @@ public class ProxyFrame extends AppFrame implements CatchedListener, MouseListen int[] sel = getSelectedRows(); if (sel.length > 0) { Replacement r = replacements.get(sel[0]); - String s = View.showInputDialog("URL", r.urlPattern); + String s = ViewMessages.showInputDialog(this, "URL", r.urlPattern); if (s != null) { r.urlPattern = s; tableModel.setValueAt(s, sel[0], 2/*url*/); @@ -575,7 +576,7 @@ public class ProxyFrame extends AppFrame implements CatchedListener, MouseListen } catch (NumberFormatException nfe) { } if ((port <= 0) || (port > 65535)) { - View.showMessageDialog(this, translate("error.port"), translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(this, translate("error.port"), translate("error"), JOptionPane.ERROR_MESSAGE); started = false; return; } diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index 5715c5453..63bba9043 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.gui.Main; import com.jpexs.decompiler.flash.gui.MainPanel; import com.jpexs.decompiler.flash.gui.ReplaceCharacterDialog; import com.jpexs.decompiler.flash.gui.View; +import com.jpexs.decompiler.flash.gui.ViewMessages; import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel; import com.jpexs.decompiler.flash.gui.action.AddScriptDialog; import com.jpexs.decompiler.flash.tags.ABCContainerTag; @@ -797,7 +798,7 @@ public class TagTreeContextMenu extends JPopupMenu { SWF swf = itemr.getSwf(); CharacterTag characterTag = (CharacterTag) itemr; int characterId = characterTag.getCharacterId(); - ReplaceCharacterDialog replaceCharacterDialog = new ReplaceCharacterDialog(); + ReplaceCharacterDialog replaceCharacterDialog = new ReplaceCharacterDialog(Main.getDefaultDialogsOwner()); if (replaceCharacterDialog.showDialog(swf, characterId) == AppDialog.OK_OPTION) { int newCharacterId = replaceCharacterDialog.getCharacterId(); swf.replaceCharacterTags(characterTag, newCharacterId); @@ -846,7 +847,7 @@ public class TagTreeContextMenu extends JPopupMenu { String parts[]; loopinput: while (true) { - className = View.showInputDialog(AppDialog.translateForDialog("classname", AddScriptDialog.class), className); + className = ViewMessages.showInputDialog(mainPanel, AppDialog.translateForDialog("classname", AddScriptDialog.class), className); if (className == null || className.isEmpty()) { return; } @@ -856,7 +857,7 @@ public class TagTreeContextMenu extends JPopupMenu { DottedChain classNameDc = new DottedChain(parts, ""); for (ABCContainerTag ct : swf.getAbcList()) { if (ct.getABC().findClassByName(classNameDc) > -1) { - View.showMessageDialog(mainPanel, AppDialog.translateForDialog("message.classexists", AddScriptDialog.class), mainPanel.translate("error"), JOptionPane.ERROR_MESSAGE); + ViewMessages.showMessageDialog(mainPanel, AppDialog.translateForDialog("message.classexists", AddScriptDialog.class), mainPanel.translate("error"), JOptionPane.ERROR_MESSAGE); continue loopinput; } } @@ -946,7 +947,7 @@ public class TagTreeContextMenu extends JPopupMenu { FolderItem folder = (FolderItem) sel.get(0); SWF swf = folder.getSwf(); - AddScriptDialog addScriptDialog = new AddScriptDialog(swf); + AddScriptDialog addScriptDialog = new AddScriptDialog(Main.getDefaultDialogsOwner(), swf); if (addScriptDialog.showDialog() == JOptionPane.OK_OPTION) { if ((addScriptDialog.getScriptType() == AddScriptDialog.TYPE_FRAME) || (addScriptDialog.getScriptType() == AddScriptDialog.TYPE_SPRITE_FRAME)) { @@ -1475,7 +1476,7 @@ public class TagTreeContextMenu extends JPopupMenu { confirmationMessage = mainPanel.translate("message.confirm.removemultiple" + (removeDependencies ? "" : ".nodep")).replace("%count%", Integer.toString(tagsToRemove.size() + itemsToRemove.size() + itemCountFix)); } - if (View.showConfirmDialog(this, confirmationMessage, mainPanel.translate("message.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { + if (ViewMessages.showConfirmDialog(mainPanel, confirmationMessage, mainPanel.translate("message.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { if (mainPanel.folderPreviewPanel.selectedItems.isEmpty()) { tagTree.clearSelection(); }