root / trunk / build / distribution / IzPack / src / lib / com / izforge / izpack / panels / SimpleFinishPanel.java @ 21757
History | View | Annotate | Download (4.62 KB)
1 |
/*
|
---|---|
2 |
* $Id: SimpleFinishPanel.java 5819 2006-06-14 07:29:09Z cesar $
|
3 |
* IzPack
|
4 |
* Copyright (C) 2001-2004 Julien Ponge
|
5 |
*
|
6 |
* File : SimpleFinishPanel.java
|
7 |
* Description : A simple and fancy panel to end with the installation
|
8 |
* without offering automated installation features.
|
9 |
* Author's email : julien@izforge.com
|
10 |
* Author's Website : http://www.izforge.com
|
11 |
*
|
12 |
* This program is free software; you can redistribute it and/or
|
13 |
* modify it under the terms of the GNU General Public License
|
14 |
* as published by the Free Software Foundation; either version 2
|
15 |
* of the License, or any later version.
|
16 |
*
|
17 |
* This program is distributed in the hope that it will be useful,
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
20 |
* GNU General Public License for more details.
|
21 |
*
|
22 |
* You should have received a copy of the GNU General Public License
|
23 |
* along with this program; if not, write to the Free Software
|
24 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
25 |
*/
|
26 |
package com.izforge.izpack.panels; |
27 |
|
28 |
import java.awt.GridBagConstraints; |
29 |
import java.awt.GridBagLayout; |
30 |
import java.awt.Insets; |
31 |
import java.io.File; |
32 |
|
33 |
import javax.swing.Box; |
34 |
import javax.swing.BoxLayout; |
35 |
import javax.swing.JLabel; |
36 |
import javax.swing.JPanel; |
37 |
|
38 |
import com.izforge.izpack.gui.LabelFactory; |
39 |
import com.izforge.izpack.installer.InstallData; |
40 |
import com.izforge.izpack.installer.InstallerFrame; |
41 |
import com.izforge.izpack.installer.IzPanel; |
42 |
import com.izforge.izpack.installer.VariableSubstitutor; |
43 |
|
44 |
/**
|
45 |
* The simple finish panel class.
|
46 |
*
|
47 |
* @author Julien Ponge
|
48 |
*/
|
49 |
public class SimpleFinishPanel extends IzPanel |
50 |
{ |
51 |
|
52 |
/** The layout. */
|
53 |
private BoxLayout layout; |
54 |
|
55 |
/** The center panel. */
|
56 |
protected JPanel centerPanel; |
57 |
|
58 |
/** The variables substitutor. */
|
59 |
private VariableSubstitutor vs;
|
60 |
|
61 |
/**
|
62 |
* The constructor.
|
63 |
*
|
64 |
* @param parent The parent.
|
65 |
* @param idata The installation data.
|
66 |
*/
|
67 |
public SimpleFinishPanel(InstallerFrame parent, InstallData idata)
|
68 |
{ |
69 |
super(parent, idata);
|
70 |
|
71 |
vs = new VariableSubstitutor(idata.getVariables());
|
72 |
|
73 |
// The 'super' layout
|
74 |
GridBagLayout superLayout = new GridBagLayout(); |
75 |
setLayout(superLayout); |
76 |
GridBagConstraints gbConstraints = new GridBagConstraints(); |
77 |
gbConstraints.insets = new Insets(0, 0, 0, 0); |
78 |
gbConstraints.fill = GridBagConstraints.NONE;
|
79 |
gbConstraints.anchor = GridBagConstraints.CENTER;
|
80 |
|
81 |
// We initialize our 'real' layout
|
82 |
centerPanel = new JPanel(); |
83 |
layout = new BoxLayout(centerPanel, BoxLayout.Y_AXIS); |
84 |
centerPanel.setLayout(layout); |
85 |
superLayout.addLayoutComponent(centerPanel, gbConstraints); |
86 |
add(centerPanel); |
87 |
} |
88 |
|
89 |
/**
|
90 |
* Indicates wether the panel has been validated or not.
|
91 |
*
|
92 |
* @return true if the panel has been validated.
|
93 |
*/
|
94 |
public boolean isValidated() |
95 |
{ |
96 |
return true; |
97 |
} |
98 |
|
99 |
/** Called when the panel becomes active. */
|
100 |
public void panelActivate() |
101 |
{ |
102 |
parent.lockNextButton(); |
103 |
parent.lockPrevButton(); |
104 |
parent.setQuitButtonText(parent.langpack.getString("FinishPanel.done"));
|
105 |
if (idata.installSuccess)
|
106 |
{ |
107 |
// We set the information
|
108 |
centerPanel.add(LabelFactory.create(parent.icons.getImageIcon("check")));
|
109 |
centerPanel.add(Box.createVerticalStrut(20)); |
110 |
centerPanel.add(LabelFactory.create(parent.langpack |
111 |
.getString("FinishPanel.success"), parent.icons
|
112 |
.getImageIcon("information"), JLabel.TRAILING)); |
113 |
centerPanel.add(Box.createVerticalStrut(20)); |
114 |
|
115 |
if (idata.uninstallOutJar != null) |
116 |
{ |
117 |
// We prepare a message for the uninstaller feature
|
118 |
String path = translatePath("$INSTALL_PATH") + File.separator |
119 |
+ "Uninstaller";
|
120 |
|
121 |
centerPanel.add(LabelFactory.create(parent.langpack |
122 |
.getString("FinishPanel.uninst.info"), parent.icons
|
123 |
.getImageIcon("information"), JLabel.TRAILING)); |
124 |
centerPanel.add(LabelFactory.create(path, parent.icons.getImageIcon("empty"),
|
125 |
JLabel.TRAILING));
|
126 |
} |
127 |
} |
128 |
} |
129 |
|
130 |
/**
|
131 |
* Translates a relative path to a local system path.
|
132 |
*
|
133 |
* @param destination The path to translate.
|
134 |
* @return The translated path.
|
135 |
*/
|
136 |
private String translatePath(String destination) |
137 |
{ |
138 |
// Parse for variables
|
139 |
destination = vs.substitute(destination, null);
|
140 |
|
141 |
// Convert the file separator characters
|
142 |
return destination.replace('/', File.separatorChar); |
143 |
} |
144 |
} |