JIDE 3.5.15

com.jidesoft.editor.folding
Class DefaultFoldingModel

java.lang.Object
  extended by com.jidesoft.editor.folding.DefaultFoldingModel
All Implemented Interfaces:
FoldingModel, EventListener, DocumentListener

public class DefaultFoldingModel
extends Object
implements FoldingModel, DocumentListener

Default implementation of FoldingModel.


Field Summary
protected  EventListenerList _listenerList
           
 
Constructor Summary
DefaultFoldingModel(CodeEditor editor)
           
 
Method Summary
 FoldingSpan addFoldingSpan(int startOffset, int endOffset, String description)
          Adds a folding span to FoldingModel.
 void addFoldingSpanListener(FoldingSpanListener l)
          Add a listener to the list that's notified each time a change to the line marker occurs.
 void changedUpdate(DocumentEvent e)
           
 void collapseAll()
          Collapses all the foldings.
 void collapseFoldingSpan(FoldingSpan span)
          Collapses the folding span.
protected  FoldingSpan createFoldingSpan(int startOffset, int endOffset, String description)
          Creates the folding span.
 void expandAll()
          Expands all the foldings.
protected  void expandAll(boolean expand)
           
 void expandFoldingSpan(FoldingSpan span)
          Expands the folding span.
static FoldingSpan findFoldingSpanStartingAtLine(CodeEditor editor, int line)
           
protected  void fireFoldingSpanChanged(FoldingSpan foldingSpan, int type, boolean isAdjusting)
           
 void foldingSpanUpdated(FoldingSpan span)
          When a folding span start or end offset, call this method to tell the folding model.
 int getFoldedLinesCountBefore(int offset)
           
 FoldingSpan[] getFoldedSpansAtOffset(int offset)
           
static FoldingSpan[] getFoldingSpanAtOffset(CodeEditor editor, int i)
           
 FoldingSpanListener[] getFoldingSpanListeners()
          Returns an array of all the FoldingSpanListeners added to this FoldingModel with addFoldingSpanListener().
 FoldingSpan[] getFoldingSpans()
          Gets all the folding spans.
 int getLastTopLevelIndexBefore(int offset)
           
 FoldingSpan getOutermostSpanAtOffset(int offset)
           
 FoldingSpan getOutermostSpanAtViewPosition(CaretPosition vp)
           
 FoldingSpan[] getTopLevelSpans()
           
 FoldingSpan[] getVisibleSpans()
           
 boolean hasAnySpan(int startOffset, int endOffset)
           
 void insertUpdate(DocumentEvent e)
           
 boolean isAdjusting()
          Checks if the folding model is in adjusting model.
 boolean isEnabled()
          Checks if the folding model is enabled.
 void rebuild()
           
 void removeAllFoldingSpans()
          Removes all folding spans that were added before.
 boolean removeFoldingSpan(FoldingSpan foldingSpan)
          Removes a folding span that was added before.
 void removeFoldingSpanListener(FoldingSpanListener l)
          Remove a listener from the list that's notified each time a change to the line marker occurs.
 void removeUpdate(DocumentEvent e)
           
 void resetCaretPosition()
           
 void setAdjusting(boolean adjusting)
          Sets the folding model to or from the adjusting mode.
 void setEnabled(boolean enabled)
          Enables or disables this folding model.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_listenerList

protected EventListenerList _listenerList
Constructor Detail

DefaultFoldingModel

public DefaultFoldingModel(CodeEditor editor)
Method Detail

addFoldingSpan

public FoldingSpan addFoldingSpan(int startOffset,
                                  int endOffset,
                                  String description)
Description copied from interface: FoldingModel
Adds a folding span to FoldingModel. FoldingSpanEvent.FOLDING_SPAN_ADDED will be fired.

Specified by:
addFoldingSpan in interface FoldingModel
Parameters:
startOffset - the start offset, inclusive
endOffset - the end offset, exclusive
description - the description of the folding span
Returns:
the folding span that is just added.

createFoldingSpan

protected FoldingSpan createFoldingSpan(int startOffset,
                                        int endOffset,
                                        String description)
Creates the folding span. You can override this method to create your own folding span if you have to.

Parameters:
startOffset - the starting offset.
endOffset - the end offset.
description - the description of the span.
Returns:
a folding span.

removeFoldingSpan

public boolean removeFoldingSpan(FoldingSpan foldingSpan)
Description copied from interface: FoldingModel
Removes a folding span that was added before. FoldingSpanEvent.FOLDING_SPAN_REMOVED will be fired if the folding span is removed successfully.

Specified by:
removeFoldingSpan in interface FoldingModel
Parameters:
foldingSpan - the folding span
Returns:
true if the folding span is removed. If the folding span doesn't exist, it will return false.

removeAllFoldingSpans

public void removeAllFoldingSpans()
Description copied from interface: FoldingModel
Removes all folding spans that were added before. No events will be fired.

Specified by:
removeAllFoldingSpans in interface FoldingModel

isAdjusting

public boolean isAdjusting()
Description copied from interface: FoldingModel
Checks if the folding model is in adjusting model.

