|
org.netbeans.modules.editor.lib/1 1.14.0 3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.editor.Formatter
org.netbeans.editor.ext.ExtFormatter
public class ExtFormatter
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.
Nested Class Summary | |
---|---|
static class |
ExtFormatter.Simple
Simple formatter |
Constructor Summary | |
---|---|
ExtFormatter(Class kitClass)
|
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. |
void |
addFormatLayer(FormatLayer layer)
Add the new format layer to the layer hierarchy. |
Writer |
createWriter(Document doc,
int offset,
Writer writer)
Create the indentation writer. |
void |
format(FormatWriter fw)
Called by format-writer to do the format |
Iterator |
formatLayerIterator()
Get the iterator over the format layers. |
protected int |
getEOLOffset(BaseDocument bdoc,
int offset)
Returns offset of EOL for the white line |
String |
getName()
Return the name of this formatter. |
int[] |
getReformatBlock(JTextComponent target,
String typedText)
Get the block to be reformatted after keystroke was pressed. |
Object |
getSettingValue(String settingName)
Get the value of the given setting. |
protected boolean |
hasTextBefore(JTextComponent target,
String typedText)
|
int |
indentLine(Document doc,
int offset)
Indents the current line. |
int |
indentNewLine(Document doc,
int offset)
Inserts new line at given position and indents the new line with spaces. |
protected void |
initFormatLayers()
Add the desired format-layers to the formatter |
boolean |
isSimple()
Whether do no formatting at all. |
int |
reformat(BaseDocument doc,
int startOffset,
int endOffset)
Fix of #5620 - same method exists in Formatter (predecessor |
Writer |
reformat(BaseDocument doc,
int startOffset,
int endOffset,
boolean indentOnly)
Reformat a block of code. |
void |
removeFormatLayer(String layerName)
Remove the first layer which has the same name as the given one. |
boolean |
replaceFormatLayer(String layerName,
FormatLayer layer)
Replace the format-layer with the layerName with the the given layer. |
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. |
void |
settingsChange(SettingsChangeEvent evt)
|
Methods inherited from class org.netbeans.editor.Formatter |
---|
changeBlockIndent, changeRowIndent, expandTabs, getFormatter, getIndentString, getIndentString, getKitClass, getShiftWidth, getSpacesPerTab, getTabSize, insertTabString, setExpandTabs, setFormatter, setShiftWidth, setSpacesPerTab, setTabSize, shiftLine |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExtFormatter(Class kitClass)
Method Detail |
---|
protected void initFormatLayers()
public String getName()
getName
in interface FormatLayer
public void settingsChange(SettingsChangeEvent evt)
settingsChange
in interface SettingsChangeListener
settingsChange
in class Formatter
public Object getSettingValue(String settingName)
settingName
- name of the setting to get.public void setSettingValue(String settingName, Object settingValue)
public void addFormatLayer(FormatLayer layer)
public boolean replaceFormatLayer(String layerName, FormatLayer layer)
public void removeFormatLayer(String layerName)
public Iterator formatLayerIterator()
public boolean isSimple()
public void format(FormatWriter fw)
format
in interface FormatLayer
fw
- format-writer to be formatted. The format-layer
will usually create the format-support as an abstraction
level over the format-layer.public Writer reformat(BaseDocument doc, int startOffset, int endOffset, boolean indentOnly) throws BadLocationException, IOException
doc
- document to work withstartOffset
- position at which the formatting startsendOffset
- position at which the formatting endsindentOnly
- whether just the indentation should be changed
or regular formatting should be performed.
BadLocationException
IOException
public int reformat(BaseDocument doc, int startOffset, int endOffset) throws BadLocationException
doc
- document to work withstartOffset
- offset at which the formatting startsendOffset
- offset at which the formatting ends
BadLocationException
public int[] getReformatBlock(JTextComponent target, String typedText)
target
- component to which the text was typed. Caaret position
can be checked etc.typedText
- text (usually just one character) that the user has typed.
ExtKit.ExtDefaultKeyTypedAction.checkIndentHotChars()
protected boolean hasTextBefore(JTextComponent target, String typedText)
public Writer createWriter(Document doc, int offset, Writer writer)
createWriter
in class Formatter
doc
- documentoffset
- position to begin inserts atwriter
- writer to write to
public int indentLine(Document doc, int offset)
indentLine
in class Formatter
doc
- the document to work onoffset
- the offset of a character on the line
protected int getEOLOffset(BaseDocument bdoc, int offset) throws BadLocationException
BadLocationException
public int indentNewLine(Document doc, int offset)
indentNewLine
in class Formatter
doc
- the document to work onoffset
- the offset of a character on the line
protected boolean acceptSyntax(Syntax syntax)
syntax
- syntax to be tested.
|
org.netbeans.modules.editor.lib/1 1.14.0 3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |