|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.fife.ui.rsyntaxtextarea.CodeTemplateManager
public class CodeTemplateManager
Manages "code templates."
All methods in this class are synchronized for thread safety, but as a
best practice, you should probably only modify the templates known to a
CodeTemplateManager
on the EDT. Modifying a
CodeTemplate
retrieved from a CodeTemplateManager
while not on the EDT could cause problems.
Constructor Summary | |
---|---|
CodeTemplateManager()
Constructor. |
Method Summary | |
---|---|
void |
addTemplate(CodeTemplate template)
Registers the specified template with this template manager. |
KeyStroke |
getInsertTrigger()
Returns the keystroke that is the "insert trigger" for templates; that is, the character that, when inserted into an instance of RSyntaxTextArea , triggers the search for
a template matching the token ending at the caret position. |
String |
getInsertTriggerString()
Returns the "insert trigger" for templates; that is, the character that, when inserted into an instance of RSyntaxTextArea ,
triggers the search for a template matching the token ending at the
caret position. |
CodeTemplate |
getTemplate(RSyntaxTextArea textArea)
Returns the template that should be inserted at the current caret position, assuming the trigger character was pressed. |
int |
getTemplateCount()
Returns the number of templates this manager knows about. |
CodeTemplate[] |
getTemplates()
Returns the templates currently available. |
static boolean |
isValidChar(char ch)
Returns whether the specified character is a valid character for a CodeTemplate id. |
boolean |
removeTemplate(CodeTemplate template)
Returns the specified code template. |
CodeTemplate |
removeTemplate(String id)
Returns the code template with the specified id. |
void |
replaceTemplates(CodeTemplate[] newTemplates)
Replaces the current set of available templates with the ones specified. |
boolean |
saveTemplates()
Saves all templates as XML files in the current template directory. |
void |
setInsertTrigger(KeyStroke trigger)
Sets the "trigger" character for templates. |
int |
setTemplateDirectory(File dir)
Sets the directory in which to look for templates. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CodeTemplateManager()
Method Detail |
---|
public void addTemplate(CodeTemplate template)
template
- The template to register.
IllegalArgumentException
- If template
is
null
.removeTemplate(CodeTemplate)
,
removeTemplate(String)
public KeyStroke getInsertTrigger()
RSyntaxTextArea
, triggers the search for
a template matching the token ending at the caret position.
getInsertTriggerString()
,
setInsertTrigger(KeyStroke)
public String getInsertTriggerString()
RSyntaxTextArea
,
triggers the search for a template matching the token ending at the
caret position.
getInsertTrigger()
,
setInsertTrigger(KeyStroke)
public CodeTemplate getTemplate(RSyntaxTextArea textArea)
textArea
- The text area that's getting text inserted into it.
null
if no template should be inserted.public int getTemplateCount()
public CodeTemplate[] getTemplates()
public static final boolean isValidChar(char ch)
CodeTemplate
id.
ch
- The character to check.
public boolean removeTemplate(CodeTemplate template)
template
- The template to remove.
true
if the template was removed, false
if the template was not in this template manager.
IllegalArgumentException
- If template
is
null
.removeTemplate(String)
,
addTemplate(CodeTemplate)
public CodeTemplate removeTemplate(String id)
id
- The id to check for.
null
if
there was no template with the specified ID.
IllegalArgumentException
- If id
is null
.removeTemplate(CodeTemplate)
,
addTemplate(CodeTemplate)
public void replaceTemplates(CodeTemplate[] newTemplates)
newTemplates
- The new set of templates. Note that we will
be taking a shallow copy of these and sorting them.public boolean saveTemplates()
public void setInsertTrigger(KeyStroke trigger)
trigger
- The trigger character to set for templates. This means
that when this character is pressed in an
RSyntaxTextArea
, the last-typed token is found,
and is checked against all template ID's to see if a template
should be inserted. If a template ID matches, that template is
inserted; if not, the trigger character is inserted. If this
parameter is null
, no change is made to the trigger
character.getInsertTrigger()
,
getInsertTriggerString()
public int setTemplateDirectory(File dir)
dir
- The new directory in which to look for templates.
-1
if the specified directory does not exist.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |