1 | // ----------------------------------------------------------------------
|
---|
2 | // filexfer - client for triggering nanoHUB file interactions
|
---|
3 | //
|
---|
4 | // This Java applet sits in the Web browser containing the Rappture
|
---|
5 | // VNC session. When the user triggers a file I/O operation in
|
---|
6 | // Rappture, Rappture sends a signal to this applet, which pops up
|
---|
7 | // a Web page to complete the file I/O transaction.
|
---|
8 | // ======================================================================
|
---|
9 | // AUTHOR: Michael McLennan, Purdue University
|
---|
10 | // Copyright (c) 2004-2005 Purdue Research Foundation
|
---|
11 | //
|
---|
12 | // See the file "license.terms" for information on usage and
|
---|
13 | // redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
---|
14 | // ======================================================================
|
---|
15 |
|
---|
16 | import java.net.*;
|
---|
17 | import java.io.*;
|
---|
18 | import java.awt.*;
|
---|
19 |
|
---|
20 | public class monitor extends Thread {
|
---|
21 | private filexfer parent;
|
---|
22 |
|
---|
23 | public monitor(filexfer parent) {
|
---|
24 | this.parent = parent;
|
---|
25 | }
|
---|
26 |
|
---|
27 | public void run() {
|
---|
28 | String line = "";
|
---|
29 | while (true) {
|
---|
30 | try {
|
---|
31 | line = parent.istream.readLine();
|
---|
32 | if (line == null) {
|
---|
33 | parent.status.append("\nCLOSED");
|
---|
34 | stop();
|
---|
35 | }
|
---|
36 | parent.status.append("\nread "+line);
|
---|
37 |
|
---|
38 | if (line.startsWith("url ")) {
|
---|
39 | URL url = new URL("http",
|
---|
40 | parent.getCodeBase().getHost(),
|
---|
41 | parent.port, line.substring(4));
|
---|
42 |
|
---|
43 | try {
|
---|
44 | parent.getAppletContext().showDocument(url,"_blank");
|
---|
45 | parent.status.append("\nlaunched "+url);
|
---|
46 | }
|
---|
47 | catch (Exception e) {
|
---|
48 | parent.status.append("\nBad URL "+url);
|
---|
49 | }
|
---|
50 | } else {
|
---|
51 | parent.status.append("huh? |"+line+"|");
|
---|
52 | }
|
---|
53 | }
|
---|
54 | catch (java.io.IOException e){
|
---|
55 | parent.status.append("\nI/O error: "+e.getMessage());
|
---|
56 | }
|
---|
57 | catch (Exception e) {
|
---|
58 | parent.status.append("\nInternal error: "+e.getMessage());
|
---|
59 | }
|
---|
60 | }
|
---|
61 | }
|
---|
62 | }
|
---|