Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.netbeans.modules.editor.fold/1 1.5.22
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.netbeans.spi.editor.fold
Class FoldOperation

    java.lang.Object
      org.netbeans.spi.editor.fold.FoldOperation

    public final class FoldOperation

extends Object

Fold operation represents services provided to an individual fold manager.
Each manager has its own dedicated instance of fold operation.

There are three main services - creation of a new fold and adding or removing it from the hierarchy.
Adding and removing of the folds requires a valid transaction that can be obtained by `openTransaction()`.

Method Summary
`Fold` | `addToHierarchy(FoldType type, String description, boolean collapsed, int startOffset, int endOffset, int startGuardedLength, int endGuardedLength, Object extraInfo, FoldHierarchyTransaction transaction)` Create new fold instance and add it to the hierarchy.
`Object` | `getExtraInfo(Fold fold)` Return extra info object passed to fold at time of its creation.
`FoldHierarchy` | `getHierarchy()` Get the hierarchy for which this fold operations works.
`boolean` | `isAddedOrBlocked(Fold fold)` Check whether the fold is currently present in the hierarchy or blocked.
`boolean` | `isBlocked(Fold fold)` Is the given fold blocked by another fold?
`static boolean` | `isBoundsValid(int startOffset, int endOffset, int startGuardedLength, int endGuardedLength)` This static method can be used to check whether the bounds of the fold that is planned to be added are valid.
`boolean` | `isEndDamaged(Fold fold)` Check whether the ending guarded area of the fold is damaged by a document modification.
`boolean` | `isReleased()`
`boolean` | `isStartDamaged(Fold fold)` Check whether the starting guarded area of the fold is damaged by a document modification.
`FoldHierarchyTransaction` | `openTransaction()` Open a new transaction over the fold hierarchy.
`void` | `removeFromHierarchy(Fold fold, FoldHierarchyTransaction transaction)` Remove the fold that is either present in the hierarchy or blocked by another fold.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### addToHierarchy

    public Fold addToHierarchy(FoldType type,
                               String description,
                               boolean collapsed,
                               int startOffset,
                               int endOffset,
                               int startGuardedLength,
                               int endGuardedLength,
                               Object extraInfo,
                               FoldHierarchyTransaction transaction)
                        throws BadLocationException

  Create new fold instance and add it to the hierarchy.
  The fold will either become part of the hierarchy directly or it will become blocked by another fold already present in the hierarchy.
  Once the blocking fold gets removed this fold will be phyiscally added to the hierarchy automatically.

  The fold is logically bound to the fold manager that uses this fold operation.
  The fold can only be removed by this fold operation.

  Parameters:
    `type` - type of the fold to be assigned to the fold.
    `description` - textual description of the fold that will be displayed once the fold becomes collapsed.
    `collapsed` - whether the fold should initially be collapsed or expanded.
    `startOffset` - starting offset of the fold. The fold creates swing position for the offset.
    `endOffset` - ending offset of the fold. The fold creates swing position for the offset.
    `startGuardedLength` - >=0 initial guarded area of the fold (starting at the start offset). If the guarded area is modified the fold will be removed automatically.
    `endGuardedLength` - >=0 ending guarded area of the fold (ending at the end offset). If the guarded area is modified the fold will be removed automatically.
    `extraInfo` - arbitrary extra information specific for the fold being created. It's not touched or used by the folding infrastructure in any way. `null`can be passed if there is no extra information.
    The extra info of the existing fold can be obtained by `getExtraInfo(org.netbeans.api.editor.fold.Fold)`.``
  Returns:
    new fold instance that was added to the hierarchy.
  Throws:
    `BadLocationException`

### isBoundsValid

    public static boolean isBoundsValid(int startOffset,
                                        int endOffset,
                                        int startGuardedLength,
                                        int endGuardedLength)

  This static method can be used to check whether the bounds of the fold that is planned to be added are valid.
  The conditions are:

        startOffset < endOffset

        startGuardedLength >= 0

        endGuardedLength >= 0

        startOffset + startGuardedLength <= endOffset - endGuardedLength

  Returns:
    true if the bounds are OK or false otherwise.

### removeFromHierarchy

    public void removeFromHierarchy(Fold fold,
                                    FoldHierarchyTransaction transaction)

  Remove the fold that is either present in the hierarchy or blocked by another fold.

  Parameters:
    `fold` - fold to be removed
    `transaction` - non-null transaction under which the fold should be removed.

### getExtraInfo

    public Object getExtraInfo(Fold fold)

  Return extra info object passed to fold at time of its creation.

  Returns:
    extra information object specific for the fold or null if there was no extra info.

### isStartDamaged

    public boolean isStartDamaged(Fold fold)

  Check whether the starting guarded area of the fold is damaged by a document modification.

  Parameters:
    `fold` - fold to check. The fold must be managed by this fold operation.
  Returns:
    true if the starting area of the fold was damaged by the modification or false otherwise.

### isEndDamaged

    public boolean isEndDamaged(Fold fold)

  Check whether the ending guarded area of the fold is damaged by a document modification.

  Parameters:
    `fold` - fold to check. The fold must be managed by this fold operation.
  Returns:
    true if the ending area of the fold was damaged by the modification or false otherwise.

### openTransaction

    public FoldHierarchyTransaction openTransaction()

  Open a new transaction over the fold hierarchy.
  Note: Always use the following pattern:

           FoldHierarchyTransaction transaction = operation.openTransaction();
           try {
               ...
           } finally {
               transaction.commit();
           }

  Returns:
    opened transaction for further use.

### isAddedOrBlocked

    public boolean isAddedOrBlocked(Fold fold)

  Check whether the fold is currently present in the hierarchy or blocked.

  Returns:
    true if the fold is currently present in the hierarchy or blocked or false otherwise.

### isBlocked

    public boolean isBlocked(Fold fold)

  Is the given fold blocked by another fold?

### getHierarchy

    public FoldHierarchy getHierarchy()

  Get the hierarchy for which this fold operations works.

### isReleased

    public boolean isReleased()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.netbeans.modules.editor.fold/1 1.5.22
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Built on December 7 2006. | Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.