001: /*
002: * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
003: *
004: * http://izpack.org/
005: * http://izpack.codehaus.org/
006: *
007: * Copyright 2003 Jonathan Halliday
008: *
009: * Licensed under the Apache License, Version 2.0 (the "License");
010: * you may not use this file except in compliance with the License.
011: * You may obtain a copy of the License at
012: *
013: * http://www.apache.org/licenses/LICENSE-2.0
014: *
015: * Unless required by applicable law or agreed to in writing, software
016: * distributed under the License is distributed on an "AS IS" BASIS,
017: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018: * See the License for the specific language governing permissions and
019: * limitations under the License.
020: */
021:
022: package com.izforge.izpack.panels;
023:
024: import java.io.IOException;
025:
026: import net.n3.nanoxml.XMLElement;
027:
028: import com.izforge.izpack.installer.AutomatedInstallData;
029: import com.izforge.izpack.installer.PanelAutomation;
030: import com.izforge.izpack.installer.PanelAutomationHelper;
031: import com.izforge.izpack.installer.ProcessPanelWorker;
032: import com.izforge.izpack.util.AbstractUIProcessHandler;
033:
034: /**
035: * Functions to support automated usage of the CompilePanel
036: *
037: * @author Jonathan Halliday
038: * @author Tino Schwarze
039: */
040: public class ProcessPanelAutomationHelper extends PanelAutomationHelper
041: implements PanelAutomation, AbstractUIProcessHandler {
042:
043: private int noOfJobs = 0;
044:
045: private int currentJob = 0;
046:
047: /**
048: * Save data for running automated.
049: *
050: * @param installData installation parameters
051: * @param panelRoot unused.
052: */
053: public void makeXMLData(AutomatedInstallData installData,
054: XMLElement panelRoot) {
055: // not used here - during automatic installation, no automatic
056: // installation information is generated
057: }
058:
059: /**
060: * Perform the installation actions.
061: *
062: * @param panelRoot The panel XML tree root.
063: *
064: * @return true if processes were run successfully.
065: */
066: public boolean runAutomated(AutomatedInstallData idata,
067: XMLElement panelRoot) {
068: try {
069: ProcessPanelWorker worker = new ProcessPanelWorker(idata,
070: this );
071:
072: worker.run();
073:
074: return worker.getResult();
075: } catch (IOException e) {
076: e.printStackTrace();
077: return false;
078: }
079:
080: }
081:
082: public void logOutput(String message, boolean stderr) {
083: if (stderr) {
084: System.err.println(message);
085: } else {
086: System.out.println(message);
087: }
088: }
089:
090: /**
091: * Reports progress on System.out
092: *
093: * @see com.izforge.izpack.util.AbstractUIProcessHandler#startProcessing(int)
094: */
095: public void startProcessing(int noOfJobs) {
096: System.out.println("[ Starting processing ]");
097: this .noOfJobs = noOfJobs;
098: }
099:
100: /**
101: *
102: * @see com.izforge.izpack.util.AbstractUIProcessHandler#finishProcessing()
103: */
104: public void finishProcessing() {
105: System.out.println("[ Processing finished ]");
106: }
107:
108: /**
109: *
110: */
111: public void startProcess(String name) {
112: this .currentJob++;
113: System.out.println("Starting process " + name + " ("
114: + Integer.toString(this .currentJob) + "/"
115: + Integer.toString(this .noOfJobs) + ")");
116: }
117:
118: public void finishProcess() {
119: }
120: }
|