1 |
/* AppletViewer.java - |
/* AppletViewer.java - a viewer for Java applets |
2 |
Copyright (C) 2003 Thomas Fitzsimmons <fitzsim@redhat.com> |
Copyright (C) 2003 Thomas Fitzsimmons <fitzsim@redhat.com> |
3 |
|
|
4 |
This program is free software; you can redistribute it and/or modify |
This file is part of gcjappletviewer. |
|
it under the terms of the GNU General Public License as published by |
|
|
the Free Software Foundation; either version 2 of the License, or |
|
|
(at your option) any later version. |
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
GNU General Public License for more details. |
|
|
|
|
|
You should have received a copy of the GNU General Public License |
|
|
along with this program; if not, write to the Free Software |
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
|
02111-1307 USA |
|
|
|
|
|
Linking this library statically or dynamically with other modules is |
|
|
making a combined work based on this library. Thus, the terms and |
|
|
conditions of the GNU General Public License cover the whole |
|
|
combination. |
|
|
|
|
|
As a special exception, the copyright holders of this library give you |
|
|
permission to link this library with independent modules to produce an |
|
|
executable, regardless of the license terms of these independent |
|
|
modules, and to copy and distribute the resulting executable under |
|
|
terms of your choice, provided that you also meet, for each linked |
|
|
independent module, the terms and conditions of the license of that |
|
|
module. An independent module is a module which is not derived from |
|
|
or based on this library. If you modify this library, you may extend |
|
|
this exception to your version of the library, but you are not |
|
|
obligated to do so. If you do not wish to do so, delete this |
|
|
exception statement from your version. */ |
|
5 |
|
|
6 |
|
gcjappletviewer is free software; you can redistribute it and/or |
7 |
|
modify it under the terms of the GNU General Public License as |
8 |
|
published by the Free Software Foundation; either version 2 of the |
9 |
|
License, or (at your option) any later version. |
10 |
|
|
11 |
|
gcjappletviewer is distributed in the hope that it will be useful, |
12 |
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
|
General Public License for more details. |
15 |
|
|
16 |
|
You should have received a copy of the GNU General Public License |
17 |
|
along with gcjappletviewer; if not, write to the Free Software |
18 |
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
|
|
20 |
|
Linking this library statically or dynamically with other modules |
21 |
|
is making a combined work based on this library. Thus, the terms |
22 |
|
and conditions of the GNU General Public License cover the whole |
23 |
|
combination. |
24 |
|
|
25 |
|
As a special exception, the copyright holders of this library give |
26 |
|
you permission to link this library with independent modules to |
27 |
|
produce an executable, regardless of the license terms of these |
28 |
|
independent modules, and to copy and distribute the resulting |
29 |
|
executable under terms of your choice, provided that you also meet, |
30 |
|
for each linked independent module, the terms and conditions of the |
31 |
|
license of that module. An independent module is a module which is |
32 |
|
not derived from or based on this library. If you modify this |
33 |
|
library, you may extend this exception to your version of the |
34 |
|
library, but you are not obligated to do so. If you do not wish to |
35 |
|
do so, delete this exception statement from your version. |
36 |
|
*/ |
37 |
|
|
38 |
package gnu.gcjwebplugin; |
package gnu.gcjwebplugin; |
39 |
|
|
134 |
try |
try |
135 |
{ |
{ |
136 |
String code = tag.code; |
String code = tag.code; |
137 |
if (code == null) |
if (code.equals("")) |
138 |
{ |
{ |
139 |
System.err.println ("didn't find code tag"); |
System.err.println ("didn't find code tag"); |
140 |
System.exit(-1); |
System.exit(-1); |
141 |
} |
} |
142 |
URLClassLoader loader; |
URLClassLoader loader; |
143 |
|
|
144 |
if (tag.archives != null) |
if (tag.archives.size() == 0) |
145 |
loader = new URLClassLoader(tag.archives); |
loader = new URLClassLoader |
146 |
|
(new URL [] { tag.prependCodebase ("") }); |
147 |
else |
else |
148 |
loader = new URLClassLoader(new URL [] { tag.prependCodebase ("") }); |
loader = new URLClassLoader |
149 |
|
((URL []) tag.archives.toArray (new URL [tag.archives.size()])); |
150 |
|
|
151 |
Thread.currentThread().setContextClassLoader(loader); |
Thread.currentThread().setContextClassLoader(loader); |
152 |
|
|
180 |
throws IOException |
throws IOException |
181 |
{ |
{ |
182 |
if (args.length == 0) |
if (args.length == 0) |
183 |
printHelpMessage (1); |
{ |
184 |
|
System.out.println ("gcjappletviewer: no input files"); |
185 |
|
printHelpMessage (1); |
186 |
|
} |
187 |
|
|
188 |
LongOpt[] longOptions = new LongOpt[] |
LongOpt[] longOptions = new LongOpt[] |
189 |
{ |
{ |
203 |
int optionValue; |
int optionValue; |
204 |
int optionIndex; |
int optionIndex; |
205 |
|
|
206 |
String archives = null; |
String archives = ""; |
207 |
List parameters = null; |
List parameters = new ArrayList (); |
208 |
Dimension dimensions = new Dimension (-1, -1); |
Dimension dimensions = new Dimension (-1, -1); |
209 |
|
|
210 |
boolean widthGiven = false; |
boolean widthGiven = false; |
220 |
if (optionIndex == 0) // --archive |
if (optionIndex == 0) // --archive |
221 |
archives = opts.getOptarg(); |
archives = opts.getOptarg(); |
222 |
else if (optionIndex == 1) // --param |
else if (optionIndex == 1) // --param |
223 |
{ |
parameters.add (opts.getOptarg()); |
|
if (parameters == null) |
|
|
parameters = new ArrayList (); |
|
|
parameters.add (opts.getOptarg()); |
|
|
} |
|
224 |
else if (optionIndex == 2) // --width |
else if (optionIndex == 2) // --width |
225 |
{ |
{ |
226 |
widthGiven = true; |
widthGiven = true; |
248 |
|
|
249 |
System.err.println (dimensions); |
System.err.println (dimensions); |
250 |
boolean classFileGiven = false; |
boolean classFileGiven = false; |
251 |
|
|
252 |
for (int i = opts.getOptind (); i < args.length; i++) |
int optind = opts.getOptind (); |
253 |
|
if (optind == args.length) |
254 |
|
{ |
255 |
|
System.out.println ("gcjappletviewer: no input files"); |
256 |
|
printHelpMessage (1); |
257 |
|
} |
258 |
|
|
259 |
|
for (int i = optind; i < args.length; i++) |
260 |
{ |
{ |
261 |
if (args[i].endsWith(".class")) |
if (args[i].endsWith(".class")) |
262 |
{ |
{ |
263 |
classFileGiven = true; |
classFileGiven = true; |
|
|
|
|
String[] paramArray = null; |
|
|
|
|
|
if (parameters != null) |
|
|
paramArray = |
|
|
(String []) parameters.toArray (new String[] { "" }); |
|
264 |
|
|
265 |
appletTags.add (new AppletTag (args[i], |
appletTags.add (new AppletTag (args[i], |
266 |
archives, |
archives, |
267 |
paramArray, |
parameters, |
268 |
dimensions)); |
dimensions)); |
269 |
break; |
break; |
270 |
} |
} |