Author: vrubezhny
Date: 2009-07-23 11:52:38 -0400 (Thu, 23 Jul 2009)
New Revision: 16754
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoContentAssistantProposal.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
Log:
JBIDE-2808: Improve/refactor org.jboss.tools.common.kb plugin.
Old-style CA is replaced by the new one.
Source viewer configurations for jsp and xhtml are supposed to use only the new-style
compound CA processor.
Proposal displaying, icons and relevance are updated
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-07-23 15:42:11 UTC (rev
16753)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-07-23 15:52:38 UTC (rev
16754)
@@ -403,7 +403,7 @@
id="org.jboss.tools.jst.jsp.contentAssistProcessor"
name="org.jboss.tools.jst.jsp.contentAssistProcessor">
- <contentAssistProcessor
+ <!-- contentAssistProcessor
class="org.jboss.tools.jst.jsp.contentassist.ExtendedJSPContentAssistProcessor"
id="org.jboss.tools.jst.jsp.contentassist.ExtendedJSPContentAssistProcessor">
<contenttype id="org.eclipse.jst.jsp.core.jspsource">
@@ -424,10 +424,10 @@
<contenttype id="org.eclipse.wst.html.core.htmlsource">
<partitiontype id="org.eclipse.wst.html.HTML_DEFAULT" />
<partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL" />
- <partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL2" /> <!-- Is
this forgotten? -->
+ <partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL2" />
</contenttype>
</contentAssistProcessor>
-
+-->
<!--
//added by estherbin
//fix
http://jira.jboss.com/jira/browse/JBIDE-1791
@@ -454,7 +454,6 @@
</contenttype>
</contentAssistProcessor>
- <!--
<contentAssistProcessor
class="org.jboss.tools.jst.jsp.contentassist.XmlContentAssistProcessor"
id="org.jboss.tools.jst.jsp.contentassist.XmlContentAssistProcessor">
@@ -479,7 +478,7 @@
<partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL2" />
</contenttype>
</contentAssistProcessor>
- -->
+
</extension>
<extension
point="org.eclipse.ui.popupMenus">
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java 2009-07-23
15:42:11 UTC (rev 16753)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java 2009-07-23
15:52:38 UTC (rev 16754)
@@ -22,18 +22,12 @@
import org.eclipse.jface.text.formatter.MultiPassContentFormatter;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jst.jsp.core.text.IJSPPartitions;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.wst.css.core.text.ICSSPartitions;
-import org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor;
import org.eclipse.wst.html.core.text.IHTMLPartitions;
import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML;
import org.eclipse.wst.sse.ui.internal.format.StructuredFormattingStrategy;
-import org.jboss.tools.common.text.xml.contentassist.ContentAssistProcessorBuilder;
-import org.jboss.tools.common.text.xml.contentassist.ContentAssistProcessorDefinition;
import
org.jboss.tools.common.text.xml.contentassist.SortingCompoundContentAssistProcessor;
-import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
import org.jboss.tools.jst.jsp.format.HTMLFormatProcessor;
import org.osgi.framework.Bundle;
@@ -46,46 +40,21 @@
@SuppressWarnings("restriction")
protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer
sourceViewer, String partitionType) {
SortingCompoundContentAssistProcessor sortingCompoundProcessor = new
SortingCompoundContentAssistProcessor(sourceViewer, partitionType);
- List<IContentAssistProcessor> processors = new
ArrayList<IContentAssistProcessor>();
-// if (sortingCompoundProcessor.size() > 0) {
if (sortingCompoundProcessor.supportsPartitionType(partitionType)) {
- processors.add(sortingCompoundProcessor);
- }
+ // Add the default WTP CA processors to our SortingCompoundContentAssistProcessor
+ IContentAssistProcessor[] superProcessors =
super.getContentAssistProcessors(sourceViewer, partitionType);
-/*
-// IContentAssistProcessor[] processors = null;
+ if (superProcessors != null && superProcessors.length > 0) {
+ for (int i = 0; i < superProcessors.length; i++)
+ sortingCompoundProcessor.addContentAssistProcessor(partitionType,
superProcessors[i]);
+ }
- // if we have our own processors we need
- // to define them in plugin.xml file of their
- // plugins using extention point
- // "org.jboss.tools.common.text.xml.contentAssistProcessor"
-
-
- ContentAssistProcessorDefinition[] defs =
ContentAssistProcessorBuilder.getInstance().getContentAssistProcessorDefinitions(partitionType);
-
- if(defs==null) return null;
-
- List<IContentAssistProcessor> processors = new
ArrayList<IContentAssistProcessor>();
- for(int i=0; i<defs.length; i++) {
- IContentAssistProcessor processor = defs[i].createContentAssistProcessor();
- if(!processors.contains(processor)) {
- processors.add(processor);
- }
+ return new IContentAssistProcessor[] {sortingCompoundProcessor};
}
- if (partitionType == IHTMLPartitions.HTML_DEFAULT ||
- partitionType == IJSPPartitions.JSP_DEFAULT_EL) {
- processors.add(new FaceletsHtmlContentAssistProcessor());
- }
- //added by estherbin
- //fix
http://jira.jboss.com/jira/browse/JBIDE-1791
- if(partitionType.equals(ICSSPartitions.STYLE)){
- processors.add(new CSSContentAssistProcessor());
- }
-
-*/
- return (IContentAssistProcessor[])processors.toArray(new IContentAssistProcessor[0]);
+
+ return new IContentAssistProcessor[0];
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java 2009-07-23
15:42:11 UTC (rev 16753)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java 2009-07-23
15:52:38 UTC (rev 16754)
@@ -25,19 +25,10 @@
import org.eclipse.jst.jsp.ui.internal.style.jspel.LineStyleProviderForJSPEL;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.wst.css.core.text.ICSSPartitions;
-import org.eclipse.wst.html.core.text.IHTMLPartitions;
import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
-import org.eclipse.wst.xml.core.text.IXMLPartitions;
+import
org.jboss.tools.common.text.xml.contentassist.SortingCompoundContentAssistProcessor;
import org.osgi.framework.Bundle;
-import org.jboss.tools.common.model.plugin.ModelPlugin;
-import org.jboss.tools.common.text.xml.contentassist.ContentAssistProcessorBuilder;
-import org.jboss.tools.common.text.xml.contentassist.ContentAssistProcessorDefinition;
-import
org.jboss.tools.common.text.xml.contentassist.SortingCompoundContentAssistProcessor;
-import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
-import org.jboss.tools.jst.jsp.contentassist.ExtendedJSPContentAssistProcessor;
-
/**
* @author Igels
*/
@@ -49,52 +40,21 @@
protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer
sourceViewer, String partitionType) {
SortingCompoundContentAssistProcessor sortingCompoundProcessor = new
SortingCompoundContentAssistProcessor(sourceViewer, partitionType);
- List<IContentAssistProcessor> processors = new
ArrayList<IContentAssistProcessor>();
-// if (sortingCompoundProcessor.size() > 0) {
if (sortingCompoundProcessor.supportsPartitionType(partitionType)) {
- processors.add(sortingCompoundProcessor);
- return (IContentAssistProcessor[])processors.toArray(new IContentAssistProcessor[0]);
- }
+ // Add the default WTP CA processors to our SortingCompoundContentAssistProcessor
+ IContentAssistProcessor[] superProcessors =
super.getContentAssistProcessors(sourceViewer, partitionType);
- /*
- // if we have our own processors we need
- // to define them in plugin.xml file of their
- // plugins using extention point
- // "org.jboss.tools.common.text.xml.contentAssistProcessor"
-
- ContentAssistProcessorDefinition[] defs =
ContentAssistProcessorBuilder.getInstance().getContentAssistProcessorDefinitions(partitionType);
+ if (superProcessors != null && superProcessors.length > 0) {
+ for (int i = 0; i < superProcessors.length; i++)
+ sortingCompoundProcessor.addContentAssistProcessor(partitionType,
superProcessors[i]);
+ }
- if(defs==null) return null;
-
- List processors = new ArrayList();
- for(int i=0; i<defs.length; i++) {
- IContentAssistProcessor processor = defs[i].createContentAssistProcessor();
- if(!processors.contains(processor)) {
- processors.add(processor);
- }
+ return new IContentAssistProcessor[] {sortingCompoundProcessor};
}
- if ((partitionType == IXMLPartitions.XML_DEFAULT) ||
- (partitionType == IHTMLPartitions.HTML_DEFAULT) ||
- (partitionType == IJSPPartitions.JSP_DEFAULT) ||
- (partitionType == IJSPPartitions.JSP_DIRECTIVE) ||
- (partitionType == IJSPPartitions.JSP_CONTENT_DELIMITER) ||
- (partitionType == IJSPPartitions.JSP_DEFAULT_EL) ||
- (partitionType == IJSPPartitions.JSP_DEFAULT_EL2)) {
- processors.add(new ExtendedJSPContentAssistProcessor());
- return (IContentAssistProcessor[])processors.toArray(new IContentAssistProcessor[0]);
- }
- */
- IContentAssistProcessor[] superProcessors =
super.getContentAssistProcessors(sourceViewer, partitionType);
-
- if (superProcessors != null && superProcessors.length > 0) {
- for (int i = 0; i < superProcessors.length; i++)
- processors.add(superProcessors[i]);
- }
-
- return (IContentAssistProcessor[])processors.toArray(new IContentAssistProcessor[0]);
+ return new IContentAssistProcessor[0];
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-07-23
15:42:11 UTC (rev 16753)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-07-23
15:52:38 UTC (rev 16754)
@@ -162,14 +162,13 @@
* Calculates and adds the attribute name proposals to the Content Assist Request
object
*/
protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addAttributeNameProposals()
invoked"); //$NON-NLS-1$
}
/**
* Calculates and adds the attribute value proposals to the Content Assist Request
object
*/
protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor:
addAttributeValueProposals() invoked"); //$NON-NLS-1$
+// System.out.println("AbstractXMLContentAssistProcessor:
addAttributeValueProposals() invoked"); //$NON-NLS-1$
/*
IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
@@ -213,7 +212,6 @@
int attrValueEnd=eqRegionEnd + currentValueText.length();
int attrTextEnd = invokeRegion.getTextEnd();
// attrNode.getValueRegionText()
- System.out.println("AbstractXMLContentAssistProcessor:
addAttributeValueProposals() invoked");
}
else {
setErrorMessage(UNKNOWN_CONTEXT);
@@ -225,42 +223,36 @@
* Calculates and adds the comment proposals to the Content Assist Request object
*/
protected void addCommentProposal(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addCommentProposal()
invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the doc type proposals to the Content Assist Request object
*/
protected void addDocTypeProposal(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addDocTypeProposal()
invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the empty document proposals to the Content Assist Request
object
*/
protected void addEmptyDocumentProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addEmptyDocumentProposals()
invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the tag name proposals to the Content Assist Request object
*/
protected void addEndTagNameProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addEndTagNameProposals()
invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the end tag proposals to the Content Assist Request object
*/
protected void addEndTagProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addEndTagProposals()
invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the enttity proposals to the Content Assist Request object
*/
protected void addEntityProposals(ContentAssistRequest contentAssistRequest, int
documentPosition, ITextRegion completionRegion, IDOMNode treeNode) {
- System.out.println("AbstractXMLContentAssistProcessor: addEntityProposals()
invoked"); //$NON-NLS-1$
super.addEntityProposals(contentAssistRequest, documentPosition, completionRegion,
treeNode);
}
@@ -268,28 +260,24 @@
* Calculates and adds the PCDATA proposals to the Content Assist Request object
*/
protected void addPCDATAProposal(String nodeName, ContentAssistRequest
contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addPCDATAProposal()
invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the start document proposals to the Content Assist Request
object
*/
protected void addStartDocumentProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addStartDocumentProposals()
invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the tag close proposals to the Content Assist Request object
*/
protected void addTagCloseProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addTagCloseProposals()
invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the tag insertion proposals to the Content Assist Request object
*/
protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int
childPosition) {
- System.out.println("AbstractXMLContentAssistProcessor: addTagInsertionProposals()
invoked"); //$NON-NLS-1$
}
/**
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoContentAssistantProposal.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoContentAssistantProposal.java 2009-07-23
15:42:11 UTC (rev 16753)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoContentAssistantProposal.java 2009-07-23
15:52:38 UTC (rev 16754)
@@ -30,6 +30,10 @@
super(replacementString, replacementOffset, replacementLength, cursorPosition, image,
displayString, contextInformation, additionalProposalInfo, IRelevanceConstants.R_NONE);
}
+ public AutoContentAssistantProposal(String replacementString, int replacementOffset, int
replacementLength, int cursorPosition, Image image, String displayString,
IContextInformation contextInformation, String additionalProposalInfo, int relevance) {
+ super(replacementString, replacementOffset, replacementLength, cursorPosition,
image, displayString, contextInformation, additionalProposalInfo, relevance);
+ }
+
public AutoContentAssistantProposal(boolean autoContentAssistant, String
replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image
image, String displayString, IContextInformation contextInformation, String
additionalProposalInfo, int relevance) {
super(replacementString, replacementOffset, replacementLength, cursorPosition,
image, displayString, contextInformation, additionalProposalInfo, relevance);
this.autoContentAssistant = autoContentAssistant;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-07-23
15:42:11 UTC (rev 16753)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-07-23
15:52:38 UTC (rev 16754)
@@ -19,7 +19,6 @@
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
@@ -181,8 +180,11 @@
protected void addTextELProposals(ContentAssistRequest contentAssistRequest) {
TextRegion prefix = getELPrefix();
if (prefix == null || !prefix.isELStarted()) {
- CustomCompletionProposal proposal = new CustomCompletionProposal("#{}",
contentAssistRequest.getReplacementBeginPosition(), //$NON-NLS-1$
- 0, 2, null, "#{}", null,
JstUIMessages.FaceletPageContectAssistProcessor_NewELExpression, 10000); //$NON-NLS-1$
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true,
"#{}", //$NON-NLS-1$
+ contentAssistRequest.getReplacementBeginPosition(),
+ 0, 2, JSF_EL_PROPOSAL_IMAGE,
JstUIMessages.JspContentAssistProcessor_NewELExpression, null,
+ JstUIMessages.FaceletPageContectAssistProcessor_NewELExpressionTextInfo,
TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
+
contentAssistRequest.addProposal(proposal);
return;
}
@@ -209,15 +211,23 @@
String displayString = prefix.getText().substring(0, replacementLength) +
textProposal.getReplacementString();
IContextInformation contextInformation = null;
String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance() + 10000;
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
+ }
- CustomCompletionProposal proposal = new CustomCompletionProposal(replacementString,
replacementOffset, replacementLength, cursorPosition, image, displayString,
contextInformation, additionalProposalInfo, relevance);
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
contentAssistRequest.addProposal(proposal);
}
if (prefix.isELStarted() && !prefix.isELClosed()) {
- CustomCompletionProposal proposal = new CustomCompletionProposal("}",
getOffset(), //$NON-NLS-1$
- 0, 1, null, "}", null,
JstUIMessages.FaceletPageContectAssistProcessor_CloseELExpression, 10001); //$NON-NLS-1$
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal("}", //$NON-NLS-1$
+ getOffset(), 0, 1, JSF_EL_PROPOSAL_IMAGE,
JstUIMessages.JspContentAssistProcessor_CloseELExpression,
+ null, JstUIMessages.JspContentAssistProcessor_CloseELExpressionInfo,
TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
+
contentAssistRequest.addProposal(proposal);
}
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-07-23
15:42:11 UTC (rev 16753)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-07-23
15:52:38 UTC (rev 16754)
@@ -24,13 +24,16 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.eclipse.wst.xml.core.internal.document.NodeContainer;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
+import org.eclipse.wst.xml.ui.internal.editor.CMImageUtil;
+import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
+import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IResourceBundle;
@@ -56,6 +59,8 @@
*/
public class JspContentAssistProcessor extends XmlContentAssistProcessor {
+ protected static final Image JSF_EL_PROPOSAL_IMAGE =
JspEditorPlugin.getDefault().getImage(JspEditorPlugin.CA_JSF_EL_IMAGE_PATH);
+
/**
* (non-Javadoc)
* @see org.jboss.tools.jst.jsp.contentassist.XmlContentAssistProcessor#createContext()
@@ -326,8 +331,6 @@
return;
}
- // TODO Auto-generated method stub
- System.out.println("JspContentAssistProcessor: addTagInsertionProposals()
invoked"); //$NON-NLS-1$
try {
String matchString = contentAssistRequest.getMatchString();
String query = matchString;
@@ -342,32 +345,37 @@
TextProposal textProposal = proposals[i];
String replacementString = textProposal.getReplacementString();
+ String closingTag = textProposal.getLabel();
+ if (closingTag != null && closingTag.startsWith("<")) {
//$NON-NLS-1$
+ closingTag = closingTag.substring(1);
+ }
+
if (!replacementString.endsWith("/>")) { //$NON-NLS-1$
- String closingTag = textProposal.getLabel();
- if (closingTag != null && closingTag.startsWith("<")) {
//$NON-NLS-1$
- closingTag = closingTag.substring(1);
- }
-
replacementString += "</" + closingTag + ">";
//$NON-NLS-1$ //$NON-NLS-2$
}
- System.out.println("Tag Name proposal [" + (i + 1) + "/" +
proposals.length + "]: " + replacementString); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
int replacementLength = contentAssistRequest.getReplacementLength();
int cursorPosition = getCursorPositionForProposedText(replacementString);
Image image = textProposal.getImage();
- String displayString = textProposal.getLabel() + ">"; //$NON-NLS-1$
+ if (image == null) {
+ image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
+ }
+ String displayString = closingTag; //$NON-NLS-1$
IContextInformation contextInformation = null;
String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance() + 10000;
-
-
- CustomCompletionProposal proposal = new CustomCompletionProposal(replacementString,
replacementOffset, replacementLength, cursorPosition, image, displayString,
contextInformation, additionalProposalInfo, relevance);
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_TAG_INSERTION;
+ }
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true,
replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
contentAssistRequest.addProposal(proposal);
}
} finally {
- System.out.println("JspContentAssistProcessor: addTagInsertionProposals()
exited"); //$NON-NLS-1$
}
return;
}
@@ -383,8 +391,6 @@
@Override
protected void addTagNameProposals(
ContentAssistRequest contentAssistRequest, int childPosition) {
- // TODO Auto-generated method stub
- System.out.println("JspContentAssistProcessor: addTagNameProposals()
invoked"); //$NON-NLS-1$
try {
String matchString = contentAssistRequest.getMatchString();
String query = matchString;
@@ -399,36 +405,43 @@
TextProposal textProposal = proposals[i];
String replacementString = textProposal.getReplacementString();
+ String closingTag = textProposal.getLabel();
+ if (closingTag != null && closingTag.startsWith("<")) {
//$NON-NLS-1$
+ closingTag = closingTag.substring(1);
+ }
+
if (replacementString.startsWith("<")) { //$NON-NLS-1$
// Because the tag starting char is already in the text
replacementString = replacementString.substring(1);
}
if (!replacementString.endsWith("/>")) { //$NON-NLS-1$
- String closingTag = textProposal.getLabel();
- if (closingTag != null && closingTag.startsWith("<")) {
//$NON-NLS-1$
- closingTag = closingTag.substring(1);
- }
-
replacementString += "</" + closingTag + ">";
//$NON-NLS-1$ //$NON-NLS-2$
}
- System.out.println("Tag Name proposal [" + (i + 1) + "/" +
proposals.length + "]: " + replacementString); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
-
+
int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
int replacementLength = contentAssistRequest.getReplacementLength();
int cursorPosition = getCursorPositionForProposedText(replacementString);
Image image = textProposal.getImage();
- String displayString = textProposal.getLabel() + ">"; //$NON-NLS-1$
+ if (image == null) {
+ image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
+ }
+
+ String displayString = closingTag; //$NON-NLS-1$
IContextInformation contextInformation = null;
String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance() + 10000;
-
-
- CustomCompletionProposal proposal = new CustomCompletionProposal(replacementString,
replacementOffset, replacementLength, cursorPosition, image, displayString,
contextInformation, additionalProposalInfo, relevance);
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_TAG_INSERTION;
+ }
+
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true,
replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
contentAssistRequest.addProposal(proposal);
}
} finally {
- System.out.println("JspContentAssistProcessor: addTagNameProposals()
exited"); //$NON-NLS-1$
}
return;
}
@@ -441,7 +454,6 @@
* @param childPosition the
*/
protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("JspContentAssistProcessor: addAttributeNameProposals()
invoked"); //$NON-NLS-1$
try {
String matchString = contentAssistRequest.getMatchString();
String query = matchString;
@@ -455,8 +467,6 @@
for (int i = 0; proposals != null && i < proposals.length; i++) {
TextProposal textProposal = proposals[i];
- System.out.println("Tag Attribute proposal [" + (i + 1) + "/" +
proposals.length + "]: " + textProposal.getReplacementString()); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
-
if (isExistingAttribute(textProposal.getLabel()))
continue;
@@ -469,14 +479,15 @@
String displayString = textProposal.getLabel();
IContextInformation contextInformation = null;
String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance() + 10000;
+ int relevance = textProposal.getRelevance();
-
- CustomCompletionProposal proposal = new CustomCompletionProposal(replacementString,
replacementOffset, replacementLength, cursorPosition, image, displayString,
contextInformation, additionalProposalInfo, relevance);
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true,
replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
contentAssistRequest.addProposal(proposal);
}
} finally {
- System.out.println("JspContentAssistProcessor: addAttributeNameProposals()
exited"); //$NON-NLS-1$
}
}
@@ -510,13 +521,18 @@
String displayString = textProposal.getLabel();
IContextInformation contextInformation = null;
String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance() + 10000;
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_JSP_ATTRIBUTE_VALUE;
+ }
- CustomCompletionProposal proposal = new CustomCompletionProposal(replacementString,
replacementOffset, replacementLength, cursorPosition, image, displayString,
contextInformation, additionalProposalInfo, relevance);
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
contentAssistRequest.addProposal(proposal);
}
} finally {
- System.out.println("JspContentAssistProcessor: addAttributeValueProposals()
exited"); //$NON-NLS-1$
}
}
@@ -532,8 +548,6 @@
*/
@Override
protected void addAttributeValueELProposals(ContentAssistRequest contentAssistRequest)
{
- // TODO Auto-generated method stub
- System.out.println("JspContentAssistProcessor: addAttributeValueELProposals()
invoked"); //$NON-NLS-1$
try {
TextRegion prefix = getELPrefix();
if (prefix == null) {
@@ -541,8 +555,10 @@
}
if(!prefix.isELStarted()) {
- CustomCompletionProposal proposal = new CustomCompletionProposal("#{}",
getOffset(), //$NON-NLS-1$
- 0, 2, null, "#{}", null,
JstUIMessages.JspContentAssistProcessor_NewELExpression, 10000); //$NON-NLS-1$
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true,
"#{}", //$NON-NLS-1$
+ getOffset(), 0, 2, JSF_EL_PROPOSAL_IMAGE,
JstUIMessages.JspContentAssistProcessor_NewELExpression,
+ null, JstUIMessages.JspContentAssistProcessor_NewELExpressionAttrInfo,
TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
+
contentAssistRequest.addProposal(proposal);
return;
}
@@ -560,8 +576,6 @@
for (int i = 0; proposals != null && i < proposals.length; i++) {
TextProposal textProposal = proposals[i];
- System.out.println("Tag Attribute Value EL proposal [" + (i + 1) +
"/" + proposals.length + "]: " + textProposal.getReplacementString());
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
int replacementOffset = beginChangeOffset;
int replacementLength = prefix.getLength();
String replacementString = prefix.getText().substring(0, replacementLength) +
textProposal.getReplacementString();
@@ -571,19 +585,26 @@
String displayString = prefix.getText().substring(0, replacementLength) +
textProposal.getReplacementString();
IContextInformation contextInformation = null;
String additionalProposalInfo = (textProposal.getContextInfo() == null ? ""
: textProposal.getContextInfo()); //$NON-NLS-1$
- int relevance = textProposal.getRelevance() + 10000;
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
+ }
- CustomCompletionProposal proposal = new CustomCompletionProposal(replacementString,
replacementOffset, replacementLength, cursorPosition, image, displayString,
contextInformation, additionalProposalInfo, relevance);
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
contentAssistRequest.addProposal(proposal);
}
if (prefix.isELStarted() && !prefix.isELClosed()) {
- CustomCompletionProposal proposal = new CustomCompletionProposal("}",
getOffset(), //$NON-NLS-1$
- 0, 1, null, "}", null,
JstUIMessages.JspContentAssistProcessor_CloseELExpression, 10001); //$NON-NLS-1$
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal("}", //$NON-NLS-1$
+ getOffset(), 0, 1, JSF_EL_PROPOSAL_IMAGE,
JstUIMessages.JspContentAssistProcessor_CloseELExpression,
+ null, JstUIMessages.JspContentAssistProcessor_CloseELExpressionInfo,
TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
+
contentAssistRequest.addProposal(proposal);
}
} finally {
- System.out.println("JspContentAssistProcessor: addAttributeELProposals()
exited"); //$NON-NLS-1$
}
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2009-07-23
15:42:11 UTC (rev 16753)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2009-07-23
15:52:38 UTC (rev 16754)
@@ -50,8 +50,7 @@
public static String CSS_APPLY_CHANGES;
public static String ADD_FONT_FAMILY_TIP;
public static String REMOVE_FONT_FAMILY_TIP;
- public static String FaceletPageContectAssistProcessor_CloseELExpression;
- public static String FaceletPageContectAssistProcessor_NewELExpression;
+ public static String FaceletPageContectAssistProcessor_NewELExpressionTextInfo;
public static String FONT_SIZE;
public static String FONT_STYLE;
public static String FONT_WEIGHT;
@@ -107,7 +106,9 @@
public static String CSS_CLASS_NAME_NOT_VALID;
public static String CSS_INVALID_STYLE_PROPERTY;
public static String JspContentAssistProcessor_CloseELExpression;
+ public static String JspContentAssistProcessor_CloseELExpressionInfo;
public static String JspContentAssistProcessor_NewELExpression;
+ public static String JspContentAssistProcessor_NewELExpressionAttrInfo;
public static String JSPDialogCellEditor_CodeAssist;
public static String JSPDialogCellEditor_EditAttribute;
public static String JSPDialogContentProposalProvider_CloseELExpression;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2009-07-23
15:42:11 UTC (rev 16753)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2009-07-23
15:52:38 UTC (rev 16754)
@@ -16,8 +16,8 @@
ADD_FONT_FAMILY_TIP=Add font family
REMOVE_FONT_FAMILY_TIP=Remove font family
-FaceletPageContectAssistProcessor_CloseELExpression=Close EL Expression
-FaceletPageContectAssistProcessor_NewELExpression=New EL Expression
+FaceletPageContectAssistProcessor_NewELExpression=New JSF EL Expression - Create a new
text with #{}
+FaceletPageContectAssistProcessor_NewELExpressionTextInfo=#{}
FONT_FAMILY_DIALOG_TITLE=Choose font family
BUTTON_APPLY=Apply
BUTTON_CLEAR=Clear
@@ -81,8 +81,10 @@
DEFAULT_PREVIEW_TEXT=CSS file to edit will be displayed here
DEFAULT_TEXT_FOR_BROWSER_PREVIEW=Double click to edit preview. To save changes press
Enter button.
-JspContentAssistProcessor_CloseELExpression=Close EL Expression
-JspContentAssistProcessor_NewELExpression=New EL Expression
+JspContentAssistProcessor_CloseELExpression=Close JSF EL Expression
+JspContentAssistProcessor_CloseELExpressionInfo=}
+JspContentAssistProcessor_NewELExpression=New JSF EL Expression - Create a new attribute
value with #{}
+JspContentAssistProcessor_NewELExpressionAttrInfo=#{}
JSPDialogCellEditor_CodeAssist=code assist
JSPDialogCellEditor_EditAttribute=Edit {0}
JSPDialogContentProposalProvider_CloseELExpression=Close EL Expression