/[gcjwebplugin]/gcjwebplugin/src/gnu/applet/AppletViewer.java
ViewVC logotype

Diff of /gcjwebplugin/src/gnu/applet/AppletViewer.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by fitzsim, Mon Sep 15 02:52:00 2003 UTC revision 1.2 by fitzsim, Sat Oct 25 18:03:53 2003 UTC
# Line 36  exception statement from your version. * Line 36  exception statement from your version. *
36    
37  package gnu.applet;  package gnu.applet;
38    
39    import java.io.*;
40  import java.applet.Applet;  import java.applet.Applet;
41  import gnu.getopt.Getopt;  import gnu.getopt.Getopt;
42  import gnu.getopt.LongOpt;  import gnu.getopt.LongOpt;
# Line 52  public class AppletViewer extends Frame Line 53  public class AppletViewer extends Frame
53    int width = 200;    int width = 200;
54    int height = 200;    int height = 200;
55    int xid;    int xid;
56      boolean pluginmode;
57    Frame frame;    Frame frame;
58    Applet applet;    Applet applet;
59    
# Line 61  public class AppletViewer extends Frame Line 63  public class AppletViewer extends Frame
63    {    {
64    }    }
65    
66      boolean pluginMode ()
67      {
68        return pluginmode;
69      }
70    
71      void createEmbeddedWindow (int xid)
72      {
73        System.err.println ("appletviewer: set xid to " + xid);
74        frame = new EmbeddedWindow (xid);
75        frame.setSize(width,height);
76      }
77    
78    void loadApplet ()    void loadApplet ()
79    {    {
80      if (code != null)      if (code != null)
# Line 79  public class AppletViewer extends Frame Line 93  public class AppletViewer extends Frame
93    {    {
94      if (frame != null)      if (frame != null)
95        {        {
96          System.out.println ("AppletViewer: showing applet");          System.err.println ("appletviewer: show applet");
97          loader.setFrame (frame);          loader.setFrame (frame);
         frame.setSize(width,height);  
98          frame.show();          frame.show();
99        }        }
100      applet.start();      applet.start();
# Line 98  public class AppletViewer extends Frame Line 111  public class AppletViewer extends Frame
111          new LongOpt ("parameters",   LongOpt.REQUIRED_ARGUMENT, null, 0),          new LongOpt ("parameters",   LongOpt.REQUIRED_ARGUMENT, null, 0),
112          new LongOpt ("width",        LongOpt.REQUIRED_ARGUMENT, null, 0),          new LongOpt ("width",        LongOpt.REQUIRED_ARGUMENT, null, 0),
113          new LongOpt ("height",       LongOpt.REQUIRED_ARGUMENT, null, 0),          new LongOpt ("height",       LongOpt.REQUIRED_ARGUMENT, null, 0),
114          new LongOpt ("xid",          LongOpt.REQUIRED_ARGUMENT, null, 0),          new LongOpt ("plugin",       LongOpt.NO_ARGUMENT,       null, 0),
115        };        };
116    
117      int optVal;      int optVal;
# Line 137  public class AppletViewer extends Frame Line 150  public class AppletViewer extends Frame
150                  height = Integer.parseInt(opts.getOptarg());                  height = Integer.parseInt(opts.getOptarg());
151                  break;                  break;
152                case 7:                case 7:
153                  xid = Integer.parseInt(opts.getOptarg());                  pluginmode = true;
                   
154                  break;                  break;
155                }                }
156            }            }
157        }        }
158      if (xid != 0)      if (!pluginmode)
159        {        {
160          System.out.println ("AppletViewer: plugin mode: xid = " + xid);          System.err.println ("AppletViewer: standalone mode");
         frame = new EmbeddedWindow (xid);  
       }  
     else  
       {  
         System.out.println ("AppletViewer: standalone mode");  
161          frame = this;          frame = this;
162        }        }
163    
164      System.out.println ("AppletViewer: code: " + code + "\n" +      System.err.println ("AppletViewer:\n" +
165                            "code: " + code + "\n" +
166                          "codebase: " + codebase + "\n" +                          "codebase: " + codebase + "\n" +
167                          "archive: " + archive + "\n" +                          "archive: " + archive + "\n" +
168                          "documentbase: " + documentbase + "\n" +                          "documentbase: " + documentbase + "\n" +
169                          "parameters: " + parameters + "\n" +                          "parameters: " + parameters + "\n" +
170                          "width: " + width + "\n" +                          "width: " + width + "\n" +
171                          "height: " + height + "\n");                          "height: " + height + "\n" +
172                            "pluginmode: " + pluginmode);
173    }    }
174    
175    public static void main (String[] args)    public static void main (String[] args) throws java.io.IOException
176    {    {
177        BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
178        BufferedWriter stdout = new BufferedWriter (new OutputStreamWriter (System.out));
179        String input;
180    
181      AppletViewer viewer = new AppletViewer ();      AppletViewer viewer = new AppletViewer ();
182      viewer.parseArgs(args);      viewer.parseArgs(args);
183      viewer.loadApplet();      if (viewer.pluginMode())
184      viewer.showApplet();        {
185            // Tell plugin that we've started.
186            stdout.write ("running", 0, "running".length());
187            stdout.newLine ();
188            stdout.flush ();
189    
190            System.err.println ("appletviewer wrote running");
191    
192            while (true)
193              {
194                // Wait for input from plugin on stdin.
195                input = stdin.readLine ();
196    
197                System.err.println ("  PIPE: appletviewer read " + input);
198    
199                // Return confirmation string to plugin.
200                stdout.write (input, 0, input.length());
201                stdout.newLine ();
202                stdout.flush ();
203    
204                System.err.println ("  PIPE: appletviewer wrote " + input);
205    
206                if (input.compareTo ("xid") == 0)
207                  {
208                    input = stdin.readLine();
209    
210                    System.err.println ("  PIPE: appletviewer read " + input);
211    
212                    // Return confirmation string to plugin.
213                    stdout.write (input, 0, input.length());
214                    stdout.newLine ();
215                    stdout.flush ();
216    
217                    System.err.println ("  PIPE: appletviewer wrote " + input);
218    
219                    // Read the plugin window's xid in hexadecimal.
220                    int xid = Integer.decode(input).intValue();
221                    viewer.createEmbeddedWindow (xid);
222                    viewer.loadApplet();
223                    viewer.showApplet();
224                  }
225                else if (input.compareTo ("shutdown") == 0)
226                  {
227                    System.err.println ("appletviewer: shutting down");
228                    System.exit(0);
229                  }
230              }
231          }
232        else
233          {
234            viewer.loadApplet();
235            viewer.showApplet();
236          }
237    }    }
238  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26