changeset in /hg/icedtea6: Wire in the JavaConsole coded by Omair.
Deepak Bhole
dbhole at redhat.com
Wed Feb 25 13:38:58 PST 2009
changeset aa17512747b1 in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=aa17512747b1
description:
Wire in the JavaConsole coded by Omair.
diffstat:
4 files changed, 74 insertions(+), 36 deletions(-)
ChangeLog | 10 ++++
IcedTeaPlugin.cc | 30 +++++++++----
plugin/icedtea/sun/applet/JavaConsole.java | 43 ++++++++------------
plugin/icedtea/sun/applet/PluginStreamHandler.java | 27 +++++++++++-
diffs (320 lines):
diff -r 9259bc9bee36 -r aa17512747b1 ChangeLog
--- a/ChangeLog Wed Feb 25 13:34:13 2009 -0500
+++ b/ChangeLog Wed Feb 25 16:38:54 2009 -0500
@@ -1,3 +1,13 @@ 2009-02-25 Omair Majid <omajid at redhat.
+2009-02-25 Deepak Bhole <dbhole at redhat.com>
+
+ * IcedTeaPlugin.cc: Implement Show/Hide from IJVMConsole, remove
+ IJVMPerfWindow stubs, as they were empty and unused.
+ * plugin/icedtea/sun/applet/JavaConsole.java: Pack components inside panel
+ rather than directly in the frame, to fix sizing issues. Addition
+ sizing/divider related code changes for aesthetics.
+ * plugin/icedtea/sun/applet/PluginStreamHandler.java: Wire in
+ showconsole/hideconsole functionality.
+
2009-02-25 Omair Majid <omajid at redhat.com>
* plugin/icedtea/sun/applet/PluginMain.java:
diff -r 9259bc9bee36 -r aa17512747b1 IcedTeaPlugin.cc
--- a/IcedTeaPlugin.cc Wed Feb 25 13:34:13 2009 -0500
+++ b/IcedTeaPlugin.cc Wed Feb 25 16:38:54 2009 -0500
@@ -715,7 +715,7 @@ extern "C" NS_EXPORT nsresult NSGetFacto
#include <nsIFactory.h>
#include <nsIPlugin.h>
#include <nsIJVMManager.h>
-#include <nsIJVMPrefsWindow.h>
+#include <nsIJVMConsole.h>
#include <nsIJVMPlugin.h>
#include <nsIInputStream.h>
#include <nsIAsyncInputStream.h>
@@ -933,8 +933,8 @@ class IcedTeaJNIEnv;
// nsIPlugin inherits from nsIFactory.
class IcedTeaPluginFactory : public nsIPlugin,
public nsIJVMManager,
- public nsIJVMPrefsWindow,
public nsIJVMPlugin,
+ public nsIJVMConsole,
public nsIInputStreamCallback
{
public:
@@ -942,11 +942,12 @@ public:
NS_DECL_NSIFACTORY
NS_DECL_NSIPLUGIN
NS_DECL_NSIJVMMANAGER
- // nsIJVMPrefsWindow does not provide an NS_DECL macro.
+ // nsIJVMConsole does not provide an NS_DECL macro.
public:
NS_IMETHOD Show (void);
NS_IMETHOD Hide (void);
NS_IMETHOD IsVisible (PRBool* result);
+ NS_IMETHOD Print(const char* msg, const char* encodingName = NULL);
// nsIJVMPlugin does not provide an NS_DECL macro.
public:
NS_IMETHOD AddToClassPath (char const* dirPath);
@@ -1472,7 +1473,7 @@ GetURLRunnable::Run ()
}
NS_IMPL_ISUPPORTS6 (IcedTeaPluginFactory, nsIFactory, nsIPlugin, nsIJVMManager,
- nsIJVMPrefsWindow, nsIJVMPlugin, nsIInputStreamCallback)
+ nsIJVMPlugin, nsIJVMConsole, nsIInputStreamCallback)
// IcedTeaPluginFactory functions.
IcedTeaPluginFactory::IcedTeaPluginFactory ()
@@ -1785,19 +1786,23 @@ IcedTeaPluginFactory::GetJavaEnabled (PR
return NS_ERROR_NOT_IMPLEMENTED;
}
-// nsIJVMPrefsWindow functions.
+#include <typeinfo>
+
+// nsIJVMConsole functions.
NS_IMETHODIMP
IcedTeaPluginFactory::Show (void)
{
- NOT_IMPLEMENTED ();
- return NS_ERROR_NOT_IMPLEMENTED;
+ nsCString msg("showconsole");
+ this->SendMessageToAppletViewer(msg);
+ return NS_OK;
}
NS_IMETHODIMP
IcedTeaPluginFactory::Hide (void)
{
- NOT_IMPLEMENTED ();
- return NS_ERROR_NOT_IMPLEMENTED;
+ nsCString msg("hideconsole");
+ this->SendMessageToAppletViewer(msg);
+ return NS_OK;
}
NS_IMETHODIMP
@@ -2280,6 +2285,13 @@ IcedTeaPluginFactory::DisplayFailureDial
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
+}
+
+NS_IMETHODIMP
+IcedTeaPluginFactory::Print(const char* msg, const char* encoding)
+{
+ NOT_IMPLEMENTED ();
+ return NS_ERROR_NOT_IMPLEMENTED;
}
#include <nsICookieService.h>
diff -r 9259bc9bee36 -r aa17512747b1 plugin/icedtea/sun/applet/JavaConsole.java
--- a/plugin/icedtea/sun/applet/JavaConsole.java Wed Feb 25 13:34:13 2009 -0500
+++ b/plugin/icedtea/sun/applet/JavaConsole.java Wed Feb 25 16:38:54 2009 -0500
@@ -37,7 +37,6 @@ exception statement from your version. *
package sun.applet;
-import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
@@ -49,7 +48,6 @@ import java.io.FileNotFoundException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
-import java.util.Collection;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -65,8 +63,6 @@ import javax.swing.border.EmptyBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
-import net.sourceforge.jnlp.runtime.JNLPClassLoader;
-
/**
* A simple Java console for IcedTeaPlugin
*
@@ -92,8 +88,8 @@ public class JavaConsole {
consoleWindow = new JFrame("Java Console");
- Container contentPane = consoleWindow.getContentPane();
- contentPane.setLayout(new GridBagLayout());
+ JPanel contentPanel = new JPanel();
+ contentPanel.setLayout(new GridBagLayout());
GridBagConstraints c;
@@ -133,7 +129,7 @@ public class JavaConsole {
c.gridheight = 10;
c.weighty = 1;
- contentPane.add(splitPane, c);
+ contentPanel.add(splitPane, c);
/* buttons */
@@ -144,12 +140,11 @@ public class JavaConsole {
c.weighty = 0;
JPanel buttonPanel = new JPanel();
- contentPane.add(buttonPanel, c);
+ contentPanel.add(buttonPanel, c);
JButton gcButton = new JButton("Run GC");
buttonPanel.add(gcButton);
gcButton.addActionListener(new ActionListener() {
- @Override
public void actionPerformed(ActionEvent e) {
printMemoryInfo();
System.out.print("Performing Garbage Collection....");
@@ -163,7 +158,6 @@ public class JavaConsole {
JButton finalizersButton = new JButton("Run Finalizers");
buttonPanel.add(finalizersButton);
finalizersButton.addActionListener(new ActionListener() {
- @Override
public void actionPerformed(ActionEvent e) {
printMemoryInfo();
System.out.print("Running finalization....");
@@ -177,7 +171,6 @@ public class JavaConsole {
buttonPanel.add(memoryButton);
memoryButton.addActionListener(new ActionListener() {
- @Override
public void actionPerformed(ActionEvent e) {
printMemoryInfo();
}
@@ -187,7 +180,6 @@ public class JavaConsole {
JButton systemPropertiesButton = new JButton("System Properties");
buttonPanel.add(systemPropertiesButton);
systemPropertiesButton.addActionListener(new ActionListener() {
- @Override
public void actionPerformed(ActionEvent e) {
printSystemProperties();
}
@@ -197,7 +189,6 @@ public class JavaConsole {
JButton classloadersButton = new JButton("Classloaders");
buttonPanel.add(classloadersButton);
classloadersButton.addActionListener(new ActionListener() {
- @Override
public void actionPerformed(ActionEvent e) {
printClassLoaders();
}
@@ -207,34 +198,37 @@ public class JavaConsole {
JButton threadListButton = new JButton("Thread List");
buttonPanel.add(threadListButton);
threadListButton.addActionListener(new ActionListener() {
- @Override
public void actionPerformed(ActionEvent e) {
printThreadInfo();
}
});
- JButton killVmButton = new JButton("Destory VM");
- buttonPanel.add(killVmButton);
- killVmButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- System.exit(0);
- }
-
+ JButton closeButton = new JButton("Close");
+ buttonPanel.add(closeButton);
+ closeButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ hideConsole();
+ }
+ });
+ }
});
stdOutUpdater.start();
stdErrUpdater.start();
- consoleWindow.setMinimumSize(new Dimension(500, 400));
+ consoleWindow.add(contentPanel);
consoleWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
consoleWindow.pack();
+ consoleWindow.setSize(new Dimension(900, 600));
+ consoleWindow.setMinimumSize(new Dimension(900, 300));
initialized = true;
splitPane.setDividerLocation(0.5);
-
+ splitPane.setResizeWeight(0.5);
}
public void showConsole() {
@@ -315,7 +309,6 @@ public class JavaConsole {
if (toShowConsole) {
SwingUtilities.invokeLater(new Runnable() {
- @Override
public void run() {
console.showConsole();
}
diff -r 9259bc9bee36 -r aa17512747b1 plugin/icedtea/sun/applet/PluginStreamHandler.java
--- a/plugin/icedtea/sun/applet/PluginStreamHandler.java Wed Feb 25 13:34:13 2009 -0500
+++ b/plugin/icedtea/sun/applet/PluginStreamHandler.java Wed Feb 25 16:38:54 2009 -0500
@@ -52,6 +52,8 @@ import java.util.Date;
import java.util.Date;
import java.util.LinkedList;
+import javax.swing.SwingUtilities;
+
public class PluginStreamHandler {
@@ -60,6 +62,8 @@ public class PluginStreamHandler {
private BufferedWriter pluginOutputWriter;
private RequestQueue queue = new RequestQueue();
+
+ private JavaConsole console = new JavaConsole();
LinkedList<String> writeQueue = new LinkedList<String>();
@@ -378,8 +382,11 @@ public class PluginStreamHandler {
AppletSecurityContextManager.dumpStore(0);
PluginDebug.debug("APPLETVIEWER: exiting appletviewer");
System.exit(0);
+ } else if (message.equals("showconsole")) {
+ showConsole();
+ } else if (message.equals("hideconsole")) {
+ hideConsole();
}
-
} catch (IOException e) {
e.printStackTrace();
}
@@ -428,7 +435,7 @@ public class PluginStreamHandler {
*/
}
-
+
public boolean messageAvailable() {
return writeQueue.size() != 0;
}
@@ -439,4 +446,20 @@ public class PluginStreamHandler {
return ret;
}
}
+
+ private void showConsole() {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ console.showConsole();
+ }
+ });
+ }
+
+ private void hideConsole() {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ console.hideConsole();
+ }
+ });
+ }
}
More information about the distro-pkg-dev
mailing list