diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/util/logging/JavaConsole.java | 70 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/util/logging/OutputController.java | 4 |
3 files changed, 65 insertions, 21 deletions
@@ -1,5 +1,17 @@ 2013-11-10 Jiri Vanek <[email protected]> + Fixed lock in awt threads. JavaConsole window is now disposed instead of hidden. + * netx/net/sourceforge/jnlp/util/logging/JavaConsole.java: (lastSize) new + global variable to remember last size of window.(contentPanel) moved from + local to global scope. (initializeWindow) extracted from (initialize), is + handling creation and filling of window. (showConsole) is now initializing + window, and (hideConsole) is disposing it. Added override annotations and + removed duplicate code. + * netx/net/sourceforge/jnlp/util/logging/OutputController.java: messageQueConsumer + thread is now named, and its wait, have timeout. + +2013-11-10 Jiri Vanek <[email protected]> + * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: removed suspicious return when (searchForMain) had null launchDesc diff --git a/netx/net/sourceforge/jnlp/util/logging/JavaConsole.java b/netx/net/sourceforge/jnlp/util/logging/JavaConsole.java index 939b755..52bc1aa 100644 --- a/netx/net/sourceforge/jnlp/util/logging/JavaConsole.java +++ b/netx/net/sourceforge/jnlp/util/logging/JavaConsole.java @@ -44,6 +44,8 @@ import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.util.Map; import java.util.Properties; import java.util.Set; @@ -73,6 +75,7 @@ public class JavaConsole { public Map<String, String> getLoaderInfo(); } private static JavaConsole console; + private static Dimension lastSize; public static JavaConsole getConsole() { if (console == null) { @@ -107,12 +110,42 @@ public class JavaConsole { private JDialog consoleWindow; private JTextArea stdErrText; private JTextArea stdOutText; + private JPanel contentPanel = new JPanel(); private ClassLoaderInfoProvider classLoaderInfoProvider; public JavaConsole() { initialize(); } + + private void initializeWindow() { + initializeWindow(lastSize, contentPanel); + } + + private void initializeWindow(Dimension size, JPanel content) { + consoleWindow = new JDialog((JFrame) null, R("DPJavaConsole")); + consoleWindow.addWindowListener(new WindowAdapter() { + + @Override + public void windowClosed(WindowEvent e) { + lastSize=consoleWindow.getSize(); + } + + }); + consoleWindow.setIconImages(ImageResources.INSTANCE.getApplicationImages()); + + consoleWindow.add(content); + consoleWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //HIDE_ON_CLOSE can cause shut down deadlock + consoleWindow.pack(); + if (size!=null){ + consoleWindow.setSize(size); + } else { + consoleWindow.setSize(new Dimension(900, 600)); + } + consoleWindow.setMinimumSize(new Dimension(900, 300)); + + } + /** * Initialize the console */ @@ -124,10 +157,8 @@ public class JavaConsole { OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e); } - consoleWindow = new JDialog((JFrame) null, R("DPJavaConsole")); - consoleWindow.setIconImages(ImageResources.INSTANCE.getApplicationImages()); - JPanel contentPanel = new JPanel(); + contentPanel = new JPanel(); contentPanel.setLayout(new GridBagLayout()); GridBagConstraints c; @@ -174,6 +205,7 @@ public class JavaConsole { buttonPanel.add(gcButton); gcButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { printMemoryInfo(); OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, "Performing Garbage Collection...."); @@ -187,6 +219,7 @@ public class JavaConsole { buttonPanel.add(finalizersButton); finalizersButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { printMemoryInfo(); OutputController.getLogger().log(OutputController.Level.MESSAGE_ALL, R("CONSOLErunningFinalizers")); @@ -200,6 +233,7 @@ public class JavaConsole { buttonPanel.add(memoryButton); memoryButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { printMemoryInfo(); } @@ -209,6 +243,7 @@ public class JavaConsole { buttonPanel.add(systemPropertiesButton); systemPropertiesButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { printSystemProperties(); } @@ -218,6 +253,7 @@ public class JavaConsole { buttonPanel.add(classloadersButton); classloadersButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { printClassLoaders(); } @@ -227,6 +263,7 @@ public class JavaConsole { buttonPanel.add(threadListButton); threadListButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { printThreadInfo(); } @@ -236,9 +273,11 @@ public class JavaConsole { buttonPanel.add(closeButton); closeButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { hideConsole(); } @@ -246,12 +285,6 @@ public class JavaConsole { } }); - consoleWindow.add(contentPanel); - consoleWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); - consoleWindow.pack(); - consoleWindow.setSize(new Dimension(900, 600)); - consoleWindow.setMinimumSize(new Dimension(900, 300)); - splitPane.setDividerLocation(0.5); splitPane.setResizeWeight(0.5); } @@ -260,25 +293,28 @@ public class JavaConsole { showConsole(false); } - public void showConsole(boolean b) { - consoleWindow.setModal(b); + public void showConsole(boolean modal) { + initializeWindow(); + consoleWindow.setModal(modal); consoleWindow.setVisible(true); } public void hideConsole() { consoleWindow.setModal(false); consoleWindow.setVisible(false); + consoleWindow.dispose(); } public void showConsoleLater() { showConsoleLater(false); } - public void showConsoleLater(final boolean b) { + public void showConsoleLater(final boolean modal) { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - JavaConsole.getConsole().showConsole(b); + JavaConsole.getConsole().showConsole(modal); } }); } @@ -286,6 +322,7 @@ public class JavaConsole { public void hideConsoleLater() { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { JavaConsole.getConsole().hideConsole(); } @@ -364,12 +401,7 @@ public class JavaConsole { } if (toShowConsole) { - SwingUtilities.invokeLater(new Runnable() { - - public void run() { - console.showConsole(); - } - }); + console.showConsoleLater(); } } diff --git a/netx/net/sourceforge/jnlp/util/logging/OutputController.java b/netx/net/sourceforge/jnlp/util/logging/OutputController.java index 3606e6c..6a6dcd6 100644 --- a/netx/net/sourceforge/jnlp/util/logging/OutputController.java +++ b/netx/net/sourceforge/jnlp/util/logging/OutputController.java @@ -102,7 +102,7 @@ public class OutputController { while (true) { try { synchronized (OutputController.this) { - OutputController.this.wait(); + OutputController.this.wait(1000); if (!(OutputController.this == null || messageQue.isEmpty())) { flush(); } @@ -199,7 +199,7 @@ public class OutputController { outLog = new PrintStreamLogger(out); errLog = new PrintStreamLogger(err); //itw logger have to be fully initialised before start - Thread t = new Thread(messageQueConsumer); + Thread t = new Thread(messageQueConsumer, "Output controller consumer daemon"); t.setDaemon(true); t.start(); //some messages were probably posted before start of consumer |