Author: akazakov
Date: 2008-02-15 05:41:43 -0500 (Fri, 15 Feb 2008)
New Revision: 6330
Added:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/XMLTextViewerConfiguration.java
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/AutoContentAssistantProposal.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/ExtendedJSPContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletsHtmlContentAssistProcessor.java
Removed:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/RedHatStructuredTextViewerConfigurationXML.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/ExtendedStructuredTextViewerConfigurationHTML.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/ExtendedStructuredTextViewerConfigurationJSP.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatCustomCompletionProposal.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatHtmlContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatJSPContentAssistProcessor.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java
trunk/common/plugins/org.jboss.tools.common.text.xml/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/contentassist/JSPActiveContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogCellEditorContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/FaceletsJsfCResource.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1704Test.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1717Test.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/StrutsJspJbide1648Test.java
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/AbstractResourceMarkerTest.java
Log:
Got rid of "RedHat" in class names.
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -77,7 +77,7 @@
import org.jboss.tools.common.model.ui.editors.dnd.context.InnerDragBuffer;
import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
import org.jboss.tools.common.text.xml.IOccurrencePreferenceProvider;
-import org.jboss.tools.common.text.xml.RedHatStructuredTextViewerConfigurationXML;
+import org.jboss.tools.common.text.xml.XMLTextViewerConfiguration;
import org.jboss.tools.common.text.xml.XmlEditorPlugin;
import org.jboss.tools.jst.jsp.text.xpl.IStructuredTextOccurrenceStructureProvider;
@@ -102,7 +102,7 @@
/// dnd.setTextEditorDropProvider(new TextEditorDropProviderImpl());
if (useRHDSConfig) {
- super.setSourceViewerConfiguration(new RedHatStructuredTextViewerConfigurationXML());
+ super.setSourceViewerConfiguration(new XMLTextViewerConfiguration());
}
}
@@ -110,12 +110,12 @@
protected void setSourceViewerConfiguration(SourceViewerConfiguration config) {
if( useRHDSConfig
- && !(config instanceof RedHatStructuredTextViewerConfigurationXML)
+ && !(config instanceof XMLTextViewerConfiguration)
&& (config instanceof StructuredTextViewerConfigurationXML
|| !(config instanceof StructuredTextViewerConfiguration)
)
) {
- RedHatStructuredTextViewerConfigurationXML r = new
RedHatStructuredTextViewerConfigurationXML();
+ XMLTextViewerConfiguration r = new XMLTextViewerConfiguration();
r.setInitialConfiguration(config);
config = r;
}
Modified: trunk/common/plugins/org.jboss.tools.common.text.xml/plugin.xml
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.xml/plugin.xml 2008-02-15 10:36:08
UTC (rev 6329)
+++ trunk/common/plugins/org.jboss.tools.common.text.xml/plugin.xml 2008-02-15 10:41:43
UTC (rev 6330)
@@ -21,7 +21,7 @@
<extension
point="org.eclipse.wst.sse.ui.editorConfiguration">
<sourceViewerConfiguration
- class="org.jboss.tools.common.text.xml.RedHatStructuredTextViewerConfigurationXML"
+ class="org.jboss.tools.common.text.xml.XMLTextViewerConfiguration"
target="org.eclipse.core.runtime.xml"/>
<contentOutlineConfiguration
class="org.eclipse.wst.xml.ui.views.contentoutline.XMLContentOutlineConfiguration"
@@ -66,7 +66,7 @@
<extension
point="org.eclipse.wst.sse.ui.editorConfiguration">
<sourceViewerConfiguration
- class="org.jboss.tools.common.text.xml.RedHatStructuredTextViewerConfigurationXML"
+ class="org.jboss.tools.common.text.xml.XMLTextViewerConfiguration"
target="org.jboss.tools.common.model.ui.xml"/>
<contentOutlineConfiguration
class="org.eclipse.wst.xml.ui.views.contentoutline.XMLContentOutlineConfiguration"
Deleted:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/RedHatStructuredTextViewerConfigurationXML.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/RedHatStructuredTextViewerConfigurationXML.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/RedHatStructuredTextViewerConfigurationXML.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.text.xml;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML;
-import org.jboss.tools.common.text.xml.contentassist.ContentAssistProcessorBuilder;
-import org.jboss.tools.common.text.xml.contentassist.ContentAssistProcessorDefinition;
-
-/**
- * @author Igels
- */
-public class RedHatStructuredTextViewerConfigurationXML extends
StructuredTextViewerConfigurationXML {
-
- SourceViewerConfiguration initial = null;
-
- public RedHatStructuredTextViewerConfigurationXML() {
- super();
- }
-
- public void setInitialConfiguration(SourceViewerConfiguration initial) {
- this.initial = initial;
- }
-
- protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer
sourceViewer, String 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(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);
- }
- }
-
- IContentAssistProcessor[] in = getInitialProcessors(sourceViewer, partitionType);
- if(in != null && in.length > 0) {
-
- //we do not need super processors - make initial processors responcible for that
- for(int i=0; i<in.length; i++) {
- if(!processors.contains(in[i])) {
- processors.add(in[i]);
- }
- }
- } else {
- IContentAssistProcessor[] ps = super.getContentAssistProcessors(sourceViewer,
partitionType);
- for(int i=0; ps != null && i<ps.length; i++) {
- if(!processors.contains(ps[i])) {
- processors.add(ps[i]);
- }
- }
- }
- return (IContentAssistProcessor[])processors.toArray(new IContentAssistProcessor[0]);
- }
-
- /*
- * @see
org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
- * @since 3.1
- */
- public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
- if (fPreferenceStore == null)
- return null;
- if (sourceViewer == null ||
!fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED))
- return null;
-
- List allDetectors = new ArrayList(0);
-
- IHyperlinkDetector extHyperlinkDetector = getTextEditorsExtensionsHyperlinkDetector();
-
- if (extHyperlinkDetector != null) allDetectors.add(extHyperlinkDetector);
-
-/*
- IHyperlinkDetector[] superDetectors = super.getHyperlinkDetectors(sourceViewer);
- for (int m = 0; m < superDetectors.length; m++) {
- IHyperlinkDetector detector = superDetectors[m];
- if (!allDetectors.contains(detector)) {
- allDetectors.add(detector);
- }
- }
-*/
- IHyperlinkDetector[] ts = (IHyperlinkDetector[]) allDetectors.toArray(new
IHyperlinkDetector[0]);
- IHyperlinkDetector[] in = (initial != null) ?
initial.getHyperlinkDetectors(sourceViewer) : null;
- if(in == null || in.length == 0) return ts;
- if(ts == null || ts.length == 0) return in;
- ArrayList<IHyperlinkDetector> total = new ArrayList<IHyperlinkDetector>();
- for (int i = 0; i < ts.length; i++) total.add(ts[i]);
- for (int i = 0; i < in.length; i++) if(!total.contains(in[i])) total.add(in[i]);
- return total.toArray(new IHyperlinkDetector[0]);
- }
-
- private IHyperlinkDetector getTextEditorsExtensionsHyperlinkDetector() {
- Plugin plugin = Platform.getPlugin("org.jboss.tools.common.text.ext");
- return (plugin != null && plugin instanceof IAdaptable ?
(IHyperlinkDetector)((IAdaptable)plugin).getAdapter(IHyperlinkDetector.class):null);
- }
-
- IContentAssistProcessor[] getInitialProcessors(ISourceViewer sourceViewer, String
partitionType) {
- if(initial == null) return null;
- try {
- Method m =
initial.getClass().getDeclaredMethod("getContentAssistProcessors", new
Class[]{ISourceViewer.class, String.class});
- m.setAccessible(true);
- return (IContentAssistProcessor[])m.invoke(initial, new Object[]{sourceViewer,
partitionType});
- } catch (Exception e) {
- XmlEditorPlugin.getPluginLog().logError(e);
- }
-
- return null;
- }
-
-}
Copied:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/XMLTextViewerConfiguration.java
(from rev 2297,
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/RedHatStructuredTextViewerConfigurationXML.java)
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/XMLTextViewerConfiguration.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/XMLTextViewerConfiguration.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.text.xml;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+import org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML;
+import org.jboss.tools.common.text.xml.contentassist.ContentAssistProcessorBuilder;
+import org.jboss.tools.common.text.xml.contentassist.ContentAssistProcessorDefinition;
+
+/**
+ * @author Igels
+ */
+public class XMLTextViewerConfiguration extends StructuredTextViewerConfigurationXML {
+
+ SourceViewerConfiguration initial = null;
+
+ public XMLTextViewerConfiguration() {
+ super();
+ }
+
+ public void setInitialConfiguration(SourceViewerConfiguration initial) {
+ this.initial = initial;
+ }
+
+ protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer
sourceViewer, String 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(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);
+ }
+ }
+
+ IContentAssistProcessor[] in = getInitialProcessors(sourceViewer, partitionType);
+ if(in != null && in.length > 0) {
+
+ //we do not need super processors - make initial processors responcible for that
+ for(int i=0; i<in.length; i++) {
+ if(!processors.contains(in[i])) {
+ processors.add(in[i]);
+ }
+ }
+ } else {
+ IContentAssistProcessor[] ps = super.getContentAssistProcessors(sourceViewer,
partitionType);
+ for(int i=0; ps != null && i<ps.length; i++) {
+ if(!processors.contains(ps[i])) {
+ processors.add(ps[i]);
+ }
+ }
+ }
+ return (IContentAssistProcessor[])processors.toArray(new IContentAssistProcessor[0]);
+ }
+
+ /*
+ * @see
org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
+ * @since 3.1
+ */
+ public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
+ if (fPreferenceStore == null)
+ return null;
+ if (sourceViewer == null ||
!fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED))
+ return null;
+
+ List allDetectors = new ArrayList(0);
+
+ IHyperlinkDetector extHyperlinkDetector = getTextEditorsExtensionsHyperlinkDetector();
+
+ if (extHyperlinkDetector != null) allDetectors.add(extHyperlinkDetector);
+
+/*
+ IHyperlinkDetector[] superDetectors = super.getHyperlinkDetectors(sourceViewer);
+ for (int m = 0; m < superDetectors.length; m++) {
+ IHyperlinkDetector detector = superDetectors[m];
+ if (!allDetectors.contains(detector)) {
+ allDetectors.add(detector);
+ }
+ }
+*/
+ IHyperlinkDetector[] ts = (IHyperlinkDetector[]) allDetectors.toArray(new
IHyperlinkDetector[0]);
+ IHyperlinkDetector[] in = (initial != null) ?
initial.getHyperlinkDetectors(sourceViewer) : null;
+ if(in == null || in.length == 0) return ts;
+ if(ts == null || ts.length == 0) return in;
+ ArrayList<IHyperlinkDetector> total = new ArrayList<IHyperlinkDetector>();
+ for (int i = 0; i < ts.length; i++) total.add(ts[i]);
+ for (int i = 0; i < in.length; i++) if(!total.contains(in[i])) total.add(in[i]);
+ return total.toArray(new IHyperlinkDetector[0]);
+ }
+
+ private IHyperlinkDetector getTextEditorsExtensionsHyperlinkDetector() {
+ Plugin plugin = Platform.getPlugin("org.jboss.tools.common.text.ext");
+ return (plugin != null && plugin instanceof IAdaptable ?
(IHyperlinkDetector)((IAdaptable)plugin).getAdapter(IHyperlinkDetector.class):null);
+ }
+
+ IContentAssistProcessor[] getInitialProcessors(ISourceViewer sourceViewer, String
partitionType) {
+ if(initial == null) return null;
+ try {
+ Method m =
initial.getClass().getDeclaredMethod("getContentAssistProcessors", new
Class[]{ISourceViewer.class, String.class});
+ m.setAccessible(true);
+ return (IContentAssistProcessor[])m.invoke(initial, new Object[]{sourceViewer,
partitionType});
+ } catch (Exception e) {
+ XmlEditorPlugin.getPluginLog().logError(e);
+ }
+
+ return null;
+ }
+
+}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2008-02-15 10:36:08 UTC (rev
6329)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2008-02-15 10:41:43 UTC (rev
6330)
@@ -7,7 +7,7 @@
<extension point="org.eclipse.wst.sse.ui.editorConfiguration">
<sourceViewerConfiguration
- class="org.jboss.tools.jst.jsp.ExtendedStructuredTextViewerConfigurationJSP"
+ class="org.jboss.tools.jst.jsp.JSPTextViewerConfiguration"
target="org.eclipse.jst.jsp.core.jspsource"/>
<contentOutlineConfiguration
class="org.eclipse.jst.jsp.ui.views.contentoutline.JSPContentOutlineConfiguration"
@@ -53,7 +53,7 @@
target="org.eclipse.jst.jsp.core.jspsource"/>
<sourceViewerConfiguration
- class="org.jboss.tools.jst.jsp.ExtendedStructuredTextViewerConfigurationHTML"
+ class="org.jboss.tools.jst.jsp.HTMLTextViewerConfiguration"
target="org.eclipse.wst.html.core.htmlsource"/>
<contentOutlineConfiguration
class="org.eclipse.wst.html.ui.views.contentoutline.HTMLContentOutlineConfiguration"
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/ExtendedStructuredTextViewerConfigurationHTML.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/ExtendedStructuredTextViewerConfigurationHTML.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/ExtendedStructuredTextViewerConfigurationHTML.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp;
-
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.formatter.IContentFormatter;
-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.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.jst.jsp.contentassist.RedHatHtmlContentAssistProcessor;
-import org.jboss.tools.jst.jsp.format.HTMLFormatProcessor;
-import org.osgi.framework.Bundle;
-
-public class ExtendedStructuredTextViewerConfigurationHTML extends
StructuredTextViewerConfigurationHTML {
-
- public ExtendedStructuredTextViewerConfigurationHTML() {
- super();
- }
-
- protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer
sourceViewer, String partitionType) {
-// IContentAssistProcessor[] processors = null;
-
- // 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);
- }
- }
-
- if (partitionType == IHTMLPartitions.HTML_DEFAULT ||
- partitionType == IJSPPartitions.JSP_DEFAULT_EL) {
- processors.add(new RedHatHtmlContentAssistProcessor());
- }
-
- return (IContentAssistProcessor[])processors.toArray(new IContentAssistProcessor[0]);
- }
-
-
- /*
- * @see
org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
- * @since 3.1
- */
- public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
- if (fPreferenceStore == null)
- return null;
- if (sourceViewer == null ||
!fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED))
- return null;
-
- List allDetectors = new ArrayList(0);
-
- IHyperlinkDetector extHyperlinkDetector = getTextEditorsExtensionsHyperlinkDetector();
-
- if (extHyperlinkDetector != null) allDetectors.add(extHyperlinkDetector);
-
-/*
- IHyperlinkDetector[] superDetectors = super.getHyperlinkDetectors(sourceViewer);
- for (int m = 0; m < superDetectors.length; m++) {
- IHyperlinkDetector detector = superDetectors[m];
- if (!allDetectors.contains(detector)) {
- allDetectors.add(detector);
- }
- }
-*/
- return (IHyperlinkDetector[]) allDetectors.toArray(new IHyperlinkDetector[0]);
- }
-
- private IHyperlinkDetector getTextEditorsExtensionsHyperlinkDetector() {
- Plugin plugin = Platform.getPlugin("org.jboss.tools.common.text.ext");
- return (plugin != null && plugin instanceof IAdaptable ?
(IHyperlinkDetector)((IAdaptable)plugin).getAdapter(IHyperlinkDetector.class):null);
- }
-
- private IHyperlinkDetector getTextEditorsExtensionsHyperlinkDetector1() {
- IHyperlinkDetector result = null;
- final Object[] bundleActivationResult = new Object[] { Boolean.FALSE };
- final Bundle bundle = Platform.getBundle("org.jboss.tools.common.text.ext");
- if (bundle != null && bundle.getState() == org.osgi.framework.Bundle.ACTIVE) {
- bundleActivationResult[0] = Boolean.TRUE;
- } else {
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- bundleActivationResult[0] = Boolean.TRUE;
- }
- });
- }
-
- if (Boolean.TRUE.equals(bundleActivationResult[0])) {
- try {
- Dictionary headers = bundle.getHeaders();
- String pluginClass = (String)headers.get("Plugin-Class");
- Class plugin = bundle.loadClass(pluginClass);
-
- Object obj = plugin.newInstance();
- if (obj instanceof IAdaptable) {
- result =
(IHyperlinkDetector)((IAdaptable)obj).getAdapter(IHyperlinkDetector.class);
- }
- } catch (Exception x) {
- JspEditorPlugin.getPluginLog().logError("Error in loading hyperlink
detector", x);
- }
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- * @see
org.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()));
- return formatter;
- }
-}
\ No newline at end of file
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/ExtendedStructuredTextViewerConfigurationJSP.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/ExtendedStructuredTextViewerConfigurationJSP.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/ExtendedStructuredTextViewerConfigurationJSP.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp;
-
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-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.jst.jsp.ui.StructuredTextViewerConfigurationJSP;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.wst.html.core.text.IHTMLPartitions;
-import org.eclipse.wst.xml.core.text.IXMLPartitions;
-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.jst.jsp.contentassist.RedHatHtmlContentAssistProcessor;
-import org.jboss.tools.jst.jsp.contentassist.RedHatJSPContentAssistProcessor;
-
-/**
- * @author Igels
- */
-public class ExtendedStructuredTextViewerConfigurationJSP extends
StructuredTextViewerConfigurationJSP {
-
- public ExtendedStructuredTextViewerConfigurationJSP() {
- super();
- }
-
- protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer
sourceViewer, String 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(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);
- }
- }
-
- 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 RedHatJSPContentAssistProcessor());
- 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]);
- }
-
- /*
- * @see
org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
- * @since 3.1
- */
- public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
- if (fPreferenceStore == null)
- return null;
- if (sourceViewer == null ||
!fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED))
- return null;
-
- List allDetectors = new ArrayList(0);
-
- IHyperlinkDetector extHyperlinkDetector = getTextEditorsExtensionsHyperlinkDetector();
-
- if (extHyperlinkDetector != null) allDetectors.add(extHyperlinkDetector);
-
-/* IHyperlinkDetector[] superDetectors = super.getHyperlinkDetectors(sourceViewer);
- for (int m = 0; m < superDetectors.length; m++) {
- IHyperlinkDetector detector = superDetectors[m];
- if (!allDetectors.contains(detector)) {
- allDetectors.add(detector);
- }
- }
-*/
- return (IHyperlinkDetector[]) allDetectors.toArray(new IHyperlinkDetector[0]);
- }
-
- private IHyperlinkDetector getTextEditorsExtensionsHyperlinkDetector() {
- Plugin plugin = Platform.getPlugin("org.jboss.tools.common.text.ext");
- return (plugin != null && plugin instanceof IAdaptable ?
(IHyperlinkDetector)((IAdaptable)plugin).getAdapter(IHyperlinkDetector.class):null);
- }
-
- private IHyperlinkDetector getTextEditorsExtensionsHyperlinkDetector1() {
- IHyperlinkDetector result = null;
- final Object[] bundleActivationResult = new Object[] { Boolean.FALSE };
- final Bundle bundle = Platform.getBundle("org.jboss.tools.common.text.ext");
- if (bundle != null && bundle.getState() == org.osgi.framework.Bundle.ACTIVE) {
- bundleActivationResult[0] = Boolean.TRUE;
- } else {
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- bundleActivationResult[0] = Boolean.TRUE;
- }
- });
- }
-
- if (Boolean.TRUE.equals(bundleActivationResult[0])) {
- try {
- Dictionary headers = bundle.getHeaders();
- String pluginClass = (String)headers.get("Plugin-Class");
- Class plugin = bundle.loadClass(pluginClass);
-
- Object obj = plugin.newInstance();
- if (obj instanceof IAdaptable) {
- result =
(IHyperlinkDetector)((IAdaptable)obj).getAdapter(IHyperlinkDetector.class);
- }
- } catch (Exception x) {
- JspEditorPlugin.getPluginLog().logError("Error in loading hyperlink
detector", x);
- }
- }
- return result;
- }
-}
\ No newline at end of file
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java
(from rev 6207,
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/ExtendedStructuredTextViewerConfigurationHTML.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp;
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.formatter.IContentFormatter;
+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.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.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
+import org.jboss.tools.jst.jsp.format.HTMLFormatProcessor;
+import org.osgi.framework.Bundle;
+
+public class HTMLTextViewerConfiguration extends StructuredTextViewerConfigurationHTML {
+
+ public HTMLTextViewerConfiguration() {
+ super();
+ }
+
+ protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer
sourceViewer, String partitionType) {
+// IContentAssistProcessor[] processors = null;
+
+ // 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);
+ }
+ }
+
+ if (partitionType == IHTMLPartitions.HTML_DEFAULT ||
+ partitionType == IJSPPartitions.JSP_DEFAULT_EL) {
+ processors.add(new FaceletsHtmlContentAssistProcessor());
+ }
+
+ return (IContentAssistProcessor[])processors.toArray(new IContentAssistProcessor[0]);
+ }
+
+
+ /*
+ * @see
org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
+ * @since 3.1
+ */
+ public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
+ if (fPreferenceStore == null)
+ return null;
+ if (sourceViewer == null ||
!fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED))
+ return null;
+
+ List allDetectors = new ArrayList(0);
+
+ IHyperlinkDetector extHyperlinkDetector = getTextEditorsExtensionsHyperlinkDetector();
+
+ if (extHyperlinkDetector != null) allDetectors.add(extHyperlinkDetector);
+
+/*
+ IHyperlinkDetector[] superDetectors = super.getHyperlinkDetectors(sourceViewer);
+ for (int m = 0; m < superDetectors.length; m++) {
+ IHyperlinkDetector detector = superDetectors[m];
+ if (!allDetectors.contains(detector)) {
+ allDetectors.add(detector);
+ }
+ }
+*/
+ return (IHyperlinkDetector[]) allDetectors.toArray(new IHyperlinkDetector[0]);
+ }
+
+ private IHyperlinkDetector getTextEditorsExtensionsHyperlinkDetector() {
+ Plugin plugin = Platform.getPlugin("org.jboss.tools.common.text.ext");
+ return (plugin != null && plugin instanceof IAdaptable ?
(IHyperlinkDetector)((IAdaptable)plugin).getAdapter(IHyperlinkDetector.class):null);
+ }
+
+ private IHyperlinkDetector getTextEditorsExtensionsHyperlinkDetector1() {
+ IHyperlinkDetector result = null;
+ final Object[] bundleActivationResult = new Object[] { Boolean.FALSE };
+ final Bundle bundle = Platform.getBundle("org.jboss.tools.common.text.ext");
+ if (bundle != null && bundle.getState() == org.osgi.framework.Bundle.ACTIVE) {
+ bundleActivationResult[0] = Boolean.TRUE;
+ } else {
+ BusyIndicator.showWhile(null, new Runnable() {
+ public void run() {
+ bundleActivationResult[0] = Boolean.TRUE;
+ }
+ });
+ }
+
+ if (Boolean.TRUE.equals(bundleActivationResult[0])) {
+ try {
+ Dictionary headers = bundle.getHeaders();
+ String pluginClass = (String)headers.get("Plugin-Class");
+ Class plugin = bundle.loadClass(pluginClass);
+
+ Object obj = plugin.newInstance();
+ if (obj instanceof IAdaptable) {
+ result =
(IHyperlinkDetector)((IAdaptable)obj).getAdapter(IHyperlinkDetector.class);
+ }
+ } catch (Exception x) {
+ JspEditorPlugin.getPluginLog().logError("Error in loading hyperlink
detector", x);
+ }
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.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()));
+ return formatter;
+ }
+}
\ No newline at end of file
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java
(from rev 6207,
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/ExtendedStructuredTextViewerConfigurationJSP.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp;
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+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.jst.jsp.ui.StructuredTextViewerConfigurationJSP;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+import org.eclipse.wst.html.core.text.IHTMLPartitions;
+import org.eclipse.wst.xml.core.text.IXMLPartitions;
+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.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
+import org.jboss.tools.jst.jsp.contentassist.ExtendedJSPContentAssistProcessor;
+
+/**
+ * @author Igels
+ */
+public class JSPTextViewerConfiguration extends StructuredTextViewerConfigurationJSP {
+
+ public JSPTextViewerConfiguration() {
+ super();
+ }
+
+ protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer
sourceViewer, String 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(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);
+ }
+ }
+
+ 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]);
+ }
+
+ /*
+ * @see
org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
+ * @since 3.1
+ */
+ public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
+ if (fPreferenceStore == null)
+ return null;
+ if (sourceViewer == null ||
!fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED))
+ return null;
+
+ List allDetectors = new ArrayList(0);
+
+ IHyperlinkDetector extHyperlinkDetector = getTextEditorsExtensionsHyperlinkDetector();
+
+ if (extHyperlinkDetector != null) allDetectors.add(extHyperlinkDetector);
+
+/* IHyperlinkDetector[] superDetectors = super.getHyperlinkDetectors(sourceViewer);
+ for (int m = 0; m < superDetectors.length; m++) {
+ IHyperlinkDetector detector = superDetectors[m];
+ if (!allDetectors.contains(detector)) {
+ allDetectors.add(detector);
+ }
+ }
+*/
+ return (IHyperlinkDetector[]) allDetectors.toArray(new IHyperlinkDetector[0]);
+ }
+
+ private IHyperlinkDetector getTextEditorsExtensionsHyperlinkDetector() {
+ Plugin plugin = Platform.getPlugin("org.jboss.tools.common.text.ext");
+ return (plugin != null && plugin instanceof IAdaptable ?
(IHyperlinkDetector)((IAdaptable)plugin).getAdapter(IHyperlinkDetector.class):null);
+ }
+
+ private IHyperlinkDetector getTextEditorsExtensionsHyperlinkDetector1() {
+ IHyperlinkDetector result = null;
+ final Object[] bundleActivationResult = new Object[] { Boolean.FALSE };
+ final Bundle bundle = Platform.getBundle("org.jboss.tools.common.text.ext");
+ if (bundle != null && bundle.getState() == org.osgi.framework.Bundle.ACTIVE) {
+ bundleActivationResult[0] = Boolean.TRUE;
+ } else {
+ BusyIndicator.showWhile(null, new Runnable() {
+ public void run() {
+ bundleActivationResult[0] = Boolean.TRUE;
+ }
+ });
+ }
+
+ if (Boolean.TRUE.equals(bundleActivationResult[0])) {
+ try {
+ Dictionary headers = bundle.getHeaders();
+ String pluginClass = (String)headers.get("Plugin-Class");
+ Class plugin = bundle.loadClass(pluginClass);
+
+ Object obj = plugin.newInstance();
+ if (obj instanceof IAdaptable) {
+ result =
(IHyperlinkDetector)((IAdaptable)obj).getAdapter(IHyperlinkDetector.class);
+ }
+ } catch (Exception x) {
+ JspEditorPlugin.getPluginLog().logError("Error in loading hyperlink
detector", x);
+ }
+ }
+ return result;
+ }
+}
\ No newline at end of file
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoContentAssistantProposal.java
(from rev 6207,
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatCustomCompletionProposal.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoContentAssistantProposal.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoContentAssistantProposal.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.contentassist;
+
+import org.eclipse.jface.text.ITextOperationTarget;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
+import org.eclipse.wst.sse.ui.internal.contentassist.IRelevanceConstants;
+
+/**
+ * @author Igels
+ */
+public class AutoContentAssistantProposal extends CustomCompletionProposal {
+
+ private boolean autoContentAssistant = false;
+
+ public AutoContentAssistantProposal(String replacementString, int replacementOffset, int
replacementLength, int cursorPosition, Image image, String displayString,
IContextInformation contextInformation, String additionalProposalInfo) {
+ super(replacementString, replacementOffset, replacementLength, cursorPosition, image,
displayString, contextInformation, additionalProposalInfo, IRelevanceConstants.R_NONE);
+ }
+
+ 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;
+ }
+
+ public AutoContentAssistantProposal(String replacementString, int replacementOffset, int
replacementLength, int cursorPosition, Image image, String displayString,
IContextInformation contextInformation, String additionalProposalInfo, int relevance,
boolean updateReplacementLengthOnValidate) {
+ super(replacementString, replacementOffset, replacementLength, cursorPosition,
image, displayString, contextInformation, additionalProposalInfo, relevance,
updateReplacementLengthOnValidate);
+ }
+
+ public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
+ super.apply(viewer, trigger, stateMask, offset);
+ if(autoContentAssistant) {
+ Point selection = getSelection(viewer.getDocument());
+ viewer.setSelectedRange(selection.x, selection.y);
+ if(viewer instanceof ITextOperationTarget) {
+ ((ITextOperationTarget)viewer).doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
+ }
+ }
+ }
+
+ /**
+ * Return cursor position of proposal replacement string.
+ */
+ public int getCursorPosition() {
+ int cursorPosition = -1;
+ int firstAttributeEndPosition = getReplacementString().indexOf("=");
+ int openEndTagPosition = getReplacementString().indexOf("</");
+ int closeStartAndEndTagPosition = getReplacementString().indexOf("/>");
+ if(firstAttributeEndPosition>-1) {
+ cursorPosition = firstAttributeEndPosition + 2;
+ } else if(openEndTagPosition>-1) {
+ cursorPosition = openEndTagPosition;
+ } else if(closeStartAndEndTagPosition>-1) {
+ cursorPosition = closeStartAndEndTagPosition;
+ }
+ return cursorPosition>-1?cursorPosition:super.getCursorPosition();
+ }
+}
\ No newline at end of file
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/ExtendedJSPContentAssistProcessor.java
(from rev 6327,
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatJSPContentAssistProcessor.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/ExtendedJSPContentAssistProcessor.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/ExtendedJSPContentAssistProcessor.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -0,0 +1,712 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.contentassist;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+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;
+import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
+import org.eclipse.jst.jsp.core.internal.regions.DOMJSPRegionContexts;
+import org.eclipse.jst.jsp.core.text.IJSPPartitions;
+import org.eclipse.jst.jsp.ui.internal.JSPUIPlugin;
+import org.eclipse.jst.jsp.ui.internal.contentassist.JSPContentAssistProcessor;
+import org.eclipse.jst.jsp.ui.internal.preferences.JSPUIPreferenceNames;
+import org.eclipse.jst.jsp.ui.internal.templates.TemplateContextTypeIdsJSP;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor;
+import org.eclipse.wst.html.core.text.IHTMLPartitions;
+import
org.eclipse.wst.javascript.ui.internal.common.contentassist.JavaScriptContentAssistProcessor;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
+import org.eclipse.wst.sse.core.utils.StringUtils;
+import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
+import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
+import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
+import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
+import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
+import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentAssistUtilities;
+import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentModelGenerator;
+import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
+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.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
+import org.jboss.tools.common.kb.KbConnectorFactory;
+import org.jboss.tools.common.kb.KbConnectorType;
+import org.jboss.tools.common.kb.KbException;
+import org.jboss.tools.common.kb.KbProposal;
+import org.jboss.tools.common.kb.KbTldResource;
+import org.jboss.tools.common.kb.TagDescriptor;
+import org.jboss.tools.common.kb.wtp.TLDVersionHelper;
+import org.jboss.tools.common.kb.wtp.WtpKbConnector;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.web.project.WebProject;
+import org.jboss.tools.jst.web.tld.TaglibData;
+import org.jboss.tools.jst.web.tld.VpeTaglibListener;
+import org.jboss.tools.jst.web.tld.VpeTaglibManager;
+import org.jboss.tools.jst.web.tld.VpeTaglibManagerProvider;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author Igels
+ */
+public class ExtendedJSPContentAssistProcessor extends JSPContentAssistProcessor{
+
+ private JSPActiveContentAssistProcessor jspActiveCAP;
+ private WtpKbConnector wtpKbConnector;
+ private IDocument document;
+ private boolean dontOpenTag = false;
+
+
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int
documentPosition) {
+ try {
+ String text = viewer.getDocument().get(0, documentPosition);
+ int lastOpenTag = text.lastIndexOf('<');
+ int lastCloseTag = text.lastIndexOf('>');
+ dontOpenTag = lastCloseTag<lastOpenTag;
+ } catch (Exception e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+
+ document = viewer.getDocument();
+ //added by Max Areshkau JBIDE-788
+ updateActiveContentAssistProcessor(document);
+ ICompletionProposal[] proposals = super.computeCompletionProposals(viewer,
documentPosition);
+ // If proposal list from super is empty to try to get it from Red Hat dinamic jsp
content assist processor.
+ try {
+ if(proposals.length == 0) {
+ String partitionType = getPartitionType((StructuredTextViewer) viewer,
documentPosition);
+ IContentAssistProcessor p = (IContentAssistProcessor)
fPartitionToProcessorMap.get(partitionType);
+ if (!(p instanceof JavaScriptContentAssistProcessor || p instanceof
CSSContentAssistProcessor)) {
+
+ IndexedRegion treeNode = ContentAssistUtils.getNodeAt((StructuredTextViewer) viewer,
documentPosition);
+ Node node = (Node) treeNode;
+
+ while (node != null && node.getNodeType() == Node.TEXT_NODE &&
node.getParentNode() != null)
+ node = node.getParentNode();
+ IDOMNode xmlnode = (IDOMNode) node;
+ if(xmlnode!=null) {
+ fTextViewer = viewer;
+ IStructuredDocumentRegion sdRegion =
getStructuredDocumentRegion(documentPosition);
+ ITextRegion completionRegion = getCompletionRegion(documentPosition, node);
+ if(completionRegion!=null) {
+ String matchString = getMatchString(sdRegion, completionRegion,
documentPosition);
+ ContentAssistRequest contentAssistRequest =
computeCompletionProposals(documentPosition, matchString, completionRegion, (IDOMNode)
treeNode, xmlnode);
+ if(contentAssistRequest!=null) {
+ proposals = contentAssistRequest.getCompletionProposals();
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ proposals = getUniqProposals(proposals);
+ return proposals;
+ }
+
+ public static ICompletionProposal[] getUniqProposals(ICompletionProposal[] proposals) {
+ ArrayList uniqProposals = new ArrayList(proposals.length);
+ HashSet displayStrings = new HashSet(proposals.length);
+ for(int i=0; i<proposals.length; i++) {
+ String str = proposals[i].getDisplayString();
+ if(str==null || !displayStrings.contains(str)) {
+ displayStrings.add(str);
+ uniqProposals.add(proposals[i]);
+ }
+ }
+ return (ICompletionProposal[])uniqProposals.toArray(new
ICompletionProposal[uniqProposals.size()]);
+ }
+
+ /**
+ * int map that points [partition > processor]. This takes place of
+ * embedded adapters for now.
+ */
+ protected void initPartitionToProcessorMap() {
+ super.initPartitionToProcessorMap();
+ }
+
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ char[] autoActivChars = null;
+ char[] superAutoActivChars = super.getCompletionProposalAutoActivationCharacters();
+ if(superAutoActivChars==null) {
+ return superAutoActivChars;
+ }
+
+ autoActivChars = superAutoActivChars;
+ IPreferenceStore store = JSPUIPlugin.getDefault().getPreferenceStore();
+ if(store.isDefault(JSPUIPreferenceNames.AUTO_PROPOSE_CODE)) {
+// String superDefaultChars =
store.getDefaultString(JSPUIPreferenceNames.AUTO_PROPOSE_CODE);
+ StringBuffer redhatDefaultChars = new StringBuffer(new String(superAutoActivChars));
+ if(redhatDefaultChars.indexOf(".")<0) {
+ redhatDefaultChars.append('.');
+ store.setDefault(JSPUIPreferenceNames.AUTO_PROPOSE_CODE,
redhatDefaultChars.toString());
+ store.setValue(JSPUIPreferenceNames.AUTO_PROPOSE_CODE,
redhatDefaultChars.toString());
+ }
+ autoActivChars = new char[redhatDefaultChars.length()];
+ redhatDefaultChars.getChars(0, redhatDefaultChars.length(), autoActivChars, 0);
+ }
+
+ return autoActivChars;
+ }
+
+ public void updateActiveContentAssistProcessor(IDocument document) {
+ TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(document);
+ if (manager != null) {
+ List list = manager.getTaglibTrackers();
+ for(int i=0; i<list.size(); i++) {
+ TaglibTracker tracker = (TaglibTracker)list.get(i);
+
+ String version = TLDVersionHelper.getTldVersion(tracker);
+ KbTldResource resource = new KbTldResource(tracker.getURI(), "",
tracker.getPrefix(), version);
+ getWtpKbConnector().registerResource(resource);
+ addActiveContentAssistProcessorToProcessorMap(tracker.getURI(),
tracker.getPrefix(), version);
+ }
+ }
+ }
+
+ private void addActiveContentAssistProcessorToProcessorMap(String uri, String prefix,
String version) {
+ try {
+ List names = getWtpKbConnector().getAllTagNamesFromTldByUri(uri, version);
+ for(Iterator iter = names.iterator(); iter.hasNext();) {
+ String fullName = prefix + ":" + iter.next();
+ fNameToProcessorMap.put(fullName, jspActiveCAP);
+ }
+ } catch (KbException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ }
+
+ private WtpKbConnector getWtpKbConnector() {
+ if(wtpKbConnector == null && document != null) {
+ try {
+ wtpKbConnector =
(WtpKbConnector)KbConnectorFactory.getIntstance().createConnector(KbConnectorType.JSP_WTP_KB_CONNECTOR,
document);
+ jspActiveCAP.setKbConnector(wtpKbConnector);
+ } catch (ClassNotFoundException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ } catch (InstantiationException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ } catch (IllegalAccessException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ }
+ return wtpKbConnector;
+ }
+
+ protected void init() {
+ super.init();
+ jspActiveCAP = new JSPActiveContentAssistProcessor();
+ jspActiveCAP.init();
+ }
+
+ public XMLContentModelGenerator getContentGenerator() {
+ if (fGenerator == null){
+ fGenerator = new XMLContentModelGenerator(){
+ public void generateTag(Node parent, CMElementDeclaration elementDecl, StringBuffer
buffer) {
+ if (elementDecl == null || buffer == null) {
+ return;
+ }
+ try {
+ String tagName = getRequiredName(parent, elementDecl);
+ TagDescriptor info = getWtpKbConnector().getTagInformation("/" + tagName
+ "/");
+ if (info != null) {
+ KbProposal proposal = info.generateProposal();
+ String replString = proposal.getReplacementString();
+ boolean hasBody = info.hasBody();
+
+ if (replString != null && replString.length() > 0) {
+ if(!dontOpenTag) {
+ buffer.append("<");
+ }
+ buffer.append(replString);
+ buffer.append(">");
+ if (hasBody) {
+ buffer.append("</");
+ buffer.append(tagName);
+ buffer.append(">");
+ }
+ return;
+ }
+ }
+ } catch (Exception x) {
+ JspEditorPlugin.getPluginLog().logError("", x);
+ }
+ super.generateTag(parent, elementDecl, buffer);
+ return;
+ }
+ };
+ }
+ return fGenerator;
+ }
+
+ protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int
childPosition) {
+ List cmnodes = null;
+ Node parent = contentAssistRequest.getParent();
+ String error = null;
+
+ if (parent != null && parent.getNodeType() == Node.DOCUMENT_NODE &&
((IDOMDocument) parent).isXMLType() && !isCursorAfterXMLPI(contentAssistRequest))
{
+ return;
+ }
+ // only want proposals if cursor is after doctype...
+ if (!isCursorAfterDoctype(contentAssistRequest))
+ return;
+
+ if (parent != null && parent instanceof IDOMNode &&
isCommentNode((IDOMNode) parent)) {
+ // loop and find non comment node?
+ while (parent != null && isCommentNode((IDOMNode) parent)) {
+ parent = parent.getParentNode();
+ }
+ }
+
+ if (parent.getNodeType() == Node.ELEMENT_NODE) {
+ CMElementDeclaration parentDecl = getCMElementDeclaration(parent);
+ if (parentDecl != null) {
+ // XSD-specific ability - no filtering
+ CMDataType childType = parentDecl.getDataType();
+ if (childType != null) {
+ String[] childStrings = childType.getEnumeratedValues();
+ if (childStrings != null) {
+ // the content string is the sole valid child...so
+ // replace the rest
+ int begin = contentAssistRequest.getReplacementBeginPosition();
+ int length = contentAssistRequest.getReplacementLength();
+ if (parent instanceof IDOMNode) {
+ if (((IDOMNode) parent).getLastStructuredDocumentRegion() != ((IDOMNode)
parent).getFirstStructuredDocumentRegion()) {
+ begin = ((IDOMNode) parent).getFirstStructuredDocumentRegion().getEndOffset();
+ length = ((IDOMNode) parent).getLastStructuredDocumentRegion().getStartOffset() -
begin;
+ }
+ }
+ String proposedInfo = getAdditionalInfo(parentDecl, childType);
+ for (int i = 0; i < childStrings.length; i++) {
+ CustomCompletionProposal textProposal = new
AutoContentAssistantProposal(childStrings[i].indexOf("=")>-1,
childStrings[i], begin, length, childStrings[i].length(),
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENUM),
childStrings[i], null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
+ contentAssistRequest.addProposal(textProposal);
+ }
+ }
+ }
+ }
+ if (parentDecl != null && parentDecl.getContentType() ==
CMElementDeclaration.PCDATA) {
+ addPCDATAProposal(parentDecl.getNodeName(), contentAssistRequest);
+ }
+ else {
+ // retrieve the list of all possible children within this parent context
+ cmnodes = getAvailableChildElementDeclarations((Element)parent, childPosition,
ModelQueryAction.INSERT);
+
+ // retrieve the list of the possible children within this parent context
and at this index
+ List strictCMNodeSuggestions = null;
+ if
(XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_STRICT.equals(XMLUIPlugin.getInstance().getPreferenceStore().getString(XMLUIPreferenceNames.SUGGESTION_STRATEGY)))
+ {
+ strictCMNodeSuggestions =
getValidChildElementDeclarations((Element)parent, childPosition, ModelQueryAction.INSERT);
+ }
+ Iterator nodeIterator = cmnodes.iterator();
+ if (!nodeIterator.hasNext()) {
+ if (getCMElementDeclaration(parent) != null)
+ error = NLS.bind(XMLUIMessages._Has_no_available_child, (new
Object[]{parent.getNodeName()}));
+ else
+ error = NLS.bind(XMLUIMessages.Element__is_unknown, (new
Object[]{parent.getNodeName()}));
+ }
+ String matchString = contentAssistRequest.getMatchString();
+ // chop off any leading <'s and whitespace from the
+ // matchstring
+ while ((matchString.length() > 0) &&
(Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString,
"<"))) //$NON-NLS-1$
+ //$NON-NLS-1$
+ matchString = matchString.substring(1);
+ while (nodeIterator.hasNext()) {
+ Object o = nodeIterator.next();
+ if (o instanceof CMElementDeclaration) {
+ CMElementDeclaration elementDecl = (CMElementDeclaration) o;
+ // only add proposals for the child element's that
+ // begin with the matchstring
+ String tagname = getRequiredName(parent, elementDecl);
+ boolean isStrictCMNodeSuggestion = strictCMNodeSuggestions !=
null ? strictCMNodeSuggestions.contains(elementDecl) : false;
+
+ Image image = CMImageUtil.getImage(elementDecl);
+
+ if (image == null) {
+ if (strictCMNodeSuggestions != null) {
+ image = isStrictCMNodeSuggestion ?
+
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC_EMPHASIZED)
:
+
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC_DEEMPHASIZED);
+ }
+ else {
+ image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
+ }
+
+ }
+ // Account for the < and >. If attributes were
+ // added, the cursor will be placed
+ // at the offset before of the first character of the
+ // first attribute name.
+// int markupAdjustment = getContentGenerator().getMinimalStartTagLength(parent,
elementDecl);
+ if (beginsWith(tagname, matchString)) {
+ String proposedText = getRequiredText(parent, elementDecl);
+
+ int markupAdjustment = getCursorPositionForProposedText(proposedText);
+
+ String proposedInfo = getAdditionalInfo(parentDecl, elementDecl);
+ int relevance = isStrictCMNodeSuggestion ?
XMLRelevanceConstants.R_STRICTLY_VALID_TAG_INSERTION :
XMLRelevanceConstants.R_TAG_INSERTION;
+ CustomCompletionProposal proposal = new AutoContentAssistantProposal(true,
proposedText, contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null,
proposedInfo, relevance);
+ contentAssistRequest.addProposal(proposal);
+ }
+ }
+ }
+ if (contentAssistRequest.getProposals().size() == 0) {
+ if (error != null)
+ setErrorMessage(error);
+ else if (contentAssistRequest.getMatchString() != null &&
contentAssistRequest.getMatchString().length() > 0)
+ setErrorMessage(NLS.bind(XMLUIMessages.No_known_child_tag, (new
Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()})));
+ //$NON-NLS-1$ = "No known child tag names of <{0}> begin with
\"{1}\"."
+ else
+ setErrorMessage(NLS.bind(XMLUIMessages.__Has_no_known_child, (new
Object[]{parent.getNodeName()})));
+ }
+ }
+ }
+ else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
+ // Can only prompt with elements if the cursor position is past
+ // the XML processing
+ // instruction and DOCTYPE declaration
+ boolean xmlpiFound = false;
+ boolean doctypeFound = false;
+ int minimumOffset = -1;
+
+ for (Node child = parent.getFirstChild(); child != null; child =
child.getNextSibling()) {
+
+ boolean xmlpi = (child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE &&
child.getNodeName().equals("xml")); //$NON-NLS-1$
+ boolean doctype = child.getNodeType() == Node.DOCUMENT_TYPE_NODE;
+ if (xmlpi || doctype && minimumOffset < 0)
+ minimumOffset = ((IDOMNode)
child).getFirstStructuredDocumentRegion().getStartOffset() + ((IDOMNode)
child).getFirstStructuredDocumentRegion().getTextLength();
+ xmlpiFound = xmlpiFound || xmlpi;
+ doctypeFound = doctypeFound || doctype;
+ }
+
+ if (contentAssistRequest.getReplacementBeginPosition() >= minimumOffset) {
+ List childDecls = getAvailableRootChildren((Document) parent, childPosition);
+ for (int i = 0; i < childDecls.size(); i++) {
+ CMElementDeclaration ed = (CMElementDeclaration) childDecls.get(i);
+ if (ed != null) {
+ Image image = CMImageUtil.getImage(ed);
+ if (image == null) {
+ image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
+ }
+ String proposedText = getRequiredText(parent, ed);
+ String tagname = getRequiredName(parent, ed);
+ // account for the < and >
+ int markupAdjustment = getContentGenerator().getMinimalStartTagLength(parent, ed);
+ String proposedInfo = getAdditionalInfo(null, ed);
+ CustomCompletionProposal proposal = new AutoContentAssistantProposal(false,
proposedText, contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null,
proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
+
+ contentAssistRequest.addProposal(proposal);
+ }
+ }
+ }
+ }
+ }
+
+ // WTP
+ private int getCursorPositionForProposedText(String proposedText) {
+ int cursorAdjustment;
+ cursorAdjustment = proposedText.indexOf("\"\"") + 1; //$NON-NLS-1$
+ // otherwise, after the first tag
+ if(cursorAdjustment==0)
+ cursorAdjustment = proposedText.indexOf('>') + 1;
+ if(cursorAdjustment==0)
+ cursorAdjustment = proposedText.length() + 1;
+
+ return cursorAdjustment;
+ }
+
+ protected void addTagNameProposals(ContentAssistRequest contentAssistRequest, int
childPosition) {
+ List cmnodes = null;
+ Node parent = contentAssistRequest.getParent();
+ IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
+ String error = null;
+ String matchString = contentAssistRequest.getMatchString();
+ if (parent.getNodeType() == Node.ELEMENT_NODE) {
+ // retrieve the list of children
+ cmnodes = getAvailableChildElementDeclarations((Element)parent, childPosition,
ModelQueryAction.INSERT);
+ Iterator nodeIterator = cmnodes.iterator();
+ // chop off any leading <'s and whitespace from the matchstring
+ while ((matchString.length() > 0) &&
(Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString,
"<"))) //$NON-NLS-1$
+ //$NON-NLS-1$
+ matchString = matchString.substring(1);
+ if (!nodeIterator.hasNext())
+ error = NLS.bind(XMLUIMessages.__Has_no_known_child, (new
Object[]{parent.getNodeName()}));
+ while (nodeIterator.hasNext()) {
+ CMNode elementDecl = (CMNode) nodeIterator.next();
+ if (elementDecl != null) {
+ // only add proposals for the child element's that begin
+ // with the matchstring
+ String proposedText = null;
+ int cursorAdjustment = 0;
+
+ // do a check to see if partial attributes of partial tag
+ // names are in list
+ if ((node != null && node.getAttributes() != null &&
node.getAttributes().getLength() > 0 && attributeInList(node, parent,
elementDecl)) || ((node.getNodeType() != Node.TEXT_NODE) &&
node.getFirstStructuredDocumentRegion().isEnded())) {
+
+ proposedText = getRequiredName(parent, elementDecl);
+ cursorAdjustment = proposedText.length();
+ }
+ else {
+ proposedText = getRequiredName(parent, elementDecl);
+
+ StringBuffer buffer = new StringBuffer();
+ KbProposal proposal;
+ TagDescriptor info;
+ try {
+ proposal = getWtpKbConnector().getProposal("/" +
proposedText);
+ info = getWtpKbConnector().getTagInformation("/" +
proposedText + "/");
+ if (proposal != null && info != null) {
+ String replString = proposal.getReplacementString();
+ boolean hasBody = info.hasBody();
+
+ if (replString != null && replString.length() > 0) {
+ if(!dontOpenTag) {
+ buffer.append("<");
+ }
+ buffer.append(replString);
+ buffer.append(">");
+ if (hasBody) {
+ buffer.append("</");
+ buffer.append(proposedText);
+ buffer.append(">");
+ }
+ proposedText = buffer.toString();
+ }
+ } else {
+ if(elementDecl instanceof CMElementDeclaration) {
+ cursorAdjustment = proposedText.length();
+ if (elementDecl instanceof CMElementDeclaration) {
+ CMElementDeclaration ed = (CMElementDeclaration) elementDecl;
+ if (ed.getContentType() == CMElementDeclaration.EMPTY) {
+ proposedText += getContentGenerator().getStartTagClose(parent, ed);
+ cursorAdjustment = proposedText.length();
+ }
+ else {
+ cursorAdjustment = proposedText.length() + 1;
+ proposedText += "></" + getRequiredName(parent, elementDecl) +
">"; //$NON-NLS-2$//$NON-NLS-1$
+ }
+ }
+ }
+ }
+ } catch (KbException e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ }
+ if (beginsWith(proposedText, matchString) || beginsWith(proposedText,
"<" + matchString)) {
+ Image image = CMImageUtil.getImage(elementDecl);
+ if (image == null) {
+ image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
+ }
+ String proposedInfo = getAdditionalInfo(getCMElementDeclaration(parent),
elementDecl);
+ CustomCompletionProposal proposal = new
AutoContentAssistantProposal(proposedText.indexOf('\"')>-1 &&
proposedText.indexOf("=")>-1, proposedText,
contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), cursorAdjustment, image,
getRequiredName(parent, elementDecl), null, proposedInfo,
XMLRelevanceConstants.R_TAG_NAME);
+ contentAssistRequest.addProposal(proposal);
+ }
+ }
+ }
+ if (contentAssistRequest.getProposals().size() == 0) {
+ if (error != null)
+ setErrorMessage(error);
+ else if (contentAssistRequest.getMatchString() != null &&
contentAssistRequest.getMatchString().length() > 0)
+ setErrorMessage(NLS.bind(XMLUIMessages.No_known_child_tag_names, (new
Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()})));
+ //$NON-NLS-1$ = "No known child tag names of <{0}> begin with
\"{1}\""
+ else
+ setErrorMessage(NLS.bind(XMLUIMessages.__Has_no_known_child, (new
Object[]{parent.getNodeName()})));
+ }
+ }
+ else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
+ List childElements = getAvailableRootChildren((Document) parent, childPosition);
+ for (int i = 0; i < childElements.size(); i++) {
+ CMNode ed = (CMNode) childElements.get(i);
+ if (ed == null)
+ continue;
+ String proposedText = null;
+ int cursorAdjustment = 0;
+ if(ed instanceof CMElementDeclaration) {
+ // proposedText = getRequiredName(parent, ed);
+ StringBuffer sb = new StringBuffer();
+ getContentGenerator().generateTag(parent, (CMElementDeclaration)ed, sb);
+ // tag starts w/ '<', but we want to compare to name
+ proposedText = sb.toString().substring(1);
+
+ if (!beginsWith(proposedText, matchString))
+ continue;
+
+ cursorAdjustment = getCursorPositionForProposedText(proposedText);
+
+ if (ed instanceof CMElementDeclaration) {
+ CMElementDeclaration elementDecl = (CMElementDeclaration) ed;
+ if (elementDecl.getContentType() == CMElementDeclaration.EMPTY) {
+ proposedText += getContentGenerator().getStartTagClose(parent, elementDecl);
+ cursorAdjustment = proposedText.length();
+ }
+ }
+
+ String proposedInfo = getAdditionalInfo(null, ed);
+ Image image = CMImageUtil.getImage(ed);
+ if (image == null) {
+ image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
+ }
+ CustomCompletionProposal proposal = new
AutoContentAssistantProposal(proposedText.indexOf('\"')>-1, proposedText,
contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), cursorAdjustment, image,
getRequiredName(parent, ed), null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
+ contentAssistRequest.addProposal(proposal);
+ contentAssistRequest.addProposal(proposal);
+ }
+ }
+ }
+ }
+
+ private boolean isCommentNode(IDOMNode node) {
+ return (node != null && node instanceof IDOMElement && ((IDOMElement)
node).isCommentTag());
+ }
+
+ protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
+
+ // JBIDE-1717 Workaround:
+ // The WTP processes the Attribute Containers in a different way comparing to how it
does for
+ // the simple attributes.
+ // Also the whitespace-text placed after the attribute value is the part of that
attribute value.
+ // These facts both are the reason of the JBIDE-1717 issue appeared.
+ // This workaround tries to add the attribute name proposals in case of WTP itself
doesn't adds them
+ // because it faced the attribute container (In other words, some JSF-variable is used
as the
+ // attribute's value
+ if (fViewer != null) {
+ int documentPosition = contentAssistRequest.getReplacementBeginPosition();
+ // check the actual partition type
+ String partitionType = getPartitionType((StructuredTextViewer) fViewer,
documentPosition);
+
+ IStructuredDocument structuredDocument = (IStructuredDocument) fViewer.getDocument();
+ IStructuredDocumentRegion fn =
structuredDocument.getRegionAtCharacterOffset(documentPosition);
+ // check if it's in an attribute value, if so, don't add CDATA
+ // proposal
+ ITextRegion attrContainer = (fn != null) ?
fn.getRegionAtCharacterOffset(documentPosition) : null;
+ boolean doPerformProposalsComputing = false;
+
+ if (attrContainer != null && attrContainer instanceof ITextRegionContainer) {
+ if (attrContainer.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
+ // test location of the cursor
+ // return null if it's in the middle of an open/close
+ // delimeter
+ Iterator attrRegions = ((ITextRegionContainer)
attrContainer).getRegions().iterator();
+ ITextRegion testRegion = null;
+ while (attrRegions.hasNext()) {
+ testRegion = (ITextRegion) attrRegions.next();
+ // need to check for other valid attribute regions
+ if (XMLContentAssistUtilities.isJSPOpenDelimiter(testRegion.getType())) {
+ if (!(((ITextRegionContainer) attrContainer).getEndOffset(testRegion) <=
documentPosition))
+ break;
+ }
+ else if (XMLContentAssistUtilities.isJSPCloseDelimiter(testRegion.getType())) {
+ if (!(((ITextRegionContainer) attrContainer).getStartOffset(testRegion) >=
documentPosition))
+ break;
+ }
+ }
+ if (!(testRegion.getType().equals(DOMJSPRegionContexts.JSP_CONTENT)))
+ doPerformProposalsComputing = true;
+ }
+ }
+ //
+
+ if (doPerformProposalsComputing) {
+ ICompletionProposal[] embeddedResults = null;
+ IContentAssistProcessor p = (IContentAssistProcessor)
fPartitionToProcessorMap.get(partitionType);
+ if (p != null) {
+ embeddedResults = p.computeCompletionProposals(fViewer, documentPosition);
+ // TODO: Probably it's needed to get bean methods, objects, and constants if
there are any...
+ // as it's done in JSPContentAssistProcessor but...
+ }
+ else {
+ // the partition type is probably not mapped
+ }
+ for (int i = 0; embeddedResults != null && i < embeddedResults.length;
i++)
+ contentAssistRequest.addProposal(embeddedResults[i]);
+ }
+ }
+ super.addAttributeNameProposals(contentAssistRequest);
+ }
+
+ protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
+ // JBIDE-1704:
+ // Check the position in the value:
+ // The following position:
+ // <nodeName attrName="attrValue"| .../>
+ // is marked as attribute value, but the value itself is complete.
+ // There are no proposals to be correct at this position.
+
+ String text = contentAssistRequest.getText();
+ String matchString = contentAssistRequest.getMatchString();
+
+ if (matchString.length() > StringUtils.strip(text).length() &&
+ ( (matchString.startsWith("\"") &&
matchString.endsWith("\"") &&
+ (matchString.indexOf("\"") !=
matchString.lastIndexOf("\"")))
+ || (matchString.startsWith("'") &&
matchString.endsWith("\"") &&
+ (matchString.indexOf("\"") !=
matchString.lastIndexOf("\""))))) {
+ return;
+ }
+
+ super.addAttributeValueProposals(contentAssistRequest);
+ }
+
+ /**
+ * StructuredTextViewer must be set before using this.
+ */
+ public IStructuredDocumentRegion getStructuredDocumentRegion(int pos) {
+ IStructuredDocumentRegion sdRegion =
ContentAssistUtils.getStructuredDocumentRegion(fTextViewer, pos);
+ ITextRegion region = (sdRegion == null ? null :
sdRegion.getRegionAtCharacterOffset(pos));
+ if (region == null) {
+ return null;
+ }
+
+ if (region.getType() == DOMRegionContext.XML_TAG_OPEN &&
+ sdRegion.getStartOffset(region) == pos) {
+ // The offset is at the beginning of the region
+ if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset()) &&
(sdRegion.getPrevious() != null) && (!sdRegion.getPrevious().isEnded())) {
+ // Is the region also the start of the node? If so, the
+ // previous IStructuredDocumentRegion is
+ // where to look for a useful region.
+ sdRegion = sdRegion.getPrevious();
+ }
+ else {
+ // Is there no separating whitespace from the previous region?
+ // If not,
+ // then that region is the important one
+ ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(pos - 1);
+ if ((previousRegion != null) && (previousRegion != region) &&
(previousRegion.getTextLength() == previousRegion.getLength())) {
+ sdRegion = sdRegion.getPrevious();
+ }
+ }
+ }
+
+ return sdRegion;
+ }
+
+}
\ No newline at end of file
Copied:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletsHtmlContentAssistProcessor.java
(from rev 6300,
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatHtmlContentAssistProcessor.java)
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletsHtmlContentAssistProcessor.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletsHtmlContentAssistProcessor.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -0,0 +1,608 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.jsp.contentassist;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+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.jst.jsp.core.internal.contentmodel.TaglibController;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
+import org.eclipse.wst.html.ui.internal.contentassist.HTMLContentAssistProcessor;
+import org.eclipse.wst.html.ui.internal.preferences.HTMLUIPreferenceNames;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.sse.core.utils.StringUtils;
+import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
+import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
+import org.eclipse.wst.xml.core.internal.document.AttrImpl;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
+import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
+import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
+import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
+import org.eclipse.wst.xml.ui.internal.util.SharedXMLEditorPluginImageHelper;
+import org.jboss.tools.common.kb.AttributeDescriptor;
+import org.jboss.tools.common.kb.KbConnectorFactory;
+import org.jboss.tools.common.kb.KbConnectorType;
+import org.jboss.tools.common.kb.KbProposal;
+import org.jboss.tools.common.kb.KbQuery;
+import org.jboss.tools.common.kb.KbTldResource;
+import org.jboss.tools.common.kb.wtp.JspWtpKbConnector;
+import org.jboss.tools.common.kb.wtp.TLDVersionHelper;
+import org.jboss.tools.common.kb.wtp.WtpKbConnector;
+import org.jboss.tools.common.model.util.ELParser;
+import org.jboss.tools.common.reporting.ProblemReportingHelper;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.editor.TLDRegisterHelper;
+import org.jboss.tools.jst.jsp.outline.ValueHelper;
+import org.jboss.tools.jst.jsp.support.kb.FaceletsJsfCResource;
+import org.jboss.tools.jst.jsp.support.kb.WTPKbdBeanMethodResource;
+import org.jboss.tools.jst.jsp.support.kb.WTPKbdBeanPropertyResource;
+import org.jboss.tools.jst.jsp.support.kb.WTPKbdBundlePropertyResource;
+import org.jboss.tools.jst.web.tld.TaglibData;
+import org.jboss.tools.jst.web.tld.VpeTaglibListener;
+import org.jboss.tools.jst.web.tld.VpeTaglibManager;
+import org.jboss.tools.jst.web.tld.VpeTaglibManagerProvider;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ * @author Igels
+ */
+public class FaceletsHtmlContentAssistProcessor extends HTMLContentAssistProcessor
implements VpeTaglibListener {
+
+ private JSPActiveContentAssistProcessor jspActiveCAP;
+ private WtpKbConnector wtpKbConnector;
+ private IDocument document;
+ private IEditorInput editorInput;
+ private VpeTaglibManager tldManager;
+ private boolean isFacelets = false;
+ public static final String faceletUri = "http://java.sun.com/jsf/facelets";
+ public static final String faceletHtmlUri =
"http://www.w3.org/1999/xhtml/facelets";
+ public static final String faceletHtmlPrefix = "0fHP";
+ public static final String JSFCAttributeName = "jsfc";
+ public static final String faceletHtmlPrefixStart = faceletHtmlPrefix + ":";
+ //Added by Max Areshkau JBIDE-788
+ public static final KbTldResource faceletHtmlResource = new
KbTldResource(faceletHtmlUri, "", faceletHtmlPrefix, null);
+
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer textViewer, int
documentPosition) {
+ document = textViewer.getDocument();
+ editorInput =
JspEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput();
+ //added by Max Areshkau JBIDE-788
+ IndexedRegion treeNode = ContentAssistUtils.getNodeAt(textViewer,
documentPosition);
+ IDOMNode node = (IDOMNode) treeNode;
+ registerToTldManager(textViewer, node);
+
+ ICompletionProposal[] proposals = super.computeCompletionProposals(textViewer,
documentPosition);
+ if(proposals!=null) {
+ for(int i=0; i<proposals.length; i++) {
+ if(proposals[i] instanceof AutoContentAssistantProposal) {
+ fErrorMessage = null;
+ break;
+ }
+ }
+ }
+ if(isFacelets) {
+ return getUniqProposals(proposals);
+ }
+ proposals = getUniqProposals(proposals);
+ return proposals;
+ }
+
+ private ICompletionProposal[] getUniqProposals(ICompletionProposal[] proposals) {
+ if(proposals==null) {
+ return null;
+ }
+ HashMap uniqProposals = new HashMap(proposals.length);
+ ArrayList uniqProposalList = new ArrayList(proposals.length);
+ for(int i=0; i<proposals.length; i++) {
+ int eq = proposals[i].getDisplayString().indexOf('=');
+ String str = proposals[i].getDisplayString();;
+ if(eq>0) {
+ str = str.substring(0, eq);
+ }
+ Object proposal = uniqProposals.get(str);
+ if(proposal==null || proposals[i] instanceof AutoContentAssistantProposal) {
+ uniqProposals.put(str, proposals[i]);
+ uniqProposalList.add(proposals[i]);
+ if(proposal!=null) {
+ uniqProposalList.remove(proposal);
+ }
+ }
+ }
+ return (ICompletionProposal[])uniqProposalList.toArray(new
ICompletionProposal[uniqProposals.size()]);
+ }
+
+ protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int
childPosition) {
+ if(!addELFaceletsProposals(contentAssistRequest, childPosition)) {
+ String request = "/" + contentAssistRequest.getMatchString();
+ Collection kbProposals = null;
+ try {
+ kbProposals = getWtpKbConnector().getProposals(request);
+ } catch(Exception e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ for (Iterator iter = kbProposals.iterator(); iter.hasNext();) {
+ KbProposal kbProposal = (KbProposal) iter.next();
+ if(ignoreProposal(kbProposal)) {
+ continue;
+ }
+ String proposedInfo = kbProposal.getContextInfo();
+ String kbReplacementString = kbProposal.getReplacementString();
+ String replacementString = "<" + kbReplacementString +
">";
+ String displayString = kbProposal.getLabel();
+ boolean autoContentAssistant = replacementString.indexOf('\"')>-1
&& replacementString.indexOf("=")>-1;
+ int cursorAdjustment = replacementString.length();;
+ if(!kbReplacementString.endsWith("/")) {
+ replacementString = replacementString + "</" + displayString +
">";
+ }
+ Image image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal(autoContentAssistant, replacementString,
contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), cursorAdjustment, image, displayString, null,
proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
+ contentAssistRequest.addProposal(proposal);
+ }
+ super.addTagInsertionProposals(contentAssistRequest, childPosition);
+ }
+ }
+
+ private boolean addELFaceletsProposals(ContentAssistRequest contentAssistRequest, int
childPosition) {
+ if(isFacelets) {
+ IDOMNode node = (IDOMNode)contentAssistRequest.getNode();
+ IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion();
+ ITextRegionList openRegions = open.getRegions();
+ int i = openRegions.indexOf(contentAssistRequest.getRegion());
+ if(i < 0) return false;
+ String currentValue = contentAssistRequest.getText();
+ int start = contentAssistRequest.getStartOffset();
+ int offset = contentAssistRequest.getReplacementBeginPosition() - start;
+ String matchString = currentValue.substring(0, offset);
+ ValueHelper h = new ValueHelper();
+ IEditorInput input = h.getEditorInput();
+ ArrayList proposals = new ArrayList();
+ WTPKbdBeanPropertyResource r1 = new WTPKbdBeanPropertyResource(input,
h.getConnector());
+ proposals.addAll(r1.queryProposal(matchString));
+ WTPKbdBeanMethodResource r2 = new WTPKbdBeanMethodResource(input, h.getConnector());
+ proposals.addAll(r2.queryProposal(matchString));
+ WTPKbdBundlePropertyResource r3 = new WTPKbdBundlePropertyResource(input,
h.getConnector());
+ proposals.addAll(r3.queryProposal(matchString));
+
+ for (Iterator iter = proposals.iterator(); iter.hasNext();) {
+ KbProposal kbProposal = cleanFaceletProposal((KbProposal)iter.next());
+ kbProposal.postProcess(currentValue, offset);
+ int relevance = kbProposal.getRelevance();
+ if(relevance==KbProposal.R_NONE) {
+ relevance = XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE;
+ }
+
+ if(kbProposal.getStart() >= 0) {
+ String replacementString = kbProposal.getReplacementString();
+ int replacementBeginPosition = start + kbProposal.getStart();
+ int replacementLength = kbProposal.getEnd() - kbProposal.getStart();
+ int cursorPositionDelta = 0;
+ int cursorPosition = kbProposal.getPosition() + cursorPositionDelta;
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal(kbProposal.autoActivationContentAssistantAfterApplication(),
replacementString,
+ replacementBeginPosition, replacementLength, cursorPosition,
SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE),
+ kbProposal.getLabel(), null, kbProposal.getContextInfo(), relevance);
+ contentAssistRequest.addProposal(proposal);
+ continue;
+ } else {
+ StringBuffer replacementStringBuffer = new
StringBuffer(kbProposal.getReplacementString());
+ int replacementBeginPosition = start;
+ int replacementLength = 0;
+ int cursorPositionDelta = 0;
+ String replacementString = replacementStringBuffer.toString();
+ int cursorPosition = kbProposal.getPosition() + cursorPositionDelta;
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal(kbProposal.autoActivationContentAssistantAfterApplication(),
replacementString,
+ replacementBeginPosition, replacementLength, cursorPosition,
SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE),
+ kbProposal.getLabel(), null, kbProposal.getContextInfo(), relevance);
+ contentAssistRequest.addProposal(proposal);
+ }
+ }
+ ELParser p = new ELParser();
+ ELParser.Token root = p.parse(currentValue);
+ ELParser.Token c = root == null ? null : ELParser.getTokenAt(root, offset);
+ if(ELParser.getPrecedingOpen(c, offset) != null) return true;
+ }
+ return false;
+ }
+
+ protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
+ Element element = (Element)contentAssistRequest.getNode();
+ NamedNodeMap attributes = element.getAttributes();
+
+ String tagName = element.getNodeName();
+ if(isFacelets && tagName.indexOf(':')<0) {
+ tagName = faceletHtmlPrefixStart + tagName;
+ }
+ String request = "/" + tagName + "@" +
contentAssistRequest.getMatchString();
+ Collection kbProposals = null;
+ try {
+ kbProposals = getWtpKbConnector().getProposals(request);
+ } catch(Exception e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ for (Iterator iter = kbProposals.iterator(); iter.hasNext();) {
+ KbProposal kbProposal = cleanFaceletProposal((KbProposal)iter.next());
+ String proposedInfo = kbProposal.getContextInfo();
+ String replacementString = kbProposal.getReplacementString() +
"=\"\"";
+ String displayString = kbProposal.getLabel();
+ AttrImpl attr = (AttrImpl)attributes.getNamedItem(displayString);
+ if(attr!=null) {
+ ITextRegion region = attr.getNameRegion();
+ IStructuredDocumentRegion docRegion = contentAssistRequest.getDocumentRegion();
+ if(docRegion.getStartOffset(region)>contentAssistRequest.getReplacementBeginPosition()
||
+ docRegion.getEndOffset(region)<
contentAssistRequest.getReplacementBeginPosition() +
contentAssistRequest.getReplacementLength()) {
+ continue;
+ }
+ }
+ boolean autoContentAssistant = true;
+ int cursorAdjustment = replacementString.length() - 1;
+ Image image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal(autoContentAssistant, replacementString,
contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), cursorAdjustment, image, displayString, null,
proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
+ contentAssistRequest.addProposal(proposal);
+ }
+ addJsfAttributeNameProposalsForFaceletTag(contentAssistRequest);
+ super.addAttributeNameProposals(contentAssistRequest);
+ }
+
+ private void addJsfAttributeNameProposalsForFaceletTag(ContentAssistRequest
contentAssistRequest) {
+ // Ignore if jsp is not facelet jsp
+ if(!isFacelets) {
+ return;
+ }
+
+ Element element = (Element)contentAssistRequest.getNode();
+
+ String tagName = element.getNodeName();
+ // Only HTML tags
+ if(tagName.indexOf(':')>0) {
+ return;
+ }
+
+ NamedNodeMap attributes = element.getAttributes();
+ Node jsfC = attributes.getNamedItem(JSFCAttributeName);
+ if(jsfC==null || (!(jsfC instanceof Attr))) {
+ return;
+ }
+ Attr jsfCAttribute = (Attr)jsfC;
+ String jsfTagName = jsfCAttribute.getValue();
+ if(jsfTagName==null || jsfTagName.indexOf(':')<1) {
+ return;
+ }
+
+ String request = "/" + jsfTagName + "@" +
contentAssistRequest.getMatchString();
+ Collection kbProposals = null;
+ try {
+ kbProposals = getWtpKbConnector().getProposals(request);
+ } catch(Exception e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ for (Iterator iter = kbProposals.iterator(); iter.hasNext();) {
+ KbProposal kbProposal = (KbProposal)iter.next();
+ if(ignoreProposal(kbProposal)) {
+ continue;
+ }
+ String proposedInfo = kbProposal.getContextInfo();
+ String replacementString = kbProposal.getReplacementString() +
"=\"\"";
+ String displayString = kbProposal.getLabel();
+ AttrImpl attr = (AttrImpl)attributes.getNamedItem(displayString);
+ if(attr!=null) {
+ ITextRegion region = attr.getNameRegion();
+ IStructuredDocumentRegion docRegion = contentAssistRequest.getDocumentRegion();
+ if(docRegion.getStartOffset(region)>contentAssistRequest.getReplacementBeginPosition()
||
+ docRegion.getEndOffset(region)<
contentAssistRequest.getReplacementBeginPosition() +
contentAssistRequest.getReplacementLength()) {
+ continue;
+ }
+ }
+ boolean autoContentAssistant = true;
+ int cursorAdjustment = replacementString.length() - 1;
+ Image image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal(autoContentAssistant, replacementString,
contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), cursorAdjustment, image, displayString, null,
proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
+ contentAssistRequest.addProposal(proposal);
+ }
+ }
+
+ protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
+ // JBIDE-1704:
+ // Check the position in the value:
+ // The following position:
+ // <nodeName attrName="attrValue"| .../>
+ // is marked as attribute value, but the value itself is complete.
+ // There are no proposals to be correct at this position.
+
+ String text = contentAssistRequest.getText();
+ String matchString = contentAssistRequest.getMatchString();
+
+ if (matchString.length() > StringUtils.strip(text).length() &&
+ ( (matchString.startsWith("\"") &&
matchString.endsWith("\"") &&
+ (matchString.indexOf("\"") !=
matchString.lastIndexOf("\"")))
+ || (matchString.startsWith("'") &&
matchString.endsWith("\"") &&
+ (matchString.indexOf("\"") !=
matchString.lastIndexOf("\""))))) {
+ return;
+ }
+
+ if (jspActiveCAP != null) {
+ jspActiveCAP.setFacelets(isFacelets);
+ jspActiveCAP.addAttributeValueProposals(contentAssistRequest);
+ }
+ IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
+ String tagName = node.getNodeName();
+ CMElementDeclaration elementDecl = getCMElementDeclaration(node);
+
+ IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion();
+ ITextRegionList openRegions = open.getRegions();
+ int i = openRegions.indexOf(contentAssistRequest.getRegion());
+ if (i < 0)
+ return;
+ ITextRegion nameRegion = null;
+ while (i >= 0) {
+ nameRegion = openRegions.get(i--);
+ if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)
+ break;
+ }
+
+ String attributeName = open.getText(nameRegion);
+
+ boolean faceletJsfTag = false;
+ if(isFacelets && tagName.indexOf(':')<1 &&
!JSFCAttributeName.equals(attributeName)) {
+ Element element = (Element)node;
+
+ NamedNodeMap attributes = element.getAttributes();
+ Node jsfC =
attributes.getNamedItem(FaceletsHtmlContentAssistProcessor.JSFCAttributeName);
+ if(jsfC!=null && (jsfC instanceof Attr)) {
+ Attr jsfCAttribute = (Attr)jsfC;
+ String jsfTagName = jsfCAttribute.getValue();
+ if(jsfTagName!=null && jsfTagName.indexOf(':')>0) {
+ tagName = jsfTagName;
+ faceletJsfTag = true;
+ }
+ }
+ }
+
+ if(!faceletJsfTag && isFacelets && tagName.indexOf(':')<0)
{
+ tagName = faceletHtmlPrefixStart + tagName;
+ }
+ String query = new
StringBuffer(KbQuery.TAG_SEPARATOR).append(tagName).append(KbQuery.ATTRIBUTE_SEPARATOR).append(attributeName).toString();
+ AttributeDescriptor ad = null;
+ try {
+ ad = getWtpKbConnector().getAttributeInformation(query);
+ } catch(Exception e) {
+ ProblemReportingHelper.reportProblem(JspEditorPlugin.PLUGIN_ID, "ERROR: Can't
get Attribute Descriptor from KB by " + query + "", e);
+ }
+ if(ad!=null) {
+ CMAttributeDeclaration attrDecl = null;
+ if (elementDecl != null) {
+ CMNamedNodeMap attributes = elementDecl.getAttributes();
+ String noprefixName = DOMNamespaceHelper.getUnprefixedName(attributeName);
+ if (attributes != null) {
+ attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(noprefixName);
+ if (attrDecl == null) {
+ attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(attributeName);
+ }
+ }
+ }
+ if (attrDecl == null || attrDecl.getAttrType() == null) {
+ return;
+ }
+ }
+
+ super.addAttributeValueProposals(contentAssistRequest);
+ }
+
+ protected void addTagNameProposals(ContentAssistRequest contentAssistRequest, int
childPosition) {
+ String request = "/" + contentAssistRequest.getMatchString();
+ Collection kbProposals = null;
+ try {
+ kbProposals = getWtpKbConnector().getProposals(request);
+ } catch(Exception e) {
+ JspEditorPlugin.getPluginLog().logError(e);
+ }
+ if(kbProposals!=null) {
+ for (Iterator iter = kbProposals.iterator(); iter.hasNext();) {
+ KbProposal kbProposal = (KbProposal) iter.next();
+ if(ignoreProposal(kbProposal)) {
+ continue;
+ }
+ String proposedInfo = kbProposal.getContextInfo();
+ String kbReplacementString = kbProposal.getReplacementString();
+ String replacementString = kbReplacementString + ">";
+ String displayString = kbProposal.getLabel();
+ boolean autoContentAssistant = replacementString.indexOf('\"')>-1
&& replacementString.indexOf("=")>-1;
+ int cursorAdjustment = replacementString.length();
+ if(!kbReplacementString.endsWith("/")) {
+ replacementString = replacementString + "</" + displayString +
">";
+ }
+ Image image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal(autoContentAssistant, replacementString,
contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), cursorAdjustment, image, displayString, null,
proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
+ contentAssistRequest.addProposal(proposal);
+ }
+ }
+ super.addTagNameProposals(contentAssistRequest, childPosition);
+ }
+
+ private boolean ignoreProposal(KbProposal proposal) {
+ if(isFacelets) {
+ return proposal.getLabel().startsWith(faceletHtmlPrefixStart);
+ }
+ return false;
+ }
+
+ private KbProposal cleanFaceletProposal(KbProposal proposal) {
+ if(isFacelets) {
+ proposal.setLabel(removeFaceletsPrefix(proposal.getLabel()));
+ proposal.setReplacementString(removeFaceletsPrefix(proposal.getReplacementString()));
+ }
+ return proposal;
+ }
+
+ private String removeFaceletsPrefix(String tagName) {
+ if(tagName.startsWith(faceletHtmlPrefixStart)) {
+ return tagName.substring(faceletHtmlPrefixStart.length());
+ }
+ return tagName;
+ }
+
+ private WtpKbConnector getWtpKbConnector() {
+ if(wtpKbConnector == null && document != null) {
+ try {
+ wtpKbConnector =
(WtpKbConnector)KbConnectorFactory.getIntstance().createConnector(KbConnectorType.JSP_WTP_KB_CONNECTOR,
document);
+ jspActiveCAP.setKbConnector(wtpKbConnector);
+ FaceletsJsfCResource fsfCResource = new
FaceletsJsfCResource(wtpKbConnector);
+ wtpKbConnector.registerResource(fsfCResource);
+ } catch(Exception e) {
+ ProblemReportingHelper.reportProblem(JspEditorPlugin.PLUGIN_ID, "ERROR:
Can't create WtpKbConnector.", e);
+ }
+ }
+ return wtpKbConnector;
+ }
+
+ private void registerToTldManager(ITextViewer viewer,IDOMNode node) {
+ if((tldManager==null) && (viewer instanceof VpeTaglibManagerProvider)) {
+ tldManager = ((VpeTaglibManagerProvider)viewer).getTaglibManager();
+ tldManager.setReferenceNode(node);
+ if(tldManager!=null) {
+ tldManager.addTaglibListener(this);
+ updateActiveContentAssistProcessor(document);
+ }
+ } else if(tldManager!=null) {
+ tldManager.setReferenceNode(node);
+ updateActiveContentAssistProcessor(document);
+ }
+ }
+
+ public void taglibPrefixChanged(String[] prefixs) {
+ updateActiveContentAssistProcessor(document);
+ }
+
+ public void addTaglib(String uri, String prefix) {
+ }
+
+ public void removeTaglib(String uri, String prefix) {
+ }
+
+ public static void registerTld(TaglibData data, JspWtpKbConnector wtpKbConnector,
IDocument document, IEditorInput input) {
+ TLDRegisterHelper.registerTld(data, wtpKbConnector, document, input);
+ }
+
+ public void updateActiveContentAssistProcessor(IDocument document) {
+ if(tldManager==null) {
+ TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(document);
+ if (manager != null) {
+ List list = manager.getTaglibTrackers();
+ for(int i=0; i<list.size(); i++) {
+ TaglibTracker tracker = (TaglibTracker)list.get(i);
+ String version = TLDVersionHelper.getTldVersion(tracker);
+ KbTldResource resource = new KbTldResource(tracker.getURI(), "",
tracker.getPrefix(), version);
+ getWtpKbConnector().registerResource(resource);
+ }
+ }
+ } else {
+ List list = tldManager.getTagLibs();
+ if(list==null) {
+ return;
+ }
+ ((JspWtpKbConnector)getWtpKbConnector()).unregisterAllResources(true);
+ isFacelets = false;
+ for(int i=0; i<list.size(); i++) {
+ TaglibData data = (TaglibData)list.get(i);
+ registerTld(data, (JspWtpKbConnector)getWtpKbConnector(), document, editorInput);
+ isFacelets = isFacelets || data.getUri().equals(faceletUri);
+ }
+ if(isFacelets) {
+ getWtpKbConnector().registerResource(faceletHtmlResource);
+ ((JspWtpKbConnector)getWtpKbConnector()).unregisterJspResource();
+ }
+ }
+ }
+
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ char[] autoActivChars = null;
+ char[] superAutoActivChars = super.getCompletionProposalAutoActivationCharacters();
+ if(superAutoActivChars==null) {
+ return superAutoActivChars;
+ }
+
+ autoActivChars = superAutoActivChars;
+ IPreferenceStore store = HTMLUIPlugin.getDefault().getPreferenceStore();
+ if(store.isDefault(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE)) {
+// String superDefaultChars =
store.getDefaultString(JSPUIPreferenceNames.AUTO_PROPOSE_CODE);
+ StringBuffer redhatDefaultChars = new StringBuffer(new String(superAutoActivChars));
+ if(redhatDefaultChars.indexOf(".")<0) {
+ redhatDefaultChars.append('.');
+ store.setDefault(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE,
redhatDefaultChars.toString());
+ store.setValue(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE,
redhatDefaultChars.toString());
+ }
+ autoActivChars = new char[redhatDefaultChars.length()];
+ redhatDefaultChars.getChars(0, redhatDefaultChars.length(), autoActivChars, 0);
+ }
+
+ return autoActivChars;
+ }
+
+ protected void init() {
+ super.init();
+ jspActiveCAP = new JSPActiveContentAssistProcessor();
+ jspActiveCAP.init();
+ }
+
+
+ /**
+ * StructuredTextViewer must be set before using this.
+ */
+ public IStructuredDocumentRegion getStructuredDocumentRegion(int pos) {
+ IStructuredDocumentRegion sdRegion =
ContentAssistUtils.getStructuredDocumentRegion(fTextViewer, pos);
+ ITextRegion region = (sdRegion == null ? null :
sdRegion.getRegionAtCharacterOffset(pos));
+ if (region == null) {
+ return null;
+ }
+
+ if (region.getType() == DOMRegionContext.XML_TAG_OPEN &&
+ sdRegion.getStartOffset(region) == pos) {
+ // The offset is at the beginning of the region
+ if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset()) &&
(sdRegion.getPrevious() != null) && (!sdRegion.getPrevious().isEnded())) {
+ // Is the region also the start of the node? If so, the
+ // previous IStructuredDocumentRegion is
+ // where to look for a useful region.
+ sdRegion = sdRegion.getPrevious();
+ }
+ else {
+ // Is there no separating whitespace from the previous region?
+ // If not,
+ // then that region is the important one
+ ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(pos - 1);
+ if ((previousRegion != null) && (previousRegion != region) &&
(previousRegion.getTextLength() == previousRegion.getLength())) {
+ sdRegion = sdRegion.getPrevious();
+ }
+ }
+ }
+
+ return sdRegion;
+ }
+
+}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPActiveContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPActiveContentAssistProcessor.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPActiveContentAssistProcessor.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -53,16 +53,16 @@
boolean faceletJsfTag = false;
String htmlQuery = null;
- if(isFacelets && tagName.indexOf(':')<1 &&
!RedHatHtmlContentAssistProcessor.JSFCAttributeName.equals(attributeName)) {
+ if(isFacelets && tagName.indexOf(':')<1 &&
!FaceletsHtmlContentAssistProcessor.JSFCAttributeName.equals(attributeName)) {
Element element = (Element)node;
NamedNodeMap attributes = element.getAttributes();
- Node jsfC =
attributes.getNamedItem(RedHatHtmlContentAssistProcessor.JSFCAttributeName);
+ Node jsfC =
attributes.getNamedItem(FaceletsHtmlContentAssistProcessor.JSFCAttributeName);
if(jsfC!=null && (jsfC instanceof Attr)) {
Attr jsfCAttribute = (Attr)jsfC;
String jsfTagName = jsfCAttribute.getValue();
if(jsfTagName!=null && jsfTagName.indexOf(':')>0) {
- htmlQuery = new
StringBuffer(KbQuery.TAG_SEPARATOR).append(RedHatHtmlContentAssistProcessor.faceletHtmlPrefixStart
+
tagName).append(KbQuery.ATTRIBUTE_SEPARATOR).append(attributeName).append(KbQuery.ENUMERATION_SEPARATOR).append(matchString).toString();
+ htmlQuery = new
StringBuffer(KbQuery.TAG_SEPARATOR).append(FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart
+
tagName).append(KbQuery.ATTRIBUTE_SEPARATOR).append(attributeName).append(KbQuery.ENUMERATION_SEPARATOR).append(matchString).toString();
tagName = jsfTagName;
faceletJsfTag = true;
}
@@ -70,7 +70,7 @@
}
if(!faceletJsfTag && isFacelets && tagName.indexOf(':')<0)
{
- tagName = RedHatHtmlContentAssistProcessor.faceletHtmlPrefixStart + tagName;
+ tagName = FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart + tagName;
}
String query = new
StringBuffer(KbQuery.TAG_SEPARATOR).append(tagName).append(KbQuery.ATTRIBUTE_SEPARATOR).append(attributeName).append(KbQuery.ENUMERATION_SEPARATOR).append(matchString).toString();
@@ -107,7 +107,7 @@
replacementString += ("\"");
}
int cursorPosition = kbProposal.getPosition() + cursorPositionDelta;
- RedHatCustomCompletionProposal proposal = new
RedHatCustomCompletionProposal(kbProposal.autoActivationContentAssistantAfterApplication(),
replacementString,
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal(kbProposal.autoActivationContentAssistantAfterApplication(),
replacementString,
replacementBeginPosition, replacementLength, cursorPosition,
SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE),
kbProposal.getLabel(), null, kbProposal.getContextInfo(), relevance);
contentAssistRequest.addProposal(proposal);
@@ -138,7 +138,7 @@
}
String replacementString = replacementStringBuffer.toString();
int cursorPosition = kbProposal.getPosition() + cursorPositionDelta;
- RedHatCustomCompletionProposal proposal = new
RedHatCustomCompletionProposal(kbProposal.autoActivationContentAssistantAfterApplication(),
replacementString,
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal(kbProposal.autoActivationContentAssistantAfterApplication(),
replacementString,
replacementBeginPosition, replacementLength, cursorPosition,
SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE),
kbProposal.getLabel(), null, kbProposal.getContextInfo(), relevance);
contentAssistRequest.addProposal(proposal);
@@ -157,8 +157,8 @@
}
private String removeFaceletsPrefix(String tagName) {
- if(tagName.startsWith(RedHatHtmlContentAssistProcessor.faceletHtmlPrefixStart)) {
- return
tagName.substring(RedHatHtmlContentAssistProcessor.faceletHtmlPrefixStart.length());
+ if(tagName.startsWith(FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart)) {
+ return
tagName.substring(FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart.length());
}
return tagName;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogCellEditorContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogCellEditorContentAssistProcessor.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogCellEditorContentAssistProcessor.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -84,18 +84,18 @@
boolean faceletJsfTag = false;
String htmlQuery = null;
- if(isFacelets && tagName.indexOf(':')<1 &&
!RedHatHtmlContentAssistProcessor.JSFCAttributeName.equals(attributeName)) {
+ if(isFacelets && tagName.indexOf(':')<1 &&
!FaceletsHtmlContentAssistProcessor.JSFCAttributeName.equals(attributeName)) {
Element element = (Element)node;
String jsfTagName = valueHelper.getFaceletJsfTag(element);
if(jsfTagName != null) {
faceletJsfTag = true;
tagName = jsfTagName;
- htmlQuery = new
StringBuffer(KbQuery.TAG_SEPARATOR).append(RedHatHtmlContentAssistProcessor.faceletHtmlPrefixStart
+
tagName).append(KbQuery.ATTRIBUTE_SEPARATOR).append(attributeName).append(KbQuery.ENUMERATION_SEPARATOR).append(matchString).toString();
+ htmlQuery = new
StringBuffer(KbQuery.TAG_SEPARATOR).append(FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart
+
tagName).append(KbQuery.ATTRIBUTE_SEPARATOR).append(attributeName).append(KbQuery.ENUMERATION_SEPARATOR).append(matchString).toString();
}
}
if(!faceletJsfTag && isFacelets && tagName.indexOf(':')<0)
{
- tagName = RedHatHtmlContentAssistProcessor.faceletHtmlPrefixStart + tagName;
+ tagName = FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart + tagName;
}
String query = new
StringBuffer(KbQuery.TAG_SEPARATOR).append(tagName).append(KbQuery.ATTRIBUTE_SEPARATOR).append(attributeName).append(KbQuery.ENUMERATION_SEPARATOR).append(matchString).toString();
@@ -121,7 +121,7 @@
int replacementLength = kbProposal.getEnd() - kbProposal.getStart();
int cursorPositionDelta = 0;
int cursorPosition = kbProposal.getPosition() + cursorPositionDelta;
- RedHatCustomCompletionProposal proposal = new
RedHatCustomCompletionProposal(kbProposal.autoActivationContentAssistantAfterApplication(),
replacementString,
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal(kbProposal.autoActivationContentAssistantAfterApplication(),
replacementString,
replacementBeginPosition, replacementLength, cursorPosition,
SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE),
kbProposal.getLabel(), null, kbProposal.getContextInfo(), relevance);
proposalsList.add(proposal);
@@ -132,7 +132,7 @@
int cursorPositionDelta = 0;
String replacementString = replacementStringBuffer.toString();
int cursorPosition = kbProposal.getPosition() + cursorPositionDelta;
- RedHatCustomCompletionProposal proposal = new
RedHatCustomCompletionProposal(kbProposal.autoActivationContentAssistantAfterApplication(),
replacementString,
+ AutoContentAssistantProposal proposal = new
AutoContentAssistantProposal(kbProposal.autoActivationContentAssistantAfterApplication(),
replacementString,
replacementBeginPosition, replacementLength, cursorPosition,
SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE),
kbProposal.getLabel(), null, kbProposal.getContextInfo(), relevance);
proposalsList.add(proposal);
@@ -150,8 +150,8 @@
return proposal;
}
private String removeFaceletsPrefix(String tagName) {
- if(tagName.startsWith(RedHatHtmlContentAssistProcessor.faceletHtmlPrefixStart)) {
- return
tagName.substring(RedHatHtmlContentAssistProcessor.faceletHtmlPrefixStart.length());
+ if(tagName.startsWith(FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart)) {
+ return
tagName.substring(FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart.length());
}
return tagName;
}
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatCustomCompletionProposal.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatCustomCompletionProposal.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatCustomCompletionProposal.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.contentassist;
-
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
-import org.eclipse.wst.sse.ui.internal.contentassist.IRelevanceConstants;
-
-/**
- * @author Igels
- */
-public class RedHatCustomCompletionProposal extends CustomCompletionProposal {
-
- private boolean autoContentAssistant = false;
-
- public RedHatCustomCompletionProposal(String replacementString, int replacementOffset,
int replacementLength, int cursorPosition, Image image, String displayString,
IContextInformation contextInformation, String additionalProposalInfo) {
- super(replacementString, replacementOffset, replacementLength, cursorPosition, image,
displayString, contextInformation, additionalProposalInfo, IRelevanceConstants.R_NONE);
- }
-
- public RedHatCustomCompletionProposal(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;
- }
-
- public RedHatCustomCompletionProposal(String replacementString, int replacementOffset,
int replacementLength, int cursorPosition, Image image, String displayString,
IContextInformation contextInformation, String additionalProposalInfo, int relevance,
boolean updateReplacementLengthOnValidate) {
- super(replacementString, replacementOffset, replacementLength, cursorPosition,
image, displayString, contextInformation, additionalProposalInfo, relevance,
updateReplacementLengthOnValidate);
- }
-
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- super.apply(viewer, trigger, stateMask, offset);
- if(autoContentAssistant) {
- Point selection = getSelection(viewer.getDocument());
- viewer.setSelectedRange(selection.x, selection.y);
- if(viewer instanceof ITextOperationTarget) {
- ((ITextOperationTarget)viewer).doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
- }
- }
- }
-
- /**
- * Red Hat. Return cursor position of proposal replasement string.
- */
- public int getCursorPosition() {
- int cursorPosition = -1;
- int firstAttributeEndPosition = getReplacementString().indexOf("=");
- int openEndTagPosition = getReplacementString().indexOf("</");
- int closeStartAndEndTagPosition = getReplacementString().indexOf("/>");
- if(firstAttributeEndPosition>-1) {
- cursorPosition = firstAttributeEndPosition + 2;
- } else if(openEndTagPosition>-1) {
- cursorPosition = openEndTagPosition;
- } else if(closeStartAndEndTagPosition>-1) {
- cursorPosition = closeStartAndEndTagPosition;
- }
- return cursorPosition>-1?cursorPosition:super.getCursorPosition();
- }
-}
\ No newline at end of file
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatHtmlContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatHtmlContentAssistProcessor.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatHtmlContentAssistProcessor.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -1,608 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.contentassist;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-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.jst.jsp.core.internal.contentmodel.TaglibController;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
-import org.eclipse.wst.html.ui.internal.contentassist.HTMLContentAssistProcessor;
-import org.eclipse.wst.html.ui.internal.preferences.HTMLUIPreferenceNames;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.eclipse.wst.xml.core.internal.document.AttrImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.eclipse.wst.xml.ui.internal.util.SharedXMLEditorPluginImageHelper;
-import org.jboss.tools.common.kb.AttributeDescriptor;
-import org.jboss.tools.common.kb.KbConnectorFactory;
-import org.jboss.tools.common.kb.KbConnectorType;
-import org.jboss.tools.common.kb.KbProposal;
-import org.jboss.tools.common.kb.KbQuery;
-import org.jboss.tools.common.kb.KbTldResource;
-import org.jboss.tools.common.kb.wtp.JspWtpKbConnector;
-import org.jboss.tools.common.kb.wtp.TLDVersionHelper;
-import org.jboss.tools.common.kb.wtp.WtpKbConnector;
-import org.jboss.tools.common.model.util.ELParser;
-import org.jboss.tools.common.reporting.ProblemReportingHelper;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.editor.TLDRegisterHelper;
-import org.jboss.tools.jst.jsp.outline.ValueHelper;
-import org.jboss.tools.jst.jsp.support.kb.FaceletsJsfCResource;
-import org.jboss.tools.jst.jsp.support.kb.WTPKbdBeanMethodResource;
-import org.jboss.tools.jst.jsp.support.kb.WTPKbdBeanPropertyResource;
-import org.jboss.tools.jst.jsp.support.kb.WTPKbdBundlePropertyResource;
-import org.jboss.tools.jst.web.tld.TaglibData;
-import org.jboss.tools.jst.web.tld.VpeTaglibListener;
-import org.jboss.tools.jst.web.tld.VpeTaglibManager;
-import org.jboss.tools.jst.web.tld.VpeTaglibManagerProvider;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * @author Igels
- */
-public class RedHatHtmlContentAssistProcessor extends HTMLContentAssistProcessor
implements VpeTaglibListener {
-
- private JSPActiveContentAssistProcessor jspActiveCAP;
- private WtpKbConnector wtpKbConnector;
- private IDocument document;
- private IEditorInput editorInput;
- private VpeTaglibManager tldManager;
- private boolean isFacelets = false;
- public static final String faceletUri = "http://java.sun.com/jsf/facelets";
- public static final String faceletHtmlUri =
"http://www.w3.org/1999/xhtml/facelets";
- public static final String faceletHtmlPrefix = "0fHP";
- public static final String JSFCAttributeName = "jsfc";
- public static final String faceletHtmlPrefixStart = faceletHtmlPrefix + ":";
- //Added by Max Areshkau JBIDE-788
- public static final KbTldResource faceletHtmlResource = new
KbTldResource(faceletHtmlUri, "", faceletHtmlPrefix, null);
-
- public ICompletionProposal[] computeCompletionProposals(ITextViewer textViewer, int
documentPosition) {
- document = textViewer.getDocument();
- editorInput =
JspEditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput();
- //added by Max Areshkau JBIDE-788
- IndexedRegion treeNode = ContentAssistUtils.getNodeAt(textViewer,
documentPosition);
- IDOMNode node = (IDOMNode) treeNode;
- registerToTldManager(textViewer, node);
-
- ICompletionProposal[] proposals = super.computeCompletionProposals(textViewer,
documentPosition);
- if(proposals!=null) {
- for(int i=0; i<proposals.length; i++) {
- if(proposals[i] instanceof RedHatCustomCompletionProposal) {
- fErrorMessage = null;
- break;
- }
- }
- }
- if(isFacelets) {
- return getUniqProposals(proposals);
- }
- proposals = getUniqProposals(proposals);
- return proposals;
- }
-
- private ICompletionProposal[] getUniqProposals(ICompletionProposal[] proposals) {
- if(proposals==null) {
- return null;
- }
- HashMap uniqProposals = new HashMap(proposals.length);
- ArrayList uniqProposalList = new ArrayList(proposals.length);
- for(int i=0; i<proposals.length; i++) {
- int eq = proposals[i].getDisplayString().indexOf('=');
- String str = proposals[i].getDisplayString();;
- if(eq>0) {
- str = str.substring(0, eq);
- }
- Object proposal = uniqProposals.get(str);
- if(proposal==null || proposals[i] instanceof RedHatCustomCompletionProposal) {
- uniqProposals.put(str, proposals[i]);
- uniqProposalList.add(proposals[i]);
- if(proposal!=null) {
- uniqProposalList.remove(proposal);
- }
- }
- }
- return (ICompletionProposal[])uniqProposalList.toArray(new
ICompletionProposal[uniqProposals.size()]);
- }
-
- protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int
childPosition) {
- if(!addELFaceletsProposals(contentAssistRequest, childPosition)) {
- String request = "/" + contentAssistRequest.getMatchString();
- Collection kbProposals = null;
- try {
- kbProposals = getWtpKbConnector().getProposals(request);
- } catch(Exception e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- for (Iterator iter = kbProposals.iterator(); iter.hasNext();) {
- KbProposal kbProposal = (KbProposal) iter.next();
- if(ignoreProposal(kbProposal)) {
- continue;
- }
- String proposedInfo = kbProposal.getContextInfo();
- String kbReplacementString = kbProposal.getReplacementString();
- String replacementString = "<" + kbReplacementString +
">";
- String displayString = kbProposal.getLabel();
- boolean autoContentAssistant = replacementString.indexOf('\"')>-1
&& replacementString.indexOf("=")>-1;
- int cursorAdjustment = replacementString.length();;
- if(!kbReplacementString.endsWith("/")) {
- replacementString = replacementString + "</" + displayString +
">";
- }
- Image image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- RedHatCustomCompletionProposal proposal = new
RedHatCustomCompletionProposal(autoContentAssistant, replacementString,
contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), cursorAdjustment, image, displayString, null,
proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- super.addTagInsertionProposals(contentAssistRequest, childPosition);
- }
- }
-
- private boolean addELFaceletsProposals(ContentAssistRequest contentAssistRequest, int
childPosition) {
- if(isFacelets) {
- IDOMNode node = (IDOMNode)contentAssistRequest.getNode();
- IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion();
- ITextRegionList openRegions = open.getRegions();
- int i = openRegions.indexOf(contentAssistRequest.getRegion());
- if(i < 0) return false;
- String currentValue = contentAssistRequest.getText();
- int start = contentAssistRequest.getStartOffset();
- int offset = contentAssistRequest.getReplacementBeginPosition() - start;
- String matchString = currentValue.substring(0, offset);
- ValueHelper h = new ValueHelper();
- IEditorInput input = h.getEditorInput();
- ArrayList proposals = new ArrayList();
- WTPKbdBeanPropertyResource r1 = new WTPKbdBeanPropertyResource(input,
h.getConnector());
- proposals.addAll(r1.queryProposal(matchString));
- WTPKbdBeanMethodResource r2 = new WTPKbdBeanMethodResource(input, h.getConnector());
- proposals.addAll(r2.queryProposal(matchString));
- WTPKbdBundlePropertyResource r3 = new WTPKbdBundlePropertyResource(input,
h.getConnector());
- proposals.addAll(r3.queryProposal(matchString));
-
- for (Iterator iter = proposals.iterator(); iter.hasNext();) {
- KbProposal kbProposal = cleanFaceletProposal((KbProposal)iter.next());
- kbProposal.postProcess(currentValue, offset);
- int relevance = kbProposal.getRelevance();
- if(relevance==KbProposal.R_NONE) {
- relevance = XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE;
- }
-
- if(kbProposal.getStart() >= 0) {
- String replacementString = kbProposal.getReplacementString();
- int replacementBeginPosition = start + kbProposal.getStart();
- int replacementLength = kbProposal.getEnd() - kbProposal.getStart();
- int cursorPositionDelta = 0;
- int cursorPosition = kbProposal.getPosition() + cursorPositionDelta;
- RedHatCustomCompletionProposal proposal = new
RedHatCustomCompletionProposal(kbProposal.autoActivationContentAssistantAfterApplication(),
replacementString,
- replacementBeginPosition, replacementLength, cursorPosition,
SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE),
- kbProposal.getLabel(), null, kbProposal.getContextInfo(), relevance);
- contentAssistRequest.addProposal(proposal);
- continue;
- } else {
- StringBuffer replacementStringBuffer = new
StringBuffer(kbProposal.getReplacementString());
- int replacementBeginPosition = start;
- int replacementLength = 0;
- int cursorPositionDelta = 0;
- String replacementString = replacementStringBuffer.toString();
- int cursorPosition = kbProposal.getPosition() + cursorPositionDelta;
- RedHatCustomCompletionProposal proposal = new
RedHatCustomCompletionProposal(kbProposal.autoActivationContentAssistantAfterApplication(),
replacementString,
- replacementBeginPosition, replacementLength, cursorPosition,
SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE),
- kbProposal.getLabel(), null, kbProposal.getContextInfo(), relevance);
- contentAssistRequest.addProposal(proposal);
- }
- }
- ELParser p = new ELParser();
- ELParser.Token root = p.parse(currentValue);
- ELParser.Token c = root == null ? null : ELParser.getTokenAt(root, offset);
- if(ELParser.getPrecedingOpen(c, offset) != null) return true;
- }
- return false;
- }
-
- protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
- Element element = (Element)contentAssistRequest.getNode();
- NamedNodeMap attributes = element.getAttributes();
-
- String tagName = element.getNodeName();
- if(isFacelets && tagName.indexOf(':')<0) {
- tagName = faceletHtmlPrefixStart + tagName;
- }
- String request = "/" + tagName + "@" +
contentAssistRequest.getMatchString();
- Collection kbProposals = null;
- try {
- kbProposals = getWtpKbConnector().getProposals(request);
- } catch(Exception e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- for (Iterator iter = kbProposals.iterator(); iter.hasNext();) {
- KbProposal kbProposal = cleanFaceletProposal((KbProposal)iter.next());
- String proposedInfo = kbProposal.getContextInfo();
- String replacementString = kbProposal.getReplacementString() +
"=\"\"";
- String displayString = kbProposal.getLabel();
- AttrImpl attr = (AttrImpl)attributes.getNamedItem(displayString);
- if(attr!=null) {
- ITextRegion region = attr.getNameRegion();
- IStructuredDocumentRegion docRegion = contentAssistRequest.getDocumentRegion();
- if(docRegion.getStartOffset(region)>contentAssistRequest.getReplacementBeginPosition()
||
- docRegion.getEndOffset(region)<
contentAssistRequest.getReplacementBeginPosition() +
contentAssistRequest.getReplacementLength()) {
- continue;
- }
- }
- boolean autoContentAssistant = true;
- int cursorAdjustment = replacementString.length() - 1;
- Image image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- RedHatCustomCompletionProposal proposal = new
RedHatCustomCompletionProposal(autoContentAssistant, replacementString,
contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), cursorAdjustment, image, displayString, null,
proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- addJsfAttributeNameProposalsForFaceletTag(contentAssistRequest);
- super.addAttributeNameProposals(contentAssistRequest);
- }
-
- private void addJsfAttributeNameProposalsForFaceletTag(ContentAssistRequest
contentAssistRequest) {
- // Ignore if jsp is not facelet jsp
- if(!isFacelets) {
- return;
- }
-
- Element element = (Element)contentAssistRequest.getNode();
-
- String tagName = element.getNodeName();
- // Only HTML tags
- if(tagName.indexOf(':')>0) {
- return;
- }
-
- NamedNodeMap attributes = element.getAttributes();
- Node jsfC = attributes.getNamedItem(JSFCAttributeName);
- if(jsfC==null || (!(jsfC instanceof Attr))) {
- return;
- }
- Attr jsfCAttribute = (Attr)jsfC;
- String jsfTagName = jsfCAttribute.getValue();
- if(jsfTagName==null || jsfTagName.indexOf(':')<1) {
- return;
- }
-
- String request = "/" + jsfTagName + "@" +
contentAssistRequest.getMatchString();
- Collection kbProposals = null;
- try {
- kbProposals = getWtpKbConnector().getProposals(request);
- } catch(Exception e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- for (Iterator iter = kbProposals.iterator(); iter.hasNext();) {
- KbProposal kbProposal = (KbProposal)iter.next();
- if(ignoreProposal(kbProposal)) {
- continue;
- }
- String proposedInfo = kbProposal.getContextInfo();
- String replacementString = kbProposal.getReplacementString() +
"=\"\"";
- String displayString = kbProposal.getLabel();
- AttrImpl attr = (AttrImpl)attributes.getNamedItem(displayString);
- if(attr!=null) {
- ITextRegion region = attr.getNameRegion();
- IStructuredDocumentRegion docRegion = contentAssistRequest.getDocumentRegion();
- if(docRegion.getStartOffset(region)>contentAssistRequest.getReplacementBeginPosition()
||
- docRegion.getEndOffset(region)<
contentAssistRequest.getReplacementBeginPosition() +
contentAssistRequest.getReplacementLength()) {
- continue;
- }
- }
- boolean autoContentAssistant = true;
- int cursorAdjustment = replacementString.length() - 1;
- Image image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- RedHatCustomCompletionProposal proposal = new
RedHatCustomCompletionProposal(autoContentAssistant, replacementString,
contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), cursorAdjustment, image, displayString, null,
proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- }
-
- protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
- // JBIDE-1704:
- // Check the position in the value:
- // The following position:
- // <nodeName attrName="attrValue"| .../>
- // is marked as attribute value, but the value itself is complete.
- // There are no proposals to be correct at this position.
-
- String text = contentAssistRequest.getText();
- String matchString = contentAssistRequest.getMatchString();
-
- if (matchString.length() > StringUtils.strip(text).length() &&
- ( (matchString.startsWith("\"") &&
matchString.endsWith("\"") &&
- (matchString.indexOf("\"") !=
matchString.lastIndexOf("\"")))
- || (matchString.startsWith("'") &&
matchString.endsWith("\"") &&
- (matchString.indexOf("\"") !=
matchString.lastIndexOf("\""))))) {
- return;
- }
-
- if (jspActiveCAP != null) {
- jspActiveCAP.setFacelets(isFacelets);
- jspActiveCAP.addAttributeValueProposals(contentAssistRequest);
- }
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
- String tagName = node.getNodeName();
- CMElementDeclaration elementDecl = getCMElementDeclaration(node);
-
- IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion();
- ITextRegionList openRegions = open.getRegions();
- int i = openRegions.indexOf(contentAssistRequest.getRegion());
- if (i < 0)
- return;
- ITextRegion nameRegion = null;
- while (i >= 0) {
- nameRegion = openRegions.get(i--);
- if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)
- break;
- }
-
- String attributeName = open.getText(nameRegion);
-
- boolean faceletJsfTag = false;
- if(isFacelets && tagName.indexOf(':')<1 &&
!JSFCAttributeName.equals(attributeName)) {
- Element element = (Element)node;
-
- NamedNodeMap attributes = element.getAttributes();
- Node jsfC =
attributes.getNamedItem(RedHatHtmlContentAssistProcessor.JSFCAttributeName);
- if(jsfC!=null && (jsfC instanceof Attr)) {
- Attr jsfCAttribute = (Attr)jsfC;
- String jsfTagName = jsfCAttribute.getValue();
- if(jsfTagName!=null && jsfTagName.indexOf(':')>0) {
- tagName = jsfTagName;
- faceletJsfTag = true;
- }
- }
- }
-
- if(!faceletJsfTag && isFacelets && tagName.indexOf(':')<0)
{
- tagName = faceletHtmlPrefixStart + tagName;
- }
- String query = new
StringBuffer(KbQuery.TAG_SEPARATOR).append(tagName).append(KbQuery.ATTRIBUTE_SEPARATOR).append(attributeName).toString();
- AttributeDescriptor ad = null;
- try {
- ad = getWtpKbConnector().getAttributeInformation(query);
- } catch(Exception e) {
- ProblemReportingHelper.reportProblem(JspEditorPlugin.PLUGIN_ID, "ERROR: Can't
get Attribute Descriptor from KB by " + query + "", e);
- }
- if(ad!=null) {
- CMAttributeDeclaration attrDecl = null;
- if (elementDecl != null) {
- CMNamedNodeMap attributes = elementDecl.getAttributes();
- String noprefixName = DOMNamespaceHelper.getUnprefixedName(attributeName);
- if (attributes != null) {
- attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(noprefixName);
- if (attrDecl == null) {
- attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(attributeName);
- }
- }
- }
- if (attrDecl == null || attrDecl.getAttrType() == null) {
- return;
- }
- }
-
- super.addAttributeValueProposals(contentAssistRequest);
- }
-
- protected void addTagNameProposals(ContentAssistRequest contentAssistRequest, int
childPosition) {
- String request = "/" + contentAssistRequest.getMatchString();
- Collection kbProposals = null;
- try {
- kbProposals = getWtpKbConnector().getProposals(request);
- } catch(Exception e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- if(kbProposals!=null) {
- for (Iterator iter = kbProposals.iterator(); iter.hasNext();) {
- KbProposal kbProposal = (KbProposal) iter.next();
- if(ignoreProposal(kbProposal)) {
- continue;
- }
- String proposedInfo = kbProposal.getContextInfo();
- String kbReplacementString = kbProposal.getReplacementString();
- String replacementString = kbReplacementString + ">";
- String displayString = kbProposal.getLabel();
- boolean autoContentAssistant = replacementString.indexOf('\"')>-1
&& replacementString.indexOf("=")>-1;
- int cursorAdjustment = replacementString.length();
- if(!kbReplacementString.endsWith("/")) {
- replacementString = replacementString + "</" + displayString +
">";
- }
- Image image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- RedHatCustomCompletionProposal proposal = new
RedHatCustomCompletionProposal(autoContentAssistant, replacementString,
contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), cursorAdjustment, image, displayString, null,
proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- }
- super.addTagNameProposals(contentAssistRequest, childPosition);
- }
-
- private boolean ignoreProposal(KbProposal proposal) {
- if(isFacelets) {
- return proposal.getLabel().startsWith(faceletHtmlPrefixStart);
- }
- return false;
- }
-
- private KbProposal cleanFaceletProposal(KbProposal proposal) {
- if(isFacelets) {
- proposal.setLabel(removeFaceletsPrefix(proposal.getLabel()));
- proposal.setReplacementString(removeFaceletsPrefix(proposal.getReplacementString()));
- }
- return proposal;
- }
-
- private String removeFaceletsPrefix(String tagName) {
- if(tagName.startsWith(faceletHtmlPrefixStart)) {
- return tagName.substring(faceletHtmlPrefixStart.length());
- }
- return tagName;
- }
-
- private WtpKbConnector getWtpKbConnector() {
- if(wtpKbConnector == null && document != null) {
- try {
- wtpKbConnector =
(WtpKbConnector)KbConnectorFactory.getIntstance().createConnector(KbConnectorType.JSP_WTP_KB_CONNECTOR,
document);
- jspActiveCAP.setKbConnector(wtpKbConnector);
- FaceletsJsfCResource fsfCResource = new
FaceletsJsfCResource(wtpKbConnector);
- wtpKbConnector.registerResource(fsfCResource);
- } catch(Exception e) {
- ProblemReportingHelper.reportProblem(JspEditorPlugin.PLUGIN_ID, "ERROR:
Can't create WtpKbConnector.", e);
- }
- }
- return wtpKbConnector;
- }
-
- private void registerToTldManager(ITextViewer viewer,IDOMNode node) {
- if((tldManager==null) && (viewer instanceof VpeTaglibManagerProvider)) {
- tldManager = ((VpeTaglibManagerProvider)viewer).getTaglibManager();
- tldManager.setReferenceNode(node);
- if(tldManager!=null) {
- tldManager.addTaglibListener(this);
- updateActiveContentAssistProcessor(document);
- }
- } else if(tldManager!=null) {
- tldManager.setReferenceNode(node);
- updateActiveContentAssistProcessor(document);
- }
- }
-
- public void taglibPrefixChanged(String[] prefixs) {
- updateActiveContentAssistProcessor(document);
- }
-
- public void addTaglib(String uri, String prefix) {
- }
-
- public void removeTaglib(String uri, String prefix) {
- }
-
- public static void registerTld(TaglibData data, JspWtpKbConnector wtpKbConnector,
IDocument document, IEditorInput input) {
- TLDRegisterHelper.registerTld(data, wtpKbConnector, document, input);
- }
-
- public void updateActiveContentAssistProcessor(IDocument document) {
- if(tldManager==null) {
- TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(document);
- if (manager != null) {
- List list = manager.getTaglibTrackers();
- for(int i=0; i<list.size(); i++) {
- TaglibTracker tracker = (TaglibTracker)list.get(i);
- String version = TLDVersionHelper.getTldVersion(tracker);
- KbTldResource resource = new KbTldResource(tracker.getURI(), "",
tracker.getPrefix(), version);
- getWtpKbConnector().registerResource(resource);
- }
- }
- } else {
- List list = tldManager.getTagLibs();
- if(list==null) {
- return;
- }
- ((JspWtpKbConnector)getWtpKbConnector()).unregisterAllResources(true);
- isFacelets = false;
- for(int i=0; i<list.size(); i++) {
- TaglibData data = (TaglibData)list.get(i);
- registerTld(data, (JspWtpKbConnector)getWtpKbConnector(), document, editorInput);
- isFacelets = isFacelets || data.getUri().equals(faceletUri);
- }
- if(isFacelets) {
- getWtpKbConnector().registerResource(faceletHtmlResource);
- ((JspWtpKbConnector)getWtpKbConnector()).unregisterJspResource();
- }
- }
- }
-
- public char[] getCompletionProposalAutoActivationCharacters() {
- char[] autoActivChars = null;
- char[] superAutoActivChars = super.getCompletionProposalAutoActivationCharacters();
- if(superAutoActivChars==null) {
- return superAutoActivChars;
- }
-
- autoActivChars = superAutoActivChars;
- IPreferenceStore store = HTMLUIPlugin.getDefault().getPreferenceStore();
- if(store.isDefault(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE)) {
-// String superDefaultChars =
store.getDefaultString(JSPUIPreferenceNames.AUTO_PROPOSE_CODE);
- StringBuffer redhatDefaultChars = new StringBuffer(new String(superAutoActivChars));
- if(redhatDefaultChars.indexOf(".")<0) {
- redhatDefaultChars.append('.');
- store.setDefault(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE,
redhatDefaultChars.toString());
- store.setValue(HTMLUIPreferenceNames.AUTO_PROPOSE_CODE,
redhatDefaultChars.toString());
- }
- autoActivChars = new char[redhatDefaultChars.length()];
- redhatDefaultChars.getChars(0, redhatDefaultChars.length(), autoActivChars, 0);
- }
-
- return autoActivChars;
- }
-
- protected void init() {
- super.init();
- jspActiveCAP = new JSPActiveContentAssistProcessor();
- jspActiveCAP.init();
- }
-
-
- /**
- * StructuredTextViewer must be set before using this.
- */
- public IStructuredDocumentRegion getStructuredDocumentRegion(int pos) {
- IStructuredDocumentRegion sdRegion =
ContentAssistUtils.getStructuredDocumentRegion(fTextViewer, pos);
- ITextRegion region = (sdRegion == null ? null :
sdRegion.getRegionAtCharacterOffset(pos));
- if (region == null) {
- return null;
- }
-
- if (region.getType() == DOMRegionContext.XML_TAG_OPEN &&
- sdRegion.getStartOffset(region) == pos) {
- // The offset is at the beginning of the region
- if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset()) &&
(sdRegion.getPrevious() != null) && (!sdRegion.getPrevious().isEnded())) {
- // Is the region also the start of the node? If so, the
- // previous IStructuredDocumentRegion is
- // where to look for a useful region.
- sdRegion = sdRegion.getPrevious();
- }
- else {
- // Is there no separating whitespace from the previous region?
- // If not,
- // then that region is the important one
- ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(pos - 1);
- if ((previousRegion != null) && (previousRegion != region) &&
(previousRegion.getTextLength() == previousRegion.getLength())) {
- sdRegion = sdRegion.getPrevious();
- }
- }
- }
-
- return sdRegion;
- }
-
-}
\ No newline at end of file
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatJSPContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatJSPContentAssistProcessor.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatJSPContentAssistProcessor.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -1,712 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.contentassist;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-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;
-import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
-import org.eclipse.jst.jsp.core.internal.regions.DOMJSPRegionContexts;
-import org.eclipse.jst.jsp.core.text.IJSPPartitions;
-import org.eclipse.jst.jsp.ui.internal.JSPUIPlugin;
-import org.eclipse.jst.jsp.ui.internal.contentassist.JSPContentAssistProcessor;
-import org.eclipse.jst.jsp.ui.internal.preferences.JSPUIPreferenceNames;
-import org.eclipse.jst.jsp.ui.internal.templates.TemplateContextTypeIdsJSP;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor;
-import org.eclipse.wst.html.core.text.IHTMLPartitions;
-import
org.eclipse.wst.javascript.ui.internal.common.contentassist.JavaScriptContentAssistProcessor;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentAssistUtilities;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentModelGenerator;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
-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.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-import org.jboss.tools.common.kb.KbConnectorFactory;
-import org.jboss.tools.common.kb.KbConnectorType;
-import org.jboss.tools.common.kb.KbException;
-import org.jboss.tools.common.kb.KbProposal;
-import org.jboss.tools.common.kb.KbTldResource;
-import org.jboss.tools.common.kb.TagDescriptor;
-import org.jboss.tools.common.kb.wtp.TLDVersionHelper;
-import org.jboss.tools.common.kb.wtp.WtpKbConnector;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.web.project.WebProject;
-import org.jboss.tools.jst.web.tld.TaglibData;
-import org.jboss.tools.jst.web.tld.VpeTaglibListener;
-import org.jboss.tools.jst.web.tld.VpeTaglibManager;
-import org.jboss.tools.jst.web.tld.VpeTaglibManagerProvider;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * @author Igels
- */
-public class RedHatJSPContentAssistProcessor extends JSPContentAssistProcessor{
-
- private JSPActiveContentAssistProcessor jspActiveCAP;
- private WtpKbConnector wtpKbConnector;
- private IDocument document;
- private boolean dontOpenTag = false;
-
-
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int
documentPosition) {
- try {
- String text = viewer.getDocument().get(0, documentPosition);
- int lastOpenTag = text.lastIndexOf('<');
- int lastCloseTag = text.lastIndexOf('>');
- dontOpenTag = lastCloseTag<lastOpenTag;
- } catch (Exception e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
-
- document = viewer.getDocument();
- //added by Max Areshkau JBIDE-788
- updateActiveContentAssistProcessor(document);
- ICompletionProposal[] proposals = super.computeCompletionProposals(viewer,
documentPosition);
- // If proposal list from super is empty to try to get it from Red Hat dinamic jsp
content assist processor.
- try {
- if(proposals.length == 0) {
- String partitionType = getPartitionType((StructuredTextViewer) viewer,
documentPosition);
- IContentAssistProcessor p = (IContentAssistProcessor)
fPartitionToProcessorMap.get(partitionType);
- if (!(p instanceof JavaScriptContentAssistProcessor || p instanceof
CSSContentAssistProcessor)) {
-
- IndexedRegion treeNode = ContentAssistUtils.getNodeAt((StructuredTextViewer) viewer,
documentPosition);
- Node node = (Node) treeNode;
-
- while (node != null && node.getNodeType() == Node.TEXT_NODE &&
node.getParentNode() != null)
- node = node.getParentNode();
- IDOMNode xmlnode = (IDOMNode) node;
- if(xmlnode!=null) {
- fTextViewer = viewer;
- IStructuredDocumentRegion sdRegion =
getStructuredDocumentRegion(documentPosition);
- ITextRegion completionRegion = getCompletionRegion(documentPosition, node);
- if(completionRegion!=null) {
- String matchString = getMatchString(sdRegion, completionRegion,
documentPosition);
- ContentAssistRequest contentAssistRequest =
computeCompletionProposals(documentPosition, matchString, completionRegion, (IDOMNode)
treeNode, xmlnode);
- if(contentAssistRequest!=null) {
- proposals = contentAssistRequest.getCompletionProposals();
- }
- }
- }
- }
- }
- } catch (Exception e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- proposals = getUniqProposals(proposals);
- return proposals;
- }
-
- public static ICompletionProposal[] getUniqProposals(ICompletionProposal[] proposals) {
- ArrayList uniqProposals = new ArrayList(proposals.length);
- HashSet displayStrings = new HashSet(proposals.length);
- for(int i=0; i<proposals.length; i++) {
- String str = proposals[i].getDisplayString();
- if(str==null || !displayStrings.contains(str)) {
- displayStrings.add(str);
- uniqProposals.add(proposals[i]);
- }
- }
- return (ICompletionProposal[])uniqProposals.toArray(new
ICompletionProposal[uniqProposals.size()]);
- }
-
- /**
- * int map that points [partition > processor]. This takes place of
- * embedded adapters for now.
- */
- protected void initPartitionToProcessorMap() {
- super.initPartitionToProcessorMap();
- }
-
- public char[] getCompletionProposalAutoActivationCharacters() {
- char[] autoActivChars = null;
- char[] superAutoActivChars = super.getCompletionProposalAutoActivationCharacters();
- if(superAutoActivChars==null) {
- return superAutoActivChars;
- }
-
- autoActivChars = superAutoActivChars;
- IPreferenceStore store = JSPUIPlugin.getDefault().getPreferenceStore();
- if(store.isDefault(JSPUIPreferenceNames.AUTO_PROPOSE_CODE)) {
-// String superDefaultChars =
store.getDefaultString(JSPUIPreferenceNames.AUTO_PROPOSE_CODE);
- StringBuffer redhatDefaultChars = new StringBuffer(new String(superAutoActivChars));
- if(redhatDefaultChars.indexOf(".")<0) {
- redhatDefaultChars.append('.');
- store.setDefault(JSPUIPreferenceNames.AUTO_PROPOSE_CODE,
redhatDefaultChars.toString());
- store.setValue(JSPUIPreferenceNames.AUTO_PROPOSE_CODE,
redhatDefaultChars.toString());
- }
- autoActivChars = new char[redhatDefaultChars.length()];
- redhatDefaultChars.getChars(0, redhatDefaultChars.length(), autoActivChars, 0);
- }
-
- return autoActivChars;
- }
-
- public void updateActiveContentAssistProcessor(IDocument document) {
- TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(document);
- if (manager != null) {
- List list = manager.getTaglibTrackers();
- for(int i=0; i<list.size(); i++) {
- TaglibTracker tracker = (TaglibTracker)list.get(i);
-
- String version = TLDVersionHelper.getTldVersion(tracker);
- KbTldResource resource = new KbTldResource(tracker.getURI(), "",
tracker.getPrefix(), version);
- getWtpKbConnector().registerResource(resource);
- addActiveContentAssistProcessorToProcessorMap(tracker.getURI(),
tracker.getPrefix(), version);
- }
- }
- }
-
- private void addActiveContentAssistProcessorToProcessorMap(String uri, String prefix,
String version) {
- try {
- List names = getWtpKbConnector().getAllTagNamesFromTldByUri(uri, version);
- for(Iterator iter = names.iterator(); iter.hasNext();) {
- String fullName = prefix + ":" + iter.next();
- fNameToProcessorMap.put(fullName, jspActiveCAP);
- }
- } catch (KbException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- }
-
- private WtpKbConnector getWtpKbConnector() {
- if(wtpKbConnector == null && document != null) {
- try {
- wtpKbConnector =
(WtpKbConnector)KbConnectorFactory.getIntstance().createConnector(KbConnectorType.JSP_WTP_KB_CONNECTOR,
document);
- jspActiveCAP.setKbConnector(wtpKbConnector);
- } catch (ClassNotFoundException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- } catch (InstantiationException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- } catch (IllegalAccessException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- }
- return wtpKbConnector;
- }
-
- protected void init() {
- super.init();
- jspActiveCAP = new JSPActiveContentAssistProcessor();
- jspActiveCAP.init();
- }
-
- public XMLContentModelGenerator getContentGenerator() {
- if (fGenerator == null){
- fGenerator = new XMLContentModelGenerator(){
- public void generateTag(Node parent, CMElementDeclaration elementDecl, StringBuffer
buffer) {
- if (elementDecl == null || buffer == null) {
- return;
- }
- try {
- String tagName = getRequiredName(parent, elementDecl);
- TagDescriptor info = getWtpKbConnector().getTagInformation("/" + tagName
+ "/");
- if (info != null) {
- KbProposal proposal = info.generateProposal();
- String replString = proposal.getReplacementString();
- boolean hasBody = info.hasBody();
-
- if (replString != null && replString.length() > 0) {
- if(!dontOpenTag) {
- buffer.append("<");
- }
- buffer.append(replString);
- buffer.append(">");
- if (hasBody) {
- buffer.append("</");
- buffer.append(tagName);
- buffer.append(">");
- }
- return;
- }
- }
- } catch (Exception x) {
- JspEditorPlugin.getPluginLog().logError("", x);
- }
- super.generateTag(parent, elementDecl, buffer);
- return;
- }
- };
- }
- return fGenerator;
- }
-
- protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int
childPosition) {
- List cmnodes = null;
- Node parent = contentAssistRequest.getParent();
- String error = null;
-
- if (parent != null && parent.getNodeType() == Node.DOCUMENT_NODE &&
((IDOMDocument) parent).isXMLType() && !isCursorAfterXMLPI(contentAssistRequest))
{
- return;
- }
- // only want proposals if cursor is after doctype...
- if (!isCursorAfterDoctype(contentAssistRequest))
- return;
-
- if (parent != null && parent instanceof IDOMNode &&
isCommentNode((IDOMNode) parent)) {
- // loop and find non comment node?
- while (parent != null && isCommentNode((IDOMNode) parent)) {
- parent = parent.getParentNode();
- }
- }
-
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- CMElementDeclaration parentDecl = getCMElementDeclaration(parent);
- if (parentDecl != null) {
- // XSD-specific ability - no filtering
- CMDataType childType = parentDecl.getDataType();
- if (childType != null) {
- String[] childStrings = childType.getEnumeratedValues();
- if (childStrings != null) {
- // the content string is the sole valid child...so
- // replace the rest
- int begin = contentAssistRequest.getReplacementBeginPosition();
- int length = contentAssistRequest.getReplacementLength();
- if (parent instanceof IDOMNode) {
- if (((IDOMNode) parent).getLastStructuredDocumentRegion() != ((IDOMNode)
parent).getFirstStructuredDocumentRegion()) {
- begin = ((IDOMNode) parent).getFirstStructuredDocumentRegion().getEndOffset();
- length = ((IDOMNode) parent).getLastStructuredDocumentRegion().getStartOffset() -
begin;
- }
- }
- String proposedInfo = getAdditionalInfo(parentDecl, childType);
- for (int i = 0; i < childStrings.length; i++) {
- CustomCompletionProposal textProposal = new
RedHatCustomCompletionProposal(childStrings[i].indexOf("=")>-1,
childStrings[i], begin, length, childStrings[i].length(),
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENUM),
childStrings[i], null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
- contentAssistRequest.addProposal(textProposal);
- }
- }
- }
- }
- if (parentDecl != null && parentDecl.getContentType() ==
CMElementDeclaration.PCDATA) {
- addPCDATAProposal(parentDecl.getNodeName(), contentAssistRequest);
- }
- else {
- // retrieve the list of all possible children within this parent context
- cmnodes = getAvailableChildElementDeclarations((Element)parent, childPosition,
ModelQueryAction.INSERT);
-
- // retrieve the list of the possible children within this parent context
and at this index
- List strictCMNodeSuggestions = null;
- if
(XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_STRICT.equals(XMLUIPlugin.getInstance().getPreferenceStore().getString(XMLUIPreferenceNames.SUGGESTION_STRATEGY)))
- {
- strictCMNodeSuggestions =
getValidChildElementDeclarations((Element)parent, childPosition, ModelQueryAction.INSERT);
- }
- Iterator nodeIterator = cmnodes.iterator();
- if (!nodeIterator.hasNext()) {
- if (getCMElementDeclaration(parent) != null)
- error = NLS.bind(XMLUIMessages._Has_no_available_child, (new
Object[]{parent.getNodeName()}));
- else
- error = NLS.bind(XMLUIMessages.Element__is_unknown, (new
Object[]{parent.getNodeName()}));
- }
- String matchString = contentAssistRequest.getMatchString();
- // chop off any leading <'s and whitespace from the
- // matchstring
- while ((matchString.length() > 0) &&
(Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString,
"<"))) //$NON-NLS-1$
- //$NON-NLS-1$
- matchString = matchString.substring(1);
- while (nodeIterator.hasNext()) {
- Object o = nodeIterator.next();
- if (o instanceof CMElementDeclaration) {
- CMElementDeclaration elementDecl = (CMElementDeclaration) o;
- // only add proposals for the child element's that
- // begin with the matchstring
- String tagname = getRequiredName(parent, elementDecl);
- boolean isStrictCMNodeSuggestion = strictCMNodeSuggestions !=
null ? strictCMNodeSuggestions.contains(elementDecl) : false;
-
- Image image = CMImageUtil.getImage(elementDecl);
-
- if (image == null) {
- if (strictCMNodeSuggestions != null) {
- image = isStrictCMNodeSuggestion ?
-
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC_EMPHASIZED)
:
-
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC_DEEMPHASIZED);
- }
- else {
- image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
-
- }
- // Account for the < and >. If attributes were
- // added, the cursor will be placed
- // at the offset before of the first character of the
- // first attribute name.
-// int markupAdjustment = getContentGenerator().getMinimalStartTagLength(parent,
elementDecl);
- if (beginsWith(tagname, matchString)) {
- String proposedText = getRequiredText(parent, elementDecl);
-
- int markupAdjustment = getCursorPositionForProposedText(proposedText);
-
- String proposedInfo = getAdditionalInfo(parentDecl, elementDecl);
- int relevance = isStrictCMNodeSuggestion ?
XMLRelevanceConstants.R_STRICTLY_VALID_TAG_INSERTION :
XMLRelevanceConstants.R_TAG_INSERTION;
- CustomCompletionProposal proposal = new RedHatCustomCompletionProposal(true,
proposedText, contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null,
proposedInfo, relevance);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- if (contentAssistRequest.getProposals().size() == 0) {
- if (error != null)
- setErrorMessage(error);
- else if (contentAssistRequest.getMatchString() != null &&
contentAssistRequest.getMatchString().length() > 0)
- setErrorMessage(NLS.bind(XMLUIMessages.No_known_child_tag, (new
Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()})));
- //$NON-NLS-1$ = "No known child tag names of <{0}> begin with
\"{1}\"."
- else
- setErrorMessage(NLS.bind(XMLUIMessages.__Has_no_known_child, (new
Object[]{parent.getNodeName()})));
- }
- }
- }
- else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
- // Can only prompt with elements if the cursor position is past
- // the XML processing
- // instruction and DOCTYPE declaration
- boolean xmlpiFound = false;
- boolean doctypeFound = false;
- int minimumOffset = -1;
-
- for (Node child = parent.getFirstChild(); child != null; child =
child.getNextSibling()) {
-
- boolean xmlpi = (child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE &&
child.getNodeName().equals("xml")); //$NON-NLS-1$
- boolean doctype = child.getNodeType() == Node.DOCUMENT_TYPE_NODE;
- if (xmlpi || doctype && minimumOffset < 0)
- minimumOffset = ((IDOMNode)
child).getFirstStructuredDocumentRegion().getStartOffset() + ((IDOMNode)
child).getFirstStructuredDocumentRegion().getTextLength();
- xmlpiFound = xmlpiFound || xmlpi;
- doctypeFound = doctypeFound || doctype;
- }
-
- if (contentAssistRequest.getReplacementBeginPosition() >= minimumOffset) {
- List childDecls = getAvailableRootChildren((Document) parent, childPosition);
- for (int i = 0; i < childDecls.size(); i++) {
- CMElementDeclaration ed = (CMElementDeclaration) childDecls.get(i);
- if (ed != null) {
- Image image = CMImageUtil.getImage(ed);
- if (image == null) {
- image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- String proposedText = getRequiredText(parent, ed);
- String tagname = getRequiredName(parent, ed);
- // account for the < and >
- int markupAdjustment = getContentGenerator().getMinimalStartTagLength(parent, ed);
- String proposedInfo = getAdditionalInfo(null, ed);
- CustomCompletionProposal proposal = new RedHatCustomCompletionProposal(false,
proposedText, contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null,
proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
-
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
- }
-
- // WTP
- private int getCursorPositionForProposedText(String proposedText) {
- int cursorAdjustment;
- cursorAdjustment = proposedText.indexOf("\"\"") + 1; //$NON-NLS-1$
- // otherwise, after the first tag
- if(cursorAdjustment==0)
- cursorAdjustment = proposedText.indexOf('>') + 1;
- if(cursorAdjustment==0)
- cursorAdjustment = proposedText.length() + 1;
-
- return cursorAdjustment;
- }
-
- protected void addTagNameProposals(ContentAssistRequest contentAssistRequest, int
childPosition) {
- List cmnodes = null;
- Node parent = contentAssistRequest.getParent();
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
- String error = null;
- String matchString = contentAssistRequest.getMatchString();
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- // retrieve the list of children
- cmnodes = getAvailableChildElementDeclarations((Element)parent, childPosition,
ModelQueryAction.INSERT);
- Iterator nodeIterator = cmnodes.iterator();
- // chop off any leading <'s and whitespace from the matchstring
- while ((matchString.length() > 0) &&
(Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString,
"<"))) //$NON-NLS-1$
- //$NON-NLS-1$
- matchString = matchString.substring(1);
- if (!nodeIterator.hasNext())
- error = NLS.bind(XMLUIMessages.__Has_no_known_child, (new
Object[]{parent.getNodeName()}));
- while (nodeIterator.hasNext()) {
- CMNode elementDecl = (CMNode) nodeIterator.next();
- if (elementDecl != null) {
- // only add proposals for the child element's that begin
- // with the matchstring
- String proposedText = null;
- int cursorAdjustment = 0;
-
- // do a check to see if partial attributes of partial tag
- // names are in list
- if ((node != null && node.getAttributes() != null &&
node.getAttributes().getLength() > 0 && attributeInList(node, parent,
elementDecl)) || ((node.getNodeType() != Node.TEXT_NODE) &&
node.getFirstStructuredDocumentRegion().isEnded())) {
-
- proposedText = getRequiredName(parent, elementDecl);
- cursorAdjustment = proposedText.length();
- }
- else {
- proposedText = getRequiredName(parent, elementDecl);
-
- StringBuffer buffer = new StringBuffer();
- KbProposal proposal;
- TagDescriptor info;
- try {
- proposal = getWtpKbConnector().getProposal("/" +
proposedText);
- info = getWtpKbConnector().getTagInformation("/" +
proposedText + "/");
- if (proposal != null && info != null) {
- String replString = proposal.getReplacementString();
- boolean hasBody = info.hasBody();
-
- if (replString != null && replString.length() > 0) {
- if(!dontOpenTag) {
- buffer.append("<");
- }
- buffer.append(replString);
- buffer.append(">");
- if (hasBody) {
- buffer.append("</");
- buffer.append(proposedText);
- buffer.append(">");
- }
- proposedText = buffer.toString();
- }
- } else {
- if(elementDecl instanceof CMElementDeclaration) {
- cursorAdjustment = proposedText.length();
- if (elementDecl instanceof CMElementDeclaration) {
- CMElementDeclaration ed = (CMElementDeclaration) elementDecl;
- if (ed.getContentType() == CMElementDeclaration.EMPTY) {
- proposedText += getContentGenerator().getStartTagClose(parent, ed);
- cursorAdjustment = proposedText.length();
- }
- else {
- cursorAdjustment = proposedText.length() + 1;
- proposedText += "></" + getRequiredName(parent, elementDecl) +
">"; //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
- } catch (KbException e) {
- JspEditorPlugin.getPluginLog().logError(e);
- }
- }
- if (beginsWith(proposedText, matchString) || beginsWith(proposedText,
"<" + matchString)) {
- Image image = CMImageUtil.getImage(elementDecl);
- if (image == null) {
- image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- String proposedInfo = getAdditionalInfo(getCMElementDeclaration(parent),
elementDecl);
- CustomCompletionProposal proposal = new
RedHatCustomCompletionProposal(proposedText.indexOf('\"')>-1 &&
proposedText.indexOf("=")>-1, proposedText,
contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), cursorAdjustment, image,
getRequiredName(parent, elementDecl), null, proposedInfo,
XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- if (contentAssistRequest.getProposals().size() == 0) {
- if (error != null)
- setErrorMessage(error);
- else if (contentAssistRequest.getMatchString() != null &&
contentAssistRequest.getMatchString().length() > 0)
- setErrorMessage(NLS.bind(XMLUIMessages.No_known_child_tag_names, (new
Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()})));
- //$NON-NLS-1$ = "No known child tag names of <{0}> begin with
\"{1}\""
- else
- setErrorMessage(NLS.bind(XMLUIMessages.__Has_no_known_child, (new
Object[]{parent.getNodeName()})));
- }
- }
- else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
- List childElements = getAvailableRootChildren((Document) parent, childPosition);
- for (int i = 0; i < childElements.size(); i++) {
- CMNode ed = (CMNode) childElements.get(i);
- if (ed == null)
- continue;
- String proposedText = null;
- int cursorAdjustment = 0;
- if(ed instanceof CMElementDeclaration) {
- // proposedText = getRequiredName(parent, ed);
- StringBuffer sb = new StringBuffer();
- getContentGenerator().generateTag(parent, (CMElementDeclaration)ed, sb);
- // tag starts w/ '<', but we want to compare to name
- proposedText = sb.toString().substring(1);
-
- if (!beginsWith(proposedText, matchString))
- continue;
-
- cursorAdjustment = getCursorPositionForProposedText(proposedText);
-
- if (ed instanceof CMElementDeclaration) {
- CMElementDeclaration elementDecl = (CMElementDeclaration) ed;
- if (elementDecl.getContentType() == CMElementDeclaration.EMPTY) {
- proposedText += getContentGenerator().getStartTagClose(parent, elementDecl);
- cursorAdjustment = proposedText.length();
- }
- }
-
- String proposedInfo = getAdditionalInfo(null, ed);
- Image image = CMImageUtil.getImage(ed);
- if (image == null) {
- image =
XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- CustomCompletionProposal proposal = new
RedHatCustomCompletionProposal(proposedText.indexOf('\"')>-1,
proposedText, contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), cursorAdjustment, image,
getRequiredName(parent, ed), null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
-
- private boolean isCommentNode(IDOMNode node) {
- return (node != null && node instanceof IDOMElement && ((IDOMElement)
node).isCommentTag());
- }
-
- protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
-
- // JBIDE-1717 Workaround:
- // The WTP processes the Attribute Containers in a different way comparing to how it
does for
- // the simple attributes.
- // Also the whitespace-text placed after the attribute value is the part of that
attribute value.
- // These facts both are the reason of the JBIDE-1717 issue appeared.
- // This workaround tries to add the attribute name proposals in case of WTP itself
doesn't adds them
- // because it faced the attribute container (In other words, some JSF-variable is used
as the
- // attribute's value
- if (fViewer != null) {
- int documentPosition = contentAssistRequest.getReplacementBeginPosition();
- // check the actual partition type
- String partitionType = getPartitionType((StructuredTextViewer) fViewer,
documentPosition);
-
- IStructuredDocument structuredDocument = (IStructuredDocument) fViewer.getDocument();
- IStructuredDocumentRegion fn =
structuredDocument.getRegionAtCharacterOffset(documentPosition);
- // check if it's in an attribute value, if so, don't add CDATA
- // proposal
- ITextRegion attrContainer = (fn != null) ?
fn.getRegionAtCharacterOffset(documentPosition) : null;
- boolean doPerformProposalsComputing = false;
-
- if (attrContainer != null && attrContainer instanceof ITextRegionContainer) {
- if (attrContainer.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- // test location of the cursor
- // return null if it's in the middle of an open/close
- // delimeter
- Iterator attrRegions = ((ITextRegionContainer)
attrContainer).getRegions().iterator();
- ITextRegion testRegion = null;
- while (attrRegions.hasNext()) {
- testRegion = (ITextRegion) attrRegions.next();
- // need to check for other valid attribute regions
- if (XMLContentAssistUtilities.isJSPOpenDelimiter(testRegion.getType())) {
- if (!(((ITextRegionContainer) attrContainer).getEndOffset(testRegion) <=
documentPosition))
- break;
- }
- else if (XMLContentAssistUtilities.isJSPCloseDelimiter(testRegion.getType())) {
- if (!(((ITextRegionContainer) attrContainer).getStartOffset(testRegion) >=
documentPosition))
- break;
- }
- }
- if (!(testRegion.getType().equals(DOMJSPRegionContexts.JSP_CONTENT)))
- doPerformProposalsComputing = true;
- }
- }
- //
-
- if (doPerformProposalsComputing) {
- ICompletionProposal[] embeddedResults = null;
- IContentAssistProcessor p = (IContentAssistProcessor)
fPartitionToProcessorMap.get(partitionType);
- if (p != null) {
- embeddedResults = p.computeCompletionProposals(fViewer, documentPosition);
- // TODO: Probably it's needed to get bean methods, objects, and constants if
there are any...
- // as it's done in JSPContentAssistProcessor but...
- }
- else {
- // the partition type is probably not mapped
- }
- for (int i = 0; embeddedResults != null && i < embeddedResults.length;
i++)
- contentAssistRequest.addProposal(embeddedResults[i]);
- }
- }
- super.addAttributeNameProposals(contentAssistRequest);
- }
-
- protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
- // JBIDE-1704:
- // Check the position in the value:
- // The following position:
- // <nodeName attrName="attrValue"| .../>
- // is marked as attribute value, but the value itself is complete.
- // There are no proposals to be correct at this position.
-
- String text = contentAssistRequest.getText();
- String matchString = contentAssistRequest.getMatchString();
-
- if (matchString.length() > StringUtils.strip(text).length() &&
- ( (matchString.startsWith("\"") &&
matchString.endsWith("\"") &&
- (matchString.indexOf("\"") !=
matchString.lastIndexOf("\"")))
- || (matchString.startsWith("'") &&
matchString.endsWith("\"") &&
- (matchString.indexOf("\"") !=
matchString.lastIndexOf("\""))))) {
- return;
- }
-
- super.addAttributeValueProposals(contentAssistRequest);
- }
-
- /**
- * StructuredTextViewer must be set before using this.
- */
- public IStructuredDocumentRegion getStructuredDocumentRegion(int pos) {
- IStructuredDocumentRegion sdRegion =
ContentAssistUtils.getStructuredDocumentRegion(fTextViewer, pos);
- ITextRegion region = (sdRegion == null ? null :
sdRegion.getRegionAtCharacterOffset(pos));
- if (region == null) {
- return null;
- }
-
- if (region.getType() == DOMRegionContext.XML_TAG_OPEN &&
- sdRegion.getStartOffset(region) == pos) {
- // The offset is at the beginning of the region
- if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset()) &&
(sdRegion.getPrevious() != null) && (!sdRegion.getPrevious().isEnded())) {
- // Is the region also the start of the node? If so, the
- // previous IStructuredDocumentRegion is
- // where to look for a useful region.
- sdRegion = sdRegion.getPrevious();
- }
- else {
- // Is there no separating whitespace from the previous region?
- // If not,
- // then that region is the important one
- ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(pos - 1);
- if ((previousRegion != null) && (previousRegion != region) &&
(previousRegion.getTextLength() == previousRegion.getLength())) {
- sdRegion = sdRegion.getPrevious();
- }
- }
- }
-
- return sdRegion;
- }
-
-}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -104,8 +104,8 @@
import org.jboss.tools.common.text.xml.IOccurrencePreferenceProvider;
import org.jboss.tools.common.text.xml.XmlEditorPlugin;
import org.jboss.tools.common.text.xml.ui.FreeCaretStyledText;
-import org.jboss.tools.jst.jsp.ExtendedStructuredTextViewerConfigurationHTML;
-import org.jboss.tools.jst.jsp.ExtendedStructuredTextViewerConfigurationJSP;
+import org.jboss.tools.jst.jsp.HTMLTextViewerConfiguration;
+import org.jboss.tools.jst.jsp.JSPTextViewerConfiguration;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.editor.IJSPTextEditor;
import org.jboss.tools.jst.jsp.editor.ITextFormatter;
@@ -153,20 +153,20 @@
dnd.setTextEditorDropProvider(new TextEditorDropProviderImpl());
this.parentEditor = parentEditor;
super
- .setSourceViewerConfiguration(new ExtendedStructuredTextViewerConfigurationJSP());
+ .setSourceViewerConfiguration(new JSPTextViewerConfiguration());
}
protected void setSourceViewerConfiguration(SourceViewerConfiguration config) {
if (config instanceof StructuredTextViewerConfigurationJSP) {
- if (!(config instanceof ExtendedStructuredTextViewerConfigurationJSP)) {
- config = new ExtendedStructuredTextViewerConfigurationJSP();
+ if (!(config instanceof JSPTextViewerConfiguration)) {
+ config = new JSPTextViewerConfiguration();
}
} else if (config instanceof StructuredTextViewerConfigurationHTML) {
- if (!(config instanceof ExtendedStructuredTextViewerConfigurationHTML)) {
- config = new ExtendedStructuredTextViewerConfigurationHTML();
+ if (!(config instanceof HTMLTextViewerConfiguration)) {
+ config = new HTMLTextViewerConfiguration();
}
} else {
- config = new ExtendedStructuredTextViewerConfigurationJSP();
+ config = new JSPTextViewerConfiguration();
}
super.setSourceViewerConfiguration(config);
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -24,7 +24,7 @@
import org.eclipse.ui.contentassist.ContentAssistHandler;
import org.jboss.tools.common.meta.key.WizardKeys;
import org.jboss.tools.jst.jsp.contentassist.JSPDialogCellEditorContentAssistProcessor;
-import org.jboss.tools.jst.jsp.contentassist.RedHatHtmlContentAssistProcessor;
+import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.RootElement;
/**
@@ -66,7 +66,7 @@
String nodeName = "" + context.getProperty("nodeName");
String query = "/";
if(valueHelper.isFacetets() && nodeName.indexOf(':') < 0) {
- query += RedHatHtmlContentAssistProcessor.faceletHtmlPrefixStart;
+ query += FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart;
}
query += nodeName + "@" + attributeName;
RootElement root = (RootElement)valueHelper.getInitalInput(query);
@@ -89,7 +89,7 @@
String nodeName = "" + context.getProperty("nodeName");
String query = "/";
if(valueHelper != null && valueHelper.isFacetets() &&
nodeName.indexOf(":") < 0) {
- query += RedHatHtmlContentAssistProcessor.faceletHtmlPrefixStart;
+ query += FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart;
}
query += nodeName + "@" + attributeName;
context.setProperty("query", query);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -36,7 +36,7 @@
import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
import org.eclipse.wst.xml.ui.internal.properties.EnumeratedStringPropertyDescriptor;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.contentassist.RedHatHtmlContentAssistProcessor;
+import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
import org.jboss.tools.jst.jsp.editor.IVisualController;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
@@ -126,8 +126,8 @@
jsfTagName = valueHelper.getFaceletJsfTag((Element)fNode);
}
if(jsfTagName != null) tagName = jsfTagName;
- if(jsfTagName == null && valueHelper.isFacetets() &&
tagName.indexOf(':') < 0 &&
!RedHatHtmlContentAssistProcessor.JSFCAttributeName.equals(attributeName)) {
- tagName = RedHatHtmlContentAssistProcessor.faceletHtmlPrefixStart + tagName;
+ if(jsfTagName == null && valueHelper.isFacetets() &&
tagName.indexOf(':') < 0 &&
!FaceletsHtmlContentAssistProcessor.JSFCAttributeName.equals(attributeName)) {
+ tagName = FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart + tagName;
}
return "/" + tagName + "@" + attributeName;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/ValueHelper.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -46,7 +46,7 @@
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.util.ModelFeatureFactory;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
-import org.jboss.tools.jst.jsp.contentassist.RedHatHtmlContentAssistProcessor;
+import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.AttributeValueResource;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.AttributeValueResourceFactory;
import org.jboss.tools.jst.jsp.drop.treeviewer.model.ModelElement;
@@ -325,11 +325,11 @@
kbConnector.unregisterAllResources(true);
for(int i = 0; i < list.size(); i++) {
TaglibData data = list.get(i);
- RedHatHtmlContentAssistProcessor.registerTld(data, kbConnector, document,
editorInput);
- isFacelets = isFacelets ||
data.getUri().equals(RedHatHtmlContentAssistProcessor.faceletUri);
+ FaceletsHtmlContentAssistProcessor.registerTld(data, kbConnector, document,
editorInput);
+ isFacelets = isFacelets ||
data.getUri().equals(FaceletsHtmlContentAssistProcessor.faceletUri);
}
if(isFacelets) {
- kbConnector.registerResource(RedHatHtmlContentAssistProcessor.faceletHtmlResource);
+ kbConnector.registerResource(FaceletsHtmlContentAssistProcessor.faceletHtmlResource);
kbConnector.unregisterJspResource();
}
}
@@ -340,7 +340,7 @@
if(name.indexOf(':') >= 0) return null;
NamedNodeMap attributes = element.getAttributes();
- Node jsfC =
attributes.getNamedItem(RedHatHtmlContentAssistProcessor.JSFCAttributeName);
+ Node jsfC =
attributes.getNamedItem(FaceletsHtmlContentAssistProcessor.JSFCAttributeName);
if(jsfC != null && (jsfC instanceof Attr)) {
Attr jsfCAttribute = (Attr)jsfC;
String jsfTagName = jsfCAttribute.getValue();
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/FaceletsJsfCResource.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/FaceletsJsfCResource.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/FaceletsJsfCResource.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -16,7 +16,7 @@
import java.util.Iterator;
import org.jboss.tools.common.reporting.ProblemReportingHelper;
-import org.jboss.tools.jst.jsp.contentassist.RedHatHtmlContentAssistProcessor;
+import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
import org.jboss.tools.common.kb.KbDinamicResource;
import org.jboss.tools.common.kb.KbException;
import org.jboss.tools.common.kb.KbProposal;
@@ -90,7 +90,7 @@
}
private boolean ignoreProposal(KbProposal proposal) {
- return
proposal.getLabel().startsWith(RedHatHtmlContentAssistProcessor.faceletHtmlPrefixStart) ||
proposal.getLabel().indexOf(':')<0;
+ return
proposal.getLabel().startsWith(FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart)
|| proposal.getLabel().indexOf(':')<0;
}
/**
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1704Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1704Test.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1704Test.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -20,8 +20,8 @@
import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
import org.jboss.tools.common.test.util.TestProjectProvider;
-import org.jboss.tools.jst.jsp.contentassist.RedHatCustomCompletionProposal;
-import org.jboss.tools.jst.jsp.contentassist.RedHatJSPContentAssistProcessor;
+import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
+import org.jboss.tools.jst.jsp.contentassist.ExtendedJSPContentAssistProcessor;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.test.TestUtil;
@@ -169,7 +169,7 @@
for (int k = 0; result != null && k < result.length; k++) {
// There should not be a proposal of type Red.Proposal in the result
- assertFalse("Content Assistant peturned proposals of type (" +
result[k].getClass().getName() + ").", (result[k] instanceof
RedHatCustomCompletionProposal));
+ assertFalse("Content Assistant peturned proposals of type (" +
result[k].getClass().getName() + ").", (result[k] instanceof
AutoContentAssistantProposal));
}
}
}
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1717Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1717Test.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JsfJspJbide1717Test.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -17,7 +17,7 @@
import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.jboss.tools.common.test.util.TestProjectProvider;
-import org.jboss.tools.jst.jsp.contentassist.RedHatCustomCompletionProposal;
+import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.test.TestUtil;
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -24,7 +24,7 @@
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.jboss.tools.common.test.util.TestProjectProvider;
-import org.jboss.tools.jst.jsp.contentassist.RedHatCustomCompletionProposal;
+import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.test.TestUtil;
@@ -147,8 +147,8 @@
assertTrue("Content Assistant peturned no proposals", (result != null
&& result.length > 0));
for (int i = 0; i < result.length; i++) {
- assertTrue("Content Assistant peturned proposals which type (" +
result[i].getClass().getName() + ") differs from
RedHatCustomCompletionProposal", (result[i] instanceof
RedHatCustomCompletionProposal));
- RedHatCustomCompletionProposal proposal = (RedHatCustomCompletionProposal)result[i];
+ assertTrue("Content Assistant peturned proposals which type (" +
result[i].getClass().getName() + ") differs from
RedHatCustomCompletionProposal", (result[i] instanceof
AutoContentAssistantProposal));
+ AutoContentAssistantProposal proposal = (AutoContentAssistantProposal)result[i];
String proposalString = proposal.getReplacementString();
int proposalReplacementOffset = proposal.getReplacementOffset();
int proposalReplacementLength = proposal.getReplacementLength();
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1641Test.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -15,7 +15,7 @@
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.jboss.tools.common.test.util.TestProjectProvider;
-import org.jboss.tools.jst.jsp.contentassist.RedHatCustomCompletionProposal;
+import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.test.TestUtil;
@@ -144,9 +144,9 @@
boolean bPropoosalToApplyFound = false;
for (int i = 0; i < result.length; i++) {
- if (!(result[i] instanceof RedHatCustomCompletionProposal))
+ if (!(result[i] instanceof AutoContentAssistantProposal))
continue;
- RedHatCustomCompletionProposal proposal = (RedHatCustomCompletionProposal)result[i];
+ AutoContentAssistantProposal proposal = (AutoContentAssistantProposal)result[i];
String proposalString = proposal.getReplacementString();
// try {
// System.out.println("Result#" + i + " ==> Offs: " +
offsetToTest + " RedHatCustomCompletionProposal[" + proposalString + "],
Offs: " + proposalReplacementOffset + ", Len: " + proposalReplacementLength
+ ", Doc: [" + document.get(proposalReplacementOffset,
proposalReplacementLength));
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/StrutsJspJbide1648Test.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/StrutsJspJbide1648Test.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/StrutsJspJbide1648Test.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -14,7 +14,7 @@
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
import org.jboss.tools.common.test.util.TestProjectProvider;
-import org.jboss.tools.jst.jsp.contentassist.RedHatCustomCompletionProposal;
+import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.jst.jsp.test.TestUtil;
Modified:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/AbstractResourceMarkerTest.java
===================================================================
---
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/AbstractResourceMarkerTest.java 2008-02-15
10:36:08 UTC (rev 6329)
+++
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/tests/AbstractResourceMarkerTest.java 2008-02-15
10:41:43 UTC (rev 6330)
@@ -27,9 +27,8 @@
*
*/
public AbstractResourceMarkerTest() {
- // TODO Auto-generated constructor stub
}
-
+
/**
*
*/
@@ -53,11 +52,11 @@
return number;
}
-
+
protected void assertMarkerIsCreated(IFile file, MarkerData markerData) throws
CoreException {
assertMarkerIsCreated(file, markerData.type, markerData.pattern, markerData.line);
}
-
+
protected void assertMarkerIsCreated(IFile file, String type, String pattern, int
expectedLine)
throws CoreException {
@@ -70,20 +69,20 @@
assertEquals("Marker matches the '" + pattern + "' pattern was
found at wrong line",
expectedLine,line);
}
-
+
protected void assertMarkersIsCreated(IFile file, MarkerData[] markersData) throws
CoreException {
for (MarkerData markerData : markersData) {
assertMarkerIsCreated(file, markerData);
}
}
-
+
/**
*
* @author eskimo
*
*/
public static class MarkerData {
-
+
private String type;
private String pattern;
private int line = -1;
@@ -93,7 +92,7 @@
this.pattern = pattern;
this.line = line;
}
-
+
public int getLine() {
return line;
}
@@ -117,7 +116,5 @@
public void setPattern(String pattern) {
this.pattern = pattern;
}
-
}
-
-}
+}
\ No newline at end of file