KickJava   Java API By Example, From Geeks To Geeks.

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


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 2004 Klaus Bartz
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.InstallData;
27 import com.izforge.izpack.installer.InstallerFrame;
28
29 /**
30  * The taget directory selection panel.
31  *
32  * @author Julien Ponge
33  */

34 public class TargetPanel extends PathInputPanel
35 {
36
37     /**
38      *
39      */

40     private static final long serialVersionUID = 3256443616359429170L;
41
42     /**
43      * The constructor.
44      *
45      * @param parent The parent window.
46      * @param idata The installation data.
47      */

48     public TargetPanel(InstallerFrame parent, InstallData idata)
49     {
50         super(parent, idata);
51         // load the default directory info (if present)
52
loadDefaultInstallDir(parent, idata);
53         if (getDefaultInstallDir() != null)
54         {
55             // override the system default that uses app name (which is set in
56
// the Installer class)
57
idata.setInstallPath(getDefaultInstallDir());
58         }
59     }
60
61     /** Called when the panel becomes active. */
62     public void panelActivate()
63     {
64         // Resolve the default for chosenPath
65
super.panelActivate();
66         // Set the default or old value to the path selection panel.
67
pathSelectionPanel.setPath(idata.getInstallPath());
68     }
69
70     /**
71      * This method simple delegates to <code>PathInputPanel.loadDefaultInstallDir</code> with the
72      * current parent as installer frame.
73      */

74     public void loadDefaultDir()
75     {
76         super.loadDefaultInstallDir(parent, idata);
77     }
78
79     /**
80      * Indicates wether the panel has been validated or not.
81      *
82      * @return Wether the panel has been validated or not.
83      */

84     public boolean isValidated()
85     {
86         // Standard behavior of PathInputPanel.
87
if (!super.isValidated()) return (false);
88         idata.setInstallPath(pathSelectionPanel.getPath());
89         return (true);
90     }
91
92     /**
93      * Returns the default install directory. This is equal to
94      * <code>PathInputPanel.getDefaultInstallDir</code>
95      *
96      * @return the default install directory
97      */

98     public String JavaDoc getDefaultDir()
99     {
100         return getDefaultInstallDir();
101     }
102
103     /**
104      * Sets the default install directory to the given String. This is equal to
105      * <code>PathInputPanel.setDefaultInstallDir</code>
106      *
107      * @param defaultDir path to be used for the install directory
108      */

109     public void setDefaultDir(String JavaDoc defaultDir)
110     {
111         setDefaultInstallDir(defaultDir);
112     }
113
114     /**
115      * Asks to make the XML panel data.
116      *
117      * @param panelRoot The tree to put the data in.
118      */

119     public void makeXMLData(XMLElement panelRoot)
120     {
121         new TargetPanelAutomationHelper().makeXMLData(idata, panelRoot);
122     }
123
124     /*
125      * (non-Javadoc)
126      *
127      * @see com.izforge.izpack.installer.IzPanel#getSummaryBody()
128      */

129     public String JavaDoc getSummaryBody()
130     {
131         return (idata.getInstallPath());
132     }
133 }
134
Popular Tags