001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.editor.fold;
043:
044: import javax.swing.event.DocumentEvent;
045: import javax.swing.text.BadLocationException;
046: import javax.swing.text.Document;
047: import org.netbeans.api.editor.fold.Fold;
048: import org.netbeans.api.editor.fold.FoldHierarchy;
049: import org.netbeans.api.editor.fold.FoldHierarchyEvent;
050: import org.netbeans.api.editor.fold.FoldStateChange;
051: import org.netbeans.api.editor.fold.FoldType;
052:
053: /**
054: * Accessor for the package-private functionality in org.netbeans.api.editor.fold.
055: *
056: * @author Miloslav Metelka
057: * @version 1.00
058: */
059:
060: public abstract class ApiPackageAccessor {
061:
062: private static ApiPackageAccessor INSTANCE;
063:
064: public static ApiPackageAccessor get() {
065: return INSTANCE;
066: }
067:
068: /**
069: * Register the accessor. The method can only be called once
070: * - othewise it throws IllegalStateException.
071: *
072: * @param accessor instance.
073: */
074: public static void register(ApiPackageAccessor accessor) {
075: if (INSTANCE != null) {
076: throw new IllegalStateException("Already registered"); // NOI18N
077: }
078: INSTANCE = accessor;
079: }
080:
081: public abstract FoldHierarchy createFoldHierarchy(
082: FoldHierarchyExecution execution);
083:
084: public abstract Fold createFold(FoldOperationImpl operation,
085: FoldType type, String description, boolean collapsed,
086: Document doc, int startOffset, int endOffset,
087: int startGuardedLength, int endGuardedLength,
088: Object extraInfo) throws BadLocationException;
089:
090: public abstract FoldHierarchyEvent createFoldHierarchyEvent(
091: FoldHierarchy source, Fold[] removedFolds,
092: Fold[] addedFolds, FoldStateChange[] foldStateChanges,
093: int affectedStartOffset, int affectedEndOffset);
094:
095: public abstract FoldStateChange createFoldStateChange(Fold fold);
096:
097: public abstract void foldSetCollapsed(Fold fold, boolean collapsed);
098:
099: public abstract void foldSetParent(Fold fold, Fold parent);
100:
101: public abstract void foldExtractToChildren(Fold fold, int index,
102: int length, Fold targetFold);
103:
104: public abstract Fold foldReplaceByChildren(Fold fold, int index);
105:
106: public abstract void foldSetDescription(Fold fold,
107: String description);
108:
109: public abstract void foldSetStartOffset(Fold fold, Document doc,
110: int startOffset) throws BadLocationException;
111:
112: public abstract void foldSetEndOffset(Fold fold, Document doc,
113: int endOffset) throws BadLocationException;
114:
115: public abstract boolean foldIsStartDamaged(Fold fold);
116:
117: public abstract boolean foldIsEndDamaged(Fold fold);
118:
119: public abstract boolean foldIsExpandNecessary(Fold fold);
120:
121: public abstract void foldInsertUpdate(Fold fold, DocumentEvent evt);
122:
123: public abstract void foldRemoveUpdate(Fold fold, DocumentEvent evt);
124:
125: public abstract FoldOperationImpl foldGetOperation(Fold fold);
126:
127: public abstract int foldGetRawIndex(Fold fold);
128:
129: public abstract void foldSetRawIndex(Fold fold, int rawIndex);
130:
131: public abstract void foldUpdateRawIndex(Fold fold, int rawIndexDelta);
132:
133: public abstract Object foldGetExtraInfo(Fold fold);
134:
135: public abstract void foldStateChangeCollapsedChanged(
136: FoldStateChange fsc);
137:
138: public abstract void foldStateChangeDescriptionChanged(
139: FoldStateChange fsc);
140:
141: public abstract void foldStateChangeStartOffsetChanged(
142: FoldStateChange fsc, int originalStartOffset);
143:
144: public abstract void foldStateChangeEndOffsetChanged(
145: FoldStateChange fsc, int originalEndOffset);
146:
147: }
|