1 19 20 21 package org.netbeans.modules.web.core.palette.items; 22 import java.awt.Dialog ; 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 25 import javax.swing.JSpinner ; 26 import javax.swing.SpinnerNumberModel ; 27 import javax.swing.text.JTextComponent ; 28 import org.openide.DialogDescriptor; 29 import org.openide.DialogDisplayer; 30 import org.openide.util.NbBundle; 31 32 33 34 38 public class ChooseCustomizer extends javax.swing.JPanel { 39 40 private Dialog dialog = null; 41 private DialogDescriptor descriptor = null; 42 private boolean dialogOK = false; 43 44 private Choose choose; 45 JTextComponent target; 46 47 public ChooseCustomizer(Choose choose, JTextComponent target) { 48 this.choose = choose; 49 this.target = target; 50 51 initComponents(); 52 } 53 54 public boolean showDialog() { 55 56 dialogOK = false; 57 58 String displayName = ""; 59 try { 60 displayName = NbBundle.getBundle("org.netbeans.modules.web.core.palette.items.resources.Bundle").getString("NAME_jsp-Choose"); } 62 catch (Exception e) {} 63 64 descriptor = new DialogDescriptor 65 (this, NbBundle.getMessage(ChooseCustomizer.class, "LBL_Customizer_InsertPrefix") + " " + displayName, true, 66 DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, 67 new ActionListener () { 68 public void actionPerformed(ActionEvent e) { 69 if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) { 70 evaluateInput(); 71 dialogOK = true; 72 } 73 dialog.dispose(); 74 } 75 } 76 ); 77 78 dialog = DialogDisplayer.getDefault().createDialog(descriptor); 79 dialog.setVisible(true); 80 repaint(); 81 82 return dialogOK; 83 } 84 85 private void evaluateInput() { 86 87 int whens = ((Integer )jSpinner1.getValue()).intValue(); 88 choose.setWhens(whens); 89 90 choose.setOtherwise(jCheckBox1.isSelected()); 91 } 92 93 98 private void initComponents() { 100 java.awt.GridBagConstraints gridBagConstraints; 101 102 jLabel2 = new javax.swing.JLabel (); 103 jSpinner1 = new javax.swing.JSpinner (); 104 jCheckBox1 = new javax.swing.JCheckBox (); 105 106 setLayout(new java.awt.GridBagLayout ()); 107 108 jLabel2.setLabelFor(jSpinner1); 109 org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(ChooseCustomizer.class, "LBL_Choose_Whens")); 110 gridBagConstraints = new java.awt.GridBagConstraints (); 111 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 112 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 113 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 114 add(jLabel2, gridBagConstraints); 115 jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ChooseCustomizer.class, "ACSN_Choose_Whens")); 116 jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ChooseCustomizer.class, "ACSD_Choose_Whens")); 117 118 jSpinner1.setModel(new SpinnerNumberModel (Choose.DEFAULT_WHENS, 1, Integer.MAX_VALUE, 1)); 119 jSpinner1.setEditor(new JSpinner.NumberEditor (jSpinner1, "#")); 120 jSpinner1.setValue(new Integer (Choose.DEFAULT_WHENS)); 121 gridBagConstraints = new java.awt.GridBagConstraints (); 122 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 123 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 124 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 18); 125 add(jSpinner1, gridBagConstraints); 126 127 jCheckBox1.setSelected(true); 128 org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(ChooseCustomizer.class, "LBL_Choose_Otherwise")); 129 jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 130 jCheckBox1.setMargin(new java.awt.Insets (0, 0, 0, 0)); 131 gridBagConstraints = new java.awt.GridBagConstraints (); 132 gridBagConstraints.gridx = 0; 133 gridBagConstraints.gridy = 1; 134 gridBagConstraints.gridwidth = 2; 135 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 136 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 137 gridBagConstraints.weightx = 1.0; 138 gridBagConstraints.weighty = 1.0; 139 gridBagConstraints.insets = new java.awt.Insets (11, 11, 11, 0); 140 add(jCheckBox1, gridBagConstraints); 141 jCheckBox1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ChooseCustomizer.class, "ACSN_Choose_Otherwise")); 142 jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ChooseCustomizer.class, "ACSD_Choose_Otherwise")); 143 144 } 146 147 private javax.swing.JCheckBox jCheckBox1; 149 private javax.swing.JLabel jLabel2; 150 private javax.swing.JSpinner jSpinner1; 151 153 } 154 | Popular Tags |