|
org.netbeans.modules.editor.settings/1 1.31.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.netbeans.api.editor.settings.CodeTemplateDescription
public final class CodeTemplateDescription
The definition of a code template. A code template is basically a piece of code with an abbreviation associated to it. When a user types the abbreviation to the editor and presses the expansion key the code associated with the abbreviation gets expanded. The code can contain various parameters that the user can enter during the expansion.
The CodeTemplateDescriptions can be obtained from
CodeTemplateSettings class that can be loaded from MimeLookup
for a particular mime type. See the example below.
Lookup l = MimeLookup.getLookup(MimePath.parse(mimePath)); CodeTemplateSettings cds = l.lookup(CodeTemplateSettings.class); ListcodeTemplates = cds.getCodeTemplateDescriptions();
IMPORTANT: There is a much more powerful API for working with editor
code templates in
Editor Code Templates
module. If you are retrieving this class from MimeLookup you should
probably use the Editor Code Templates API instead.
CodeTemplateSettings| Constructor Summary | |
|---|---|
CodeTemplateDescription(String abbreviation,
String description,
String parametrizedText)
Creates a new code template description. |
|
CodeTemplateDescription(String abbreviation,
String description,
String parametrizedText,
List<String> contexts,
String uniqueId)
Creates a new code template description. |
|
CodeTemplateDescription(String abbreviation,
String description,
String parametrizedText,
List<String> contexts,
String uniqueId,
String mimePath)
Creates a new code template description. |
|
| Method Summary | |
|---|---|
boolean |
equals(Object obj)
Checks whether this code template is equal with a code template passed in as the obj parameter. |
String |
getAbbreviation()
Gets the abbreviation text that triggers expansion of this code template. |
List<String> |
getContexts()
Gets the list of contexts that apply for this code template. |
String |
getDescription()
Gets textual description of this code template. |
String |
getMimePath()
Gets the mime path where this code template was registered. |
String |
getParametrizedText()
Gets the code text of this code template. |
String |
getUniqueId()
Gets an id that can be used for identifying this template. |
int |
hashCode()
|
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public CodeTemplateDescription(String abbreviation,
String description,
String parametrizedText)
null for the contexts parameter.
abbreviation - The abbreviation text that expands this code template.description - The code template's display text.parametrizedText - The actual code template that will get expanded when
a user writes the abbreviation in the editor.
public CodeTemplateDescription(String abbreviation,
String description,
String parametrizedText,
List<String> contexts,
String uniqueId)
Usually clients do not need to create CodeTemplateDescriptions
by themselvs. Instead they use MimeLookup and CodeTemplateSettings
to access code templates registered in the system.
abbreviation - The abbreviation text that expands this code template.description - The code template's display text.
Can be nullparametrizedText - The actual code template that will get expanded when
a user writes the abbreviation in the editor.contexts - The list of context ids that apply for this code template.
Can be nulluniqueId - The id uniquely identifying this template. If you pass
non-null value, please make sure that it is really a unique
id for this template. Can be null.
public CodeTemplateDescription(String abbreviation,
String description,
String parametrizedText,
List<String> contexts,
String uniqueId,
String mimePath)
#CodeTemplates(String, String, String, List, String ,
but with additional mimePath parameter.
abbreviation - The abbreviation text that expands this code template.description - The code template's display text.
Can be nullparametrizedText - The actual code template that will get expanded when
a user writes the abbreviation in the editor.contexts - The list of context ids that apply for this code template.
Can be nulluniqueId - The id uniquely identifying this template. If you pass
non-null value, please make sure that it is really a unique
id for this template. Can be null.mimePath - The mime path where this code template description was registered for.| Method Detail |
|---|
public String getAbbreviation()
The abbreviation text should be unique among all code templates defined for a one mime type so that each code template can be expanded individually.
public String getDescription()
null if this
code template has no descriptions.public String getParametrizedText()
public List<String> getContexts()
The actual identifiers are defined by each particular language (mime type) and can be different for different languages. The language defines contexts for its constructs such as loops, methods, classes, if-else blocks, etc. and than tags each code template available for that language with a context, where it is meaningful to apply the template.
public String getUniqueId()
Unique ids can be useful for tools importing and exporting code templates from other applications such as TextMate, etc.
null.public String getMimePath()
null if the registration mime
path is unknown.public String toString()
toString in class Objectpublic boolean equals(Object obj)
obj parameter. By definition two code templates are
equal if all their fields are equal - ie. all abbreviation, description,
parametrizedText, contexts, uniqueId and mimePath fields are equal.
equals in class Objectobj - The code template to compare with.
true if and only if this code template is equal to
the obj code template.public int hashCode()
hashCode in class Object
|
org.netbeans.modules.editor.settings/1 1.31.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||