Statistics
| Revision:

root / import / ext3D / trunk / install-extension3d / IzPack / src / lib / com / izforge / izpack / panels / InstallPanelAutomationHelper.java @ 15280

History | View | Annotate | Download (3.92 KB)

1
/*
2
 *  $Id: InstallPanelAutomationHelper.java,v 1.1 2006/06/14 07:29:07 cesar Exp $
3
 *  IzPack
4
 *  Copyright (C) 2003 Jonathan Halliday, Julien Ponge
5
 *
6
 *  File :               InstallPanelAutomationHelper.java
7
 *  Description :        Automation support functions for InstallPanel.
8
 *  Author's email :     jonathan.halliday@arjuna.com
9
 *  Author's Website :   http://www.arjuna.com
10
 *
11
 *  This program is free software; you can redistribute it and/or
12
 *  modify it under the terms of the GNU General Public License
13
 *  as published by the Free Software Foundation; either version 2
14
 *  of the License, or any later version.
15
 *
16
 *  This program is distributed in the hope that it will be useful,
17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 *  GNU General Public License for more details.
20
 *
21
 *  You should have received a copy of the GNU General Public License
22
 *  along with this program; if not, write to the Free Software
23
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24
 */
25
package com.izforge.izpack.panels;
26

    
27
import net.n3.nanoxml.XMLElement;
28

    
29
import com.izforge.izpack.installer.AutomatedInstallData;
30
import com.izforge.izpack.installer.PanelAutomation;
31
import com.izforge.izpack.installer.PanelAutomationHelper;
32
import com.izforge.izpack.installer.Unpacker;
33
import com.izforge.izpack.util.AbstractUIProgressHandler;
34

    
35
/**
36
 * Functions to support automated usage of the InstallPanel
37
 *
38
 * @author Jonathan Halliday
39
 */
40
public class InstallPanelAutomationHelper extends PanelAutomationHelper 
41
                                            implements PanelAutomation, AbstractUIProgressHandler
42
{
43
  // state var for thread sync.
44
  private boolean done = false;
45

    
46
  private int noOfPacks = 0;
47
  
48
  /**
49
   * Null op - this panel type has no state to serialize.
50
   *
51
   * @param installData unused.
52
   * @param panelRoot unused.
53
   */
54
  public void makeXMLData(AutomatedInstallData installData, XMLElement panelRoot)
55
  {
56
    // do nothing.
57
  }
58

    
59
  /**
60
   *  Perform the installation actions.
61
   *
62
   * @param panelRoot The panel XML tree root.
63
   */
64
  public void runAutomated(AutomatedInstallData idata, XMLElement panelRoot)
65
  {
66
    Unpacker unpacker = new Unpacker(idata, this);
67
    unpacker.start();
68
    done = false;
69
    while (!done && unpacker.isAlive())
70
    {
71
      try
72
      {
73
                          Thread.sleep(100);
74
      }
75
      catch (InterruptedException e)
76
      {
77
        // ignore it, we're waiting for the unpacker to finish...
78
      }
79
    }
80
  }
81

    
82
  /**
83
   * Reports progress on System.out
84
   *
85
   * @see AbstractUIProgressHandler#startAction(String, int)
86
   */
87
  public void startAction (String name, int no_of_steps)
88
  {
89
    System.out.println("[ Starting to unpack ]");
90
    this.noOfPacks = no_of_steps;
91
  }
92

    
93
  /**
94
   * Sets state variable for thread sync.
95
   *
96
   * @see com.izforge.izpack.util.AbstractUIProgressHandler#stopAction()
97
   */
98
  public void stopAction()
99
  {
100
    System.out.println("[ Unpacking finished. ]");
101
    done = true;
102
  }
103

    
104
  /**
105
   * Null op.
106
   *
107
   * @param val
108
   * @param msg
109
   * @see com.izforge.izpack.util.AbstractUIProgressHandler#progress(int, String)
110
   */
111
  public void progress(int val, String msg)
112
  {
113
    // silent for now. should log individual files here, if we had a verbose mode?
114
  }
115

    
116
  /**
117
   * Reports progress to System.out
118
   *
119
   * @param packName The currently installing pack.
120
   * @param stepno The number of the pack
121
   * @param stepsize unused
122
   * @see com.izforge.izpack.util.AbstractUIProgressHandler#nextStep(String, int, int)
123
   */
124
  public void nextStep (String packName, int stepno, int stepsize)
125
  {
126
    System.out.print("[ Processing package: " + packName +" (");
127
    System.out.print (stepno);
128
    System.out.print ('/');
129
    System.out.print (this.noOfPacks);
130
    System.out.println (") ]");
131
  }
132

    
133
}