KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > retouche > editor > options > CodeFoldingEditorPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.retouche.editor.options;
21
22 import java.awt.event.ItemEvent JavaDoc;
23 import java.util.HashMap JavaDoc;
24 import java.util.Map JavaDoc;
25 import org.netbeans.editor.SettingsNames;
26 //import org.netbeans.editor.ext.java.JavaSettingsNames;
27
import org.openide.util.NbBundle;
28
29 /**
30  * This file is originally from Retouche, the Java Support
31  * infrastructure in NetBeans. I have modified the file as little
32  * as possible to make merging Retouche fixes back as simple as
33  * possible.
34  *
35  *
36  * @author Martin Roskanin
37  */

38 public class CodeFoldingEditorPanel extends javax.swing.JPanel JavaDoc {
39
40     CodeFoldingEditor foldingEditor;
41
42     /** Creates new form CodeFoldingEditorPanel */
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)); //NOI18N
51
methodCB.setMnemonic(getBundleString("CFEP_Method_Mnemonic").charAt(0)); //NOI18N
52
innerCB.setMnemonic(getBundleString("CFEP_InnerClass_Mnemonic").charAt(0)); //NOI18N
53
importCB.setMnemonic(getBundleString("CFEP_Import_Mnemonic").charAt(0)); //NOI18N
54
javadocCB.setMnemonic(getBundleString("CFEP_Javadoc_Mnemonic").charAt(0)); //NOI18N
55
initialCommentCB.setMnemonic(getBundleString("CFEP_InitialComment_Mnemonic").charAt(0)); //NOI18N
56
}
57     
58     /** This method is called from within the constructor to
59      * initialize the form.
60      * WARNING: Do NOT modify this code. The content of this method is
61      * always regenerated by the Form Editor.
62      */

63     private void initComponents() {//GEN-BEGIN:initComponents
64
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
65
66         enableFoldingCB = new javax.swing.JCheckBox JavaDoc();
67         jLabel1 = new javax.swing.JLabel JavaDoc();
68         methodCB = new javax.swing.JCheckBox JavaDoc();
69         innerCB = new javax.swing.JCheckBox JavaDoc();
70         importCB = new javax.swing.JCheckBox JavaDoc();
71         javadocCB = new javax.swing.JCheckBox JavaDoc();
72         initialCommentCB = new javax.swing.JCheckBox JavaDoc();
73
74         setLayout(new java.awt.GridBagLayout JavaDoc());
75
76         enableFoldingCB.setText(getBundleString( "CFEP_UseCF" ));
77         enableFoldingCB.addItemListener(new java.awt.event.ItemListener JavaDoc() {
78             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
79                 checkBoxChange(evt);
80             }
81         });
82
83         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(12, 12, 12, 0);
89         add(enableFoldingCB, gridBagConstraints);
90
91         jLabel1.setText(getBundleString( "CFEP_CollapsedByDefault" ));
92         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
93         gridBagConstraints.gridx = 0;
94         gridBagConstraints.gridy = 1;
95         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
96         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 5, 11);
97         add(jLabel1, gridBagConstraints);
98
99         methodCB.setText(getBundleString( "CFEP_Method" ));
100         methodCB.addItemListener(new java.awt.event.ItemListener JavaDoc() {
101             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
102                 methodCBItemStateChanged(evt);
103             }
104         });
105
106         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
107         gridBagConstraints.gridx = 0;
108         gridBagConstraints.gridy = 2;
109         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
110         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 24, 0, 0);
111         add(methodCB, gridBagConstraints);
112
113         innerCB.setText(getBundleString( "CFEP_InnerClass" ));
114         innerCB.addItemListener(new java.awt.event.ItemListener JavaDoc() {
115             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
116                 innerCBItemStateChanged(evt);
117             }
118         });
119
120         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
121         gridBagConstraints.gridx = 0;
122         gridBagConstraints.gridy = 3;
123         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
124         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 24, 0, 0);
125         add(innerCB, gridBagConstraints);
126
127         importCB.setText(getBundleString( "CFEP_Import" ));
128         importCB.addItemListener(new java.awt.event.ItemListener JavaDoc() {
129             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
130                 importCBItemStateChanged(evt);
131             }
132         });
133
134         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
135         gridBagConstraints.gridx = 0;
136         gridBagConstraints.gridy = 4;
137         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
138         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 24, 0, 0);
139         add(importCB, gridBagConstraints);
140
141         javadocCB.setText(getBundleString( "CFEP_Javadoc" ));
142         javadocCB.addItemListener(new java.awt.event.ItemListener JavaDoc() {
143             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
144                 javadocCBItemStateChanged(evt);
145             }
146         });
147
148         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
149         gridBagConstraints.gridx = 0;
150         gridBagConstraints.gridy = 5;
151         gridBagConstraints.insets = new java.awt.Insets JavaDoc(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 JavaDoc() {
157             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
158                 initialCommentCBItemStateChanged(evt);
159             }
160         });
161
162         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
163         gridBagConstraints.gridx = 0;
164         gridBagConstraints.gridy = 6;
165         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 24, 0, 0);
166         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
167         add(initialCommentCB, gridBagConstraints);
168
169     }//GEN-END:initComponents
170

