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: package com.izforge.izpack.panels;
022:
023: import com.izforge.izpack.Pack;
024: import net.n3.nanoxml.XMLElement;
025:
026: import com.izforge.izpack.installer.InstallData;
027: import com.izforge.izpack.installer.InstallerFrame;
028: import com.izforge.izpack.util.AbstractUIHandler;
029: import com.izforge.izpack.util.Debug;
030: import com.izforge.izpack.util.OsConstraint;
031: import java.util.ArrayList;
032: import java.util.HashMap;
033: import java.util.Iterator;
034:
035: /**
036: * The taget directory selection panel.
037: *
038: * @author Julien Ponge
039: * @author Jeff Gordon
040: */
041: public class UserPathPanel extends UserPathInputPanel {
042:
043: /**
044: *
045: */
046: private static final long serialVersionUID = 3256443616359429170L;
047: private static String this Name = "UserPathPanel";
048: private boolean _skip = false;
049: public static String pathVariableName = "UserPathPanelVariable";
050: public static String pathPackDependsName = "UserPathPanelDependsName";
051: public static String pathElementName = "UserPathPanelElement";
052: private XMLElement panelElement;
053:
054: /**
055: * The constructor.
056: *
057: * @param parent The parent window.
058: * @param idata The installation data.
059: */
060: public UserPathPanel(InstallerFrame parent, InstallData idata) {
061: super (parent, idata, this Name, parent.langpack
062: .getString(this Name + ".variableName"));
063: // load the default directory info (if present)
064: if (getDefaultDir() != null) {
065: idata.setVariable(pathVariableName, getDefaultDir());
066: }
067: }
068:
069: /** Called when the panel becomes active. */
070: public void panelActivate() {
071: boolean found = false;
072: System.out.println(this Name
073: + " looking for activation condition");
074: // Need to have a way to supress panel if not in selected packs.
075: String dependsName = idata.getVariable(pathPackDependsName);
076: if (dependsName != null && !(dependsName.equalsIgnoreCase(""))) {
077: System.out.println("Checking for pack dependency of "
078: + dependsName);
079: Iterator iter = idata.selectedPacks.iterator();
080: while (iter.hasNext()) {
081: Pack pack = (Pack) iter.next();
082: System.out.println("- Checking if " + pack.name
083: + " equals " + dependsName);
084: if (pack.name.equalsIgnoreCase(dependsName)) {
085: found = true;
086: System.out.println("-- Found " + dependsName
087: + ", panel will be shown");
088: break;
089: }
090: }
091: _skip = !(found);
092: } else {
093: System.out
094: .println("Not Checking for a pack dependency, panel will be shown");
095: _skip = false;
096: }
097: if (_skip) {
098: System.out.println(this Name + " will not be shown");
099: parent.skipPanel();
100: return;
101: }
102: super .panelActivate();
103: // Set the default or old value to the path selection panel.
104: _pathSelectionPanel
105: .setPath(idata.getVariable(pathVariableName));
106: }
107:
108: /**
109: * Indicates whether the panel has been validated or not.
110: *
111: * @return Whether the panel has been validated or not.
112: */
113: public boolean isValidated() {
114: // Standard behavior of PathInputPanel.
115: if (!super .isValidated()) {
116: return (false);
117: }
118: idata.setVariable(pathVariableName, _pathSelectionPanel
119: .getPath());
120: return (true);
121: }
122:
123: /**
124: * Asks to make the XML panel data.
125: *
126: * @param panelRoot The tree to put the data in.
127: */
128: public void makeXMLData(XMLElement panelRoot) {
129: if (!(_skip)) {
130: new UserPathPanelAutomationHelper().makeXMLData(idata,
131: panelRoot);
132: }
133: }
134:
135: /*
136: * (non-Javadoc)
137: *
138: * @see com.izforge.izpack.installer.IzPanel#getSummaryBody()
139: */
140: public String getSummaryBody() {
141: if (_skip) {
142: return null;
143: } else {
144: return (idata.getVariable(pathVariableName));
145: }
146: }
147: }
|