Statistics
| Revision:

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

History | View | Annotate | Download (2.98 KB)

1
/*
2
 *  $Id: ImgPacksPanelAutomationHelper.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 :               ImgPacksPanelAutomationHelper.java
7
 *  Description :        Automation support functions for ImgPacksPanel.
8
 *  Author's email :     julien@izforge.com
9
 *  Author's Website :   http://www.izforge.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 java.util.Vector;
28

    
29
import net.n3.nanoxml.XMLElement;
30

    
31
import com.izforge.izpack.Pack;
32
import com.izforge.izpack.installer.AutomatedInstallData;
33
import com.izforge.izpack.installer.PanelAutomation;
34

    
35
/**
36
 * Functions to support automated usage of the ImgPacksPanel
37
 *
38
 * @author Jonathan Halliday
39
 * @author Julien Ponge
40
 */
41
public class ImgPacksPanelAutomationHelper implements PanelAutomation
42
{
43
        /**
44
         *  Asks to make the XML panel data.
45
         *
46
         * @param idata The installation data.
47
         * @param panelRoot The XML root to write the data in.
48
         */
49
        public void makeXMLData(AutomatedInstallData idata, XMLElement panelRoot)
50
        {
51
                // Selected packs markup
52
                XMLElement sel = new XMLElement("selected");
53

    
54
                // We add each selected pack to sel
55
                int size = idata.selectedPacks.size();
56
                for (int i = 0; i < size; i++)
57
                {
58
                        XMLElement el = new XMLElement("pack");
59
                        Pack pack = (Pack) idata.selectedPacks.get(i);
60
                        Integer integer = new Integer(idata.availablePacks.indexOf(pack));
61
                        el.setAttribute("index", integer.toString());
62
                        sel.addChild(el);
63
                }
64

    
65
                // Joining
66
                panelRoot.addChild(sel);
67
        }
68

    
69

    
70
        /**
71
         *  Asks to run in the automated mode.
72
         *
73
         * @param idata The installation data.
74
         * @param panelRoot The root of the panel data.
75
         */
76
        public void runAutomated(AutomatedInstallData idata, XMLElement panelRoot)
77
        {
78
                // We get the selected markup
79
                XMLElement sel = panelRoot.getFirstChildNamed("selected");
80

    
81
                // We get the packs markups
82
                Vector pm = sel.getChildrenNamed("pack");
83

    
84
                // We select each of them
85
                int size = pm.size();
86
                idata.selectedPacks.clear();
87
                for (int i = 0; i < size; i++)
88
                {
89
                        XMLElement el = (XMLElement) pm.get(i);
90
                        Integer integer = new Integer(el.getAttribute("index"));
91
                        int index = integer.intValue();
92
                        idata.selectedPacks.add(idata.availablePacks.get(index));
93
                }
94
        }
95
}