KickJava   Java API By Example, From Geeks To Geeks.

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


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 net.n3.nanoxml.XMLElement;
25
26 import com.izforge.izpack.installer.AutomatedInstallData;
27 import com.izforge.izpack.installer.PanelAutomation;
28
29 /**
30  * Functions to support automated usage of the TargetPanel
31  *
32  * @author Jonathan Halliday
33  * @author Julien Ponge
34  */

35 public class TargetPanelAutomationHelper implements PanelAutomation
36 {
37
38     /**
39      * Asks to make the XML panel data.
40      *
41      * @param idata The installation data.
42      * @param panelRoot The tree to put the data in.
43      */

44     public void makeXMLData(AutomatedInstallData idata, XMLElement panelRoot)
45     {
46         // Installation path markup
47
XMLElement ipath = new XMLElement("installpath");
48         // check this writes even if value is the default,
49
// because without the constructor, default does not get set.
50
ipath.setContent(idata.getInstallPath());
51
52         // Checkings to fix bug #1864
53
XMLElement prev = panelRoot.getFirstChildNamed("installpath");
54         if (prev != null) panelRoot.removeChild(prev);
55
56         panelRoot.addChild(ipath);
57     }
58
59     /**
60      * Asks to run in the automated mode.
61      *
62      * @param idata The installation data.
63      * @param panelRoot The XML tree to read the data from.
64      *
65      * @return always true.
66      */

67     public boolean runAutomated(AutomatedInstallData idata, XMLElement panelRoot)
68     {
69         // We set the installation path
70
XMLElement ipath = panelRoot.getFirstChildNamed("installpath");
71         idata.setInstallPath(ipath.getContent());
72         return true;
73     }
74 }
75
Popular Tags