001: /*
002: * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
003: *
004: * http://izpack.org/
005: * http://izpack.codehaus.org/
006: *
007: * Copyright 2004 Klaus Bartz
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 net.n3.nanoxml.XMLElement;
025:
026: import com.izforge.izpack.installer.InstallData;
027: import com.izforge.izpack.installer.InstallerFrame;
028:
029: /**
030: * The taget directory selection panel.
031: *
032: * @author Julien Ponge
033: */
034: public class TargetPanel extends PathInputPanel {
035:
036: /**
037: *
038: */
039: private static final long serialVersionUID = 3256443616359429170L;
040:
041: /**
042: * The constructor.
043: *
044: * @param parent The parent window.
045: * @param idata The installation data.
046: */
047: public TargetPanel(InstallerFrame parent, InstallData idata) {
048: super (parent, idata);
049: // load the default directory info (if present)
050: loadDefaultInstallDir(parent, idata);
051: if (getDefaultInstallDir() != null) {
052: // override the system default that uses app name (which is set in
053: // the Installer class)
054: idata.setInstallPath(getDefaultInstallDir());
055: }
056: }
057:
058: /** Called when the panel becomes active. */
059: public void panelActivate() {
060: // Resolve the default for chosenPath
061: super .panelActivate();
062: // Set the default or old value to the path selection panel.
063: pathSelectionPanel.setPath(idata.getInstallPath());
064: }
065:
066: /**
067: * This method simple delegates to <code>PathInputPanel.loadDefaultInstallDir</code> with the
068: * current parent as installer frame.
069: */
070: public void loadDefaultDir() {
071: super .loadDefaultInstallDir(parent, idata);
072: }
073:
074: /**
075: * Indicates wether the panel has been validated or not.
076: *
077: * @return Wether the panel has been validated or not.
078: */
079: public boolean isValidated() {
080: // Standard behavior of PathInputPanel.
081: if (!super .isValidated())
082: return (false);
083: idata.setInstallPath(pathSelectionPanel.getPath());
084: return (true);
085: }
086:
087: /**
088: * Returns the default install directory. This is equal to
089: * <code>PathInputPanel.getDefaultInstallDir</code>
090: *
091: * @return the default install directory
092: */
093: public String getDefaultDir() {
094: return getDefaultInstallDir();
095: }
096:
097: /**
098: * Sets the default install directory to the given String. This is equal to
099: * <code>PathInputPanel.setDefaultInstallDir</code>
100: *
101: * @param defaultDir path to be used for the install directory
102: */
103: public void setDefaultDir(String defaultDir) {
104: setDefaultInstallDir(defaultDir);
105: }
106:
107: /**
108: * Asks to make the XML panel data.
109: *
110: * @param panelRoot The tree to put the data in.
111: */
112: public void makeXMLData(XMLElement panelRoot) {
113: new TargetPanelAutomationHelper().makeXMLData(idata, panelRoot);
114: }
115:
116: /*
117: * (non-Javadoc)
118: *
119: * @see com.izforge.izpack.installer.IzPanel#getSummaryBody()
120: */
121: public String getSummaryBody() {
122: return (idata.getInstallPath());
123: }
124:
125: }
|