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 UseBeanCustomizer extends javax.swing.JPanel { 39 40 private Dialog dialog = null; 41 private DialogDescriptor descriptor = null; 42 private boolean dialogOK = false; 43 44 UseBean useBean; 45 JTextComponent target; 46 47 48 public UseBeanCustomizer(UseBean useBean, JTextComponent target) { 49 this.useBean = useBean; 50 this.target = target; 51 52 initComponents(); 53 54 jComboBox1.setModel(new DefaultComboBoxModel (useBean.getBeans())); 55 if (useBean.getBeanIndex() > -1) 56 jComboBox1.setSelectedIndex(useBean.getBeanIndex()); 57 58 jComboBox2.setModel(new DefaultComboBoxModel (UseBean.scopes)); 59 jComboBox2.setSelectedIndex(useBean.getScopeIndex()); 60 61 } 62 63 public boolean showDialog() { 64 65 dialogOK = false; 66 67 String displayName = ""; 68 try { 69 displayName = NbBundle.getBundle("org.netbeans.modules.web.core.palette.items.resources.Bundle").getString("NAME_jsp-UseBean"); } 71 catch (Exception e) {} 72 73 descriptor = new DialogDescriptor 74 (this, NbBundle.getMessage(UseBeanCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true, 75 DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, 76 new ActionListener () { 77 public void actionPerformed(ActionEvent e) { 78 if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) { 79 evaluateInput(); 80 dialogOK = true; 81 } 82 dialog.dispose(); 83 } 84 } 85 ); 86 87 dialog = DialogDisplayer.getDefault().createDialog(descriptor); 88 dialog.setVisible(true); 89 repaint(); 90 91 return dialogOK; 92 } 93 94 private void evaluateInput() { 95 96 int beanIndex = jComboBox1.getSelectedIndex(); 97 useBean.setBeanIndex(beanIndex); 98 if (beanIndex == -1 && jComboBox1.getSelectedItem() != null) useBean.setBean(jComboBox1.getSelectedItem().toString()); 100 101 String clazz = jTextField1.getText(); 102 useBean.setClazz(clazz); 103 104 int scopeIndex = jComboBox2.getSelectedIndex(); 105 useBean.setScopeIndex(scopeIndex); 106 107 } 108 109 114 private void initComponents() { 116 java.awt.GridBagConstraints gridBagConstraints; 117 118 jFileChooser1 = new javax.swing.JFileChooser (); 119 jLabel4 = new javax.swing.JLabel (); 120 jTextField1 = new javax.swing.JTextField (); 121 jLabel1 = new javax.swing.JLabel (); 122 jLabel2 = new javax.swing.JLabel (); 123 jComboBox1 = new javax.swing.JComboBox (); 124 jComboBox2 = new javax.swing.JComboBox (); 125 126 jFileChooser1.setCurrentDirectory(null); 127 128 setLayout(new java.awt.GridBagLayout ()); 129 130 jLabel4.setLabelFor(jComboBox2); 131 org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(UseBeanCustomizer.class, "LBL_UseBean_Scope")); 132 gridBagConstraints = new java.awt.GridBagConstraints (); 133 gridBagConstraints.gridx = 0; 134 gridBagConstraints.gridy = 2; 135 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 136 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 137 gridBagConstraints.weighty = 1.0; 138 gridBagConstraints.insets = new java.awt.Insets (12, 12, 12, 0); 139 add(jLabel4, gridBagConstraints); 140 jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(UseBeanCustomizer.class, "ACSN_UseBean_Scope")); 141 jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(UseBeanCustomizer.class, "ACSD_UseBean_Scope")); 142 143 jTextField1.setColumns(35); 144 gridBagConstraints = new java.awt.GridBagConstraints (); 145 gridBagConstraints.gridx = 1; 146 gridBagConstraints.gridy = 1; 147 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 148 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 149 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 12); 150 add(jTextField1, gridBagConstraints); 151 152 jLabel1.setLabelFor(jComboBox1); 153 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(UseBeanCustomizer.class, "LBL_UseBean_ID")); 154 gridBagConstraints = new java.awt.GridBagConstraints (); 155 gridBagConstraints.gridx = 0; 156 gridBagConstraints.gridy = 0; 157 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 158 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 159 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 160 add(jLabel1, gridBagConstraints); 161 jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(UseBeanCustomizer.class, "ACSN_UseBean_ID")); 162 jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(UseBeanCustomizer.class, "ACSD_UseBean_ID")); 163 164 jLabel2.setLabelFor(jTextField1); 165 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(UseBeanCustomizer.class, "LBL_UseBean_Class")); 166 gridBagConstraints = new java.awt.GridBagConstraints (); 167 gridBagConstraints.gridx = 0; 168 gridBagConstraints.gridy = 1; 169 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 170 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 171 gridBagConstraints.insets = new java.awt.Insets (0, 12, 0, 0); 172 add(jLabel2, gridBagConstraints); 173 jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(UseBeanCustomizer.class, "ACSN_UseBean_Class")); 174 jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(UseBeanCustomizer.class, "ACSD_UseBean_Class")); 175 176 jComboBox1.setEditable(true); 177 gridBagConstraints = new java.awt.GridBagConstraints (); 178 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 179 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 180 add(jComboBox1, gridBagConstraints); 181 182 gridBagConstraints = new java.awt.GridBagConstraints (); 183 gridBagConstraints.gridx = 1; 184 gridBagConstraints.gridy = 2; 185 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 186 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 187 gridBagConstraints.weightx = 1.0; 188 gridBagConstraints.weighty = 1.0; 189 gridBagConstraints.insets = new java.awt.Insets (12, 12, 12, 12); 190 add(jComboBox2, gridBagConstraints); 191 192 } 194 195 private javax.swing.JComboBox jComboBox1; 197 private javax.swing.JComboBox jComboBox2; 198 private javax.swing.JFileChooser jFileChooser1; 199 private javax.swing.JLabel jLabel1; 200 private javax.swing.JLabel jLabel2; 201 private javax.swing.JLabel jLabel4; 202 private javax.swing.JTextField jTextField1; 203 205 } 206 | Popular Tags |