1 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 33 34 public abstract class JavaFoldManager implements FoldManager { 35 36 public static final FoldType INITIAL_COMMENT_FOLD_TYPE = new FoldType("initial-comment"); 38 public static final FoldType IMPORTS_FOLD_TYPE = new FoldType("imports"); 40 public static final FoldType JAVADOC_FOLD_TYPE = new FoldType("javadoc"); 42 public static final FoldType CODE_BLOCK_FOLD_TYPE = new FoldType("code-block"); 44 private static final String IMPORTS_FOLD_DESCRIPTION = "..."; 46 private static final String COMMENT_FOLD_DESCRIPTION = "/*...*/"; 48 private static final String JAVADOC_FOLD_DESCRIPTION = "/**...*/"; 50 private static final String CODE_BLOCK_FOLD_DESCRIPTION = "{...}"; 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 description; 70 71 private int startGuardedLength; 72 73 private int endGuardedLength; 74 75 protected FoldTemplate(FoldType type, String 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 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 |