diff options
author | Jiri Vanek <[email protected]> | 2013-11-10 11:30:43 +0100 |
---|---|---|
committer | Jiri Vanek <[email protected]> | 2013-11-10 11:30:43 +0100 |
commit | 2a61c4b99672d8033b67ae8df8665c09e508941b (patch) | |
tree | 03185b7c00a2bc3a0a2d0d7485e4c3a4d9f91142 /netx/net/sourceforge/jnlp/util/logging | |
parent | cf63aa76a56b525aa72476725c5ce88f41ce39e9 (diff) |
Fixed lock in awt threads. JavaConsole window is now disposed instead of hidden.
Diffstat (limited to 'netx/net/sourceforge/jnlp/util/logging')
-rw-r--r-- | netx/net/sourceforge/jnlp/util/logging/JavaConsole.java | 70 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/util/logging/OutputController.java | 4 |
2 files changed, 53 insertions, 21 deletions
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 |