Custom Structuredtexteditor automatic Prompts
The previous introduction focuses on two points: the Structuredtexteditor framework and the WTP data model, in this section you can customize one of our most common WTP structuredtexteditor features, which is automatic prompting.
"WTP Structuredtexteditor prompt function Implementation Analysis"
For a brief knowledge of the Eclipse Text Editor framework, JFace Text framework, and WTP Structuredtexteditor, see:
"Eclipse plug-in Development" based on WTP Development Custom JSP Editor (ii): Create your own jspeditor based on WTP Structuredtexteditor
"Sourceviewer Prompt policy Configuration"
In chapter two, we said that if you want to customize a isourceviewer to automatically prompt the policy, you can configure it in the isourceviewer corresponding sourceviewerconfiguration. For WTP JSP Structuredtexteditor, the isourceviewer here is Structuredtextviewer, the sourceviewerconfiguration here is Structuredtextviewerconfigurationjsp. Let's take a look at the configuration of the auto prompt policy in WTP structuredtextviewerconfigurationjsp:
(The following code extracts the subclass structuredtextviewerconfigurationjsp Class):
protected icontentassistprocessor[] Getcontentassistprocessors (isourceviewer sourceviewer, String Partitiontype) {
icontentassistprocessor[] processors = NULL;
//other code omitted ...
Else if (partitiontype = ixmlpartitions.xml_default) | | (Partitiontype = = Ihtmlpartitions.html_default) | | (Partitiontype = = ihtmlpartitions.html_comment) | | (Partitiontype = = Ijsppartitions.jsp_default) | | (Partitiontype = = ijsppartitions.jsp_directive) | | (Partitiontype = = Ijsppartitions.jsp_content_delimiter) | | (Partitiontype = = Ijsppartitions.jsp_content_javascript) | | (Partitiontype = = ijsppartitions.jsp_comment)) {
//JSP
processors = new icontentassistprocessor[]{new jspcontentassistprocessor ()};
}
Else if (partitiontype = ixmlpartitions.xml_cdata) | | (Partitiontype = = Ijsppartitions.jsp_content_java)) {
//JSP java
processors = new icontentassistprocessor[]{new jspjavacontentassistprocessor ()};
}
//other code omitted ...
return processors;
}
The above code, as we can see, icontentassistprocessor is associated with a specific partition type (partition type). To understand the problem, you need to see how this particular partition type (partition type) is computed.
PS: partition type is the concept of jface text framework, the relevant knowledge you are interested in further to understand the JFace text framework.