1 19 20 package org.netbeans.modules.tasklist.html; 21 22 import java.awt.*; 23 import javax.swing.*; 24 import javax.swing.text.*; 25 import javax.swing.event.*; 26 import java.awt.event.*; 27 import org.openide.loaders.DataObject; 28 29 import org.openide.util.NbBundle; 30 31 40 public class RewritePanel extends javax.swing.JPanel 41 implements ActionListener { 42 43 private static final long serialVersionUID = 1; 44 45 private RewriteAction action; 46 private Document doc; 47 private DataObject dobj; 48 49 50 public RewritePanel(RewriteAction action, Document doc, DataObject dobj) { 51 this.action = action; 52 this.doc = doc; 53 this.dobj = dobj; 54 initComponents(); 55 xhtmlCB.addActionListener(this); 56 previewButton.addActionListener(this); 57 } 58 59 public void actionPerformed(ActionEvent evt) { 60 if (evt.getSource() == xhtmlCB) { 61 boolean xml = xhtmlCB.isSelected(); 64 if (upperRB.isSelected()) { 65 upperRB.setSelected(false); 66 lowerRB.setSelected(true); 67 } 68 upperRB.setEnabled(!xml); 69 if (omitCB.isSelected()) { 70 omitCB.setSelected(false); 71 } 72 omitCB.setEnabled(!xml); 73 } else if (evt.getSource() == previewButton) { 74 action.preview(this, doc, dobj); 75 } 76 } 77 78 83 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 85 86 caseButtonGroup = new javax.swing.ButtonGroup (); 87 jLabel1 = new javax.swing.JLabel (); 88 xhtmlCB = new javax.swing.JCheckBox (); 89 replaceCB = new javax.swing.JCheckBox (); 90 lowerRB = new javax.swing.JRadioButton (); 91 upperRB = new javax.swing.JRadioButton (); 92 omitCB = new javax.swing.JCheckBox (); 93 indentCB = new javax.swing.JCheckBox (); 94 wrapCB = new javax.swing.JCheckBox (); 95 wrapText = new javax.swing.JTextField (); 96 previewButton = new javax.swing.JButton (); 97 98 setLayout(new java.awt.GridBagLayout ()); 99 100 setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (12, 12, 11, 11))); 101 jLabel1.setText(NbBundle.getMessage(RewritePanel.class, "RewriteSettings")); gridBagConstraints = new java.awt.GridBagConstraints (); 103 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 104 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 105 add(jLabel1, gridBagConstraints); 106 107 xhtmlCB.setText(NbBundle.getMessage(RewritePanel.class, "ConvertXHTML")); gridBagConstraints = new java.awt.GridBagConstraints (); 109 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 110 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 111 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 112 add(xhtmlCB, gridBagConstraints); 113 114 replaceCB.setText(NbBundle.getMessage(RewritePanel.class, "ReplaceFont")); gridBagConstraints = new java.awt.GridBagConstraints (); 116 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 117 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 118 add(replaceCB, gridBagConstraints); 119 120 lowerRB.setSelected(true); 121 lowerRB.setText(NbBundle.getMessage(RewritePanel.class, "Lowercase")); caseButtonGroup.add(lowerRB); 123 gridBagConstraints = new java.awt.GridBagConstraints (); 124 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 125 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 126 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 127 add(lowerRB, gridBagConstraints); 128 129 upperRB.setText(NbBundle.getMessage(RewritePanel.class, "Uppercase")); caseButtonGroup.add(upperRB); 131 gridBagConstraints = new java.awt.GridBagConstraints (); 132 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 133 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 134 add(upperRB, gridBagConstraints); 135 136 omitCB.setText(NbBundle.getMessage(RewritePanel.class, "OmitOptional")); gridBagConstraints = new java.awt.GridBagConstraints (); 138 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 139 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 140 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 141 add(omitCB, gridBagConstraints); 142 143 indentCB.setText(NbBundle.getMessage(RewritePanel.class, "Indent")); gridBagConstraints = new java.awt.GridBagConstraints (); 145 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 146 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 147 add(indentCB, gridBagConstraints); 148 149 wrapCB.setText(NbBundle.getMessage(RewritePanel.class, "WrapCol")); gridBagConstraints = new java.awt.GridBagConstraints (); 151 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 152 add(wrapCB, gridBagConstraints); 153 154 wrapText.setColumns(3); 155 wrapText.setText("68"); 156 wrapText.setHorizontalAlignment(javax.swing.JTextField.TRAILING); 157 gridBagConstraints = new java.awt.GridBagConstraints (); 158 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 159 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 160 add(wrapText, gridBagConstraints); 161 162 previewButton.setText(NbBundle.getMessage(RewritePanel.class, "Preview")); gridBagConstraints = new java.awt.GridBagConstraints (); 164 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 165 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 166 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 167 add(previewButton, gridBagConstraints); 168 169 } 171 172 private javax.swing.JCheckBox indentCB; 174 private javax.swing.JCheckBox replaceCB; 175 private javax.swing.JRadioButton upperRB; 176 private javax.swing.JTextField wrapText; 177 private javax.swing.JButton previewButton; 178 private javax.swing.JCheckBox omitCB; 179 private javax.swing.JCheckBox wrapCB; 180 private javax.swing.JLabel jLabel1; 181 private javax.swing.JCheckBox xhtmlCB; 182 private javax.swing.ButtonGroup caseButtonGroup; 183 private javax.swing.JRadioButton lowerRB; 184 186 boolean getXHTML() { 187 return xhtmlCB.isSelected(); 188 } 189 190 boolean getIndent() { 191 return indentCB.isSelected(); 192 } 193 194 boolean getReplace() { 195 return replaceCB.isSelected(); 196 } 197 198 boolean getOmit() { 199 return omitCB.isSelected(); 200 } 201 202 boolean getUpper() { 203 return upperRB.isSelected(); 204 } 205 206 int getWrapCol() { 207 if (!wrapCB.isSelected()) { 208 return 0; 209 } 210 String str = wrapText.getText().trim(); 211 int col = 68; 212 try { 213 col = Integer.parseInt(str); 214 } catch (Exception e) { 215 } 216 return col; 217 } 218 219 void setXHTML(boolean on) { 220 xhtmlCB.setSelected(on); 221 } 222 223 void setIndent(boolean on) { 224 indentCB.setSelected(on); 225 } 226 227 void setReplace(boolean on) { 228 replaceCB.setSelected(on); 229 } 230 231 void setOmit(boolean on) { 232 omitCB.setSelected(on); 233 } 234 235 void setUpper(boolean on) { 236 upperRB.setSelected(on); 237 lowerRB.setSelected(!on); 238 } 239 240 void setWrapCol(int col) { 241 if (col == 0) { 242 wrapCB.setSelected(false); 243 } else { 244 wrapText.setText(Integer.toString(col)); 245 wrapCB.setSelected(true); 246 } 247 } 248 249 void setXML(boolean on) { 250 xhtmlCB.setEnabled(!on); 252 if (on) { 253 upperRB.setSelected(false); 254 lowerRB.setSelected(true); 255 omitCB.setSelected(false); 256 omitCB.setEnabled(false); 257 replaceCB.setSelected(false); 258 replaceCB.setEnabled(false); 259 } 260 } 261 } 262 | Popular Tags |