1 19 20 package org.netbeans.modules.web.core.palette.items; 21 import java.awt.Dialog ; 22 import java.awt.event.ActionEvent ; 23 import java.awt.event.ActionListener ; 24 import javax.swing.DefaultComboBoxModel ; 25 import javax.swing.text.JTextComponent ; 26 import org.openide.DialogDescriptor; 27 import org.openide.DialogDisplayer; 28 import org.openide.util.NbBundle; 29 30 31 32 33 34 38 public class SetPropertyCustomizer extends javax.swing.JPanel { 39 40 private Dialog dialog = null; 41 private DialogDescriptor descriptor = null; 42 private boolean dialogOK = false; 43 44 SetProperty setProperty; 45 JTextComponent target; 46 47 public SetPropertyCustomizer(SetProperty setProperty, JTextComponent target) { 48 this.setProperty = setProperty; 49 this.target = target; 50 51 initComponents(); 52 53 jComboBox1.setModel(new DefaultComboBoxModel (SetProperty.implicitBeans)); 54 jComboBox1.setSelectedIndex(setProperty.getBeanIndex()); 55 } 56 57 private void setClassName() { 58 59 int beanIndex = jComboBox1.getSelectedIndex(); 60 if (beanIndex == -1) 61 jTextField1.setText(""); 62 else if (beanIndex < GetProperty.implicitBeans.length) 63 jTextField1.setText(GetProperty.implicitTypes[beanIndex]); 64 else { 65 } 67 } 68 69 public boolean showDialog() { 70 71 dialogOK = false; 72 73 String displayName = ""; 74 try { 75 displayName = NbBundle.getBundle("org.netbeans.modules.web.core.palette.items.resources.Bundle").getString("NAME_jsp-SetProperty"); } 77 catch (Exception e) {} 78 79 descriptor = new DialogDescriptor 80 (this, NbBundle.getMessage(SetPropertyCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true, 81 DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, 82 new ActionListener () { 83 public void actionPerformed(ActionEvent e) { 84 if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) { 85 evaluateInput(); 86 dialogOK = true; 87 } 88 dialog.dispose(); 89 } 90 } 91 ); 92 93 dialog = DialogDisplayer.getDefault().createDialog(descriptor); 94 dialog.setVisible(true); 95 repaint(); 96 97 return dialogOK; 98 } 99 100 private void evaluateInput() { 101 102 int beanIndex = jComboBox1.getSelectedIndex(); 103 setProperty.setBeanIndex(beanIndex); 104 if (beanIndex == -1) { Object item = jComboBox1.getSelectedItem(); 106 if (item != null) 107 setProperty.setBean(item.toString()); 108 } 109 110 String property = jTextField2.getText(); 111 setProperty.setProperty(property); 112 113 String value = jTextField3.getText(); 114 setProperty.setValue(value); 115 116 } 117 118 123 private void initComponents() { 125 java.awt.GridBagConstraints gridBagConstraints; 126 127 jTextField1 = new javax.swing.JTextField (); 128 jLabel1 = new javax.swing.JLabel (); 129 jLabel2 = new javax.swing.JLabel (); 130 jComboBox1 = new javax.swing.JComboBox (); 131 jLabel3 = new javax.swing.JLabel (); 132 jTextField2 = new javax.swing.JTextField (); 133 jLabel4 = new javax.swing.JLabel (); 134 jTextField3 = new javax.swing.JTextField (); 135 136 setLayout(new java.awt.GridBagLayout ()); 137 138 jTextField1.setColumns(35); 139 jTextField1.setEditable(false); 140 gridBagConstraints = new java.awt.GridBagConstraints (); 141 gridBagConstraints.gridx = 1; 142 gridBagConstraints.gridy = 1; 143 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 144 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 145 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 12); 146 add(jTextField1, gridBagConstraints); 147 148 jLabel1.setLabelFor(jComboBox1); 149 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(SetPropertyCustomizer.class, "LBL_SetProperty_Bean")); 150 gridBagConstraints = new java.awt.GridBagConstraints (); 151 gridBagConstraints.gridx = 0; 152 gridBagConstraints.gridy = 0; 153 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 154 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 155 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 156 add(jLabel1, gridBagConstraints); 157 jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SetPropertyCustomizer.class, "ACSN_SetProperty_Bean")); 158 jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SetPropertyCustomizer.class, "ACSD_SetProperty_Bean")); 159 160 jLabel2.setLabelFor(jTextField1); 161 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(SetPropertyCustomizer.class, "LBL_SetProperty_Class")); 162 gridBagConstraints = new java.awt.GridBagConstraints (); 163 gridBagConstraints.gridx = 0; 164 gridBagConstraints.gridy = 1; 165 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 166 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 167 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 0); 168 add(jLabel2, gridBagConstraints); 169 jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SetPropertyCustomizer.class, "ACSN_SetProperty_Class")); 170 jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SetPropertyCustomizer.class, "ACSD_SetProperty_Class")); 171 172 jComboBox1.setEditable(true); 173 jComboBox1.addActionListener(new java.awt.event.ActionListener () { 174 public void actionPerformed(java.awt.event.ActionEvent evt) { 175 jComboBox1ActionPerformed(evt); 176 } 177 }); 178 179 gridBagConstraints = new java.awt.GridBagConstraints (); 180 gridBagConstraints.gridx = 1; 181 gridBagConstraints.gridy = 0; 182 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 183 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 184 add(jComboBox1, gridBagConstraints); 185 186 jLabel3.setLabelFor(jTextField2); 187 org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(SetPropertyCustomizer.class, "LBL_SetProperty_PropertyName")); 188 gridBagConstraints = new java.awt.GridBagConstraints (); 189 gridBagConstraints.gridx = 0; 190 gridBagConstraints.gridy = 2; 191 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 192 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 193 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 194 add(jLabel3, gridBagConstraints); 195 jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SetPropertyCustomizer.class, "ACSN_SetProperty_PropertyName")); 196 jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SetPropertyCustomizer.class, "ACSD_SetProperty_PropertyName")); 197 198 gridBagConstraints = new java.awt.GridBagConstraints (); 199 gridBagConstraints.gridx = 1; 200 gridBagConstraints.gridy = 2; 201 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 202 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 203 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 204 add(jTextField2, gridBagConstraints); 205 206 jLabel4.setLabelFor(jTextField3); 207 org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(SetPropertyCustomizer.class, "LBL_SetProperty_PropertyValue")); 208 gridBagConstraints = new java.awt.GridBagConstraints (); 209 gridBagConstraints.gridx = 0; 210 gridBagConstraints.gridy = 3; 211 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 212 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 213 gridBagConstraints.insets = new java.awt.Insets (12, 12, 12, 0); 214 add(jLabel4, gridBagConstraints); 215 jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(SetPropertyCustomizer.class, "ACSN_SetProperty_PropertyValue")); 216 jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(SetPropertyCustomizer.class, "ACSD_SetProperty_PropertyValue")); 217 218 gridBagConstraints = new java.awt.GridBagConstraints (); 219 gridBagConstraints.gridx = 1; 220 gridBagConstraints.gridy = 3; 221 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 222 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 223 gridBagConstraints.weightx = 1.0; 224 gridBagConstraints.weighty = 1.0; 225 gridBagConstraints.insets = new java.awt.Insets (12, 12, 12, 12); 226 add(jTextField3, gridBagConstraints); 227 228 } 230 private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) { setClassName(); 232 } 234 235 private javax.swing.JComboBox jComboBox1; 237 private javax.swing.JLabel jLabel1; 238 private javax.swing.JLabel jLabel2; 239 private javax.swing.JLabel jLabel3; 240 private javax.swing.JLabel jLabel4; 241 private javax.swing.JTextField jTextField1; 242 private javax.swing.JTextField jTextField2; 243 private javax.swing.JTextField jTextField3; 244 246 } 247 | Popular Tags |