KickJava   Java API By Example, From Geeks To Geeks.

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


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.beans.PropertyEditorSupport JavaDoc;
23 import java.util.HashMap JavaDoc;
24 import java.util.Map JavaDoc;
25 import org.openide.util.HelpCtx;
26 import org.openide.util.NbBundle;
27
28 /**
29  * This file is originally from Retouche, the Java Support
30  * infrastructure in NetBeans. I have modified the file as little
31  * as possible to make merging Retouche fixes back as simple as
32  * possible.
33  *
34  *
35  * @author Martin Roskanin
36  */

37 public class CodeFoldingEditor extends PropertyEditorSupport JavaDoc{
38
39     protected HelpCtx getHelpCtx () {
40         return HelpCtx.DEFAULT_HELP;
41     }
42
43     /** Creates a new instance of CodeFoldingEditor */
44     public CodeFoldingEditor() {
45     }
46
47     public boolean supportsCustomEditor() {
48         return true;
49     }
50
51     
52     private CodeFoldingEditorPanel editorPanel;
53     
54     /**
55      * Create custom editor tightly coupled with this editor
56      */

57     public java.awt.Component JavaDoc getCustomEditor() {
58         if( editorPanel == null ) {
59             editorPanel = new CodeFoldingEditorPanel( this );
60             HelpCtx.setHelpIDString( editorPanel, getHelpCtx().getHelpID() );
61             refreshEditorPanel();
62         }
63         return editorPanel;
64     }
65
66     private void refreshEditorPanel() {
67         if( editorPanel != null ) {
68             editorPanel.setValue( (Map JavaDoc)getValue() );
69         }
70     }
71
72     /**
73      * Sets the value for editor / customEditor
74      */

75     public void setValue( Object JavaDoc obj ) {
76         Object JavaDoc oldValue = getValue();
77         if( (obj != null) && (! obj.equals( oldValue ) ) ) {
78             super.setValue( obj );
79             if( ( editorPanel != null ) && (! editorPanel.getValue().equals( getValue() ) ) ) {
80                 refreshEditorPanel();
81             }
82         }
83     }
84
85     /**
86      * The way our customEditor notifies us when user changes something.
87      */

88     protected void customEditorChange() {
89         // forward it to parent, which will fire propertyChange
90
super.setValue( new HashMap JavaDoc( editorPanel.getValue() ) );
91     }
92
93     /**
94      * Return the label to be shown in the PropertySheet
95      */

96     public String JavaDoc getAsText() {
97         return NbBundle.getBundle( CodeFoldingEditor.class ).getString( "PROP_CodeFolding" ); // NOI18N
98
}
99
100     /**
101      * Don't bother if the user tried to edit our label in the PropertySheet
102      */

103     public void setAsText( String JavaDoc s ) {
104     }
105     
106     
107 }
108
109
Popular Tags