Author: mareshkau
Date: 2010-04-28 13:23:21 -0400 (Wed, 28 Apr 2010)
New Revision: 21785
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/contentassist/
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/contentassist/XHTMLContentAssistProcessor.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/contentassist/XHTMLTemplateCompletionProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/schema/editorContentAssistent.exsd
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
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
Log:
https://jira.jboss.org/jira/browse/JBIDE-6131, source code vpe-templates has been added as
proposals to CA, draft version
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2010-04-28 16:04:31 UTC (rev
21784)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2010-04-28 17:23:21 UTC (rev
21785)
@@ -518,5 +518,9 @@
</newWizardShortcut>
</perspectiveExtension>
</extension>
+ <extension
+ point="org.jboss.tools.jst.jsp.editorContentAssistent">
+ <contentassisten
class="org.jboss.tools.jsf.ui.editor.pref.template.contentassist.XHTMLContentAssistProcessor"/>
+ </extension>
</plugin>
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/contentassist/XHTMLContentAssistProcessor.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/contentassist/XHTMLContentAssistProcessor.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/contentassist/XHTMLContentAssistProcessor.java 2010-04-28
17:23:21 UTC (rev 21785)
@@ -0,0 +1,223 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.ui.editor.pref.template.contentassist;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+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.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.jboss.tools.jsf.ui.JsfUiPlugin;
+import org.jboss.tools.jsf.ui.editor.pref.template.TemplateContextTypeIdsXHTML;
+import org.w3c.dom.Node;
+
+/**
+ * XHTML Contetn assist processor, processor which add's templates
+ * proposals to CA
+ *
+ * @author mareshkau
+ *
+ */
+public class XHTMLContentAssistProcessor implements IContentAssistProcessor,
+ IPropertyChangeListener {
+
+ protected IPreferenceStore fPreferenceStore = null;
+ protected boolean isXHTML = false;
+ private XHTMLTemplateCompletionProcessor fTemplateProcessor = null;
+
+ public XHTMLContentAssistProcessor() {
+
+ super();
+ }
+
+ /**
+ * Add the proposals for a completely empty document
+ */
+ // protected void addEmptyDocumentProposals(List<ICompletionProposal>
+ // contentAssistRequest) {
+ // addTemplates(contentAssistRequest, TemplateContextTypeIdsXHTML.NEW);
+ // }
+
+ // protected void addStartDocumentProposals(List<ICompletionProposal>
+ // contentAssistRequest) {
+ // if (isXHTML)
+ // addEmptyDocumentProposals(contentAssistRequest);
+ // }
+
+ // protected void addTagInsertionProposals(List<ICompletionProposal>
+ // contentAssistRequest, int childPosition) {
+ // addTemplates(contentAssistRequest, TemplateContextTypeIdsXHTML.TAG);
+ // }
+
+ /**
+ * Adds templates to the list of proposals
+ *
+ * @param contentAssistRequest
+ * @param context
+ */
+ // private void addTemplates(List<ICompletionProposal> contentAssistRequest,
+ // String context) {
+ // addTemplates(contentAssistRequest, context,
+ // contentAssistRequest.getReplacementBeginPosition());
+ // }
+
+ /**
+ * Adds templates to the list of proposals
+ *
+ * @param contentAssistRequest
+ * @param context
+ * @param startOffset
+ */
+ private void addTemplates(ITextViewer fTextViewer,
+ List<ICompletionProposal> contentAssistRequest,
+ List<String> fTemplateContexts, int startOffset) {
+ if (contentAssistRequest == null)
+ return;
+
+ // if already adding template proposals for a certain context type, do
+ // not add again
+ if (getTemplateCompletionProcessor() != null) {
+ for (String context : fTemplateContexts) {
+ getTemplateCompletionProcessor().setContextType(context);
+ ICompletionProposal[] proposals = getTemplateCompletionProcessor()
+ .computeCompletionProposals(fTextViewer, startOffset);
+ for (int i = 0; i < proposals.length; ++i) {
+ contentAssistRequest.add(proposals[i]);
+ }
+ }
+ }
+ }
+
+ protected boolean beginsWith(String aString, String prefix) {
+ if (aString == null || prefix == null || prefix.length() == 0)
+ return true;
+ int minimumLength = Math.min(prefix.length(), aString.length());
+ String beginning = aString.substring(0, minimumLength);
+ return beginning.equalsIgnoreCase(prefix);
+ }
+
+ // protected List<ICompletionProposal>
+ // computeCompletionProposals(ITextViewer textViewer, int documentPosition)
+ // {
+ // List<ICompletionProposal> request=new ArrayList<ICompletionProposal>();
+ // addTemplates(textViewer,request, TemplateContextTypeIdsXHTML.ALL,
+ // documentPosition);
+ // return request;
+ // }
+
+ /**
+ * Return a list of proposed code completions based on the specified
+ * location within the document that corresponds to the current cursor
+ * position within the text-editor control.
+ *
+ * @param documentPosition
+ * a location within the document
+ * @return an array of code-assist items
+ */
+ public ICompletionProposal[] computeCompletionProposals(
+ ITextViewer textViewer, int documentPosition) {
+ List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
+ List<String> fContextTypes = new ArrayList<String>();
+ //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]);
+ }
+
+ protected String getEmptyTagCloseString() {
+ if (isXHTML)
+ return " />"; //$NON-NLS-1$
+ return ">"; //$NON-NLS-1$
+ }
+
+ private XHTMLTemplateCompletionProcessor getTemplateCompletionProcessor() {
+ if (this.fTemplateProcessor == null) {
+ this.fTemplateProcessor = new XHTMLTemplateCompletionProcessor();
+ }
+ return this.fTemplateProcessor;
+ }
+
+ /**
+ * Determine if this Document is an XHTML Document. Oprates solely off of
+ * the Document Type declaration
+ */
+ protected boolean getXHTML(Node node) {
+ // TODO Maksim Areshkau, implement it
+ return true;
+ }
+
+ protected void init() {
+ getPreferenceStore().addPropertyChangeListener(this);
+ }
+
+ public void release() {
+ getPreferenceStore().removePropertyChangeListener(this);
+ }
+
+ protected boolean stringsEqual(String a, String b) {
+ return a.equalsIgnoreCase(b);
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ String property = event.getProperty();
+ }
+
+ protected IPreferenceStore getPreferenceStore() {
+ if (this.fPreferenceStore == null)
+ this.fPreferenceStore = JsfUiPlugin.getDefault().getPreferenceStore();
+
+ return this.fPreferenceStore;
+ }
+
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
+ int documentPosition, IndexedRegion indexedNode, ITextRegion region) {
+ return computeCompletionProposals(viewer, documentPosition);
+ }
+
+ public IContextInformation[] computeContextInformation(ITextViewer viewer,
+ int offset) {
+
+ return new IContextInformation[0];
+ }
+
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ return new char[0];
+ }
+
+ public char[] getContextInformationAutoActivationCharacters() {
+ return new char[0];
+ }
+
+ public IContextInformationValidator getContextInformationValidator() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getErrorMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/contentassist/XHTMLTemplateCompletionProcessor.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/contentassist/XHTMLTemplateCompletionProcessor.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/pref/template/contentassist/XHTMLTemplateCompletionProcessor.java 2010-04-28
17:23:21 UTC (rev 21785)
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.ui.editor.pref.template.contentassist;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateCompletionProcessor;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateProposal;
+import org.eclipse.jface.text.templates.persistence.TemplateStore;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.html.ui.internal.contentassist.ReplaceNameTemplateContext;
+import org.jboss.tools.jsf.ui.JsfUiPlugin;
+
+
+/**
+ * This class copy of HTMLTemplateCompletionProcessor, because it easiest way to
+ * use this I haven't founded a possibility to extends from class and ovveride it
+ *
+ * @author mareshkau
+ *
+ */
+public class XHTMLTemplateCompletionProcessor extends TemplateCompletionProcessor {
+
+ private static final class ProposalComparator implements
Comparator<TemplateProposal> {
+ public int compare(TemplateProposal o1, TemplateProposal o2) {
+ return o2.getRelevance() - o1.getRelevance();
+ }
+ }
+
+ private static final Comparator<TemplateProposal> fgProposalComparator = new
ProposalComparator();
+ private String fContextTypeId = null;
+
+ /*
+ * Copied from super class except instead of calling createContext(viewer,
+ * region) call createContext(viewer, region, offset) instead
+ */
+ @Override
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset)
{
+
+ ITextSelection selection = (ITextSelection)
viewer.getSelectionProvider().getSelection();
+
+ // adjust offset to end of normalized selection
+ if (selection.getOffset() == offset)
+ offset = selection.getOffset() + selection.getLength();
+
+ String prefix = extractPrefix(viewer, offset);
+ Region region = new Region(offset - prefix.length(), prefix.length());
+ TemplateContext context = createContext(viewer, region, offset);
+ if (context == null)
+ return new ICompletionProposal[0];
+ // name of the selection variables {line, word}_selection
+ context.setVariable("selection", selection.getText()); //$NON-NLS-1$
+
+ Template[] templates = getTemplates(context.getContextType().getId());
+
+ List matches = new ArrayList();
+ for (int i = 0; i < templates.length; i++) {
+ Template template = templates[i];
+ try {
+ context.getContextType().validate(template.getPattern());
+ }
+ catch (TemplateException e) {
+ continue;
+ }
+ if (template.matches(prefix, context.getContextType().getId()))
+ matches.add(createProposal(template, context, (IRegion) region,
getRelevance(template, prefix)));
+ }
+
+ Collections.sort(matches, fgProposalComparator);
+
+ return (ICompletionProposal[]) matches.toArray(new
ICompletionProposal[matches.size()]);
+ }
+
+ /**
+ * Creates a concrete template context for the given region in the
+ * document. This involves finding out which context type is valid at the
+ * given location, and then creating a context of this type. The default
+ * implementation returns a <code>SmartReplaceTemplateContext</code> for
+ * the context type at the given location. This takes the offset at which
+ * content assist was invoked into consideration.
+ *
+ * @param viewer
+ * the viewer for which the context is created
+ * @param region
+ * the region into <code>document</code> for which the
+ * context is created
+ * @param offset
+ * the original offset where content assist was invoked
+ * @return a template context that can handle template insertion at the
+ * given location, or <code>null</code>
+ */
+ private TemplateContext createContext(ITextViewer viewer, IRegion region, int offset) {
+ // pretty much same code as super.createContext except create
+ // SmartReplaceTemplateContext
+ TemplateContextType contextType = getContextType(viewer, region);
+ if (contextType != null) {
+ IDocument document = viewer.getDocument();
+ return new ReplaceNameTemplateContext(contextType, document, region.getOffset(),
region.getLength(), offset);
+ }
+ return null;
+ }
+
+ protected ICompletionProposal createProposal(Template template, TemplateContext context,
IRegion region, int relevance) {
+ return new TemplateProposal(template, context, region, getImage(template), relevance);
+ }
+
+ protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) {
+ TemplateContextType type = null;
+
+ ContextTypeRegistry registry = getTemplateContextRegistry();
+ if (registry != null)
+ type = registry.getContextType(fContextTypeId);
+
+ return type;
+ }
+
+// protected Image getImage(Template template) {
+// // just return the same image for now
+// return
HTMLEditorPluginImageHelper.getInstance().getImage(HTMLEditorPluginImages.IMG_OBJ_TAG_TEMPLATE);
+// }
+
+ private ContextTypeRegistry getTemplateContextRegistry() {
+ return JsfUiPlugin.getDefault().getTemplateContextRegistry();
+ }
+
+ protected Template[] getTemplates(String contextTypeId) {
+ Template templates[] = null;
+
+ TemplateStore store = getTemplateStore();
+ if (store != null)
+ templates = store.getTemplates(contextTypeId);
+
+ return templates;
+ }
+
+ private TemplateStore getTemplateStore() {
+ return JsfUiPlugin.getDefault().getTemplateStore();
+ }
+
+ void setContextType(String contextTypeId) {
+ fContextTypeId = contextTypeId;
+ }
+
+ @Override
+ protected Image getImage(Template template) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2010-04-28 16:04:31 UTC (rev
21784)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2010-04-28 17:23:21 UTC (rev
21785)
@@ -5,7 +5,8 @@
<extension-point id="occurrenceStructureProviders"
name="%occurrenceStructureProvidersExtensionPoint" />
<extension-point id="visulaEditorImplementations" name="Visual Editor
Implementations" schema="schema/visulaEditorImplementations.exsd">
- </extension-point>
+ </extension-point>
+ <extension-point id="editorContentAssistent"
name="editorContentAssistent"
schema="schema/editorContentAssistent.exsd"/>
<extension point="org.eclipse.wst.sse.ui.editorConfiguration">
<sourceViewerConfiguration
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/schema/editorContentAssistent.exsd
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/schema/editorContentAssistent.exsd
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/schema/editorContentAssistent.exsd 2010-04-28
17:23:21 UTC (rev 21785)
@@ -0,0 +1,99 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.jst.jsp"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.jboss.tools.jst.jsp"
id="editorContentAssistent" name="editorContentAssistent"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="contentassisten">
+ <complexType>
+ <attribute name="class" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"
basedOn=":org.eclipse.jface.text.contentassist.IContentAssistProcessor"
deprecated="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
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 2010-04-28
16:04:31 UTC (rev 21784)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java 2010-04-28
17:23:21 UTC (rev 21785)
@@ -7,11 +7,20 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.jst.jsp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.text.ITextHover;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.formatter.IContentFormatter;
@@ -30,67 +39,100 @@
import org.eclipse.wst.sse.ui.internal.taginfo.TextHoverManager;
import org.jboss.tools.jst.jsp.format.HTMLFormatProcessor;
import org.jboss.tools.jst.jsp.jspeditor.info.ChainTextHover;
+import org.osgi.framework.Bundle;
@SuppressWarnings("restriction")
-public class HTMLTextViewerConfiguration extends StructuredTextViewerConfigurationHTML
implements ITextViewerConfiguration{
+public class HTMLTextViewerConfiguration extends
+ StructuredTextViewerConfigurationHTML implements
+ ITextViewerConfiguration {
- TextViewerConfigurationDelegate configurationDelegate;
+ TextViewerConfigurationDelegate configurationDelegate;
+
+ private static final String TEMPLATES_CONTENT_ASSISTANT =
"org.jboss.tools.jst.jsp.editorContentAssistent"; //$NON-NLS-1$
+ private static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
+
public HTMLTextViewerConfiguration() {
super();
configurationDelegate = new TextViewerConfigurationDelegate(this);
}
- protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer
sourceViewer, String partitionType) {
- return configurationDelegate.getContentAssistProcessors(sourceViewer, partitionType);
+ protected IContentAssistProcessor[] getContentAssistProcessors(
+ ISourceViewer sourceViewer, String partitionType) {
+ return configurationDelegate.getContentAssistProcessors(sourceViewer,
+ partitionType);
}
/*
- * @see
org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
+ * @see
+ * org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors
+ * (org.eclipse.jface.text.source.ISourceViewer)
+ *
* @since 3.1
*/
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
- return configurationDelegate.getHyperlinkDetectors(
- sourceViewer,
- fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED));
+ return configurationDelegate
+ .getHyperlinkDetectors(
+ sourceViewer,
+ fPreferenceStore
+ .getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED));
}
/*
* (non-Javadoc)
- * @see
org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML#getContentFormatter(org.eclipse.jface.text.source.ISourceViewer)
+ *
+ * @seeorg.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML#
+ * getContentFormatter(org.eclipse.jface.text.source.ISourceViewer)
*/
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
- MultiPassContentFormatter formatter = new
MultiPassContentFormatter(getConfiguredDocumentPartitioning(sourceViewer),
IHTMLPartitions.HTML_DEFAULT);
- formatter.setMasterStrategy(new StructuredFormattingStrategy(new
HTMLFormatProcessor()));
+ MultiPassContentFormatter formatter = new MultiPassContentFormatter(
+ getConfiguredDocumentPartitioning(sourceViewer),
+ IHTMLPartitions.HTML_DEFAULT);
+ formatter.setMasterStrategy(new StructuredFormattingStrategy(
+ new HTMLFormatProcessor()));
return formatter;
}
public IContentAssistProcessor[] getContentAssistProcessorsForPartitionType(
ISourceViewer sourceViewer, String partitionType) {
- return super.getContentAssistProcessors(sourceViewer, partitionType);
+ IContentAssistProcessor[] results = super.getContentAssistProcessors(
+ sourceViewer, partitionType);
+ // added by Maksim Areshkau
+ if ("org.eclipse.wst.html.HTML_DEFAULT".equalsIgnoreCase(partitionType)) {
//$NON-NLS-1$
+ List<IContentAssistProcessor> contAssists = getVpeTestExtensions();
+ contAssists.addAll(Arrays.asList(results));
+ results = contAssists.toArray(new IContentAssistProcessor[0]);
+ }
+ return results;
}
/**
* Create documentation hovers based on hovers contributed via
- * <code>org.eclipse.wst.sse.ui.editorConfiguration</code> extension
- * point
+ * <code>org.eclipse.wst.sse.ui.editorConfiguration</code> extension point
*
- * Copied from {@link org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration} because
of private modifier
+ * Copied from
+ * {@link org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration} because
+ * of private modifier
*
* @param partitionType
* @return
*/
@SuppressWarnings("unchecked")
private ITextHover[] createDocumentationHovers(String partitionType) {
- List extendedTextHover =
ExtendedConfigurationBuilder.getInstance().getConfigurations(ExtendedConfigurationBuilder.DOCUMENTATIONTEXTHOVER,
partitionType);
- ITextHover[] hovers = (ITextHover[]) extendedTextHover.toArray(new
ITextHover[extendedTextHover.size()]);
+ List extendedTextHover = ExtendedConfigurationBuilder.getInstance()
+ .getConfigurations(
+ ExtendedConfigurationBuilder.DOCUMENTATIONTEXTHOVER,
+ partitionType);
+ ITextHover[] hovers = (ITextHover[]) extendedTextHover
+ .toArray(new ITextHover[extendedTextHover.size()]);
return hovers;
}
@Override
protected IInformationProvider getInformationProvider(
ISourceViewer sourceViewer, String partitionType) {
-
- ITextHover chainTextHover = new
ChainTextHover(createDocumentationHovers(partitionType));
+
+ ITextHover chainTextHover = new ChainTextHover(
+ createDocumentationHovers(partitionType));
return new TextHoverInformationProvider(chainTextHover);
}
@@ -100,21 +142,27 @@
ITextHover textHover = null;
/*
- * Returns a default problem, annotation, and best match hover
- * depending on stateMask
+ * Returns a default problem, annotation, and best match hover depending
+ * on stateMask
*/
- TextHoverManager.TextHoverDescriptor[] hoverDescs =
SSEUIPlugin.getDefault().getTextHoverManager().getTextHovers();
+ TextHoverManager.TextHoverDescriptor[] hoverDescs = SSEUIPlugin
+ .getDefault().getTextHoverManager().getTextHovers();
int i = 0;
while (i < hoverDescs.length && textHover == null) {
- if (hoverDescs[i].isEnabled() &&
computeStateMask(hoverDescs[i].getModifierString()) == stateMask) {
+ if (hoverDescs[i].isEnabled()
+ && computeStateMask(hoverDescs[i].getModifierString()) == stateMask) {
String hoverType = hoverDescs[i].getId();
if (TextHoverManager.PROBLEM_HOVER.equalsIgnoreCase(hoverType))
textHover = new ProblemAnnotationHoverProcessor();
- else if (TextHoverManager.ANNOTATION_HOVER.equalsIgnoreCase(hoverType))
+ else if (TextHoverManager.ANNOTATION_HOVER
+ .equalsIgnoreCase(hoverType))
textHover = new AnnotationHoverProcessor();
- else if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType))
- textHover = new ChainTextHover(createDocumentationHovers(contentType));
- else if (TextHoverManager.DOCUMENTATION_HOVER.equalsIgnoreCase(hoverType)) {
+ else if (TextHoverManager.COMBINATION_HOVER
+ .equalsIgnoreCase(hoverType))
+ textHover = new ChainTextHover(
+ createDocumentationHovers(contentType));
+ else if (TextHoverManager.DOCUMENTATION_HOVER
+ .equalsIgnoreCase(hoverType)) {
ITextHover[] hovers = createDocumentationHovers(contentType);
if (hovers.length > 0) {
textHover = hovers[0];
@@ -125,6 +173,30 @@
}
return textHover;
}
-
-
-}
\ No newline at end of file
+
+ /**
+ * Returns all extensions of {@value #VPE_TEST_EXTENTION_POINT_ID}
+ */
+ public List<IContentAssistProcessor> getVpeTestExtensions() {
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = extensionRegistry
+ .getExtensionPoint(TEMPLATES_CONTENT_ASSISTANT);
+ IExtension[] extensions = extensionPoint.getExtensions();
+ List<IContentAssistProcessor> contentAssisteProcessors = new
ArrayList<IContentAssistProcessor>();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] confElements = extension
+ .getConfigurationElements();
+ for (IConfigurationElement configurationElement : confElements) {
+ IContentAssistProcessor contentAssistProcessor;
+ try {
+ contentAssistProcessor = (IContentAssistProcessor) configurationElement
+ .createExecutableExtension(CLASS_ATTRIBUTE);
+ contentAssisteProcessors.add(contentAssistProcessor);
+ } catch (CoreException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ }
+ }
+ return contentAssisteProcessors;
+ }
+}