Specified by:
isAdjusting in interface FoldingModel
Returns:
true if the folding model is in adjusting mode. Otherwise false.

setAdjusting

public void setAdjusting(boolean adjusting)
Description copied from interface: FoldingModel
Sets the folding model to or from the adjusting mode.

Specified by:
setAdjusting in interface FoldingModel
Parameters:
adjusting - the flag

expandFoldingSpan

public void expandFoldingSpan(FoldingSpan span)
Description copied from interface: FoldingModel
Expands the folding span.

Specified by:
expandFoldingSpan in interface FoldingModel
Parameters:
span - the folding span

collapseFoldingSpan

public void collapseFoldingSpan(FoldingSpan span)
Description copied from interface: FoldingModel
Collapses the folding span.

Specified by:
collapseFoldingSpan in interface FoldingModel
Parameters:
span - the folding span

expandAll

protected void expandAll(boolean expand)

expandAll

public void expandAll()
Description copied from interface: FoldingModel
Expands all the foldings.

Specified by:
expandAll in interface FoldingModel

collapseAll

public void collapseAll()
Description copied from interface: FoldingModel
Collapses all the foldings.

Specified by:
collapseAll in interface FoldingModel

foldingSpanUpdated

public void foldingSpanUpdated(FoldingSpan span)
Description copied from interface: FoldingModel
When a folding span start or end offset, call this method to tell the folding model. However if you are using DefaultFoldingSpan, there is no need for calling it because DefaultFoldingSpan will call it automatically.

Specified by:
foldingSpanUpdated in interface FoldingModel
Parameters:
span - the folding span

getFoldingSpans

public FoldingSpan[] getFoldingSpans()
Description copied from interface: FoldingModel
Gets all the folding spans.

Specified by:
getFoldingSpans in interface FoldingModel
Returns:
all the folding spans.

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: FoldingModel
Enables or disables this folding model.

Specified by:
setEnabled in interface FoldingModel
Parameters:
enabled - the flag

isEnabled

public boolean isEnabled()
Description copied from interface: FoldingModel
Checks if the folding model is enabled.

Specified by:
isEnabled in interface FoldingModel
Returns:
true if the folding model is enabled. Otherwise false.

fireFoldingSpanChanged

protected void fireFoldingSpanChanged(FoldingSpan foldingSpan,
                                      int type,
                                      boolean isAdjusting)

addFoldingSpanListener

public void addFoldingSpanListener(FoldingSpanListener l)
Description copied from interface: FoldingModel
Add a listener to the list that's notified each time a change to the line marker occurs.

Specified by:
addFoldingSpanListener in interface FoldingModel
Parameters:
l - the FoldingSpanListener

removeFoldingSpanListener

public void removeFoldingSpanListener(FoldingSpanListener l)
Description copied from interface: FoldingModel
Remove a listener from the list that's notified each time a change to the line marker occurs.

Specified by:
removeFoldingSpanListener in interface FoldingModel
Parameters:
l - the FoldingSpanListener
See Also:
FoldingModel.addFoldingSpanListener(com.jidesoft.editor.folding.FoldingSpanListener)

getFoldingSpanListeners

public FoldingSpanListener[] getFoldingSpanListeners()
Description copied from interface: FoldingModel
Returns an array of all the FoldingSpanListeners added to this FoldingModel with addFoldingSpanListener().

Specified by:
getFoldingSpanListeners in interface FoldingModel
Returns:
all of the FoldingSpanListeners added or an empty array if no listeners have been added

toString

public String toString()
Overrides:
toString in class Object

rebuild

public void rebuild()

getLastTopLevelIndexBefore

public int getLastTopLevelIndexBefore(int offset)

getFoldedLinesCountBefore

public int getFoldedLinesCountBefore(int offset)

getTopLevelSpans

public FoldingSpan[] getTopLevelSpans()

getOutermostSpanAtViewPosition

public FoldingSpan getOutermostSpanAtViewPosition(CaretPosition vp)

getOutermostSpanAtOffset

public FoldingSpan getOutermostSpanAtOffset(int offset)

getFoldedSpansAtOffset

public FoldingSpan[] getFoldedSpansAtOffset(int offset)

hasAnySpan

public boolean hasAnySpan(int startOffset,
                          int endOffset)

getVisibleSpans

public FoldingSpan[] getVisibleSpans()

insertUpdate

public void insertUpdate(DocumentEvent e)
Specified by:
insertUpdate in interface DocumentListener

removeUpdate

public void removeUpdate(DocumentEvent e)
Specified by:
removeUpdate in interface DocumentListener

changedUpdate

public void changedUpdate(DocumentEvent e)
Specified by:
changedUpdate in interface DocumentListener

resetCaretPosition

public void resetCaretPosition()

findFoldingSpanStartingAtLine

public static FoldingSpan findFoldingSpanStartingAtLine(CodeEditor editor,
                                                        int line)

getFoldingSpanAtOffset

public static FoldingSpan[] getFoldingSpanAtOffset(CodeEditor editor,
                                                   int i)

JIDE 3.5.15