harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r607321 - in /harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer: AppletFrame.java AppletInfo.java ViewerAppletContext.java ViewerAppletStub.java
Date Fri, 28 Dec 2007 20:17:35 GMT
Author: apetrenko
Date: Fri Dec 28 12:17:35 2007
New Revision: 607321

URL: http://svn.apache.org/viewvc?rev=607321&view=rev
Log:
Initial status bar implementation
Applet frames shutdown handler is implemented

Modified:
    harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java
    harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletInfo.java
    harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletContext.java
    harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletStub.java

Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java?rev=607321&r1=607320&r2=607321&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletFrame.java
Fri Dec 28 12:17:35 2007
@@ -20,17 +20,27 @@
 import java.applet.Applet;
 import java.awt.BorderLayout;
 import java.awt.Dimension;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.util.HashSet;
 
 import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
 
 class AppletFrame extends JFrame {
 	private final AppletInfo appletInfo;
 	private final Applet applet;
+	private final JLabel statusLabel;
+	
+	private static ShutdownHandler shutdownHandler = new ShutdownHandler();
 	
 	public AppletFrame(AppletInfo appletInfo) throws Exception {
 		this.appletInfo = appletInfo;
+		shutdownHandler.addFrame(this);
 		
 		// Load applet class
 		URL []urls = new URL[1];
@@ -42,8 +52,20 @@
 		
 		// Create applet pane
 		setLayout(new BorderLayout());
+		JPanel appletPanel = new JPanel();
+		appletPanel.add(applet);
+		add(appletPanel, BorderLayout.CENTER);
 		applet.setPreferredSize(new Dimension(appletInfo.getWidth(), appletInfo.getHeight()));
-		add(applet, BorderLayout.CENTER);
+		
+		// Create status pane
+		JPanel panel = new JPanel();
+		statusLabel = new JLabel();
+		panel.add(statusLabel);
+		add(panel, BorderLayout.SOUTH);
+		appletInfo.setStatusLabel(statusLabel);
+		
+		statusLabel.setMinimumSize(new Dimension(100, 40));
+		statusLabel.setHorizontalAlignment(SwingConstants.LEFT);
 
 		// Start applet and make frame visible
 		// Init should be called after pack to make components displayable
@@ -51,5 +73,38 @@
 		applet.init();
 		setVisible(true);		
 		applet.start();
+	}		
+	
+	private  static class ShutdownHandler implements WindowListener {
+		HashSet<JFrame> frameList = new HashSet<JFrame>();
+
+		public void windowActivated(WindowEvent e) {
+		}
+
+		public void windowClosed(WindowEvent e) {
+		}
+
+		public void windowClosing(WindowEvent e) {
+			frameList.remove(e.getWindow());
+			if (frameList.isEmpty())
+				System.exit(0);
+		}
+
+		public void windowDeactivated(WindowEvent e) {
+		}
+
+		public void windowDeiconified(WindowEvent e) {
+		}
+
+		public void windowIconified(WindowEvent e) {
+		}
+
+		public void windowOpened(WindowEvent e) {
+		}
+		
+		public void addFrame(JFrame frame) {
+			frameList.add(frame);
+			frame.addWindowListener(this);
+		}
 	}
 }

Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletInfo.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletInfo.java?rev=607321&r1=607320&r2=607321&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletInfo.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/AppletInfo.java
Fri Dec 28 12:17:35 2007
@@ -21,6 +21,8 @@
 import java.net.URL;
 import java.util.HashMap;
 
+import javax.swing.JLabel;
+
 public class AppletInfo {
 	private static final int DEFAULT_WIDTH=300;
 	private static final int DEFAULT_HEIGHT=200;	
@@ -31,6 +33,7 @@
 	private int width;
 	private int height;
 	private HashMap<String, String> params;
+	private JLabel statusLabel = null;
 	
 	public AppletInfo() {
 		params = new HashMap<String, String>();
@@ -94,5 +97,14 @@
 
 	public void setHeight(String heightStr) {		
 		this.height = (heightStr == null)?DEFAULT_HEIGHT:Integer.parseInt(heightStr);
+	}
+
+	public void setStatusLabel(JLabel statusLabel) {
+		this.statusLabel  = statusLabel;
+	}
+
+	public void setStatus(String text) {
+		if (statusLabel != null)
+			statusLabel.setText(text);
 	}
 }

Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletContext.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletContext.java?rev=607321&r1=607320&r2=607321&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletContext.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletContext.java
Fri Dec 28 12:17:35 2007
@@ -29,7 +29,10 @@
 import java.util.Iterator;
 
 class ViewerAppletContext implements AppletContext {
-	public ViewerAppletContext() {
+	private final AppletInfo appletInfo;
+
+	public ViewerAppletContext(AppletInfo appletInfo) {
+		this.appletInfo = appletInfo;
 	}
 
 	public Applet getApplet(String name) {
@@ -76,8 +79,6 @@
 	}
 
 	public void showStatus(String status) {
-		// TODO Auto-generated method stub
-
+		appletInfo.setStatus(status);
 	}
-
 }

Modified: harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletStub.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletStub.java?rev=607321&r1=607320&r2=607321&view=diff
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletStub.java
(original)
+++ harmony/enhanced/jdktools/trunk/modules/tools/src/main/java/org/apache/harmony/tools/appletviewer/ViewerAppletStub.java
Fri Dec 28 12:17:35 2007
@@ -23,13 +23,17 @@
 import java.awt.Dimension;
 import java.net.URL;
 
+import javax.swing.JLabel;
+
 class ViewerAppletStub implements AppletStub {
     private final Component appletPane;
     private final AppletInfo appletInfo;
+    private final AppletContext appletContext;
 
     ViewerAppletStub(Component appletPane, AppletInfo appletInfo) {
         this.appletPane = appletPane;
         this.appletInfo = appletInfo;
+        this.appletContext = new ViewerAppletContext(appletInfo);
     }
     
     public boolean isActive() {
@@ -49,7 +53,7 @@
     }
     
     public AppletContext getAppletContext() {
-        return new ViewerAppletContext();
+        return appletContext;
     }
     
     public void appletResize(int width, int height) {



Mime
View raw message