1 package org.apache.axis.tool.service.swing.ui; 2 3 import java.awt.LayoutManager ; 4 import java.io.File ; 5 6 import javax.swing.JFileChooser ; 7 import javax.swing.JFrame ; 8 import javax.swing.JOptionPane ; 9 import javax.swing.JPanel ; 10 import javax.swing.JTextArea ; 11 import javax.swing.filechooser.FileFilter ; 12 13 28 public abstract class WizardPane extends JPanel { 29 protected JTextArea descriptionLabel; 30 protected JFrame ownerFrame; 31 32 protected int descWidth=400; 33 protected int descHeight=100; 34 protected int width=400; 35 protected int height=300; 36 protected int hgap=5; 37 protected int vgap=5; 38 39 protected WizardPane() { 40 } 41 42 protected WizardPane(JFrame ownerFrame) { 43 this.ownerFrame = ownerFrame; 44 } 45 46 protected WizardPane(boolean isDoubleBuffered) { 47 super(isDoubleBuffered); 48 } 49 50 protected WizardPane(LayoutManager layout) { 51 super(layout); 52 } 53 54 protected WizardPane(LayoutManager layout, boolean isDoubleBuffered) { 55 super(layout, isDoubleBuffered); 56 } 57 58 protected void initDescription(String desc){ 59 this.descriptionLabel = new JTextArea (desc); 60 this.descriptionLabel.setOpaque(false); 61 this.descriptionLabel.setEditable(false); 62 this.descriptionLabel.setAutoscrolls(true); 63 this.descriptionLabel.setBounds(0,0,descWidth,descHeight); 64 this.add(this.descriptionLabel); 65 } 66 67 public abstract boolean validateValues(); 68 69 protected void showErrorMessage(String message){ 70 JOptionPane.showMessageDialog(this,message,"Error",JOptionPane.ERROR_MESSAGE); 71 } 72 73 74 protected String browseForAFile(final String extension){ 75 String str=""; 76 JFileChooser fc=new JFileChooser (); 77 fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); 78 fc.addChoosableFileFilter(new FileFilter (){ 79 public boolean accept(File f) { 80 if (f.getName().endsWith(extension) || f.isDirectory()) 81 return true; 82 else 83 return false; 84 } 85 86 public String getDescription() { 87 return extension + " file filter "; 88 } 89 }); 90 91 int returnVal = fc.showOpenDialog(this); 92 if(returnVal == JFileChooser.APPROVE_OPTION) { 93 str=fc.getSelectedFile().getAbsolutePath().trim(); 94 } 95 return str; 96 } 97 98 protected String browseForAFolder(){ 99 String str=""; 100 JFileChooser fc=new JFileChooser (); 101 fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 102 int returnVal = fc.showOpenDialog(this); 103 if(returnVal == JFileChooser.APPROVE_OPTION) { 104 str=fc.getSelectedFile().getAbsolutePath().trim(); 105 } 106 return str; 107 } 108 } 109 | Popular Tags |