Author: mareshkau
Date: 2010-05-06 05:47:16 -0400 (Thu, 06 May 2010)
New Revision: 21933
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.properties
trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.properties
trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/XHTMLContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/XHTMLTemplateCompletionProcessor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-6131
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.properties
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.properties 2010-05-06 07:45:29 UTC
(rev 21932)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.properties 2010-05-06 09:47:16 UTC
(rev 21933)
@@ -25,7 +25,6 @@
PreferencePage_JSFFlowTabbed=JSF Flow Diagram
PreferencePage_Validator=Validator
PreferencePage_JSFValidator=JSF Validator
-VPE_Templates=Templates
NewWizardCat_JBossTools=JBoss Tools
NewWizardCat_JSF=JSF
@@ -38,12 +37,3 @@
ImportWizardCat_Struts=Struts
ImportWizardDescription_JSFProject=Create a new Project from a JSF project in the file
system. This does not copy the project to the workspace.
ImportWizardDescription_JSFWar=Create a new Project from a JSF project in a WAR file. The
content of WAR file will be copied to the workspace.
-
-All_XHTML_context_type_Extension_Element.name=All XHTML
-XHTML_New_context_type_Extension_Element.name=New XHTML
-XHTML_Tag_context_type_Extension_Element.name=XHTML Tag
-XHTML_Attribute_context_type_Extension_Element.name=XHTML Attribute
-XHTML_Attribute_value_context_type_Extension_Element.name=XHTML Attribute value
-
-NewXHTMLPage = XHTML Page
-NewXHTMLPageDescription = Create a New XHTML Page
\ No newline at end of file
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2010-05-06 07:45:29 UTC (rev
21932)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2010-05-06 09:47:16 UTC (rev
21933)
@@ -8,13 +8,6 @@
id="org.jboss.tools.jsf.ui"
name="%PreferencePage_JSF">
</page>
- <page
- name="%VPE_Templates"
- category="org.jboss.tools.vpe.editor"
- class="org.jboss.tools.jsf.ui.editor.pref.template.VPETemplatePreferencePage"
- id="org.jboss.tools.jsf.ui.editor.pref.template">
- <keywordReference id="org.eclipse.wst.html.ui.templates"/>
- </page>
<page category="org.jboss.tools.jsf.ui"
class="org.jboss.tools.jsf.ui.preferences.JSFProjectPreferencesPage"
id="org.jboss.tools.jsf.ui.project"
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.properties 2010-05-06 07:45:29 UTC
(rev 21932)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.properties 2010-05-06 09:47:16 UTC
(rev 21933)
@@ -42,7 +42,17 @@
ViewName_WebProjects=Web Projects
ViewCategory_JBossToolsWeb=JBoss Tools Web
+VPE_Templates=Templates
+All_XHTML_context_type_Extension_Element.name=All XHTML
+XHTML_New_context_type_Extension_Element.name=New XHTML
+XHTML_Tag_context_type_Extension_Element.name=XHTML Tag
+XHTML_Attribute_context_type_Extension_Element.name=XHTML Attribute
+XHTML_Attribute_value_context_type_Extension_Element.name=XHTML Attribute value
+
+NewXHTMLPage = XHTML Page
+NewXHTMLPageDescription = Create a New XHTML Page
+
Bundle-Name.0 = Web UI
NavigatorContent_FileContentProvider=JBoss Tools File Content Provider
NavigatorContent_ProjectContentProvider=JBoss Tools Project Content Provider
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2010-05-06 07:45:29 UTC (rev
21932)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2010-05-06 09:47:16 UTC (rev
21933)
@@ -44,6 +44,13 @@
<page category="org.jboss.tools.common.model.ui"
class="org.jboss.tools.jst.web.ui.internal.preferences.LibrarySetsPreferencePage"
id="org.jboss.tools.common.xstudio.libsets"
name="%PreferencePage_LibrarySets">
</page>
+ <page
+ name="%VPE_Templates"
+ category="org.jboss.tools.vpe.editor"
+ class="org.jboss.tools.jst.web.ui.editor.pref.template.VPETemplatePreferencePage"
+ id="org.jboss.tools.jsf.ui.editor.pref.template">
+ <keywordReference id="org.eclipse.wst.html.ui.templates"/>
+ </page>
</extension>
<extension point="org.eclipse.ui.editors">
<editor
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/XHTMLContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/XHTMLContentAssistProcessor.java 2010-05-06
07:45:29 UTC (rev 21932)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/XHTMLContentAssistProcessor.java 2010-05-06
09:47:16 UTC (rev 21933)
@@ -14,6 +14,7 @@
import java.util.List;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
@@ -21,6 +22,8 @@
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
+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.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
@@ -134,18 +137,44 @@
public ICompletionProposal[] computeCompletionProposals(
ITextViewer textViewer, int documentPosition) {
List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
+ List<String> fContextTypes = getContentTypes(textViewer, documentPosition);
+ addTemplates(textViewer, result, fContextTypes,
+ documentPosition);
+ return result.toArray(new ICompletionProposal[0]);
+ }
+ /**
+ * Function for culculation content type depending on position
+ * @param textViewer
+ * @param documentPosition
+ * @return List of content types
+ *
+ * @author mareshkau
+ */
+ private List<String> getContentTypes(ITextViewer textViewer, int
documentPosition){
List<String> fContextTypes = new ArrayList<String>();
+ IDocument document = textViewer.getDocument();
+ IStructuredModel model = null;
+ try {
+ // gets source model for read, model should be released see
+ // JBIDE-2219
+ model = StructuredModelManager.getModelManager()
+ .getExistingModelForRead(document);
+ IndexedRegion node = model.getIndexedRegion(documentPosition);
+ }
+ finally{
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
//TODO Maksim Areshkau, analize and position here
fContextTypes.add(TemplateContextTypeIdsXHTML.ALL);
fContextTypes.add(TemplateContextTypeIdsXHTML.TAG);
fContextTypes.add(TemplateContextTypeIdsXHTML.NEW);
fContextTypes.add(TemplateContextTypeIdsXHTML.ATTRIBUTE);
fContextTypes.add(TemplateContextTypeIdsXHTML.ATTRIBUTE_VALUE);
- addTemplates(textViewer, result, fContextTypes,
- documentPosition);
- return result.toArray(new ICompletionProposal[0]);
+ return fContextTypes;
}
-
+
protected String getEmptyTagCloseString() {
if (isXHTML)
return " />"; //$NON-NLS-1$
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/XHTMLTemplateCompletionProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/XHTMLTemplateCompletionProcessor.java 2010-05-06
07:45:29 UTC (rev 21932)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/editor/pref/template/contentassist/XHTMLTemplateCompletionProcessor.java 2010-05-06
09:47:16 UTC (rev 21933)
@@ -122,10 +122,12 @@
return null;
}
+ @Override
protected ICompletionProposal createProposal(Template template, TemplateContext context,
IRegion region, int relevance) {
return new TemplateProposal(template, context, region, getImage(template), relevance);
}
+ @Override
protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) {
TemplateContextType type = null;
@@ -145,6 +147,7 @@
return WebUiPlugin.getDefault().getTemplateContextRegistry();
}
+ @Override
protected Template[] getTemplates(String contextTypeId) {
Template templates[] = null;
@@ -160,7 +163,7 @@
}
void setContextType(String contextTypeId) {
- fContextTypeId = contextTypeId;
+ this.fContextTypeId = contextTypeId;
}
@Override