KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > dods > wizard > ExecThread


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  */

19
20 /*
21  *
22  * @author Nenad Vico
23  * @version 1.0.0 2003/02/26
24  *
25  */

26 package org.enhydra.dods.wizard;
27
28 import java.awt.Dimension JavaDoc;
29 import java.awt.Toolkit JavaDoc;
30 import java.io.BufferedReader JavaDoc;
31 import java.io.InputStreamReader JavaDoc;
32 import org.enhydra.dods.generator.ErrorReader;
33
34 /**
35  * This class building DODS. Output of this call will be shown in TraceDialog.
36  *
37  * @author Nenad Vico
38  * @version 1.0
39  */

40 public class ExecThread extends Thread JavaDoc {
41     
42     TraceDialog td = null; // trace dialog of this Thread
43
public ExecThread() {
44         td = new TraceDialog(DefaultDODSWizard.frame, "Building ...");
45     }
46
47     public void run() {
48         TraceDialog td = new TraceDialog(DefaultDODSWizard.frame, "Building ...");
49         Dimension JavaDoc dimension = Toolkit.getDefaultToolkit().getScreenSize();
50
51         td.setLocation((dimension.width - td.getSize().width) / 2,
52                 (dimension.height - td.getSize().height) / 2 - 10);
53         td.setVisible(true);
54         td.setDefaultFocus();
55         try {
56             
57             ErrorReader errorReader;
58             
59             Process JavaDoc process;
60             BufferedReader JavaDoc buffer;
61             BufferedReader JavaDoc error;
62             String JavaDoc s;
63
64             process = DefaultDODSWizard.getGenerator().generateAll(true);
65             if (process != null) {
66                 buffer = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getInputStream()));
67                 error = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(process.getErrorStream()));
68                 (new ErrorReader(error, true)).start();
69                 while ((s = buffer.readLine()) != null) {
70                     td.appendLine(s + "\n");
71                 }
72                 process.waitFor();
73                 int k = process.exitValue();
74             }
75             td.setButtonName("OK");
76             td.setTitle("Building (Done)");
77             DefaultDODSWizard.getGenerator().postGenerate();
78         } catch (Exception JavaDoc e) {
79             e.printStackTrace();
80         }
81     }
82 }
83
Popular Tags