1 package org.enhydra.kelp.jdev; 2 3 4 import javax.swing.JPanel ; 5 import java.awt.*; 6 import javax.swing.*; 7 import oracle.bali.ewt.wizard.WizardEvent; 8 import oracle.bali.ewt.wizard.WizardValidateListener; 9 import oracle.bali.ewt.event.Cancelable; 10 import java.awt.GridBagConstraints ; 11 import java.awt.event.ActionListener ; 12 import java.awt.event.ActionEvent ; 13 import java.awt.Insets ; 14 import java.io.File ; 15 import java.util.Hashtable ; 16 import javax.swing.JLabel ; 17 import javax.swing.JTextField ; 18 import java.awt.Dimension ; 19 20 import oracle.jdeveloper.model.JProject; 21 import oracle.ide.net.URLPath; 22 import oracle.ide.Ide; 23 24 public class PanelOne extends JPanel 25 implements WizardValidateListener 26 { 27 Model model; 28 29 GridBagLayout gridBagLayout1 = new GridBagLayout(); 30 JLabel jLabel1 = new JLabel (); 31 JLabel jLabel2 = new JLabel (); 32 JLabel jLabel3 = new JLabel (); 33 JTextField projectName = new JTextField (); 34 JTextField projectRoot = new JTextField (); 35 JButton jButtonBrowse = new JButton(); 36 37 public PanelOne(Model m) 38 { 39 try 40 { 41 jbInit(); 42 } 43 catch(Exception e) 44 { 45 e.printStackTrace(); 46 } 47 this.model = m; 48 } 49 private void jbInit() throws Exception 50 { 51 jLabel1.setText("Project name: "); 52 jLabel1.setHorizontalTextPosition(SwingConstants.RIGHT); 53 jLabel1.setHorizontalAlignment(SwingConstants.RIGHT); 54 jLabel2.setText("Project root: "); 55 jLabel2.setHorizontalTextPosition(SwingConstants.RIGHT); 56 jLabel2.setHorizontalAlignment(SwingConstants.RIGHT); 57 jLabel3.setText("Enhydra Application Wizard parameters"); 58 jLabel3.setFont(new Font("Dialog", 1, 14)); 59 jButtonBrowse.setText("Browse"); 60 jButtonBrowse.addActionListener(new java.awt.event.ActionListener () { 61 public void actionPerformed(ActionEvent e) { 62 jButtonBrowse_actionPerformed(e); 63 } 64 }); 65 this.setLayout(gridBagLayout1); 66 this.add(jLabel1, new GridBagConstraints (0, 1, 1, 1, 0.0, 0.2, java.awt.GridBagConstraints.CENTER, java.awt.GridBagConstraints.BOTH, new Insets (0, 0, 0, 0), 0, 0)); 67 this.add(jLabel3, new GridBagConstraints (0, 0, 3, 1, 0.0, 0.5, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets (0, 0, 0, 16), 97, 16)); 68 this.add(projectName, new GridBagConstraints (1, 1, 2, 1, 0.0, 0.2, java.awt.GridBagConstraints.CENTER, java.awt.GridBagConstraints.HORIZONTAL, new Insets (0, 0, 0, 0), 0, 0)); 69 this.add(jLabel2, new GridBagConstraints (0, 2, 1, 1, 0.0, 0.5, java.awt.GridBagConstraints.CENTER, java.awt.GridBagConstraints.BOTH, new Insets (0, 0, 0, 0), 0, 0)); 70 this.add(projectRoot, new GridBagConstraints (1, 2, 1, 1, 0.1, 0.5, java.awt.GridBagConstraints.CENTER, java.awt.GridBagConstraints.HORIZONTAL, new Insets (0, 0, 0, 0), 0, 0)); 71 this.add(jButtonBrowse, new GridBagConstraints (2, 2, 1, 1, 0.0, 0.5, java.awt.GridBagConstraints.CENTER, java.awt.GridBagConstraints.HORIZONTAL, new Insets (0, 0, 0, 0), 0, 0)); 72 73 } 74 public void wizardValidatePage(WizardEvent p0) 75 { 76 if ((projectName.getText().equalsIgnoreCase("")) || 77 (projectRoot.getText().equalsIgnoreCase("")) ) 78 { 79 JOptionPane.showMessageDialog(null, 80 "Please fill both input fields", 81 "Ooops", 82 JOptionPane.ERROR_MESSAGE); 83 Cancelable cancel = (Cancelable)p0; 84 cancel.cancel(); 85 } 86 model.setProjectName(this.projectName.getText()); 87 model.setProjectRoot(this.projectRoot.getText()); 88 } 89 90 public void setDefaultValues() 91 { 92 this.projectName.setText(model.getProjectName()); 93 this.projectRoot.setText(model.getProjectRoot()); 94 } 95 96 void jButtonBrowse_actionPerformed(ActionEvent e) { 97 browseForDir(); 98 } 99 100 private void browseForDir() { 101 JFileChooser chooser; 102 chooser = new JFileChooser(); 103 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 104 chooser.setCurrentDirectory(new File (model.getProjectRoot())); 105 chooser.setDialogTitle("Choose Project Root Directory"); 106 chooser.setApproveButtonText("OK"); 107 int v = chooser.showOpenDialog(this); 108 109 this.requestFocus(); 110 jButtonBrowse.requestFocus(); 111 if (v == JFileChooser.APPROVE_OPTION) { 112 if (!(chooser.getCurrentDirectory() == null)) { 113 model.setProjectRoot(chooser.getSelectedFile().toString()); 114 projectRoot.setText(model.getProjectRoot()); 115 } 116 } 117 chooser.removeAll(); 118 chooser = null; 119 } 120 121 } 122 | Popular Tags |