public class DefaultCodeFoldingModel<B extends DefaultFoldingBlock> extends java.lang.Object implements CodeFoldingModel<B>
| Modifier and Type | Field and Description | 
|---|---|
protected BasicDocument | 
document  | 
protected javax.swing.event.EventListenerList | 
listenerList  | 
protected ReadWriteLock | 
lock  | 
protected static int | 
MAX_TOOLTIP_LENGTH  | 
protected static DefaultFoldingBlock[] | 
NO_BLOCKS  | 
protected DefaultFoldingBlock | 
root  | 
| Constructor and Description | 
|---|
DefaultCodeFoldingModel(BasicDocument document)  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addCodeFoldingModelListener(CodeFoldingModelListener listener)
Adds a listener for changes to the data model. 
 | 
protected void | 
fireStructureChanged(B block)  | 
java.lang.String | 
getAbbreviatedText(B block)
Returns the abbreviated text to be used in place of the specified
 folding block when the block is collapsed. 
 | 
java.util.Iterator<B> | 
getChildren(B parent)
Returns an  
Iterator over the children of the specified
 folding block. | 
CodeFoldingModelListener[] | 
getCodeFoldingModelListeners()  | 
B[] | 
getCollapsedBlocks()
Returns the set of all collapsed blocks in the model; any collapsed
 block that also has a collapsed ancestor must be excluded from the
 return array. 
 | 
protected void | 
getCollapsedDescendants(B block,
                       java.util.Collection collapsed)  | 
BasicDocument | 
getDocument()  | 
protected B | 
getEnclosingDescendant(B block,
                      int offset)  | 
B | 
getFirstBlockAtLine(int line)
Returns the first collapsible source code block at the specified line. 
 | 
protected B | 
getFirstDescendantAtLine(B block,
                        int line)  | 
protected int | 
getLineCount()  | 
protected int | 
getLineEndOffset(int line)  | 
protected int | 
getLineFromOffset(int offset)  | 
protected int | 
getLineStartOffset(int line)  | 
B | 
getParent(B child)
Returns the parent block for the specified folding block. 
 | 
B | 
getRoot()
Returns the root block in the data model. 
 | 
B | 
getSmallestEnclosingBlock(int offset)
Returns the smallest collapsible source code block that contains the
 specified character offset. 
 | 
int[] | 
getTextOffsets(B block,
              int[] offsets)
Stores the start and end character offsets of the specified block into
 the specified two-element integer array, and returns that array; if
 the specified array is  
null, a new array is allocated. | 
java.lang.String | 
getToolTipText(B block)
Returns the tooltip text to display when the mouse is hovering over
 the specified source code block and the block is collapsed. 
 | 
void | 
insertUpdate(int offset,
            int length)  | 
protected void | 
insertUpdateChildren(B block,
                    int offset,
                    int length)  | 
boolean | 
isExpanded(B block)
Returns whether the specified folding block is expanded. 
 | 
void | 
readLock()
Acquires a read lock on the model. 
 | 
void | 
readUnlock()
Releases the previously acquired read lock on the model. 
 | 
void | 
reload()  | 
void | 
removeCodeFoldingModelListener(CodeFoldingModelListener listener)
Removes a listener from the data model. 
 | 
void | 
removeUpdate(int offset,
            int length)  | 
protected void | 
removeUpdateChildren(B block,
                    int offset,
                    int length)  | 
void | 
setExpanded(B block,
           boolean isExpanded)
Sets whether the specified folding block should be expanded. 
 | 
void | 
setRoot(B root)  | 
protected void | 
writeLock()  | 
protected void | 
writeUnlock()  | 
protected static final int MAX_TOOLTIP_LENGTH
protected static final DefaultFoldingBlock[] NO_BLOCKS
protected DefaultFoldingBlock root
protected BasicDocument document
protected javax.swing.event.EventListenerList listenerList
protected ReadWriteLock lock
public DefaultCodeFoldingModel(BasicDocument document)
public BasicDocument getDocument()
public void reload()
public void setRoot(B root)
public CodeFoldingModelListener[] getCodeFoldingModelListeners()
public void insertUpdate(int offset,
                         int length)
public void removeUpdate(int offset,
                         int length)
