KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > editor > ext > java > JavaFoldManager


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.editor.ext.java;
21
22 import org.netbeans.api.editor.fold.Fold;
23 import org.netbeans.api.editor.fold.FoldHierarchy;
24 import org.netbeans.api.editor.fold.FoldType;
25 import org.netbeans.spi.editor.fold.FoldManager;
26
27 /**
28  * Java fold maintainer creates and updates folds for java sources.
29  *
30  * @author Miloslav Metelka
31  * @version 1.00
32  */

33
34 public abstract class JavaFoldManager implements FoldManager {
35
36     public static final FoldType INITIAL_COMMENT_FOLD_TYPE = new FoldType("initial-comment"); // NOI18N
37

38     public static final FoldType IMPORTS_FOLD_TYPE = new FoldType("imports"); // NOI18N
39

40     public static final FoldType JAVADOC_FOLD_TYPE = new FoldType("javadoc"); // NOI18N
41

42     public static final FoldType CODE_BLOCK_FOLD_TYPE = new FoldType("code-block"); // NOI18N
43

44     private static final String JavaDoc IMPORTS_FOLD_DESCRIPTION = "..."; // NOI18N
45

46     private static final String JavaDoc COMMENT_FOLD_DESCRIPTION = "/*...*/"; // NOI18N
47

48     private static final String JavaDoc JAVADOC_FOLD_DESCRIPTION = "/**...*/"; // NOI18N
49

50     private static final String JavaDoc CODE_BLOCK_FOLD_DESCRIPTION = "{...}"; // NOI18N
51

52     public static final FoldTemplate INITIAL_COMMENT_FOLD_TEMPLATE
53         = new FoldTemplate(INITIAL_COMMENT_FOLD_TYPE, COMMENT_FOLD_DESCRIPTION, 2, 2);
54
55     public static final FoldTemplate IMPORTS_FOLD_TEMPLATE
56         = new FoldTemplate(IMPORTS_FOLD_TYPE, IMPORTS_FOLD_DESCRIPTION, 0, 0);
57
58     public static final FoldTemplate JAVADOC_FOLD_TEMPLATE
59         = new FoldTemplate(JAVADOC_FOLD_TYPE, JAVADOC_FOLD_DESCRIPTION, 3, 2);
60
61     public static final FoldTemplate CODE_BLOCK_FOLD_TEMPLATE
62         = new FoldTemplate(CODE_BLOCK_FOLD_TYPE, CODE_BLOCK_FOLD_DESCRIPTION, 1, 1);
63
64     
65     protected static final class FoldTemplate {
66         
67         private FoldType type;
68         
69         private String JavaDoc description;
70         
71         private int startGuardedLength;
72         
73         private int endGuardedLength;
74         
75         protected FoldTemplate(FoldType type, String JavaDoc description,
76         int startGuardedLength, int endGuardedLength) {
77             this.type = type;
78             this.description = description;
79             this.startGuardedLength = startGuardedLength;
80             this.endGuardedLength = endGuardedLength;
81         }
82         
83         public FoldType getType() {
84             return type;
85         }
86         
87         public String JavaDoc getDescription() {
88             return description;
89         }
90         
91         public int getStartGuardedLength() {
92             return startGuardedLength;
93         }
94         
95         public int getEndGuardedLength() {
96             return endGuardedLength;
97         }
98
99     }
100
101 }
102
Popular Tags