| java.lang.Object org.netbeans.editor.Formatter org.netbeans.editor.ext.ExtFormatter
All known Subclasses: org.netbeans.editor.ext.java.JavaFormatter,
ExtFormatter | public class ExtFormatter extends Formatter implements FormatLayer(Code) | | Unlike the formatter class, the ExtFormatter concentrates on providing a
support for the real formatting process. Each formatter (there's only one per
each kit) can contain one or more formatting layers. The FormatLayer
operates over the chain of the tokens provided by the FormatWriter.
The formatting consist of changing the chain of the tokens until it gets the
desired look. Each formatting requires a separate instance of
FormatWriter but the same set of format-layers is used for all the
format-writers. Although the base implementation is synchronized so that only
one format-writer at time is processed by each format-writer, in general it's
not necessary. The basic implementation processes all the format-layers
sequentialy in the order they were added to the formatter but this can be
redefined. The getSettingValue enables to get the up-to-date value
for the particular setting.
author: Miloslav Metelka version: 1.00 |
Inner Class :public static class Simple extends ExtFormatter | |
Method Summary | |
protected boolean | acceptSyntax(Syntax syntax) Whether the formatter accepts the given syntax that will be used for
parsing the text passed to the FormatWriter.
Parameters: syntax - syntax to be tested. | public synchronized void | addFormatLayer(FormatLayer layer) Add the new format layer to the layer hierarchy. | public Writer | createWriter(Document doc, int offset, Writer writer) Create the indentation writer. | public synchronized void | format(FormatWriter fw) | public Iterator | formatLayerIterator() Get the iterator over the format layers. | public String | getName() Return the name of this formatter. | public int[] | getReformatBlock(JTextComponent target, String typedText) Get the block to be reformatted after keystroke was pressed.
Parameters: target - component to which the text was typed. | public Object | getSettingValue(String settingName) Get the value of the given setting. | protected boolean | hasTextBefore(JTextComponent target, String typedText) | public int | indentLine(Document doc, int offset) Indents the current line. | public int | indentNewLine(Document doc, int offset) Inserts new line at given position and indents the new line with spaces. | protected void | initFormatLayers() | public boolean | isSimple() Whether do no formatting at all. | public Writer | reformat(BaseDocument doc, int startOffset, int endOffset, boolean indentOnly) Reformat a block of code.
Parameters: doc - document to work with Parameters: startOffset - position at which the formatting starts Parameters: endOffset - position at which the formatting ends Parameters: indentOnly - whether just the indentation should be changed or regularformatting should be performed. | public int | reformat(BaseDocument doc, int startOffset, int endOffset) | public synchronized void | removeFormatLayer(String layerName) Remove the first layer which has the same name as the given one. | public synchronized boolean | replaceFormatLayer(String layerName, FormatLayer layer) Replace the format-layer with the layerName with the the given layer. | public void | setSettingValue(String settingName, Object settingValue) This method allows to set a custom value to a setting thus overriding the
value retrieved from the Settings. | public void | settingsChange(SettingsChangeEvent evt) |
acceptSyntax | protected boolean acceptSyntax(Syntax syntax)(Code) | | Whether the formatter accepts the given syntax that will be used for
parsing the text passed to the FormatWriter.
Parameters: syntax - syntax to be tested. true whether this formatter is able to process the tokens createdby the syntax or false otherwise. |
addFormatLayer | public synchronized void addFormatLayer(FormatLayer layer)(Code) | | Add the new format layer to the layer hierarchy.
|
format | public synchronized void format(FormatWriter fw)(Code) | | Called by format-writer to do the format
|
formatLayerIterator | public Iterator formatLayerIterator()(Code) | | Get the iterator over the format layers.
|
getName | public String getName()(Code) | | Return the name of this formatter. By default it's the name of the
kit-class for which it's created without the package name.
|
getReformatBlock | public int[] getReformatBlock(JTextComponent target, String typedText)(Code) | | Get the block to be reformatted after keystroke was pressed.
Parameters: target - component to which the text was typed. Caaret position can bechecked etc. Parameters: typedText - text (usually just one character) that the user has typed. block of the code to be reformatted or null if nothing shouldreformatted. It can return block containing just one character.The caller usually expands even one character to the whole linebecause less than the whole line usually doesn't provide enoughpossibilities for formatting. See Also: ExtKit.ExtDefaultKeyTypedAction.checkIndentHotChars() |
getSettingValue | public Object getSettingValue(String settingName)(Code) | | Get the value of the given setting.
Parameters: settingName - name of the setting to get. |
indentLine | public int indentLine(Document doc, int offset)(Code) | | Indents the current line. Should not affect any other lines.
Parameters: doc - the document to work on Parameters: offset - the offset of a character on the line new offset of the original character |
indentNewLine | public int indentNewLine(Document doc, int offset)(Code) | | Inserts new line at given position and indents the new line with spaces.
Parameters: doc - the document to work on Parameters: offset - the offset of a character on the line new offset to place cursor to |
initFormatLayers | protected void initFormatLayers()(Code) | | Add the desired format-layers to the formatter
|
isSimple | public boolean isSimple()(Code) | | Whether do no formatting at all. If this method returns true, the
FormatWriter will simply write its input into the underlying writer.
|
reformat | public Writer reformat(BaseDocument doc, int startOffset, int endOffset, boolean indentOnly) throws BadLocationException, IOException(Code) | | Reformat a block of code.
Parameters: doc - document to work with Parameters: startOffset - position at which the formatting starts Parameters: endOffset - position at which the formatting ends Parameters: indentOnly - whether just the indentation should be changed or regularformatting should be performed. formatting writer. The text was already reformatted but thewriter can contain useful information. |
removeFormatLayer | public synchronized void removeFormatLayer(String layerName)(Code) | | Remove the first layer which has the same name as the given one.
|
replaceFormatLayer | public synchronized boolean replaceFormatLayer(String layerName, FormatLayer layer)(Code) | | Replace the format-layer with the layerName with the the given layer. If
there's no such layer with the same name, the layer is not replaced and
false is returned.
|
setSettingValue | public void setSettingValue(String settingName, Object settingValue)(Code) | | This method allows to set a custom value to a setting thus overriding the
value retrieved from the Settings. Once done the value is no
longer synchronized with the changes in Settings for the
particular setting. There's a map holding the names of all the custom
settings.
|
Methods inherited from org.netbeans.editor.Formatter | public void changeBlockIndent(BaseDocument doc, int startPos, int endPos, int shiftCnt) throws BadLocationException(Code)(Java Doc) public void changeRowIndent(BaseDocument doc, int pos, int newIndent) throws BadLocationException(Code)(Java Doc) public Writer createWriter(Document doc, int offset, Writer writer)(Code)(Java Doc) public boolean expandTabs()(Code)(Java Doc) public static synchronized Formatter getFormatter(Class kitClass)(Code)(Java Doc) public String getIndentString(BaseDocument doc, int indent)(Code)(Java Doc) public String getIndentString(int indent)(Code)(Java Doc) public Class getKitClass()(Code)(Java Doc) public int getShiftWidth()(Code)(Java Doc) public int getSpacesPerTab()(Code)(Java Doc) public int getTabSize()(Code)(Java Doc) public int indentLine(Document doc, int offset)(Code)(Java Doc) public int indentNewLine(Document doc, int offset)(Code)(Java Doc) public void insertTabString(BaseDocument doc, int dotPos) throws BadLocationException(Code)(Java Doc) public int reformat(BaseDocument doc, int startOffset, int endOffset) throws BadLocationException(Code)(Java Doc) public void setExpandTabs(boolean expandTabs)(Code)(Java Doc) public static synchronized void setFormatter(Class kitClass, Formatter formatter)(Code)(Java Doc) public void setShiftWidth(int shiftWidth)(Code)(Java Doc) public void setSpacesPerTab(int spacesPerTab)(Code)(Java Doc) public void setTabSize(int tabSize)(Code)(Java Doc) public void settingsChange(SettingsChangeEvent evt)(Code)(Java Doc) public void shiftLine(BaseDocument doc, int dotPos, boolean right) throws BadLocationException(Code)(Java Doc)
|
|
|