1 19 package org.netbeans.modules.j2ee.sun.ide.j2ee.ui; 20 21 import java.io.File ; 22 import java.util.HashSet ; 23 import java.util.Iterator ; 24 import java.util.Set ; 25 import javax.swing.JFileChooser ; 26 import javax.swing.JPanel ; 27 import javax.swing.event.ChangeEvent ; 28 import javax.swing.event.ChangeListener ; 29 import javax.swing.event.DocumentEvent ; 30 import javax.swing.event.DocumentListener ; 31 import org.openide.filesystems.FileUtil; 32 import org.openide.util.NbBundle; 33 34 public final class CreateDomainVisualDirectoryPanel extends JPanel { 35 36 37 40 public CreateDomainVisualDirectoryPanel() { 41 initComponents(); 42 43 44 parentDirectory.getDocument().addDocumentListener(new DocumentListener () { 45 public void changedUpdate(DocumentEvent e) { 46 locationChanged(); 47 } 48 public void insertUpdate(DocumentEvent e) { 49 locationChanged(); 50 } 51 public void removeUpdate(DocumentEvent e) { 52 locationChanged(); 53 } 54 }); 55 } 56 57 public String getName() { 58 return NbBundle.getMessage(CreateDomainVisualDirectoryPanel.class, 59 "StepName_EnterDomainDirectory"); } 61 62 63 64 String getParentDirectory() { 65 return parentDirectory.getText(); 66 } 67 68 private final Set listeners = new HashSet (1); 71 public final void addChangeListener(ChangeListener l) { 72 synchronized (listeners) { 73 listeners.add(l); 74 } 75 } 76 public final void removeChangeListener(ChangeListener l) { 77 synchronized (listeners) { 78 listeners.remove(l); 79 } 80 } 81 protected final void fireChangeEvent() { 82 Iterator it; 83 synchronized (listeners) { 84 it = new HashSet (listeners).iterator(); 85 } 86 ChangeEvent ev = new ChangeEvent (this); 87 while (it.hasNext()) { 88 ((ChangeListener )it.next()).stateChanged(ev); 89 } 90 } 91 92 void locationChanged() { 93 fireChangeEvent(); 94 } 95 96 97 private String browseDomainLocation(){ 98 String insLocation = null; 99 JFileChooser chooser = null; 100 101 chooser = new JFileChooser (); 102 103 Util.decorateChooser(chooser,parentDirectory.getText(), 104 NbBundle.getMessage(CreateDomainVisualDirectoryPanel.class, 105 "LBL_Choose_Domain")); int returnValue = chooser.showDialog(this, 107 NbBundle.getMessage(CreateDomainVisualDirectoryPanel.class, 108 "LBL_Choose_Button")); 110 if(returnValue == JFileChooser.APPROVE_OPTION){ 111 insLocation = chooser.getSelectedFile().getAbsolutePath(); 112 } 113 return insLocation; 114 } 115 116 117 118 123 private void initComponents() { 125 java.awt.GridBagConstraints gridBagConstraints; 126 127 description = new javax.swing.JLabel (); 128 parentDirectoryLabel = new javax.swing.JLabel (); 129 parentDirectory = new javax.swing.JTextField (); 130 openInstanceDirectorySelector = new javax.swing.JButton (); 131 domainNameLabel = new javax.swing.JLabel (); 132 domainNameField = new javax.swing.JTextField (); 133 spaceHack = new javax.swing.JLabel (); 134 135 setLayout(new java.awt.GridBagLayout ()); 136 137 java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/j2ee/ui/Bundle"); description.setText(bundle.getString("TXT_instanceDirectoryDescription2")); description.setEnabled(false); 140 description.setFocusable(false); 141 gridBagConstraints = new java.awt.GridBagConstraints (); 142 gridBagConstraints.gridx = 0; 143 gridBagConstraints.gridy = 0; 144 gridBagConstraints.gridwidth = 4; 145 gridBagConstraints.gridheight = 2; 146 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 147 gridBagConstraints.weightx = 1.0; 148 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 149 add(description, gridBagConstraints); 150 151 parentDirectoryLabel.setLabelFor(parentDirectory); 152 org.openide.awt.Mnemonics.setLocalizedText(parentDirectoryLabel, org.openide.util.NbBundle.getMessage(CreateDomainVisualDirectoryPanel.class, "LBL_ParentFolder")); gridBagConstraints = new java.awt.GridBagConstraints (); 154 gridBagConstraints.gridx = 0; 155 gridBagConstraints.gridy = 2; 156 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 157 gridBagConstraints.insets = new java.awt.Insets (5, 0, 6, 6); 158 add(parentDirectoryLabel, gridBagConstraints); 159 gridBagConstraints = new java.awt.GridBagConstraints (); 160 gridBagConstraints.gridx = 1; 161 gridBagConstraints.gridy = 2; 162 gridBagConstraints.gridwidth = 2; 163 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 164 gridBagConstraints.weightx = 1.0; 165 gridBagConstraints.insets = new java.awt.Insets (5, 6, 6, 6); 166 add(parentDirectory, gridBagConstraints); 167 parentDirectory.getAccessibleContext().setAccessibleDescription(bundle.getString("DSC_instanceDirectory")); 169 org.openide.awt.Mnemonics.setLocalizedText(openInstanceDirectorySelector, org.openide.util.NbBundle.getMessage(CreateDomainVisualDirectoryPanel.class, "LBL_openInstanceDirectorySelector")); openInstanceDirectorySelector.addActionListener(new java.awt.event.ActionListener () { 171 public void actionPerformed(java.awt.event.ActionEvent evt) { 172 openInstanceDirectorySelectorActionPerformed(evt); 173 } 174 }); 175 gridBagConstraints = new java.awt.GridBagConstraints (); 176 gridBagConstraints.gridx = 3; 177 gridBagConstraints.gridy = 2; 178 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 179 gridBagConstraints.insets = new java.awt.Insets (5, 6, 6, 0); 180 add(openInstanceDirectorySelector, gridBagConstraints); 181 openInstanceDirectorySelector.getAccessibleContext().setAccessibleDescription(bundle.getString("DSC_openInstanceDirectorySelector")); 183 domainNameLabel.setLabelFor(domainNameField); 184 org.openide.awt.Mnemonics.setLocalizedText(domainNameLabel, org.openide.util.NbBundle.getMessage(CreateDomainVisualDirectoryPanel.class, "LBL_domainNameLabel")); gridBagConstraints = new java.awt.GridBagConstraints (); 186 gridBagConstraints.gridx = 0; 187 gridBagConstraints.gridy = 3; 188 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 189 gridBagConstraints.insets = new java.awt.Insets (6, 0, 6, 6); 190 add(domainNameLabel, gridBagConstraints); 191 gridBagConstraints = new java.awt.GridBagConstraints (); 192 gridBagConstraints.gridx = 1; 193 gridBagConstraints.gridy = 3; 194 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 195 gridBagConstraints.weightx = 1.0; 196 gridBagConstraints.insets = new java.awt.Insets (6, 6, 5, 6); 197 add(domainNameField, gridBagConstraints); 198 199 spaceHack.setEnabled(false); 200 spaceHack.setFocusable(false); 201 gridBagConstraints = new java.awt.GridBagConstraints (); 202 gridBagConstraints.gridx = 0; 203 gridBagConstraints.gridy = 4; 204 gridBagConstraints.weighty = 1.0; 205 add(spaceHack, gridBagConstraints); 206 } 208 private void openInstanceDirectorySelectorActionPerformed(java.awt.event.ActionEvent evt) { String val = browseDomainLocation(); 210 if (null != val && val.length() >=1) 211 parentDirectory.setText(val); 212 } 214 215 private javax.swing.JLabel description; 217 private javax.swing.JTextField domainNameField; 218 private javax.swing.JLabel domainNameLabel; 219 private javax.swing.JButton openInstanceDirectorySelector; 220 private javax.swing.JTextField parentDirectory; 221 private javax.swing.JLabel parentDirectoryLabel; 222 private javax.swing.JLabel spaceHack; 223 225 } 226 227 | Popular Tags |