01: /*
02: * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
03: *
04: * http://izpack.org/
05: * http://izpack.codehaus.org/
06: *
07: * Licensed under the Apache License, Version 2.0 (the "License");
08: * you may not use this file except in compliance with the License.
09: * 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 javax.swing.JScrollPane;
23: import javax.swing.JTextArea;
24:
25: import com.izforge.izpack.gui.IzPanelLayout;
26: import com.izforge.izpack.gui.LabelFactory;
27: import com.izforge.izpack.installer.InstallData;
28: import com.izforge.izpack.installer.InstallerFrame;
29: import com.izforge.izpack.installer.IzPanel;
30: import com.izforge.izpack.installer.ResourceManager;
31:
32: /**
33: * The info panel class. Displays some raw-text informations.
34: *
35: * @author Julien Ponge
36: */
37: public class InfoPanel extends IzPanel {
38:
39: private static final long serialVersionUID = 3833748780590905399L;
40:
41: /** The info string. */
42: private String info;
43:
44: /**
45: * The constructor.
46: *
47: * @param parent The parent window.
48: * @param idata The installation data.
49: */
50: public InfoPanel(InstallerFrame parent, InstallData idata) {
51: super (parent, idata, new IzPanelLayout());
52: // We load the text.
53: loadInfo();
54: // The info label.
55: add(LabelFactory.create(parent.langpack
56: .getString("InfoPanel.info"), parent.icons
57: .getImageIcon("edit"), LEADING), NEXT_LINE);
58: // The text area which shows the info.
59: JTextArea textArea = new JTextArea(info);
60: textArea.setCaretPosition(0);
61: textArea.setEditable(false);
62: JScrollPane scroller = new JScrollPane(textArea);
63: add(scroller, NEXT_LINE);
64: // At end of layouting we should call the completeLayout method also they do nothing.
65: getLayoutHelper().completeLayout();
66: }
67:
68: /** Loads the info text. */
69: private void loadInfo() {
70: try {
71: String resNamePrifix = "InfoPanel.info";
72: info = ResourceManager.getInstance().getTextResource(
73: resNamePrifix);
74: } catch (Exception err) {
75: info = "Error : could not load the info text !";
76: }
77: }
78:
79: /**
80: * Indicates wether the panel has been validated or not.
81: *
82: * @return Always true.
83: */
84: public boolean isValidated() {
85: return true;
86: }
87: }
|