1 21 22 package com.izforge.izpack.panels; 23 24 import java.awt.GridBagConstraints ; 25 import java.awt.GridBagLayout ; 26 import java.awt.Insets ; 27 28 import javax.swing.JLabel ; 29 import javax.swing.JScrollPane ; 30 import javax.swing.JTextArea ; 31 32 import com.izforge.izpack.gui.LabelFactory; 33 import com.izforge.izpack.installer.InstallData; 34 import com.izforge.izpack.installer.InstallerFrame; 35 import com.izforge.izpack.installer.IzPanel; 36 import com.izforge.izpack.installer.ResourceManager; 37 import com.izforge.izpack.util.VariableSubstitutor; 38 39 44 public class XInfoPanel extends IzPanel 45 { 46 47 50 private static final long serialVersionUID = 3257009856274970416L; 51 52 53 private JTextArea textArea; 54 55 56 private String info; 57 58 64 public XInfoPanel(InstallerFrame parent, InstallData idata) 65 { 66 super(parent, idata); 67 68 GridBagLayout layout = new GridBagLayout (); 70 GridBagConstraints gbConstraints = new GridBagConstraints (); 71 setLayout(layout); 72 73 75 JLabel infoLabel = LabelFactory.create(parent.langpack.getString("InfoPanel.info"), parent.icons 76 .getImageIcon("edit"), JLabel.TRAILING); 77 parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.0); 78 gbConstraints.insets = new Insets (5, 5, 5, 5); 79 gbConstraints.fill = GridBagConstraints.BOTH; 80 gbConstraints.anchor = GridBagConstraints.SOUTHWEST; 81 layout.addLayoutComponent(infoLabel, gbConstraints); 82 add(infoLabel); 83 84 textArea = new JTextArea (); 85 textArea.setEditable(false); 86 JScrollPane scroller = new JScrollPane (textArea); 87 parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 0.9); 88 gbConstraints.anchor = GridBagConstraints.CENTER; 89 layout.addLayoutComponent(scroller, gbConstraints); 90 add(scroller); 91 } 92 93 94 private void loadInfo() 95 { 96 try 97 { 98 info = ResourceManager.getInstance().getTextResource("XInfoPanel.info"); 100 } 101 catch (Exception err) 102 { 103 info = "Error : could not load the info text !"; 104 } 105 } 106 107 108 private void parseText() 109 { 110 try 111 { 112 VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables()); 114 115 info = vs.substitute(info, null); 117 } 118 catch (Exception err) 119 { 120 err.printStackTrace(); 121 } 122 } 123 124 125 public void panelActivate() 126 { 127 loadInfo(); 129 parseText(); 130 131 textArea.setText(info); 133 textArea.setCaretPosition(0); 134 } 135 136 141 public boolean isValidated() 142 { 143 return true; 144 } 145 } 146 | Popular Tags |