1 19 package org.netbeans.modules.j2ee.sun.ide.j2ee.ui; 20 21 import java.util.HashSet ; 22 import java.util.Iterator ; 23 import java.util.Set ; 24 import javax.swing.JPanel ; 25 import javax.swing.event.ChangeEvent ; 26 import javax.swing.event.ChangeListener ; 27 import org.openide.ErrorManager; 28 import org.openide.util.NbBundle; 29 30 final class AddInstanceVisualInstancePanel extends JPanel { 31 32 35 AddInstanceVisualInstancePanel() { 36 initComponents(); 37 } 38 39 void setDomainsList(Object [] domainsList) { 40 if (domainsList != null) { 41 instanceSelector.setModel(new javax.swing.DefaultComboBoxModel (domainsList)); 42 } else { 43 instanceSelector.setModel(new javax.swing.DefaultComboBoxModel ()); 44 } 45 } 46 47 String getDomainDir() { 48 String tmp = (String ) instanceSelector.getSelectedItem(); 49 if (null == tmp) 50 return null; 51 int firstParen = tmp.lastIndexOf('('); 52 int lastParen = tmp.lastIndexOf(')'); 53 if (firstParen < 0) { 54 ErrorManager.getDefault().log(ErrorManager.ERROR, 55 NbBundle.getMessage(AddInstanceVisualInstancePanel.class, 56 "ERRMSG_PARSE_DOMAIN_DIR", tmp)); 57 return null; 58 } 59 if (lastParen < 0) { 60 ErrorManager.getDefault().log(ErrorManager.ERROR, 61 NbBundle.getMessage(AddInstanceVisualInstancePanel.class, 62 "ERRMSG_PARSE_DOMAIN_DIR", tmp)); 63 return null; 64 } 65 if (lastParen < firstParen) { 66 ErrorManager.getDefault().log(ErrorManager.ERROR, 67 NbBundle.getMessage(AddInstanceVisualInstancePanel.class, 68 "ERRMSG_PARSE_DOMAIN_DIR", tmp)); 69 return null; 70 } 71 return tmp.substring(firstParen+1,lastParen); 72 } 73 74 public String getName() { 75 return NbBundle.getMessage(AddInstanceVisualInstancePanel.class, 76 "StepName_PickDefaultInstance"); } 78 79 private Set listenrs = new HashSet (); 82 83 void addChangeListener(ChangeListener l) { 84 synchronized (listenrs) { 85 listenrs.add(l); 86 } 87 } 88 89 void removeChangeListener(ChangeListener l ) { 90 synchronized (listenrs) { 91 listenrs.remove(l); 92 } 93 } 94 95 private void fireChangeEvent() { 96 Iterator it; 97 synchronized (listenrs) { 98 it = new HashSet (listenrs).iterator(); 99 } 100 ChangeEvent ev = new ChangeEvent (this); 101 while (it.hasNext()) { 102 ((ChangeListener )it.next()).stateChanged (ev); 103 } 104 } 105 106 111 private void initComponents() { 113 java.awt.GridBagConstraints gridBagConstraints; 114 115 description = new javax.swing.JLabel (); 116 instanceSelectorLabel = new javax.swing.JLabel (); 117 instanceSelector = new javax.swing.JComboBox (); 118 spacingHack = new javax.swing.JLabel (); 119 120 setLayout(new java.awt.GridBagLayout ()); 121 122 java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/j2ee/ui/Bundle"); description.setText(bundle.getString("TXT_instancePanelDescription")); description.setFocusable(false); 125 gridBagConstraints = new java.awt.GridBagConstraints (); 126 gridBagConstraints.gridwidth = 3; 127 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 128 gridBagConstraints.weightx = 1.0; 129 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 0); 130 add(description, gridBagConstraints); 131 description.getAccessibleContext().setAccessibleName("Select the default domain to register"); 132 133 instanceSelectorLabel.setLabelFor(instanceSelector); 134 org.openide.awt.Mnemonics.setLocalizedText(instanceSelectorLabel, org.openide.util.NbBundle.getMessage(AddInstanceVisualInstancePanel.class, "LBL_instanceSelectorLabel")); gridBagConstraints = new java.awt.GridBagConstraints (); 136 gridBagConstraints.gridy = 1; 137 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 138 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 139 gridBagConstraints.insets = new java.awt.Insets (6, 0, 5, 6); 140 add(instanceSelectorLabel, gridBagConstraints); 141 142 instanceSelector.addActionListener(new java.awt.event.ActionListener () { 143 public void actionPerformed(java.awt.event.ActionEvent evt) { 144 instanceSelectorActionPerformed(evt); 145 } 146 }); 147 gridBagConstraints = new java.awt.GridBagConstraints (); 148 gridBagConstraints.gridy = 1; 149 gridBagConstraints.gridwidth = 2; 150 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 151 gridBagConstraints.insets = new java.awt.Insets (6, 6, 5, 0); 152 add(instanceSelector, gridBagConstraints); 153 instanceSelector.getAccessibleContext().setAccessibleDescription(bundle.getString("DSC_instanceSelector")); 155 spacingHack.setEnabled(false); 156 spacingHack.setFocusable(false); 157 gridBagConstraints = new java.awt.GridBagConstraints (); 158 gridBagConstraints.gridy = 3; 159 gridBagConstraints.weighty = 1.0; 160 add(spacingHack, gridBagConstraints); 161 } 163 private void instanceSelectorActionPerformed(java.awt.event.ActionEvent evt) { fireChangeEvent(); 165 } 167 168 private javax.swing.JLabel description; 170 private javax.swing.JComboBox instanceSelector; 171 private javax.swing.JLabel instanceSelectorLabel; 172 private javax.swing.JLabel spacingHack; 173 175 } 176 177 | Popular Tags |