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 IfCustomizer extends javax.swing.JPanel { 39 40 private Dialog dialog = null; 41 private DialogDescriptor descriptor = null; 42 private boolean dialogOK = false; 43 44 If iF; 45 JTextComponent target; 46 47 public IfCustomizer(If iF, JTextComponent target) { 48 this.iF = iF; 49 this.target = target; 50 51 initComponents(); 52 53 jComboBox2.setModel(new DefaultComboBoxModel (If.scopes)); 54 jComboBox2.setSelectedIndex(iF.getScopeIndex()); 55 56 } 57 58 public boolean showDialog() { 59 60 dialogOK = false; 61 62 String displayName = ""; 63 try { 64 displayName = NbBundle.getBundle("org.netbeans.modules.web.core.palette.items.resources.Bundle").getString("NAME_jsp-If"); } 66 catch (Exception e) {} 67 68 descriptor = new DialogDescriptor 69 (this, NbBundle.getMessage(IfCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true, 70 DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, 71 new ActionListener () { 72 public void actionPerformed(ActionEvent e) { 73 if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) { 74 evaluateInput(); 75 dialogOK = true; 76 } 77 dialog.dispose(); 78 } 79 } 80 ); 81 82 dialog = DialogDisplayer.getDefault().createDialog(descriptor); 83 dialog.setVisible(true); 84 repaint(); 85 86 return dialogOK; 87 } 88 89 private void evaluateInput() { 90 91 92 String condition = jTextField1.getText(); 93 iF.setCondition(condition); 94 95 String variable = jTextField2.getText(); 96 iF.setVariable(variable); 97 98 int scopeIndex = jComboBox2.getSelectedIndex(); 99 iF.setScopeIndex(scopeIndex); 100 101 } 102 103 108 private void initComponents() { 110 java.awt.GridBagConstraints gridBagConstraints; 111 112 jFileChooser1 = new javax.swing.JFileChooser (); 113 jLabel4 = new javax.swing.JLabel (); 114 jTextField1 = new javax.swing.JTextField (); 115 jLabel1 = new javax.swing.JLabel (); 116 jLabel2 = new javax.swing.JLabel (); 117 jComboBox2 = new javax.swing.JComboBox (); 118 jTextField2 = new javax.swing.JTextField (); 119 jLabel3 = new javax.swing.JLabel (); 120 121 jFileChooser1.setCurrentDirectory(null); 122 123 setLayout(new java.awt.GridBagLayout ()); 124 125 jLabel4.setLabelFor(jComboBox2); 126 org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(IfCustomizer.class, "LBL_If_Scope")); 127 gridBagConstraints = new java.awt.GridBagConstraints (); 128 gridBagConstraints.gridx = 0; 129 gridBagConstraints.gridy = 3; 130 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 131 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 132 gridBagConstraints.weighty = 1.0; 133 gridBagConstraints.insets = new java.awt.Insets (12, 12, 12, 0); 134 add(jLabel4, gridBagConstraints); 135 jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSN_If_Scope")); 136 jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSD_If_Scope")); 137 138 jTextField1.setColumns(35); 139 gridBagConstraints = new java.awt.GridBagConstraints (); 140 gridBagConstraints.gridx = 1; 141 gridBagConstraints.gridy = 0; 142 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 143 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 144 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 145 add(jTextField1, gridBagConstraints); 146 147 jLabel1.setLabelFor(jTextField1); 148 org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(IfCustomizer.class, "LBL_If_Condition")); 149 gridBagConstraints = new java.awt.GridBagConstraints (); 150 gridBagConstraints.gridx = 0; 151 gridBagConstraints.gridy = 0; 152 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 153 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 154 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 155 add(jLabel1, gridBagConstraints); 156 jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSN_If_Condition")); 157 jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSD_If_Condition")); 158 159 jLabel2.setLabelFor(jTextField2); 160 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(IfCustomizer.class, "LBL_If_Variable")); 161 gridBagConstraints = new java.awt.GridBagConstraints (); 162 gridBagConstraints.gridx = 0; 163 gridBagConstraints.gridy = 1; 164 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 165 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 166 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 167 add(jLabel2, gridBagConstraints); 168 jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSN_If_Variable")); 169 jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSD_If_Variable")); 170 171 gridBagConstraints = new java.awt.GridBagConstraints (); 172 gridBagConstraints.gridx = 1; 173 gridBagConstraints.gridy = 3; 174 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 175 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 176 gridBagConstraints.weightx = 1.0; 177 gridBagConstraints.weighty = 1.0; 178 gridBagConstraints.insets = new java.awt.Insets (12, 12, 12, 12); 179 add(jComboBox2, gridBagConstraints); 180 181 gridBagConstraints = new java.awt.GridBagConstraints (); 182 gridBagConstraints.gridx = 1; 183 gridBagConstraints.gridy = 1; 184 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 185 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 186 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 12); 187 add(jTextField2, gridBagConstraints); 188 189 org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(IfCustomizer.class, "LBL_If_VariableHelp")); 190 gridBagConstraints = new java.awt.GridBagConstraints (); 191 gridBagConstraints.gridx = 1; 192 gridBagConstraints.gridy = 2; 193 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 194 gridBagConstraints.insets = new java.awt.Insets (5, 12, 0, 12); 195 add(jLabel3, gridBagConstraints); 196 jLabel3.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSN_If_VariableHelp")); 197 jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(IfCustomizer.class, "ACSD_If_VariableHelp")); 198 199 } 201 202 private javax.swing.JComboBox jComboBox2; 204 private javax.swing.JFileChooser jFileChooser1; 205 private javax.swing.JLabel jLabel1; 206 private javax.swing.JLabel jLabel2; 207 private javax.swing.JLabel jLabel3; 208 private javax.swing.JLabel jLabel4; 209 private javax.swing.JTextField jTextField1; 210 private javax.swing.JTextField jTextField2; 211 213 } 214 | Popular Tags |