KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19
20 package com.izforge.izpack.panels;
21
22 import java.io.File JavaDoc;
23
24 import com.izforge.izpack.gui.IzPanelLayout;
25 import com.izforge.izpack.gui.LabelFactory;
26 import com.izforge.izpack.installer.InstallData;
27 import com.izforge.izpack.installer.InstallerFrame;
28 import com.izforge.izpack.installer.IzPanel;
29 import com.izforge.izpack.util.VariableSubstitutor;
30
31 /**
32  * The simple finish panel class.
33  *
34  * @author Julien Ponge
35  */

36 public class SimpleFinishPanel extends IzPanel
37 {
38
39     /**
40      *
41      */

42     private static final long serialVersionUID = 3689911781942572085L;
43
44     /** The variables substitutor. */
45     private VariableSubstitutor vs;
46
47     /**
48      * The constructor.
49      *
50      * @param parent The parent.
51      * @param idata The installation data.
52      */

53     public SimpleFinishPanel(InstallerFrame parent, InstallData idata)
54     {
55         super(parent, idata, new IzPanelLayout());
56         vs = new VariableSubstitutor(idata.getVariables());
57     }
58
59     /**
60      * Indicates wether the panel has been validated or not.
61      *
62      * @return true if the panel has been validated.
63      */

64     public boolean isValidated()
65     {
66         return true;
67     }
68
69     /** Called when the panel becomes active. */
70     public void panelActivate()
71     {
72         parent.lockNextButton();
73         parent.lockPrevButton();
74         parent.setQuitButtonText(parent.langpack.getString("FinishPanel.done"));
75         parent.setQuitButtonIcon("done");
76         if (idata.installSuccess)
77         {
78             
79             // We set the information
80
add(LabelFactory.create(parent.icons.getImageIcon("check")));
81             add(IzPanelLayout.createParagraphGap());
82             add(LabelFactory.create(parent.langpack.getString("FinishPanel.success"),
83                     parent.icons.getImageIcon("information"), LEADING), NEXT_LINE);
84             add(IzPanelLayout.createParagraphGap());
85             if (idata.uninstallOutJar != null)
86             {
87                 // We prepare a message for the uninstaller feature
88
String JavaDoc path = translatePath("$INSTALL_PATH") + File.separator + "Uninstaller";
89
90                 add(LabelFactory.create(parent.langpack
91                         .getString("FinishPanel.uninst.info"), parent.icons
92                         .getImageIcon("information"), LEADING), NEXT_LINE);
93                 add(LabelFactory.create(path, parent.icons.getImageIcon("empty"),
94                         LEADING), NEXT_LINE);
95             }
96         }
97         else
98             add(LabelFactory.create(parent.langpack.getString("FinishPanel.fail"),
99                     parent.icons.getImageIcon("information"), LEADING));
100         getLayoutHelper().completeLayout(); // Call, or call not?
101

102     }
103
104     /**
105      * Translates a relative path to a local system path.
106      *
107      * @param destination The path to translate.
108      * @return The translated path.
109      */

110     private String JavaDoc translatePath(String JavaDoc destination)
111     {
112         // Parse for variables
113
destination = vs.substitute(destination, null);
114
115         // Convert the file separator characters
116
return destination.replace('/', File.separatorChar);
117     }
118 }
119
Popular Tags