171     private void initialCommentCBItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_initialCommentCBItemStateChanged
172
notifyEditor();
173     }//GEN-LAST:event_initialCommentCBItemStateChanged
174

175     private void javadocCBItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_javadocCBItemStateChanged
176
notifyEditor();
177     }//GEN-LAST:event_javadocCBItemStateChanged
178

179     private void importCBItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_importCBItemStateChanged
180
notifyEditor();
181     }//GEN-LAST:event_importCBItemStateChanged
182

183     private void innerCBItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_innerCBItemStateChanged
184
notifyEditor();
185     }//GEN-LAST:event_innerCBItemStateChanged
186

187     private void methodCBItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_methodCBItemStateChanged
188
notifyEditor();
189     }//GEN-LAST:event_methodCBItemStateChanged
190

191     private void checkBoxChange(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_checkBoxChange
192
setCBoxesEnabled(evt.getStateChange() == ItemEvent.SELECTED);
193         notifyEditor();
194     }//GEN-LAST:event_checkBoxChange
195

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     /**
210      * Fill in editor with initial values
211      */

212     public void setValue( Map JavaDoc m ) {
213
214         Boolean JavaDoc val = (Boolean JavaDoc)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 // val = (Boolean)m.get(JavaSettingsNames.CODE_FOLDING_COLLAPSE_METHOD);
222
// methodCB.setSelected(val.booleanValue());
223
//
224
// val = (Boolean)m.get(JavaSettingsNames.CODE_FOLDING_COLLAPSE_INNERCLASS);
225
// innerCB.setSelected(val.booleanValue());
226
//
227
// val = (Boolean)m.get(JavaSettingsNames.CODE_FOLDING_COLLAPSE_IMPORT);
228
// importCB.setSelected(val.booleanValue());
229
//
230
// val = (Boolean)m.get(JavaSettingsNames.CODE_FOLDING_COLLAPSE_JAVADOC);
231
// javadocCB.setSelected(val.booleanValue());
232
//
233
// val = (Boolean)m.get(JavaSettingsNames.CODE_FOLDING_COLLAPSE_INITIAL_COMMENT);
234
// initialCommentCB.setSelected(val.booleanValue());
235

236     }
237
238     /**
239      * Take the result of users modifications
240      */

241     public Map JavaDoc getValue() {
242         Map JavaDoc ret = new HashMap JavaDoc(10);
243  System.err.println("Not yet storing settings");
244 // ret.put(SettingsNames.CODE_FOLDING_ENABLE, Boolean.valueOf(enableFoldingCB.isSelected()));
245
// ret.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_METHOD, Boolean.valueOf(methodCB.isSelected()));
246
// ret.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_INNERCLASS, Boolean.valueOf(innerCB.isSelected()));
247
// ret.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_IMPORT, Boolean.valueOf(importCB.isSelected()));
248
// ret.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_JAVADOC, Boolean.valueOf(javadocCB.isSelected()));
249
// ret.put(JavaSettingsNames.CODE_FOLDING_COLLAPSE_INITIAL_COMMENT, Boolean.valueOf(initialCommentCB.isSelected()));
250
return ret;
251     }
252
253     private String JavaDoc getBundleString(String JavaDoc s) {
254         return NbBundle.getMessage(CodeFoldingEditorPanel.class, s);
255     }
256
257     
258     // Variables declaration - do not modify//GEN-BEGIN:variables
259
private javax.swing.JCheckBox JavaDoc enableFoldingCB;
260     private javax.swing.JCheckBox JavaDoc importCB;
261     private javax.swing.JCheckBox JavaDoc initialCommentCB;
262     private javax.swing.JCheckBox JavaDoc innerCB;
263     private javax.swing.JLabel JavaDoc jLabel1;
264     private javax.swing.JCheckBox JavaDoc javadocCB;
265     private javax.swing.JCheckBox JavaDoc methodCB;
266     // End of variables declaration//GEN-END:variables
267

268 }
269
Popular Tags