KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > izforge > izpack > panels > ProcessPanelAutomationHelper


1 /*
2  * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
3  *
4  * http://www.izforge.com/izpack/
5  * http://developer.berlios.de/projects/izpack/
6  *
7  * Copyright 2003 Jonathan Halliday
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package com.izforge.izpack.panels;
23
24 import java.io.IOException JavaDoc;
25
26 import net.n3.nanoxml.XMLElement;
27
28 import com.izforge.izpack.installer.AutomatedInstallData;
29 import com.izforge.izpack.installer.PanelAutomation;
30 import com.izforge.izpack.installer.PanelAutomationHelper;
31 import com.izforge.izpack.installer.ProcessPanelWorker;
32 import com.izforge.izpack.util.AbstractUIProcessHandler;
33
34 /**
35  * Functions to support automated usage of the CompilePanel
36  *
37  * @author Jonathan Halliday
38  * @author Tino Schwarze
39  */

40 public class ProcessPanelAutomationHelper extends PanelAutomationHelper implements PanelAutomation,
41         AbstractUIProcessHandler
42 {
43
44     private int noOfJobs = 0;
45
46     private int currentJob = 0;
47
48     /**
49      * Save data for running automated.
50      *
51      * @param installData installation parameters
52      * @param panelRoot unused.
53      */

54     public void makeXMLData(AutomatedInstallData installData, XMLElement panelRoot)
55     {
56         // not used here - during automatic installation, no automatic
57
// installation information is generated
58
}
59
60     /**
61      * Perform the installation actions.
62      *
63      * @param panelRoot The panel XML tree root.
64      *
65      * @return true if processes were run successfully.
66      */

67     public boolean runAutomated(AutomatedInstallData idata, XMLElement panelRoot)
68     {
69         try
70         {
71             ProcessPanelWorker worker = new ProcessPanelWorker(idata, this);
72
73             worker.run();
74             
75             return worker.getResult();
76         }
77         catch (IOException JavaDoc e)
78         {
79             e.printStackTrace();
80             return false;
81         }
82
83     }
84
85     public void logOutput(String JavaDoc message, boolean stderr)
86     {
87         if (stderr)
88         {
89             System.err.println(message);
90         }
91         else
92         {
93             System.out.println(message);
94         }
95     }
96
97     /**
98      * Reports progress on System.out
99      *
100      * @see com.izforge.izpack.util.AbstractUIProcessHandler#startProcessing(int)
101      */

102     public void startProcessing(int noOfJobs)
103     {
104         System.out.println("[ Starting processing ]");
105         this.noOfJobs = noOfJobs;
106     }
107
108     /**
109      *
110      * @see com.izforge.izpack.util.AbstractUIProcessHandler#finishProcessing()
111      */

112     public void finishProcessing()
113     {
114         System.out.println("[ Processing finished ]");
115     }
116
117     /**
118      *
119      */

120     public void startProcess(String JavaDoc name)
121     {
122         this.currentJob++;
123         System.out.println("Starting process " + name + " (" + Integer.toString(this.currentJob)
124                 + "/" + Integer.toString(this.noOfJobs) + ")");
125     }
126
127     public void finishProcess()
128     {
129     }
130 }
131
Popular Tags