001/* 002 * IzPack - Copyright 2001-2005 Julien Ponge, All Rights Reserved. 003 * 004 * http://www.izforge.com/izpack/ 005 * http://developer.berlios.de/projects/izpack/ 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 020package com.izforge.izpack.panels; 021 022import java.awt.GridBagConstraints; 023import java.awt.GridBagLayout; 024import java.awt.Insets; 025 026import javax.swing.JLabel; 027import javax.swing.JScrollPane; 028import javax.swing.JTextArea; 029 030import com.izforge.izpack.gui.LabelFactory; 031import com.izforge.izpack.installer.InstallData; 032import com.izforge.izpack.installer.InstallerFrame; 033import com.izforge.izpack.installer.IzPanel; 034import com.izforge.izpack.installer.ResourceManager; 035 036/** 037 * The info panel class. Displays some raw-text informations. 038 * 039 * @author Julien Ponge 040 */ 041public class InfoPanel extends IzPanel 042{ 043 044 private static final long serialVersionUID = 3833748780590905399L; 045 046 /** The layout. */ 047 private GridBagLayout layout; 048 049 /** The layout constraints. */ 050 private GridBagConstraints gbConstraints; 051 052 /** The info label. */ 053 private JLabel infoLabel; 054 055 /** The text area. */ 056 private JTextArea textArea; 057 058 /** The scrolling container. */ 059 private JScrollPane scroller; 060 061 /** The info string. */ 062 private String info; 063 064 /** 065 * The constructor. 066 * 067 * @param parent The parent window. 068 * @param idata The installation data. 069 */ 070 public InfoPanel(InstallerFrame parent, InstallData idata) 071 { 072 super(parent, idata); 073 074 // We initialize our layout 075 layout = new GridBagLayout(); 076 gbConstraints = new GridBagConstraints(); 077 setLayout(layout); 078 079 // We load the text 080 loadInfo(); 081 082 // We add the components 083 084 infoLabel = LabelFactory.create(parent.langpack.getString("InfoPanel.info"), parent.icons 085 .getImageIcon("edit"), JLabel.TRAILING); 086 parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.1); 087 gbConstraints.insets = new Insets(5, 5, 5, 5); 088 gbConstraints.fill = GridBagConstraints.NONE; 089 gbConstraints.anchor = GridBagConstraints.SOUTHWEST; 090 layout.addLayoutComponent(infoLabel, gbConstraints); 091 add(infoLabel); 092 093 textArea = new JTextArea(info); 094 textArea.setCaretPosition(0); 095 textArea.setEditable(false); 096 scroller = new JScrollPane(textArea); 097 parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 0.9); 098 gbConstraints.fill = GridBagConstraints.BOTH; 099 gbConstraints.anchor = GridBagConstraints.CENTER; 100 layout.addLayoutComponent(scroller, gbConstraints); 101 add(scroller); 102 } 103 104 /** Loads the info text. */ 105 private void loadInfo() 106 { 107 try 108 { 109 String resNamePrifix = "InfoPanel.info"; 110 info = ResourceManager.getInstance().getTextResource(resNamePrifix); 111 } 112 catch (Exception err) 113 { 114 info = "Error : could not load the info text !"; 115 } 116 } 117 118 /** 119 * Indicates wether the panel has been validated or not. 120 * 121 * @return Always true. 122 */ 123 public boolean isValidated() 124 { 125 return true; 126 } 127}