1 6 7 package org.netbeans.test.editor.app.gui; 8 9 import javax.swing.JFileChooser ; 10 11 15 public class TestGenerateDialog extends javax.swing.JDialog { 16 17 String path, packageName; 18 boolean state; 19 20 21 public TestGenerateDialog(java.awt.Frame parent, String dir) { 22 super(parent, true); 23 initComponents(); 24 pack(); 25 setPath(dir); 26 String pack=getClass().getPackage().getName(); 27 pack=pack.substring(0,pack.lastIndexOf('.')); 28 setPackageName(pack); 29 setLocation(parent.getX()+(parent.getWidth()-getWidth())/2,parent.getY()+(parent.getHeight()-getHeight())/2); 30 } 31 32 37 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 39 40 jPanel1 = new javax.swing.JPanel (); 41 jPanel3 = new javax.swing.JPanel (); 42 jPanel4 = new javax.swing.JPanel (); 43 jLabel1 = new javax.swing.JLabel (); 44 jPanel5 = new javax.swing.JPanel (); 45 packageF = new javax.swing.JTextField (); 46 jPanel7 = new javax.swing.JPanel (); 47 jLabel2 = new javax.swing.JLabel (); 48 jPanel6 = new javax.swing.JPanel (); 49 pathF = new javax.swing.JTextField (); 50 pathB = new javax.swing.JButton (); 51 jPanel2 = new javax.swing.JPanel (); 52 generateB = new javax.swing.JButton (); 53 cancelB = new javax.swing.JButton (); 54 55 setTitle("Generate Test Settings"); 56 addWindowListener(new java.awt.event.WindowAdapter () { 57 public void windowClosing(java.awt.event.WindowEvent evt) { 58 closeDialog(evt); 59 } 60 }); 61 62 jPanel3.setLayout(new java.awt.GridBagLayout ()); 63 64 jPanel4.setLayout(new java.awt.FlowLayout (java.awt.FlowLayout.LEFT)); 65 66 jLabel1.setText("Package: "); 67 jPanel4.add(jLabel1); 68 69 gridBagConstraints = new java.awt.GridBagConstraints (); 70 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 71 gridBagConstraints.weightx = 1.0; 72 gridBagConstraints.weighty = 1.0; 73 jPanel3.add(jPanel4, gridBagConstraints); 74 75 jPanel5.setLayout(new java.awt.FlowLayout (java.awt.FlowLayout.LEFT)); 76 77 packageF.setColumns(31); 78 jPanel5.add(packageF); 79 80 gridBagConstraints = new java.awt.GridBagConstraints (); 81 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 82 gridBagConstraints.weightx = 1.0; 83 gridBagConstraints.weighty = 1.0; 84 jPanel3.add(jPanel5, gridBagConstraints); 85 86 jPanel7.setLayout(new java.awt.FlowLayout (java.awt.FlowLayout.LEFT)); 87 88 jLabel2.setText("Path: "); 89 jPanel7.add(jLabel2); 90 91 gridBagConstraints = new java.awt.GridBagConstraints (); 92 gridBagConstraints.gridx = 0; 93 gridBagConstraints.gridy = 1; 94 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 95 gridBagConstraints.weightx = 1.0; 96 gridBagConstraints.weighty = 1.0; 97 jPanel3.add(jPanel7, gridBagConstraints); 98 99 pathF.setColumns(25); 100 jPanel6.add(pathF); 101 102 pathB.setText("Path"); 103 pathB.addActionListener(new java.awt.event.ActionListener () { 104 public void actionPerformed(java.awt.event.ActionEvent evt) { 105 pathBActionPerformed(evt); 106 } 107 }); 108 109 jPanel6.add(pathB); 110 111 gridBagConstraints = new java.awt.GridBagConstraints (); 112 gridBagConstraints.gridx = 1; 113 gridBagConstraints.gridy = 1; 114 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 115 gridBagConstraints.weightx = 1.0; 116 gridBagConstraints.weighty = 1.0; 117 jPanel3.add(jPanel6, gridBagConstraints); 118 119 jPanel1.add(jPanel3); 120 121 getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); 122 123 jPanel2.setLayout(new java.awt.FlowLayout (java.awt.FlowLayout.CENTER, 10, 5)); 124 125 generateB.setText("Generate"); 126 generateB.addActionListener(new java.awt.event.ActionListener () { 127 public void actionPerformed(java.awt.event.ActionEvent evt) { 128 generateBActionPerformed(evt); 129 } 130 }); 131 132 jPanel2.add(generateB); 133 134 cancelB.setText("Cancel"); 135 cancelB.addActionListener(new java.awt.event.ActionListener () { 136 public void actionPerformed(java.awt.event.ActionEvent evt) { 137 cancelBActionPerformed(evt); 138 } 139 }); 140 141 jPanel2.add(cancelB); 142 143 getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); 144 145 pack(); 146 } 148 private void pathBActionPerformed(java.awt.event.ActionEvent evt) { setModal(false); 151 JFileChooser dlg=new JFileChooser (path); 152 dlg.setDialogTitle("Select Folder"); 153 dlg.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 154 if (dlg.showDialog(getParent(),"Select") == JFileChooser.APPROVE_OPTION) { 155 setPath(dlg.getSelectedFile().getAbsolutePath()); 156 } 157 setModal(true); 158 } 160 private void generateBActionPerformed(java.awt.event.ActionEvent evt) { state=true; 163 path=pathF.getText(); 164 packageName=packageF.getText(); 165 close(); 166 } 168 private void cancelBActionPerformed(java.awt.event.ActionEvent evt) { state=false; 171 close(); 172 } 174 175 private void closeDialog(java.awt.event.WindowEvent evt) { close(); 177 } 179 private void close() { 180 setVisible(false); 181 dispose(); 182 } 183 187 public java.lang.String getPath() { 188 return path; 189 } 190 191 195 public void setPath(java.lang.String path) { 196 this.path = path; 197 pathF.setText(path); 198 } 199 200 204 public java.lang.String getPackageName() { 205 return packageName; 206 } 207 208 212 public void setPackageName(java.lang.String packageName) { 213 this.packageName = packageName; 214 packageF.setText(packageName); 215 } 216 217 public boolean getState() { 218 return state; 219 } 220 221 private javax.swing.JButton pathB; 223 private javax.swing.JButton cancelB; 224 private javax.swing.JPanel jPanel4; 225 private javax.swing.JLabel jLabel1; 226 private javax.swing.JTextField pathF; 227 private javax.swing.JTextField packageF; 228 private javax.swing.JPanel jPanel3; 229 private javax.swing.JLabel jLabel2; 230 private javax.swing.JButton generateB; 231 private javax.swing.JPanel jPanel2; 232 private javax.swing.JPanel jPanel5; 233 private javax.swing.JPanel jPanel7; 234 private javax.swing.JPanel jPanel1; 235 private javax.swing.JPanel jPanel6; 236 238 } 239 | Popular Tags |