1 package org.apache.axis.tool.service.swing.ui; 2 3 import java.awt.event.ActionEvent ; 4 import java.awt.event.ActionListener ; 5 import java.awt.event.KeyEvent ; 6 import java.awt.event.KeyListener ; 7 8 import javax.swing.JButton ; 9 import javax.swing.JFrame ; 10 import javax.swing.JLabel ; 11 import javax.swing.JTextField ; 12 13 import org.apache.axis.tool.service.bean.Page3Bean; 14 import org.apache.axis.tool.service.bean.WizardBean; 15 import org.apache.axis.tool.util.Constants; 16 17 32 33 public class WizardPane3 extends WizardPane{ 34 35 private Page3Bean myBean; 36 37 private JLabel outputFileLocationLabel; 38 private JTextField outputFileLocationTextBox; 39 private JButton browseButton; 40 41 private JLabel outputFileNameLabel; 42 private JTextField outputFileNameTextBox; 43 44 public WizardPane3(WizardBean bean, JFrame ownerFrame) { 45 super(ownerFrame); 46 init(); 47 if (bean.getPage3bean()!=null){ 48 this.myBean = bean.getPage3bean(); 49 setBeanValues(); 50 }else{ 51 this.myBean = new Page3Bean(); 52 bean.setPage3bean(myBean); 53 } 54 } 55 56 public boolean validateValues() { 57 String text1 = myBean.getOutputFileName(); 58 String text2 = myBean.getOutputFolderName(); 59 boolean text1Validity = (text1!=null && text1.trim().length()>0); 60 boolean text2Validity = (text2!=null && text2.trim().length()>0); 61 62 return text1Validity && text2Validity; 63 } 64 65 private void setBeanValues(){ 66 this.outputFileLocationTextBox.setText(myBean.getOutputFolderName()); 67 this.outputFileNameTextBox.setText(myBean.getOutputFileName()); 68 } 69 70 private void init(){ 71 this.setLayout(null); 72 this.setSize(width,height); 73 74 initDescription("\nInput the location for the output file and the name for \n" + 75 "the compiled jar file " ); 76 77 78 this.outputFileLocationLabel = new JLabel ("Output Folder"); 79 this.add(this.outputFileLocationLabel); 80 this.outputFileLocationLabel.setBounds(hgap,descHeight,Constants.UIConstants.LABEL_WIDTH,Constants.UIConstants.GENERAL_COMP_HEIGHT); 81 82 this.outputFileLocationTextBox = new JTextField (); 83 this.add(this.outputFileLocationTextBox); 84 this.outputFileLocationTextBox.setBounds(Constants.UIConstants.LABEL_WIDTH + 2*hgap ,descHeight,Constants.UIConstants.TEXT_BOX_WIDTH,Constants.UIConstants.GENERAL_COMP_HEIGHT); 85 this.outputFileLocationTextBox.addActionListener(new ActionListener (){ 86 public void actionPerformed(ActionEvent e) { 87 handleLocationChange(); 88 } 89 }); 90 this.outputFileLocationTextBox.addKeyListener(new KeyListener (){ 91 public void keyTyped(KeyEvent e) { } 92 public void keyPressed(KeyEvent e) { 93 handleLocationChange(); 94 } 95 public void keyReleased(KeyEvent e) {} 96 }); 97 98 99 this.browseButton = new JButton ("."); 100 this.add(this.browseButton); 101 this.browseButton.setBounds(Constants.UIConstants.LABEL_WIDTH + 2*hgap +Constants.UIConstants.TEXT_BOX_WIDTH,descHeight,Constants.UIConstants.BROWSE_BUTTON_WIDTH,Constants.UIConstants.GENERAL_COMP_HEIGHT); 102 this.browseButton.addActionListener(new ActionListener (){ 103 public void actionPerformed(ActionEvent e) { 104 outputFileLocationTextBox.setText(browseForAFolder()); 105 handleLocationChange(); 106 107 } 108 }); 109 110 111 112 this.outputFileNameLabel = new JLabel ("Out File Name"); 113 this.add(this.outputFileNameLabel); 114 this.outputFileNameLabel.setBounds(hgap,descHeight +Constants.UIConstants.GENERAL_COMP_HEIGHT +vgap,Constants.UIConstants.LABEL_WIDTH,Constants.UIConstants.GENERAL_COMP_HEIGHT); 115 116 this.outputFileNameTextBox = new JTextField (); 117 this.add(this.outputFileNameTextBox); 118 this.outputFileNameTextBox.setBounds(Constants.UIConstants.LABEL_WIDTH + 2*hgap ,descHeight+Constants.UIConstants.GENERAL_COMP_HEIGHT +vgap,Constants.UIConstants.TEXT_BOX_WIDTH,Constants.UIConstants.GENERAL_COMP_HEIGHT); 119 this.outputFileNameTextBox.addActionListener(new ActionListener (){ 120 public void actionPerformed(ActionEvent e) { 121 handleFileNameChange(); 122 } 123 }); 124 this.outputFileNameTextBox.addKeyListener(new KeyListener (){ 125 public void keyTyped(KeyEvent e) { } 126 public void keyPressed(KeyEvent e) { } 127 public void keyReleased(KeyEvent e) { handleFileNameChange();} 128 }); 129 130 } 131 132 private void handleLocationChange(){ 133 myBean.setOutputFolderName(outputFileLocationTextBox.getText()); 134 } 135 136 private void handleFileNameChange(){ 137 myBean.setOutputFileName(outputFileNameTextBox.getText()); 138 } 139 140 } 141 | Popular Tags |