public final class FoldInfo extends Object
FoldOperation.addToHierarchy(FoldType, int, int, Boolean, FoldTemplate, String, Object, FoldHierarchyTransaction)
.
Set of FoldInfos can be then applied to the FoldHieararchy, creating new, and removing obsolete Folds, so that
Folds which prevail remain in the hierarchy. The mandatory information is start and end of the fold, and the FoldType
.
If necessary, a FoldTemplate
attached to the FoldType can be overriden for the specific Fold instance. Note though, that
if the FoldTemplate instance changes with the next fold update, the Fold may fire change events.
Ultimately, it is possible to hand-override the Fold's description from the FoldTemplate provided value.
If the FoldInfo is used to update an existing Fold, the or the FoldTemplate's properties collapsed state are updated to the existing Fold instance. Appropriate fold change event is fired. It is not possible to change the type of the fold.
Initial folding state can be specified, for the case the fold will be created (it does not exist). If unspecified,
the infrastructure can assign an appropriate state based on e.g. user preferences. Collapsed state is never changed
for existing folds, even though FoldInfo specifies a value.
Use FoldUtilities
to perform the process.
Modifier and Type | Method and Description |
---|---|
FoldInfo |
attach(Object extraInfo)
Attaches custom extra info to the fold.
|
FoldInfo |
collapsed(boolean state)
Records the desired collapsed state.
|
Boolean |
getCollapsed()
Provides the desired collapsed state or
null , if no specific
state is required. |
String |
getDescriptionOverride()
Returns description override.
|
int |
getEnd()
Provides end offset of the folded content
|
Object |
getExtraInfo()
Returns the extra information attached to a fold.
|
int |
getStart()
Provides start offset of the folded content
|
FoldTemplate |
getTemplate()
Provides FoldTemplate to be used with the Fold.
|
FoldType |
getType()
Provides FoldType for the fold.
|
static FoldInfo |
range(int start,
int end,
FoldType type)
Creates a FoldInfo for the specified range.
|
String |
toString() |
FoldInfo |
withDescription(String desc)
Use to provide a custom description for the fold.
|
FoldInfo |
withTemplate(FoldTemplate t)
Attaches FoldTemplate to the FoldInfo.
|
public static FoldInfo range(int start, int end, FoldType type)
start
- start offsetend
- end offsettype
- type of the foldpublic FoldInfo withTemplate(FoldTemplate t)
FoldType.getTemplate()
.t
- fold templatepublic FoldInfo withDescription(String desc)
FoldTemplate
for explanation. When null
is set, the
description Fold reverts back to the one provided by FoldTemplates (the override is cleared).desc
- description text.public FoldInfo attach(Object extraInfo)
org.netbeans.api.editor.fold.Fold#getExtraInfo()
.extraInfo
- custom datapublic String getDescriptionOverride()
null
, information from FoldTemplates should be used.null
.public Object getExtraInfo()
null
if no data is presentpublic FoldInfo collapsed(boolean state)
state
- the desired collapsed statepublic int getStart()
public int getEnd()
public FoldTemplate getTemplate()
FoldType.getTemplate()
.
Null
return value means that the FoldTemplate from the FoldType is in effect.null
public FoldType getType()
FoldOperation.update(java.util.Collection<org.netbeans.spi.editor.fold.FoldInfo>, java.util.Collection<org.netbeans.api.editor.fold.Fold>, java.util.Collection<org.netbeans.spi.editor.fold.FoldInfo>)
, the fold will be destroyed and re-created. It is not possible to change FoldType
of a Fold.null
.public Boolean getCollapsed()
null
, if no specific
state is required.
When null
is reported, the infrastructure can assign an an appropriate initial state to the fold,
e.g. based on user preferences. States of existing fold is never changed during update.null