1 2 24 package org.enhydra.tool.common.wizard; 25 26 import org.enhydra.tool.common.ToolException; 28 29 import java.awt.*; 31 import java.beans.*; 32 import java.util.ArrayList ; 33 import javax.swing.*; 34 35 43 public class TBWizardPage extends JPanel { 44 transient private BorderLayout layoutCustom; 45 transient private BorderLayout layoutMain; 46 transient private GridBagLayout layoutWizard; 47 transient private JLabel image; 48 transient private JLabel pageTitle; 49 transient private JPanel panelCustom; 50 transient private JPanel panelWizard; 51 transient private JTextArea instructions; 52 transient private TBWizardPanel wizardPanel = null; 53 54 57 public TBWizardPage() { 58 try { 59 jbInit(); 60 pmInit(); 61 } catch (Exception e) { 62 e.printStackTrace(); 63 } 64 } 65 66 public void preparePage() {} 67 68 71 public String getInstructions() { 72 return instructions.getText(); 73 } 74 75 82 public void setInstructions(String s) { 83 instructions.setText(s); 84 } 85 86 89 public String getPageTitle() { 90 return pageTitle.getText(); 91 } 92 93 96 public void setPageTitle(String s) { 97 pageTitle.setText(s); 98 } 99 100 107 public void add(TBWizardPanel panel) { 108 wizardPanel = panel; 109 panelCustom.add(wizardPanel, BorderLayout.CENTER); 110 } 111 112 public TBWizardPanel getWizardPanel() { 113 return wizardPanel; 114 } 115 116 public void validatePage() throws ToolException {} 117 118 protected Component[] getChildPanelComponents() { 120 Component[] comps = new Component[0]; 121 ArrayList list = new ArrayList (); 122 list = addAllChildren(wizardPanel, list); 123 list.trimToSize(); 124 comps = new Component[list.size()]; 125 comps = (Component[]) list.toArray(comps); 126 list.clear(); 127 return comps; 128 } 129 130 private ArrayList addAllChildren(Container container, ArrayList list) { 131 Component[] children = new Component[0]; 132 133 children = container.getComponents(); 134 for (int i = 0; i < children.length; i++) { 135 list.add(children[i]); 136 if (children[i] instanceof Container) { 137 list = addAllChildren((Container) children[i], list); 138 } 139 } 140 return list; 141 } 142 143 147 151 private void pmInit() { 152 image.setText(new String ()); 153 } 154 155 159 private void jbInit() throws Exception { 160 panelWizard = (JPanel) Beans.instantiate(getClass().getClassLoader(), 161 JPanel.class.getName()); 162 layoutWizard = 163 (GridBagLayout) Beans.instantiate(getClass().getClassLoader(), 164 GridBagLayout.class.getName()); 165 pageTitle = (JLabel) Beans.instantiate(getClass().getClassLoader(), 166 JLabel.class.getName()); 167 instructions = 168 (JTextArea) Beans.instantiate(getClass().getClassLoader(), 169 JTextArea.class.getName()); 170 panelCustom = (JPanel) Beans.instantiate(getClass().getClassLoader(), 171 JPanel.class.getName()); 172 layoutCustom = 173 (BorderLayout) Beans.instantiate(getClass().getClassLoader(), 174 BorderLayout.class.getName()); 175 layoutMain = 176 (BorderLayout) Beans.instantiate(getClass().getClassLoader(), 177 BorderLayout.class.getName()); 178 image = (JLabel) Beans.instantiate(getClass().getClassLoader(), 179 JLabel.class.getName()); 180 panelWizard.setLayout(layoutWizard); 181 pageTitle.setFont(new Font(pageTitle.getFont().getName(), 1, 12)); 182 pageTitle.setText("PAGE TITLE"); instructions.setLineWrap(true); 184 instructions.setWrapStyleWord(true); 185 instructions.setDisabledTextColor(SystemColor.windowText); 186 instructions.setBackground(SystemColor.inactiveCaptionBorder); 187 instructions.setEnabled(false); 188 instructions.setText("INSTRUCTIONS"); instructions.setEditable(false); 190 instructions.setFont(new Font(pageTitle.getFont().getName(), 0, 12)); 191 panelCustom.setLayout(layoutCustom); 192 panelWizard.add(pageTitle, 193 new GridBagConstraints(0, 0, 1, 1, 0.1, 0.1, 194 GridBagConstraints.CENTER, 195 GridBagConstraints.BOTH, 196 new Insets(2, 5, 2, 5), 5, 5)); 197 panelWizard.add(instructions, 198 new GridBagConstraints(0, 1, 1, 1, 0.2, 0.2, 199 GridBagConstraints.CENTER, 200 GridBagConstraints.BOTH, 201 new Insets(2, 5, 2, 5), 5, 5)); 202 panelWizard.add(panelCustom, 203 new GridBagConstraints(0, 2, 1, 2, 0.7, 0.7, 204 GridBagConstraints.CENTER, 205 GridBagConstraints.BOTH, 206 new Insets(2, 5, 2, 5), 5, 5)); 207 this.setLayout(layoutMain); 208 this.add(image, BorderLayout.WEST); 209 this.add(panelWizard, BorderLayout.CENTER); 210 } 211 212 } 213 | Popular Tags |