home *** CD-ROM | disk | FTP | other *** search
- package netscape.applet;
-
- import java.io.PrintStream;
- import java.util.Enumeration;
- import java.util.Hashtable;
-
- class MozillaWindow {
- int MWContext;
- Hashtable frames;
- static int totalFrames;
- private static Hashtable windows = new Hashtable();
-
- MozillaWindow(int MWContext) {
- this.MWContext = MWContext;
- this.frames = new Hashtable();
- }
-
- void add(MozillaFrame frame) {
- this.frames.put(new Integer(frame.MWContext), frame);
- ++totalFrames;
- }
-
- void remove(MozillaFrame frame) {
- this.frames.remove(new Integer(frame.MWContext));
- --totalFrames;
- if (this.frames.size() == 0) {
- if (MozillaAppletContext.debug > 0) {
- System.err.println("# Remove window " + this.MWContext);
- }
-
- windows.remove(new Integer(this.MWContext));
- }
-
- }
-
- void change(MozillaFrame frame, int oldMWContext, int newMWContext) {
- this.frames.remove(new Integer(oldMWContext));
- this.frames.put(new Integer(newMWContext), frame);
- }
-
- MozillaFrame lookupFrame(int MWContext) {
- MozillaFrame frame = (MozillaFrame)this.frames.get(new Integer(MWContext));
- return frame;
- }
-
- static int numWindows() {
- return windows.size();
- }
-
- static MozillaWindow lookupOrCreate(int MWContext) {
- Integer key = new Integer(MWContext);
- MozillaWindow win = (MozillaWindow)windows.get(key);
- if (win == null) {
- win = new MozillaWindow(MWContext);
- windows.put(key, win);
- if (MozillaAppletContext.debug > 0) {
- System.err.println("# New window " + MWContext);
- }
- }
-
- return win;
- }
-
- static void dumpState(PrintStream out) {
- Enumeration e = windows.elements();
-
- while(e.hasMoreElements()) {
- MozillaWindow w = (MozillaWindow)e.nextElement();
- w.dumpState(out, 0);
- }
-
- }
-
- static void indent(PrintStream out, int i) {
- while(true) {
- --i;
- if (i < 0) {
- return;
- }
-
- out.print(" ");
- }
- }
-
- void dumpState(PrintStream out, int i) {
- indent(out, i);
- out.println("MozillaWindow MWContext=" + this.MWContext + "(" + this.frames.size() + " frames)");
- Enumeration e = this.frames.elements();
-
- while(e.hasMoreElements()) {
- MozillaFrame f = (MozillaFrame)e.nextElement();
- f.dumpState(out, i + 1);
- }
-
- }
- }
-