001: /*
002: * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
003: *
004: * http://izpack.org/
005: * http://izpack.codehaus.org/
006: *
007: * Licensed under the Apache License, Version 2.0 (the "License");
008: * you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS,
015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: * See the License for the specific language governing permissions and
017: * limitations under the License.
018: */
019:
020: package com.izforge.izpack.panels;
021:
022: import java.io.File;
023:
024: import com.izforge.izpack.gui.IzPanelLayout;
025: import com.izforge.izpack.gui.LabelFactory;
026: import com.izforge.izpack.installer.InstallData;
027: import com.izforge.izpack.installer.InstallerFrame;
028: import com.izforge.izpack.installer.IzPanel;
029: import com.izforge.izpack.util.Log;
030: import com.izforge.izpack.util.VariableSubstitutor;
031:
032: /**
033: * The simple finish panel class.
034: *
035: * @author Julien Ponge
036: */
037: public class SimpleFinishPanel extends IzPanel {
038:
039: /**
040: *
041: */
042: private static final long serialVersionUID = 3689911781942572085L;
043:
044: /** The variables substitutor. */
045: private VariableSubstitutor vs;
046:
047: /**
048: * The constructor.
049: *
050: * @param parent The parent.
051: * @param idata The installation data.
052: */
053: public SimpleFinishPanel(InstallerFrame parent, InstallData idata) {
054: super (parent, idata, new IzPanelLayout());
055: vs = new VariableSubstitutor(idata.getVariables());
056: }
057:
058: /**
059: * Indicates wether the panel has been validated or not.
060: *
061: * @return true if the panel has been validated.
062: */
063: public boolean isValidated() {
064: return true;
065: }
066:
067: /** Called when the panel becomes active. */
068: public void panelActivate() {
069: parent.lockNextButton();
070: parent.lockPrevButton();
071: parent.setQuitButtonText(parent.langpack
072: .getString("FinishPanel.done"));
073: parent.setQuitButtonIcon("done");
074: if (idata.installSuccess) {
075:
076: // We set the information
077: add(LabelFactory.create(parent.icons.getImageIcon("check")));
078: add(IzPanelLayout.createParagraphGap());
079: add(LabelFactory.create(parent.langpack
080: .getString("FinishPanel.success"), parent.icons
081: .getImageIcon("information"), LEADING), NEXT_LINE);
082: add(IzPanelLayout.createParagraphGap());
083: if (idata.uninstallOutJar != null) {
084: // We prepare a message for the uninstaller feature
085: String path = translatePath("$INSTALL_PATH")
086: + File.separator + "Uninstaller";
087:
088: add(LabelFactory.create(parent.langpack
089: .getString("FinishPanel.uninst.info"),
090: parent.icons.getImageIcon("information"),
091: LEADING), NEXT_LINE);
092: add(LabelFactory.create(path, parent.icons
093: .getImageIcon("empty"), LEADING), NEXT_LINE);
094: }
095: } else
096: add(LabelFactory.create(parent.langpack
097: .getString("FinishPanel.fail"), parent.icons
098: .getImageIcon("information"), LEADING));
099: getLayoutHelper().completeLayout(); // Call, or call not?
100: Log.getInstance().informUser();
101: }
102:
103: /**
104: * Translates a relative path to a local system path.
105: *
106: * @param destination The path to translate.
107: * @return The translated path.
108: */
109: private String translatePath(String destination) {
110: // Parse for variables
111: destination = vs.substitute(destination, null);
112:
113: // Convert the file separator characters
114: return destination.replace('/', File.separatorChar);
115: }
116: }
|