1 19 20 package org.netbeans.modules.retouche.editor.options; 21 22 import java.awt.event.ItemEvent ; 23 import java.util.HashMap ; 24 import java.util.Map ; 25 import org.netbeans.editor.SettingsNames; 26 import org.openide.util.NbBundle; 28 29 38 public class CodeFoldingEditorPanel extends javax.swing.JPanel { 39 40 CodeFoldingEditor foldingEditor; 41 42 43 public CodeFoldingEditorPanel(CodeFoldingEditor foldingEditor) { 44 this.foldingEditor = foldingEditor; 45 initComponents(); 46 initAccessibility(); 47 } 48 49 private void initAccessibility(){ 50 enableFoldingCB.setMnemonic(getBundleString("CFEP_UseCF_Mnemonic").charAt(0)); methodCB.setMnemonic(getBundleString("CFEP_Method_Mnemonic").charAt(0)); innerCB.setMnemonic(getBundleString("CFEP_InnerClass_Mnemonic").charAt(0)); importCB.setMnemonic(getBundleString("CFEP_Import_Mnemonic").charAt(0)); javadocCB.setMnemonic(getBundleString("CFEP_Javadoc_Mnemonic").charAt(0)); initialCommentCB.setMnemonic(getBundleString("CFEP_InitialComment_Mnemonic").charAt(0)); } 57 58 63 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 65 66 enableFoldingCB = new javax.swing.JCheckBox (); 67 jLabel1 = new javax.swing.JLabel (); 68 methodCB = new javax.swing.JCheckBox (); 69 innerCB = new javax.swing.JCheckBox (); 70 importCB = new javax.swing.JCheckBox (); 71 javadocCB = new javax.swing.JCheckBox (); 72 initialCommentCB = new javax.swing.JCheckBox (); 73 74 setLayout(new java.awt.GridBagLayout ()); 75 76 enableFoldingCB.setText(getBundleString( "CFEP_UseCF" )); 77 enableFoldingCB.addItemListener(new java.awt.event.ItemListener () { 78 public void itemStateChanged(java.awt.event.ItemEvent evt) { 79 checkBoxChange(evt); 80 } 81 }); 82 83 gridBagConstraints = new java.awt.GridBagConstraints (); 84 gridBagConstraints.gridx = 0; 85 gridBagConstraints.gridy = 0; 86 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 87 gridBagConstraints.weightx = 1.0; 88 gridBagConstraints.insets = new java.awt.Insets (12, 12, 12, 0); 89 add(enableFoldingCB, gridBagConstraints); 90 91 jLabel1.setText(getBundleString( "CFEP_CollapsedByDefault" )); 92 gridBagConstraints = new java.awt.GridBagConstraints (); 93 gridBagConstraints.gridx = 0; 94 gridBagConstraints.gridy = 1; 95 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 96 gridBagConstraints.insets = new java.awt.Insets (0, 12, 5, 11); 97 add(jLabel1, gridBagConstraints); 98 99 methodCB.setText(getBundleString( "CFEP_Method" )); 100 methodCB.addItemListener(new java.awt.event.ItemListener () { 101 public void itemStateChanged(java.awt.event.ItemEvent evt) { 102 methodCBItemStateChanged(evt); 103 } 104 }); 105 106 gridBagConstraints = new java.awt.GridBagConstraints (); 107 gridBagConstraints.gridx = 0; 108 gridBagConstraints.gridy = 2; 109 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 110 gridBagConstraints.insets = new java.awt.Insets (0, 24, 0, 0); 111 add(methodCB, gridBagConstraints); 112 113 innerCB.setText(getBundleString( "CFEP_InnerClass" )); 114 innerCB.addItemListener(new java.awt.event.ItemListener () { 115 public void itemStateChanged(java.awt.event.ItemEvent evt) { 116 innerCBItemStateChanged(evt); 117 } 118 }); 119 120 gridBagConstraints = new java.awt.GridBagConstraints (); 121 gridBagConstraints.gridx = 0; 122 gridBagConstraints.gridy = 3; 123 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 124 gridBagConstraints.insets = new java.awt.Insets (0, 24, 0, 0); 125 add(innerCB, gridBagConstraints); 126 127 importCB.setText(getBundleString( "CFEP_Import" )); 128 importCB.addItemListener(new java.awt.event.ItemListener () { 129 public void itemStateChanged(java.awt.event.ItemEvent evt) { 130 importCBItemStateChanged(evt); 131 } 132 }); 133 134 gridBagConstraints = new java.awt.GridBagConstraints (); 135 gridBagConstraints.gridx = 0; 136 gridBagConstraints.gridy = 4; 137 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 138 gridBagConstraints.insets = new java.awt.Insets (0, 24, 0, 0); 139 add(importCB, gridBagConstraints); 140 141 javadocCB.setText(getBundleString( "CFEP_Javadoc" )); 142 javadocCB.addItemListener(new java.awt.event.ItemListener () { 143 public void itemStateChanged(java.awt.event.ItemEvent evt) { 144 javadocCBItemStateChanged(evt); 145 } 146 }); 147 148 gridBagConstraints = new java.awt.GridBagConstraints (); 149 gridBagConstraints.gridx = 0; 150 gridBagConstraints.gridy = 5; 151 gridBagConstraints.insets = new java.awt.Insets (0, 24, 0, 0); 152 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 153 add(javadocCB, gridBagConstraints); 154 155 initialCommentCB.setText(getBundleString( "CFEP_InitialComment" )); 156 initialCommentCB.addItemListener(new java.awt.event.ItemListener () { 157 public void itemStateChanged(java.awt.event.ItemEvent evt) { 158 initialCommentCBItemStateChanged(evt); 159 } 160 }); 161 162 gridBagConstraints = new java.awt.GridBagConstraints (); 163 gridBagConstraints.gridx = 0; 164 gridBagConstraints.gridy = 6; 165 gridBagConstraints.insets = new java.awt.Insets (0, 24, 0, 0); 166 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 167 add(initialCommentCB, gridBagConstraints); 168 169 } 171 private void initialCommentCBItemStateChanged(java.awt.event.ItemEvent evt) { notifyEditor(); 173 } 175 private void javadocCBItemStateChanged(java.awt.event.ItemEvent evt) { notifyEditor(); 177 } 179 private void importCBItemStateChanged(java.awt.event.ItemEvent evt) { notifyEditor(); 181 } 183 private void innerCBItemStateChanged(java.awt.event.ItemEvent evt) { notifyEditor(); 185 } 187 private void methodCBItemStateChanged(java.awt.event.ItemEvent evt) { notifyEditor(); 189 } 191 private void checkBoxChange(java.awt.event.ItemEvent evt) { setCBoxesEnabled(evt.getStateChange() == ItemEvent.SELECTED); 193 notifyEditor(); 194 } 196 197 private void notifyEditor() { 198 if( foldingEditor != null ) foldingEditor.customEditorChange(); 199 } 200 201 private void setCBoxesEnabled(boolean selected){ 202 methodCB.setEnabled(selected); 203 innerCB.setEnabled(selected); 204 importCB.setEnabled(selected); 205 javadocCB.setEnabled(selected); 206 initialCommentCB.setEnabled(selected); 207 } 208 209 212 public void setValue( Map m ) { 213 214 Boolean val = (Boolean )m.get(SettingsNames.CODE_FOLDING_ENABLE); 215 if (val.booleanValue() == false){ 216 setCBoxesEnabled(false); 217 } 218 enableFoldingCB.setSelected(val.booleanValue()); 219 220 System.err.println("Not yet storing settings"); 221 236 } 237 238 241 public Map getValue() { 242 Map ret = new HashMap (10); 243 System.err.println("Not yet storing settings"); 244 return ret; 251 } 252 253 private String getBundleString(String s) { 254 return NbBundle.getMessage(CodeFoldingEditorPanel.class, s); 255 } 256 257 258 private javax.swing.JCheckBox enableFoldingCB; 260 private javax.swing.JCheckBox importCB; 261 private javax.swing.JCheckBox initialCommentCB; 262 private javax.swing.JCheckBox innerCB; 263 private javax.swing.JLabel jLabel1; 264 private javax.swing.JCheckBox javadocCB; 265 private javax.swing.JCheckBox methodCB; 266 268 } 269 | Popular Tags |