Author: vrubezhny
Date: 2011-08-08 17:22:48 -0400 (Mon, 08 Aug 2011)
New Revision: 33690
Added:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/ChainTextHover.java
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/InfoHoverMessages.java
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/InfoHoverMessages.properties
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/TextHoverInformationProvider.java
Removed:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/TextHoverInformationProvider.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/ChainTextHover.java
Modified:
trunk/common/plugins/org.jboss.tools.common.text.xml/META-INF/MANIFEST.MF
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/jspeditor/info/ELInfoHoverMessages.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/ELInfoHoverMessages.properties
Log:
JBIDE-9448
EL tooltip doesn't work
Issue is fixed.
Modified: trunk/common/plugins/org.jboss.tools.common.text.xml/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.xml/META-INF/MANIFEST.MF 2011-08-08
19:48:27 UTC (rev 33689)
+++ trunk/common/plugins/org.jboss.tools.common.text.xml/META-INF/MANIFEST.MF 2011-08-08
21:22:48 UTC (rev 33690)
@@ -8,6 +8,7 @@
Bundle-Localization: plugin
Export-Package: org.jboss.tools.common.text.xml,
org.jboss.tools.common.text.xml.contentassist,
+ org.jboss.tools.common.text.xml.info,
org.jboss.tools.common.text.xml.internal.ui.preferencies,
org.jboss.tools.common.text.xml.ui,
org.jboss.tools.common.text.xml.ui.xpl,
Modified:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/XMLTextViewerConfiguration.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/XMLTextViewerConfiguration.java 2011-08-08
19:48:27 UTC (rev 33689)
+++
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/XMLTextViewerConfiguration.java 2011-08-08
21:22:48 UTC (rev 33690)
@@ -26,6 +26,7 @@
import org.eclipse.jface.text.ITextHover;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.eclipse.jface.text.information.IInformationProvider;
import org.eclipse.jface.text.quickassist.IQuickAssistAssistant;
import org.eclipse.jface.text.quickassist.QuickAssistAssistant;
import org.eclipse.jface.text.source.ISourceViewer;
@@ -33,22 +34,21 @@
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext;
+import org.eclipse.wst.sse.ui.internal.ExtendedConfigurationBuilder;
import org.eclipse.wst.sse.ui.internal.SSEUIPlugin;
import org.eclipse.wst.sse.ui.internal.derived.HTMLTextPresenter;
import org.eclipse.wst.sse.ui.internal.preferences.EditorPreferenceNames;
import org.eclipse.wst.sse.ui.internal.taginfo.AnnotationHoverProcessor;
-import org.eclipse.wst.sse.ui.internal.taginfo.BestMatchHover;
-import org.eclipse.wst.sse.ui.internal.taginfo.ProblemAnnotationHoverProcessor;
import org.eclipse.wst.sse.ui.internal.taginfo.TextHoverManager;
import org.eclipse.wst.sse.ui.internal.util.EditorUtility;
import org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML;
import
org.eclipse.wst.xml.ui.internal.contentassist.XMLStructuredContentAssistProcessor;
import org.jboss.tools.common.text.xml.contentassist.ProposalSorter;
+import org.jboss.tools.common.text.xml.info.ChainTextHover;
import org.jboss.tools.common.text.xml.xpl.MarkerProblemAnnotationHoverProcessor;
-
+import org.jboss.tools.common.text.xml.info.TextHoverInformationProvider;
/**
* @author Igels
*/
@@ -185,21 +185,76 @@
return findDeclaredMethod(sc, name, paramTypes);
}
+ /**
+ * Create documentation hovers based on hovers contributed via
+ * <code>org.eclipse.wst.sse.ui.editorConfiguration</code> extension point
+ *
+ * Copied from
+ * {@link org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration} because
+ * of private modifier
+ *
+ * @param partitionType
+ * @return
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private ITextHover[] createDocumentationHovers(String partitionType) {
+ List extendedTextHover = ExtendedConfigurationBuilder.getInstance()
+ .getConfigurations(
+ ExtendedConfigurationBuilder.DOCUMENTATIONTEXTHOVER,
+ partitionType);
+ return (ITextHover[]) extendedTextHover
+ .toArray(new ITextHover[extendedTextHover.size()]);
+ }
+
@Override
- public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int
stateMask) {
- TextHoverManager.TextHoverDescriptor[] hoverDescs =
SSEUIPlugin.getDefault().getTextHoverManager().getTextHovers();
+ protected IInformationProvider getInformationProvider(
+ ISourceViewer sourceViewer, String partitionType) {
+ ITextHover[] hovers = createDocumentationHovers(partitionType);
+ if (hovers == null) {
+ hovers = new ITextHover[] {new ChainTextHover(
+ new ITextHover[0])};
+ }
+
+ return new TextHoverInformationProvider(new ChainTextHover(
+ hovers));
+ }
+
+ @Override
+ public ITextHover getTextHover(ISourceViewer sourceViewer,
+ String contentType, int stateMask) {
+ ITextHover textHover = null;
+
+ /*
+ * Returns a default problem, annotation, and best match hover depending
+ * on stateMask
+ */
+ TextHoverManager.TextHoverDescriptor[] hoverDescs = SSEUIPlugin
+ .getDefault().getTextHoverManager().getTextHovers();
int i = 0;
- while (i < hoverDescs.length) {
- if (hoverDescs[i].isEnabled() &&
computeStateMask(hoverDescs[i].getModifierString()) == stateMask) {
+ while (i < hoverDescs.length && textHover == null) {
+ if (hoverDescs[i].isEnabled()
+ && computeStateMask(hoverDescs[i].getModifierString()) == stateMask) {
String hoverType = hoverDescs[i].getId();
- if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType)){
- return new MarkerProblemAnnotationHoverProcessor();
+ if (TextHoverManager.PROBLEM_HOVER.equalsIgnoreCase(hoverType))
+// textHover = new ProblemAnnotationHoverProcessor();
+ textHover = new MarkerProblemAnnotationHoverProcessor();
+ else if (TextHoverManager.ANNOTATION_HOVER
+ .equalsIgnoreCase(hoverType))
+ textHover = new AnnotationHoverProcessor();
+ else if (TextHoverManager.COMBINATION_HOVER
+ .equalsIgnoreCase(hoverType)) {
+ textHover = new ChainTextHover(createDocumentationHovers(contentType));
+ } else if (TextHoverManager.DOCUMENTATION_HOVER
+ .equalsIgnoreCase(hoverType)) {
+ ITextHover[] hovers = createDocumentationHovers(contentType);
+ if (hovers.length > 0) {
+ textHover = hovers[0];
+ }
}
}
i++;
}
-
- return super.getTextHover(sourceViewer, contentType, stateMask);
+ return textHover;
}
private IQuickAssistAssistant fQuickAssistant = null;
Copied:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/ChainTextHover.java
(from rev 33688,
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/ChainTextHover.java)
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/ChainTextHover.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/ChainTextHover.java 2011-08-08
21:22:48 UTC (rev 33690)
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * Copyright (c) 2009-2011 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.text.xml.info;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.ITextHoverExtension;
+import org.eclipse.jface.text.ITextHoverExtension2;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.wst.sse.ui.internal.Logger;
+import org.eclipse.wst.sse.ui.internal.taginfo.AnnotationHoverProcessor;
+import org.eclipse.wst.sse.ui.internal.taginfo.DebugInfoHoverProcessor;
+import org.jboss.tools.common.text.xml.XmlEditorPlugin;
+import org.jboss.tools.common.text.xml.xpl.MarkerProblemAnnotationHoverProcessor;
+
+
+/**
+ * Provides the best hover help documentation (by using other hover help
+ * processors) Priority of hover help processors is: ProblemHoverProcessor,
+ * FaceletTagInfoProcessor, TagInfoProcessor, AnnotationHoverProcessor
+ *
+ * The processors are acquired in order of their priorities. If a hover doesn'n
returns an information
+ * (i.e. returns null as a display string) the next processor will be acquired.
+ *
+ * @author Victor Rubezhny
+ *
+ */
+@SuppressWarnings("restriction")
+public class ChainTextHover implements ITextHover, ITextHoverExtension,
ITextHoverExtension2 {
+ private ITextHover fBestMatchHover; // current best match text hover
+ private ITextHover[] fTagInfoHovers; // documentation/information hover
+ private List<ITextHover> fTextHovers; // list of text hovers to consider in best
+ // match
+
+ public ChainTextHover(ITextHover infoTagHover) {
+ this(new ITextHover[]{infoTagHover});
+ }
+
+ public ChainTextHover(ITextHover[] infoTagHovers) {
+ fTagInfoHovers = infoTagHovers;
+ }
+
+ /**
+ * Create a list of text hovers applicable to this best match hover
+ * processor
+ *
+ * @return List of ITextHover - in abstract class this is empty list
+ */
+ private List<ITextHover> createTextHoversList() {
+ List<ITextHover> hoverList = new ArrayList<ITextHover>();
+ // if currently debugging, then add the debug hover to the list of
+ // best match
+ if (Logger.isTracing(DebugInfoHoverProcessor.TRACEFILTER)) {
+ hoverList.add(new DebugInfoHoverProcessor());
+ }
+
+// hoverList.add(new ProblemAnnotationHoverProcessor());
+ hoverList.add(new MarkerProblemAnnotationHoverProcessor());
+
+ if (fTagInfoHovers != null) {
+ for (int i = 0; i < fTagInfoHovers.length; i++) {
+// if (fTagInfoHovers[i] instanceof FaceletTagInfoHoverProcessor) {
+ if (fTagInfoHovers[i].getClass().getName().startsWith("org.jboss.tools."))
{
+ hoverList.add(fTagInfoHovers[i]);
+ }
+ }
+ for (int i = 0; i < fTagInfoHovers.length; i++) {
+// if (!(fTagInfoHovers[i] instanceof FaceletTagInfoHoverProcessor)) {
+ if
(!(fTagInfoHovers[i].getClass().getName().startsWith("org.jboss.tools."))) {
+ hoverList.add(fTagInfoHovers[i]);
+ }
+ }
+ }
+ hoverList.add(new AnnotationHoverProcessor());
+ return hoverList;
+ }
+
+ public IInformationControlCreator getHoverControlCreator() {
+ IInformationControlCreator creator = null;
+
+ if (fBestMatchHover instanceof ITextHoverExtension) {
+ creator = ((ITextHoverExtension) fBestMatchHover).getHoverControlCreator();
+ }
+ return creator;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer,
+ * org.eclipse.jface.text.IRegion)
+ */
+ public String getHoverInfo(ITextViewer viewer, IRegion hoverRegion) {
+ String displayInfo = null;
+
+ // already have a best match hover picked out from getHoverRegion call
+ if (fBestMatchHover != null) {
+ try {
+ displayInfo = fBestMatchHover.getHoverInfo(viewer, hoverRegion);
+ } catch (Exception e) {
+ XmlEditorPlugin.getPluginLog().logError(InfoHoverMessages.InfoHoover_error_gettingInfo,
e);
+ }
+ }
+ // either had no best match hover or best match hover returned null
+ if (displayInfo == null) {
+ // go through the list of text hovers and return first display string
+ Iterator<ITextHover> i = getTextHovers().iterator();
+ while ((i.hasNext()) && (displayInfo == null)) {
+ ITextHover hover = (ITextHover) i.next();
+ try {
+ if(hover instanceof ITextHoverExtension2) {
+ Object displayInfoObject = ((ITextHoverExtension2)hover).getHoverInfo2(viewer,
hoverRegion);
+ if(displayInfoObject!=null) {
+ displayInfo = displayInfoObject.toString();
+ }
+ } else {
+ displayInfo = hover.getHoverInfo(viewer, hoverRegion);
+ }
+ } catch (Exception e) {
+ XmlEditorPlugin.getPluginLog().logError(InfoHoverMessages.InfoHoover_error_gettingInfo,
e);
+ }
+ }
+ }
+ return displayInfo;
+ }
+
+ public Object getHoverInfo2(ITextViewer viewer, IRegion hoverRegion) {
+ Object objectInfo = null;
+
+ // already have a best match hover picked out from getHoverRegion call
+ if (fBestMatchHover != null) {
+ try {
+ if (fBestMatchHover instanceof ITextHoverExtension2) {
+ objectInfo = ((ITextHoverExtension2) fBestMatchHover).getHoverInfo2(viewer,
hoverRegion);
+ } else {
+ objectInfo = fBestMatchHover.getHoverInfo(viewer, hoverRegion);
+ }
+ } catch (Exception e) {
+ XmlEditorPlugin.getPluginLog().logError(InfoHoverMessages.InfoHoover_error_gettingInfo,
e);
+ }
+ }
+ // either had no best match hover or best match hover returned null
+ if (objectInfo == null) {
+ // go through the list of text hovers and return first display string
+ Iterator<ITextHover> i = getTextHovers().iterator();
+ while ((i.hasNext()) && (objectInfo == null)) {
+ ITextHover hover = (ITextHover) i.next();
+ try {
+ if(hover instanceof ITextHoverExtension2) {
+ objectInfo = ((ITextHoverExtension2)hover).getHoverInfo2(viewer, hoverRegion);
+ } else {
+ objectInfo = hover.getHoverInfo(viewer, hoverRegion);
+ }
+ } catch (Exception e) {
+ XmlEditorPlugin.getPluginLog().logError(InfoHoverMessages.InfoHoover_error_gettingInfo,
e);
+ }
+ }
+ }
+ return objectInfo;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer,
+ * int)
+ */
+ public IRegion getHoverRegion(ITextViewer viewer, int offset) {
+ IRegion hoverRegion = null;
+
+ // go through list of text hovers and return first hover region
+ ITextHover hover = null;
+ Iterator<ITextHover> i = getTextHovers().iterator();
+ while ((i.hasNext()) && (hoverRegion == null)) {
+ hover = i.next();
+ hoverRegion = hover.getHoverRegion(viewer, offset);
+ }
+
+ // store the text hover processor that found region
+ if (hoverRegion != null)
+ fBestMatchHover = hover;
+ else
+ fBestMatchHover = null;
+
+ return hoverRegion;
+ }
+
+ private List<ITextHover> getTextHovers() {
+ if (fTextHovers == null) {
+ fTextHovers = createTextHoversList();
+ }
+ return fTextHovers;
+ }
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/ChainTextHover.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/InfoHoverMessages.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/InfoHoverMessages.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/InfoHoverMessages.java 2011-08-08
21:22:48 UTC (rev 33690)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.text.xml.info;
+
+import org.eclipse.osgi.util.NLS;
+
+public class InfoHoverMessages extends NLS {
+
+ private static final String BUNDLE_NAME= InfoHoverMessages.class.getName();
+
+ private InfoHoverMessages() {
+ // Do not instantiate
+ }
+
+// public static String ELInfoHover_noAttachments; //
+// public static String ELInfoHover_noAttachedJavadoc; //
+// public static String ELInfoHover_noAttachedJavaSource; //
+// public static String ELInfoHover_noInformation; //
+// public static String ELInfoHover_error_gettingJavadoc; //
+ public static String InfoHoover_error_gettingInfo; //
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, InfoHoverMessages.class);
+ }
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/InfoHoverMessages.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/InfoHoverMessages.properties
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/InfoHoverMessages.properties
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/InfoHoverMessages.properties 2011-08-08
21:22:48 UTC (rev 33690)
@@ -0,0 +1 @@
+InfoHoover_error_gettingInfo=<em>Note: An exception occurred while getting the
Hover Info. See log for details.</em>
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/InfoHoverMessages.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/TextHoverInformationProvider.java
(from rev 33604,
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/TextHoverInformationProvider.java)
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/TextHoverInformationProvider.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/TextHoverInformationProvider.java 2011-08-08
21:22:48 UTC (rev 33690)
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2009-2011 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.text.xml.info;
+
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.ITextHoverExtension2;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.information.IInformationProvider;
+import org.eclipse.jface.text.information.IInformationProviderExtension;
+import org.eclipse.jface.text.information.IInformationProviderExtension2;
+
+/**
+ *
+ * @author Victor Rubezhny
+ *
+ */
+public class TextHoverInformationProvider implements IInformationProvider,
IInformationProviderExtension, IInformationProviderExtension2 {
+ private ITextHover fTextHover;
+
+ public TextHoverInformationProvider(ITextHover hover) {
+ fTextHover = hover;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.jface.text.information.IInformationProvider#getInformation(org.eclipse.jface.text.ITextViewer,
org.eclipse.jface.text.IRegion)
+ */
+ public String getInformation(ITextViewer textViewer, IRegion subject) {
+ return (String) getInformation2(textViewer, subject);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer,
org.eclipse.jface.text.IRegion)
+ */
+ public Object getInformation2(ITextViewer textViewer, IRegion subject) {
+ return (fTextHover instanceof ITextHoverExtension2 ?
+ ((ITextHoverExtension2)fTextHover).getHoverInfo2(textViewer, subject) :
+ fTextHover.getHoverInfo(textViewer, subject));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator()
+ */
+ public IInformationControlCreator getInformationPresenterControlCreator() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.jface.text.information.IInformationProvider#getSubject(org.eclipse.jface.text.ITextViewer,
int)
+ */
+ public IRegion getSubject(ITextViewer textViewer, int offset) {
+ return fTextHover.getHoverRegion(textViewer, offset);
+ }
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/info/TextHoverInformationProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java 2011-08-08
19:48:27 UTC (rev 33689)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java 2011-08-08
21:22:48 UTC (rev 33690)
@@ -52,9 +52,10 @@
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkDetector;
import org.jboss.tools.common.text.xml.JBDSQuickAssistProcessor;
import org.jboss.tools.common.text.xml.contentassist.ProposalSorter;
+import org.jboss.tools.common.text.xml.info.ChainTextHover;
+import org.jboss.tools.common.text.xml.info.TextHoverInformationProvider;
import org.jboss.tools.common.text.xml.xpl.MarkerProblemAnnotationHoverProcessor;
import org.jboss.tools.jst.jsp.format.HTMLFormatProcessor;
-import org.jboss.tools.jst.jsp.jspeditor.info.ChainTextHover;
@SuppressWarnings("restriction")
public class HTMLTextViewerConfiguration extends
@@ -199,21 +200,14 @@
@Override
protected IInformationProvider getInformationProvider(
ISourceViewer sourceViewer, String partitionType) {
- ITextHover chainTextHover = null;
ITextHover[] hovers = createDocumentationHovers(partitionType);
if (hovers == null) {
hovers = new ITextHover[] {new ChainTextHover(
new ITextHover[0])};
}
- if (hovers.length == 1) {
- chainTextHover = hovers[0];
- } else {
- chainTextHover = new ChainTextHover(
- hovers);
- }
-
- return new TextHoverInformationProvider(chainTextHover);
+ return new TextHoverInformationProvider(new ChainTextHover(
+ hovers));
}
@Override
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java 2011-08-08
19:48:27 UTC (rev 33689)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java 2011-08-08
21:22:48 UTC (rev 33690)
@@ -45,8 +45,9 @@
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkDetector;
import org.jboss.tools.common.text.xml.JBDSQuickAssistProcessor;
import org.jboss.tools.common.text.xml.contentassist.ProposalSorter;
+import org.jboss.tools.common.text.xml.info.ChainTextHover;
+import org.jboss.tools.common.text.xml.info.TextHoverInformationProvider;
import org.jboss.tools.common.text.xml.xpl.MarkerProblemAnnotationHoverProcessor;
-import org.jboss.tools.jst.jsp.jspeditor.info.ChainTextHover;
/**
* @author Igels
@@ -206,21 +207,14 @@
@Override
protected IInformationProvider getInformationProvider(
ISourceViewer sourceViewer, String partitionType) {
- ITextHover chainTextHover = null;
ITextHover[] hovers = createDocumentationHovers(partitionType);
if (hovers == null) {
hovers = new ITextHover[] {new ChainTextHover(
new ITextHover[0])};
}
- if (hovers.length == 1) {
- chainTextHover = hovers[0];
- } else {
- chainTextHover = new ChainTextHover(
- hovers);
- }
-
- return new TextHoverInformationProvider(chainTextHover);
+ return new TextHoverInformationProvider(new ChainTextHover(
+ hovers));
}
@Override
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/TextHoverInformationProvider.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/TextHoverInformationProvider.java 2011-08-08
19:48:27 UTC (rev 33689)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/TextHoverInformationProvider.java 2011-08-08
21:22:48 UTC (rev 33690)
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp;
-
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextHoverExtension2;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.information.IInformationProvider;
-import org.eclipse.jface.text.information.IInformationProviderExtension;
-import org.eclipse.jface.text.information.IInformationProviderExtension2;
-
-/**
- *
- * @author Victor Rubezhny
- *
- */
-class TextHoverInformationProvider implements IInformationProvider,
IInformationProviderExtension, IInformationProviderExtension2 {
- private ITextHover fTextHover;
-
- public TextHoverInformationProvider(ITextHover hover) {
- fTextHover = hover;
- }
-
- /*
- * (non-Javadoc)
- * @see
org.eclipse.jface.text.information.IInformationProvider#getInformation(org.eclipse.jface.text.ITextViewer,
org.eclipse.jface.text.IRegion)
- */
- public String getInformation(ITextViewer textViewer, IRegion subject) {
- return (String) getInformation2(textViewer, subject);
- }
-
- /*
- * (non-Javadoc)
- * @see
org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer,
org.eclipse.jface.text.IRegion)
- */
- public Object getInformation2(ITextViewer textViewer, IRegion subject) {
- return (fTextHover instanceof ITextHoverExtension2 ?
- ((ITextHoverExtension2)fTextHover).getHoverInfo2(textViewer, subject) :
- fTextHover.getHoverInfo(textViewer, subject));
- }
-
- /*
- * (non-Javadoc)
- * @see
org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator()
- */
- public IInformationControlCreator getInformationPresenterControlCreator() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see
org.eclipse.jface.text.information.IInformationProvider#getSubject(org.eclipse.jface.text.ITextViewer,
int)
- */
- public IRegion getSubject(ITextViewer textViewer, int offset) {
- return fTextHover.getHoverRegion(textViewer, offset);
- }
-}
Deleted:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/ChainTextHover.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/ChainTextHover.java 2011-08-08
19:48:27 UTC (rev 33689)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/ChainTextHover.java 2011-08-08
21:22:48 UTC (rev 33690)
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009-2011 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.jsp.jspeditor.info;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextHoverExtension;
-import org.eclipse.jface.text.ITextHoverExtension2;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.wst.sse.ui.internal.Logger;
-import org.eclipse.wst.sse.ui.internal.taginfo.AnnotationHoverProcessor;
-import org.eclipse.wst.sse.ui.internal.taginfo.DebugInfoHoverProcessor;
-import org.jboss.tools.common.text.xml.xpl.MarkerProblemAnnotationHoverProcessor;
-import org.jboss.tools.jst.jsp.JspEditorPlugin;
-
-
-/**
- * Provides the best hover help documentation (by using other hover help
- * processors) Priority of hover help processors is: ProblemHoverProcessor,
- * FaceletTagInfoProcessor, TagInfoProcessor, AnnotationHoverProcessor
- *
- * The processors are acquired in order of their priorities. If a hover doesn'n
returns an information
- * (i.e. returns null as a display string) the next processor will be acquired.
- *
- * @author Victor Rubezhny
- *
- */
-@SuppressWarnings("restriction")
-public class ChainTextHover implements ITextHover, ITextHoverExtension,
ITextHoverExtension2 {
- private ITextHover fBestMatchHover; // current best match text hover
- private ITextHover[] fTagInfoHovers; // documentation/information hover
- private List<ITextHover> fTextHovers; // list of text hovers to consider in best
- // match
-
- public ChainTextHover(ITextHover infoTagHover) {
- this(new ITextHover[]{infoTagHover});
- }
-
- public ChainTextHover(ITextHover[] infoTagHovers) {
- fTagInfoHovers = infoTagHovers;
- }
-
- /**
- * Create a list of text hovers applicable to this best match hover
- * processor
- *
- * @return List of ITextHover - in abstract class this is empty list
- */
- private List<ITextHover> createTextHoversList() {
- List<ITextHover> hoverList = new ArrayList<ITextHover>();
- // if currently debugging, then add the debug hover to the list of
- // best match
- if (Logger.isTracing(DebugInfoHoverProcessor.TRACEFILTER)) {
- hoverList.add(new DebugInfoHoverProcessor());
- }
-
-// hoverList.add(new ProblemAnnotationHoverProcessor());
- hoverList.add(new MarkerProblemAnnotationHoverProcessor());
-
- if (fTagInfoHovers != null) {
- for (int i = 0; i < fTagInfoHovers.length; i++) {
- if (fTagInfoHovers[i] instanceof FaceletTagInfoHoverProcessor) {
- hoverList.add(fTagInfoHovers[i]);
- }
- }
- for (int i = 0; i < fTagInfoHovers.length; i++) {
- if (!(fTagInfoHovers[i] instanceof FaceletTagInfoHoverProcessor)) {
- hoverList.add(fTagInfoHovers[i]);
- }
- }
- }
- hoverList.add(new AnnotationHoverProcessor());
- return hoverList;
- }
-
- public IInformationControlCreator getHoverControlCreator() {
- IInformationControlCreator creator = null;
-
- if (fBestMatchHover instanceof ITextHoverExtension) {
- creator = ((ITextHoverExtension) fBestMatchHover).getHoverControlCreator();
- }
- return creator;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer,
- * org.eclipse.jface.text.IRegion)
- */
- public String getHoverInfo(ITextViewer viewer, IRegion hoverRegion) {
- String displayInfo = null;
-
- // already have a best match hover picked out from getHoverRegion call
- if (fBestMatchHover != null) {
- try {
- displayInfo = fBestMatchHover.getHoverInfo(viewer, hoverRegion);
- } catch (Exception e) {
- JspEditorPlugin.getPluginLog().logError(ELInfoHoverMessages.ELInfoHoover_error_gettingInfo,
e);
- }
- }
- // either had no best match hover or best match hover returned null
- if (displayInfo == null) {
- // go through the list of text hovers and return first display string
- Iterator<ITextHover> i = getTextHovers().iterator();
- while ((i.hasNext()) && (displayInfo == null)) {
- ITextHover hover = (ITextHover) i.next();
- try {
- if(hover instanceof ITextHoverExtension2) {
- Object displayInfoObject = ((ITextHoverExtension2)hover).getHoverInfo2(viewer,
hoverRegion);
- if(displayInfoObject!=null) {
- displayInfo = displayInfoObject.toString();
- }
- } else {
- displayInfo = hover.getHoverInfo(viewer, hoverRegion);
- }
- } catch (Exception e) {
- JspEditorPlugin.getPluginLog().logError(ELInfoHoverMessages.ELInfoHoover_error_gettingInfo,
e);
- }
- }
- }
- return displayInfo;
- }
-
-
-
- @Override
- public Object getHoverInfo2(ITextViewer viewer, IRegion hoverRegion) {
- Object objectInfo = null;
-
- // already have a best match hover picked out from getHoverRegion call
- if (fBestMatchHover != null) {
- try {
- if (fBestMatchHover instanceof ITextHoverExtension2) {
- objectInfo = ((ITextHoverExtension2) fBestMatchHover).getHoverInfo2(viewer,
hoverRegion);
- } else {
- objectInfo = fBestMatchHover.getHoverInfo(viewer, hoverRegion);
- }
- } catch (Exception e) {
- JspEditorPlugin.getPluginLog().logError(ELInfoHoverMessages.ELInfoHoover_error_gettingInfo,
e);
- }
- }
- // either had no best match hover or best match hover returned null
- if (objectInfo == null) {
- // go through the list of text hovers and return first display string
- Iterator<ITextHover> i = getTextHovers().iterator();
- while ((i.hasNext()) && (objectInfo == null)) {
- ITextHover hover = (ITextHover) i.next();
- try {
- if(hover instanceof ITextHoverExtension2) {
- objectInfo = ((ITextHoverExtension2)hover).getHoverInfo2(viewer, hoverRegion);
- } else {
- objectInfo = hover.getHoverInfo(viewer, hoverRegion);
- }
- } catch (Exception e) {
- JspEditorPlugin.getPluginLog().logError(ELInfoHoverMessages.ELInfoHoover_error_gettingInfo,
e);
- }
- }
- }
- return objectInfo;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer,
- * int)
- */
- public IRegion getHoverRegion(ITextViewer viewer, int offset) {
- IRegion hoverRegion = null;
-
- // go through list of text hovers and return first hover region
- ITextHover hover = null;
- Iterator<ITextHover> i = getTextHovers().iterator();
- while ((i.hasNext()) && (hoverRegion == null)) {
- hover = i.next();
- hoverRegion = hover.getHoverRegion(viewer, offset);
- }
-
- // store the text hover processor that found region
- if (hoverRegion != null)
- fBestMatchHover = hover;
- else
- fBestMatchHover = null;
-
- return hoverRegion;
- }
-
- private List<ITextHover> getTextHovers() {
- if (fTextHovers == null) {
- fTextHovers = createTextHoversList();
- }
- return fTextHovers;
- }
-}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/ELInfoHoverMessages.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/ELInfoHoverMessages.java 2011-08-08
19:48:27 UTC (rev 33689)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/ELInfoHoverMessages.java 2011-08-08
21:22:48 UTC (rev 33690)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
+ * Copyright (c) 2010-2011 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,
@@ -25,7 +25,6 @@
public static String ELInfoHover_noAttachedJavaSource; //
public static String ELInfoHover_noInformation; //
public static String ELInfoHover_error_gettingJavadoc; //
- public static String ELInfoHoover_error_gettingInfo; //
static {
NLS.initializeMessages(BUNDLE_NAME, ELInfoHoverMessages.class);
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/ELInfoHoverMessages.properties
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/ELInfoHoverMessages.properties 2011-08-08
19:48:27 UTC (rev 33689)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/info/ELInfoHoverMessages.properties 2011-08-08
21:22:48 UTC (rev 33690)
@@ -3,4 +3,3 @@
ELInfoHover_noAttachedJavadoc= <em>Note: This element has no attached Javadoc and
the Javadoc could not be found in the attached source.</em>
ELInfoHover_noInformation= <em>Note: The Javadoc for this element could neither be
found in the attached source nor the attached Javadoc.</em>
ELInfoHover_error_gettingJavadoc= <em>Note: An exception occurred while getting the
Javadoc. See log for details.</em>
-ELInfoHoover_error_gettingInfo=<em>Note: An exception occurred while getting the
Hover Info. See log for details.</em>
\ No newline at end of file