protected void insertUpdateChildren(B block, int offset, int length)
protected void removeUpdateChildren(B block, int offset, int length)
public void readLock()
CodeFoldingModelreadLock in interface CodeFoldingModel<B extends DefaultFoldingBlock>public void readUnlock()
CodeFoldingModelreadUnlock in interface CodeFoldingModel<B extends DefaultFoldingBlock>public B getRoot()
CodeFoldingModelThe client must acquire a lock on the model before calling this method.
getRoot in interface CodeFoldingModel<B extends DefaultFoldingBlock>null if there is no root
         block in the modelpublic B getSmallestEnclosingBlock(int offset)
CodeFoldingModelThe client must acquire a lock on the model before calling this method.
getSmallestEnclosingBlock in interface CodeFoldingModel<B extends DefaultFoldingBlock>offset - the target character offsetnull if the model is empty or the offset is
         invalidpublic B getFirstBlockAtLine(int line)
CodeFoldingModelThe client must acquire a lock on the model before calling this method.
getFirstBlockAtLine in interface CodeFoldingModel<B extends DefaultFoldingBlock>line - the target linenull
         if the model is empty or the offset is invalidpublic B[] getCollapsedBlocks()
CodeFoldingModelThe client must acquire a lock on the model before calling this method.
getCollapsedBlocks in interface CodeFoldingModel<B extends DefaultFoldingBlock>nullpublic java.lang.String getToolTipText(B block)
CodeFoldingModelThe client must acquire a lock on the model before calling this method.
getToolTipText in interface CodeFoldingModel<B extends DefaultFoldingBlock>block - the target source code blockpublic java.util.Iterator<B> getChildren(B parent)
CodeFoldingModelIterator over the children of the specified
 folding block.  The return value may not be null; if the
 block contains no children, an empty Iterator should be
 returned.
 The client must acquire a lock on the model before calling this method.
getChildren in interface CodeFoldingModel<B extends DefaultFoldingBlock>parent - the parent folding block from this data sourcenull.public B getParent(B child)
CodeFoldingModelThe client must acquire a lock on the model before calling this method.
getParent in interface CodeFoldingModel<B extends DefaultFoldingBlock>child - the child folding block from this data sourcenull if the specified
         block is the rootpublic int[] getTextOffsets(B block, int[] offsets)
CodeFoldingModelnull, a new array is allocated.
 The client must acquire a lock on the model before calling this method.
getTextOffsets in interface CodeFoldingModel<B extends DefaultFoldingBlock>block - a folding block from this data sourceoffsets - a two-element integer array; if null,
        a new array is allocatedpublic java.lang.String getAbbreviatedText(B block)
CodeFoldingModelThe client must acquire a lock on the model before calling this method.
getAbbreviatedText in interface CodeFoldingModel<B extends DefaultFoldingBlock>block - a folding block from this data sourcepublic boolean isExpanded(B block)
CodeFoldingModelThis method may be called without acquiring a lock on the model.
isExpanded in interface CodeFoldingModel<B extends DefaultFoldingBlock>block - a folding block from this data sourcetrue if the folding block is expandedpublic void setExpanded(B block, boolean isExpanded)
CodeFoldingModelThis method may be called without acquiring a lock on the model.
setExpanded in interface CodeFoldingModel<B extends DefaultFoldingBlock>block - a folding block from this data sourceisExpanded - true if the folding block should
        be expandedpublic void addCodeFoldingModelListener(CodeFoldingModelListener listener)
CodeFoldingModelThis method may be called without acquiring a lock on the model.
addCodeFoldingModelListener in interface CodeFoldingModel<B extends DefaultFoldingBlock>listener - the listener to addpublic void removeCodeFoldingModelListener(CodeFoldingModelListener listener)
CodeFoldingModelThis method may be called without acquiring a lock on the model.
removeCodeFoldingModelListener in interface CodeFoldingModel<B extends DefaultFoldingBlock>listener - the listener to removeprotected void writeLock()
protected void writeUnlock()
protected int getLineFromOffset(int offset)
protected int getLineCount()
protected int getLineStartOffset(int line)
protected int getLineEndOffset(int line)
protected void getCollapsedDescendants(B block, java.util.Collection collapsed)
protected void fireStructureChanged(B block)