Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 71271 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jst/jsp/ui/internal/autoedit/StructuredAutoEditStrategyJSP.java (-3 / +45 lines)
Lines 14-27 Link Here
14
import org.eclipse.jface.text.DocumentCommand;
14
import org.eclipse.jface.text.DocumentCommand;
15
import org.eclipse.jface.text.IDocument;
15
import org.eclipse.jface.text.IDocument;
16
import org.eclipse.jst.jsp.ui.internal.Logger;
16
import org.eclipse.jst.jsp.ui.internal.Logger;
17
import org.eclipse.ui.IEditorPart;
18
import org.eclipse.ui.IWorkbenchPage;
19
import org.eclipse.ui.IWorkbenchWindow;
20
import org.eclipse.ui.PlatformUI;
21
import org.eclipse.ui.texteditor.ITextEditor;
17
import org.eclipse.ui.texteditor.ITextEditorExtension3;
22
import org.eclipse.ui.texteditor.ITextEditorExtension3;
23
import org.eclipse.wst.html.ui.internal.autoedit.StructuredAutoEditStrategyHTML;
18
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
24
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
19
import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
25
import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
20
import org.eclipse.wst.sse.ui.internal.StructuredDocumentCommand;
26
import org.eclipse.wst.sse.ui.internal.StructuredDocumentCommand;
21
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
27
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
22
import org.eclipse.wst.xml.ui.internal.autoedit.StructuredAutoEditStrategyXML;
23
28
24
public class StructuredAutoEditStrategyJSP extends StructuredAutoEditStrategyXML {
29
public class StructuredAutoEditStrategyJSP extends StructuredAutoEditStrategyHTML {
25
	public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
30
	public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
26
		StructuredDocumentCommand structuredDocumentCommand = (StructuredDocumentCommand) command;
31
		StructuredDocumentCommand structuredDocumentCommand = (StructuredDocumentCommand) command;
27
		Object textEditor = getActiveTextEditor();
32
		Object textEditor = getActiveTextEditor();
Lines 35-40 Link Here
35
			if (model != null) {
40
			if (model != null) {
36
				if (structuredDocumentCommand.text != null) {
41
				if (structuredDocumentCommand.text != null) {
37
					if (structuredDocumentCommand.text.equals("%")) { //$NON-NLS-1$
42
					if (structuredDocumentCommand.text.equals("%")) { //$NON-NLS-1$
43
						// scriptlet - add end %>
38
						IDOMNode node = (IDOMNode) model.getIndexedRegion(structuredDocumentCommand.offset);
44
						IDOMNode node = (IDOMNode) model.getIndexedRegion(structuredDocumentCommand.offset);
39
						try {
45
						try {
40
							if (prefixedWith(document, structuredDocumentCommand.offset, "<") && !node.getSource().endsWith("%>")) { //$NON-NLS-1$ //$NON-NLS-2$
46
							if (prefixedWith(document, structuredDocumentCommand.offset, "<") && !node.getSource().endsWith("%>")) { //$NON-NLS-1$ //$NON-NLS-2$
Lines 59-66 Link Here
59
							Logger.logException(e);
65
							Logger.logException(e);
60
						}
66
						}
61
					}
67
					}
62
					else
68
					else {
63
						super.customizeDocumentCommand(document, structuredDocumentCommand);
69
						super.customizeDocumentCommand(document, structuredDocumentCommand);
70
					}
64
				}
71
				}
65
			}
72
			}
66
		}
73
		}
Lines 69-72 Link Here
69
				model.releaseFromRead();
76
				model.releaseFromRead();
70
		}
77
		}
71
	}
78
	}
79
	
80
	/**
81
	 * Return the active text editor if possible, otherwise the active editor
82
	 * part.
83
	 * 
84
	 * @return
85
	 */
86
	private Object getActiveTextEditor() {
87
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
88
		if (window != null) {
89
			IWorkbenchPage page = window.getActivePage();
90
			if (page != null) {
91
				IEditorPart editor = page.getActiveEditor();
92
				if (editor != null) {
93
					if (editor instanceof ITextEditor)
94
						return editor;
95
					ITextEditor textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
96
					if (textEditor != null)
97
						return textEditor;
98
					return editor;
99
				}
100
			}
101
		}
102
		return null;
103
	}
104
	
105
	private boolean prefixedWith(IDocument document, int offset, String string) {
106
107
		try {
108
			return document.getLength() >= string.length() && document.get(offset - string.length(), string.length()).equals(string);
109
		} catch (BadLocationException e) {
110
			Logger.logException(e);
111
			return false;
112
		}
113
	}
72
}
114
}
(-)src/org/eclipse/jst/jsp/ui/internal/provisional/StructuredTextViewerConfigurationJSP.java (-131 / +112 lines)
Lines 56-80 Link Here
56
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
56
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
57
import org.eclipse.ui.texteditor.ITextEditor;
57
import org.eclipse.ui.texteditor.ITextEditor;
58
import org.eclipse.wst.css.core.internal.provisional.text.ICSSPartitionTypes;
58
import org.eclipse.wst.css.core.internal.provisional.text.ICSSPartitionTypes;
59
import org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor;
60
import org.eclipse.wst.css.ui.internal.style.LineStyleProviderForEmbeddedCSS;
59
import org.eclipse.wst.css.ui.internal.style.LineStyleProviderForEmbeddedCSS;
61
import org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl;
60
import org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl;
62
import org.eclipse.wst.html.core.internal.provisional.text.IHTMLPartitionTypes;
61
import org.eclipse.wst.html.core.internal.provisional.text.IHTMLPartitionTypes;
63
import org.eclipse.wst.html.core.internal.text.StructuredTextPartitionerForHTML;
62
import org.eclipse.wst.html.ui.internal.provisional.StructuredTextViewerConfigurationHTML;
64
import org.eclipse.wst.html.ui.internal.contentassist.HTMLContentAssistProcessor;
65
import org.eclipse.wst.html.ui.internal.style.LineStyleProviderForHTML;
63
import org.eclipse.wst.html.ui.internal.style.LineStyleProviderForHTML;
66
import org.eclipse.wst.html.ui.internal.taginfo.HTMLBestMatchHoverProcessor;
67
import org.eclipse.wst.html.ui.internal.taginfo.HTMLInformationProvider;
68
import org.eclipse.wst.html.ui.internal.taginfo.HTMLTagInfoHoverProcessor;
69
import org.eclipse.wst.javascript.ui.internal.common.contentassist.JavaScriptContentAssistProcessor;
70
import org.eclipse.wst.javascript.ui.internal.common.style.LineStyleProviderForJavaScript;
64
import org.eclipse.wst.javascript.ui.internal.common.style.LineStyleProviderForJavaScript;
71
import org.eclipse.wst.javascript.ui.internal.common.taginfo.JavaScriptBestMatchHoverProcessor;
72
import org.eclipse.wst.javascript.ui.internal.common.taginfo.JavaScriptInformationProvider;
73
import org.eclipse.wst.javascript.ui.internal.common.taginfo.JavaScriptTagInfoHoverProcessor;
74
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
65
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
75
import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
66
import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
76
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredPartitionTypes;
67
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredPartitionTypes;
77
import org.eclipse.wst.sse.ui.internal.SSEUIPlugin;
78
import org.eclipse.wst.sse.ui.internal.format.StructuredFormattingStrategy;
68
import org.eclipse.wst.sse.ui.internal.format.StructuredFormattingStrategy;
79
import org.eclipse.wst.sse.ui.internal.provisional.StructuredTextViewerConfiguration;
69
import org.eclipse.wst.sse.ui.internal.provisional.StructuredTextViewerConfiguration;
80
import org.eclipse.wst.sse.ui.internal.provisional.preferences.CommonEditorPreferenceNames;
70
import org.eclipse.wst.sse.ui.internal.provisional.preferences.CommonEditorPreferenceNames;
Lines 86-97 Link Here
86
import org.eclipse.wst.sse.ui.internal.taginfo.TextHoverManager;
76
import org.eclipse.wst.sse.ui.internal.taginfo.TextHoverManager;
87
import org.eclipse.wst.sse.ui.internal.util.EditorUtility;
77
import org.eclipse.wst.sse.ui.internal.util.EditorUtility;
88
import org.eclipse.wst.xml.core.internal.provisional.text.IXMLPartitions;
78
import org.eclipse.wst.xml.core.internal.provisional.text.IXMLPartitions;
89
import org.eclipse.wst.xml.core.internal.text.rules.StructuredTextPartitionerForXML;
79
import org.eclipse.wst.xml.ui.internal.provisional.StructuredTextViewerConfigurationXML;
90
import org.eclipse.wst.xml.ui.internal.doubleclick.XMLDoubleClickStrategy;
91
import org.eclipse.wst.xml.ui.internal.style.LineStyleProviderForXML;
80
import org.eclipse.wst.xml.ui.internal.style.LineStyleProviderForXML;
92
import org.eclipse.wst.xml.ui.internal.taginfo.XMLBestMatchHoverProcessor;
93
import org.eclipse.wst.xml.ui.internal.taginfo.XMLInformationProvider;
94
import org.eclipse.wst.xml.ui.internal.taginfo.XMLTagInfoHoverProcessor;
95
import org.eclipse.wst.xml.ui.internal.validation.StructuredTextReconcilingStrategyForMarkup;
81
import org.eclipse.wst.xml.ui.internal.validation.StructuredTextReconcilingStrategyForMarkup;
96
82
97
public class StructuredTextViewerConfigurationJSP extends StructuredTextViewerConfiguration {
83
public class StructuredTextViewerConfigurationJSP extends StructuredTextViewerConfiguration {
Lines 99-104 Link Here
99
	InformationPresenter fInformationPresenter = null;
85
	InformationPresenter fInformationPresenter = null;
100
86
101
	private JavaSourceViewerConfiguration fJavaSourceViewerConfiguration;
87
	private JavaSourceViewerConfiguration fJavaSourceViewerConfiguration;
88
	private StructuredTextViewerConfiguration fXMLSourceViewerConfiguration;
89
	private StructuredTextViewerConfiguration fHTMLSourceViewerConfiguration;
102
90
103
	public StructuredTextViewerConfigurationJSP() {
91
	public StructuredTextViewerConfigurationJSP() {
104
		super();
92
		super();
Lines 115-151 Link Here
115
	 *      java.lang.String)
103
	 *      java.lang.String)
116
	 */
104
	 */
117
	public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
105
	public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
118
		List allStrategies = new ArrayList(0);
106
		IAutoEditStrategy[] strategies = null;
119
107
		
120
		IAutoEditStrategy[] superStrategies = super.getAutoEditStrategies(sourceViewer, contentType);
108
		if (contentType == IXMLPartitions.XML_DEFAULT) {
121
		for (int i = 0; i < superStrategies.length; i++) {
109
			strategies = getXMLSourceViewerConfiguration().getAutoEditStrategies(sourceViewer, contentType);
122
			allStrategies.add(superStrategies[i]);
110
		} else if (contentType == IJSPPartitionTypes.JSP_CONTENT_JAVA) {
123
		}
111
			strategies = getJavaSourceViewerConfiguration().getAutoEditStrategies(sourceViewer, IJavaPartitions.JAVA_PARTITIONING);
124
112
		} else {
125
		if (contentType == IJSPPartitionTypes.JSP_CONTENT_JAVA) {
113
			List allStrategies = new ArrayList(0);
126
			allStrategies.add(getJavaSourceViewerConfiguration().getAutoEditStrategies(sourceViewer, IJavaPartitions.JAVA_PARTITIONING)[0]);
114
	
127
		}
115
			IAutoEditStrategy[] superStrategies = super.getAutoEditStrategies(sourceViewer, contentType);
128
116
			for (int i = 0; i < superStrategies.length; i++) {
129
		if (contentType == IHTMLPartitionTypes.HTML_DEFAULT || contentType == IHTMLPartitionTypes.HTML_DECLARATION) {
117
				allStrategies.add(superStrategies[i]);
130
			allStrategies.add(new StructuredAutoEditStrategyJSP());
118
			}
119
	
120
			if (contentType == IHTMLPartitionTypes.HTML_DEFAULT || contentType == IHTMLPartitionTypes.HTML_DECLARATION) {
121
				allStrategies.add(new StructuredAutoEditStrategyJSP());
122
			}
123
			
124
			strategies = (IAutoEditStrategy[]) allStrategies.toArray(new IAutoEditStrategy[0]);
131
		}
125
		}
132
126
133
		return (IAutoEditStrategy[]) allStrategies.toArray(new IAutoEditStrategy[0]);
127
		return strategies;
134
	}
128
	}
135
129
136
	public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
130
	public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
137
		if (configuredContentTypes == null) {
131
		if (configuredContentTypes == null) {
138
			String[] xmlTypes = StructuredTextPartitionerForXML.getConfiguredContentTypes();
132
			/*
139
			String[] htmlTypes = StructuredTextPartitionerForHTML.getConfiguredContentTypes();
133
			 * A little bit of cheating because assuming html's configured
134
			 * content types will add default, unknown, and all xml configured
135
			 * content types
136
			 */
137
			String[] htmlTypes = getHTMLSourceViewerConfiguration().getConfiguredContentTypes(sourceViewer);
140
			String[] jspTypes = StructuredTextPartitionerForJSP.getConfiguredContentTypes();
138
			String[] jspTypes = StructuredTextPartitionerForJSP.getConfiguredContentTypes();
141
			configuredContentTypes = new String[2 + xmlTypes.length + htmlTypes.length + jspTypes.length];
139
			configuredContentTypes = new String[htmlTypes.length + jspTypes.length];
142
143
			configuredContentTypes[0] = IStructuredPartitionTypes.DEFAULT_PARTITION;
144
			configuredContentTypes[1] = IStructuredPartitionTypes.UNKNOWN_PARTITION;
145
140
146
			int index = 0;
141
			int index = 0;
147
			System.arraycopy(xmlTypes, 0, configuredContentTypes, index += 2, xmlTypes.length);
142
			System.arraycopy(htmlTypes, 0, configuredContentTypes, index, htmlTypes.length);
148
			System.arraycopy(htmlTypes, 0, configuredContentTypes, index += xmlTypes.length, htmlTypes.length);
149
			System.arraycopy(jspTypes, 0, configuredContentTypes, index += htmlTypes.length, jspTypes.length);
143
			System.arraycopy(jspTypes, 0, configuredContentTypes, index += htmlTypes.length, jspTypes.length);
150
		}
144
		}
151
145
Lines 158-181 Link Here
158
		if (ca != null && ca instanceof ContentAssistant) {
152
		if (ca != null && ca instanceof ContentAssistant) {
159
			ContentAssistant contentAssistant = (ContentAssistant) ca;
153
			ContentAssistant contentAssistant = (ContentAssistant) ca;
160
154
161
			IContentAssistProcessor htmlContentAssistProcessor = new HTMLContentAssistProcessor();
155
			IContentAssistant htmlContentAssistant = getHTMLSourceViewerConfiguration().getContentAssistant(sourceViewer);
162
			IContentAssistProcessor jsContentAssistProcessor = new JavaScriptContentAssistProcessor();
156
163
			IContentAssistProcessor cssContentAssistProcessor = new CSSContentAssistProcessor();
164
			IContentAssistProcessor jspContentAssistProcessor = new JSPContentAssistProcessor();
157
			IContentAssistProcessor jspContentAssistProcessor = new JSPContentAssistProcessor();
165
			IContentAssistProcessor jspJavaContentAssistProcessor = new JSPJavaContentAssistProcessor();
158
			IContentAssistProcessor jspJavaContentAssistProcessor = new JSPJavaContentAssistProcessor();
166
			IContentAssistProcessor noRegionProcessorJsp = new NoRegionContentAssistProcessorForJSP();
159
			IContentAssistProcessor noRegionProcessorJsp = new NoRegionContentAssistProcessorForJSP();
167
			IContentAssistProcessor jspELContentAssistProcessor = new JSPELContentAssistProcessor();
160
			IContentAssistProcessor jspELContentAssistProcessor = new JSPELContentAssistProcessor();
168
161
169
			// HTML
162
			// HTML
170
			setContentAssistProcessor(contentAssistant, htmlContentAssistProcessor, IHTMLPartitionTypes.HTML_DEFAULT);
163
			setContentAssistProcessor(contentAssistant, htmlContentAssistant.getContentAssistProcessor(IHTMLPartitionTypes.HTML_DEFAULT), IHTMLPartitionTypes.HTML_DEFAULT);
171
			setContentAssistProcessor(contentAssistant, htmlContentAssistProcessor, IHTMLPartitionTypes.HTML_COMMENT);
164
			setContentAssistProcessor(contentAssistant, htmlContentAssistant.getContentAssistProcessor(IHTMLPartitionTypes.HTML_COMMENT), IHTMLPartitionTypes.HTML_COMMENT);
172
165
173
			// HTML JavaScript
166
			// HTML JavaScript
174
			setContentAssistProcessor(contentAssistant, jsContentAssistProcessor, IHTMLPartitionTypes.SCRIPT);
167
			setContentAssistProcessor(contentAssistant, htmlContentAssistant.getContentAssistProcessor(IHTMLPartitionTypes.SCRIPT), IHTMLPartitionTypes.SCRIPT);
175
168
176
			// CSS
169
			// CSS
177
			setContentAssistProcessor(contentAssistant, cssContentAssistProcessor, ICSSPartitionTypes.STYLE);
170
			setContentAssistProcessor(contentAssistant, htmlContentAssistant.getContentAssistProcessor(ICSSPartitionTypes.STYLE), ICSSPartitionTypes.STYLE);
178
			setContentAssistProcessor(contentAssistant, cssContentAssistProcessor, ICSSPartitionTypes.STYLE);
179
171
180
			// JSP
172
			// JSP
181
			setContentAssistProcessor(contentAssistant, jspContentAssistProcessor, IStructuredPartitionTypes.DEFAULT_PARTITION);
173
			setContentAssistProcessor(contentAssistant, jspContentAssistProcessor, IStructuredPartitionTypes.DEFAULT_PARTITION);
Lines 218-235 Link Here
218
	}
210
	}
219
211
220
	public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
212
	public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
221
		if (contentType.compareTo(IHTMLPartitionTypes.HTML_DEFAULT) == 0)
213
		ITextDoubleClickStrategy strategy = null;
222
			// HTML
214
223
			return new XMLDoubleClickStrategy();
215
		// html or javascript
224
		else if (contentType.compareTo(IHTMLPartitionTypes.SCRIPT) == 0 || contentType.compareTo(IJSPPartitionTypes.JSP_CONTENT_JAVA) == 0 || contentType.compareTo(IJSPPartitionTypes.JSP_CONTENT_JAVASCRIPT) == 0)
216
		if (contentType == IHTMLPartitionTypes.HTML_DEFAULT || contentType == IHTMLPartitionTypes.SCRIPT)
225
			// HTML JavaScript
217
			strategy = getHTMLSourceViewerConfiguration().getDoubleClickStrategy(sourceViewer, contentType);
218
		else if (contentType == IJSPPartitionTypes.JSP_CONTENT_JAVA || contentType == IJSPPartitionTypes.JSP_CONTENT_JAVASCRIPT)
226
			// JSP Java or JSP JavaScript
219
			// JSP Java or JSP JavaScript
227
			return getJavaSourceViewerConfiguration().getDoubleClickStrategy(sourceViewer, contentType);
220
			strategy = getJavaSourceViewerConfiguration().getDoubleClickStrategy(sourceViewer, contentType);
228
		else if (contentType.compareTo(IJSPPartitionTypes.JSP_DEFAULT) == 0)
221
		else if (contentType == IJSPPartitionTypes.JSP_DEFAULT)
229
			// JSP
222
			// JSP (just treat like html)
230
			return new XMLDoubleClickStrategy();
223
			strategy = getHTMLSourceViewerConfiguration().getDoubleClickStrategy(sourceViewer, IHTMLPartitionTypes.HTML_DEFAULT);
231
		else
224
		else
232
			return super.getDoubleClickStrategy(sourceViewer, contentType);
225
			strategy = super.getDoubleClickStrategy(sourceViewer, contentType);
226
227
		return strategy;
233
	}
228
	}
234
229
235
	public IHighlighter getHighlighter(ISourceViewer sourceViewer) {
230
	public IHighlighter getHighlighter(ISourceViewer sourceViewer) {
Lines 269-276 Link Here
269
			// JSP Java or JSP JavaScript
264
			// JSP Java or JSP JavaScript
270
			highlighter.addProvider(IJSPPartitionTypes.JSP_CONTENT_JAVA, new LineStyleProviderForJava());
265
			highlighter.addProvider(IJSPPartitionTypes.JSP_CONTENT_JAVA, new LineStyleProviderForJava());
271
			highlighter.addProvider(IJSPPartitionTypes.JSP_CONTENT_JAVASCRIPT, new LineStyleProviderForJavaScript());
266
			highlighter.addProvider(IJSPPartitionTypes.JSP_CONTENT_JAVASCRIPT, new LineStyleProviderForJavaScript());
272
			
267
273
			// JSPEL 
268
			// JSPEL
274
			highlighter.addProvider(IJSPPartitionTypes.JSP_DEFAULT_EL, new LineStyleProviderForJSPEL());
269
			highlighter.addProvider(IJSPPartitionTypes.JSP_DEFAULT_EL, new LineStyleProviderForJSPEL());
275
		}
270
		}
276
271
Lines 282-340 Link Here
282
			fInformationPresenter = new InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
277
			fInformationPresenter = new InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
283
278
284
			// HTML
279
			// HTML
285
			IInformationProvider htmlInformationProvider = new HTMLInformationProvider();
280
			IInformationPresenter htmlPresenter = getHTMLSourceViewerConfiguration().getInformationPresenter(sourceViewer);
281
			IInformationProvider htmlInformationProvider = htmlPresenter.getInformationProvider(IHTMLPartitionTypes.HTML_DEFAULT);
286
			fInformationPresenter.setInformationProvider(htmlInformationProvider, IHTMLPartitionTypes.HTML_DEFAULT);
282
			fInformationPresenter.setInformationProvider(htmlInformationProvider, IHTMLPartitionTypes.HTML_DEFAULT);
287
283
288
			// HTML JavaScript
284
			// HTML JavaScript
289
			IInformationProvider javascriptInformationProvider = new JavaScriptInformationProvider();
285
			IInformationProvider javascriptInformationProvider = htmlPresenter.getInformationProvider(IHTMLPartitionTypes.SCRIPT);
290
			fInformationPresenter.setInformationProvider(javascriptInformationProvider, IHTMLPartitionTypes.SCRIPT);
286
			fInformationPresenter.setInformationProvider(javascriptInformationProvider, IHTMLPartitionTypes.SCRIPT);
291
287
292
			// XML
288
			// XML
293
			IInformationProvider xmlInformationProvider = new XMLInformationProvider();
289
			IInformationPresenter xmlPresenter = getXMLSourceViewerConfiguration().getInformationPresenter(sourceViewer);
290
			IInformationProvider xmlInformationProvider = xmlPresenter.getInformationProvider(IXMLPartitions.XML_DEFAULT);
294
			fInformationPresenter.setInformationProvider(xmlInformationProvider, IXMLPartitions.XML_DEFAULT);
291
			fInformationPresenter.setInformationProvider(xmlInformationProvider, IXMLPartitions.XML_DEFAULT);
295
292
296
			fInformationPresenter.setSizeConstraints(60, 10, true, true);
293
			fInformationPresenter.setSizeConstraints(60, 10, true, true);
294
			fInformationPresenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
297
		}
295
		}
298
		return fInformationPresenter;
296
		return fInformationPresenter;
299
	}
297
	}
300
298
301
	public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
299
	public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
302
		// html
300
		ITextHover hover = null;
303
		if (contentType == IHTMLPartitionTypes.HTML_DEFAULT) {
301
304
			TextHoverManager.TextHoverDescriptor[] hoverDescs = getTextHovers();
302
		// html + javascript
305
			int i = 0;
303
		if (contentType == IHTMLPartitionTypes.HTML_DEFAULT || contentType == IHTMLPartitionTypes.SCRIPT) {
306
			while (i < hoverDescs.length) {
304
			hover = getHTMLSourceViewerConfiguration().getTextHover(sourceViewer, contentType, stateMask);
307
				if (hoverDescs[i].isEnabled() && EditorUtility.computeStateMask(hoverDescs[i].getModifierString()) == stateMask) {
308
					String hoverType = hoverDescs[i].getId();
309
					if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType))
310
						return new HTMLBestMatchHoverProcessor();
311
					else if (TextHoverManager.PROBLEM_HOVER.equalsIgnoreCase(hoverType))
312
						return new ProblemAnnotationHoverProcessor();
313
					else if (TextHoverManager.ANNOTATION_HOVER.equalsIgnoreCase(hoverType))
314
						return new AnnotationHoverProcessor();
315
					else if (TextHoverManager.DOCUMENTATION_HOVER.equalsIgnoreCase(hoverType))
316
						return new HTMLTagInfoHoverProcessor();
317
				}
318
				i++;
319
			}
320
		} else if (contentType == IHTMLPartitionTypes.SCRIPT) {
321
			// HTML JavaScript
322
			TextHoverManager.TextHoverDescriptor[] hoverDescs = getTextHovers();
323
			int i = 0;
324
			while (i < hoverDescs.length) {
325
				if (hoverDescs[i].isEnabled() && EditorUtility.computeStateMask(hoverDescs[i].getModifierString()) == stateMask) {
326
					String hoverType = hoverDescs[i].getId();
327
					if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType))
328
						return new JavaScriptBestMatchHoverProcessor();
329
					else if (TextHoverManager.PROBLEM_HOVER.equalsIgnoreCase(hoverType))
330
						return new ProblemAnnotationHoverProcessor();
331
					else if (TextHoverManager.ANNOTATION_HOVER.equalsIgnoreCase(hoverType))
332
						return new AnnotationHoverProcessor();
333
					else if (TextHoverManager.DOCUMENTATION_HOVER.equalsIgnoreCase(hoverType))
334
						return new JavaScriptTagInfoHoverProcessor();
335
				}
336
				i++;
337
			}
338
		} else if ((contentType == IJSPPartitionTypes.JSP_DEFAULT) || (contentType == IJSPPartitionTypes.JSP_DIRECTIVE)) {
305
		} else if ((contentType == IJSPPartitionTypes.JSP_DEFAULT) || (contentType == IJSPPartitionTypes.JSP_DIRECTIVE)) {
339
			// JSP
306
			// JSP
340
			TextHoverManager.TextHoverDescriptor[] hoverDescs = getTextHovers();
307
			TextHoverManager.TextHoverDescriptor[] hoverDescs = getTextHovers();
Lines 343-355 Link Here
343
				if (hoverDescs[i].isEnabled() && EditorUtility.computeStateMask(hoverDescs[i].getModifierString()) == stateMask) {
310
				if (hoverDescs[i].isEnabled() && EditorUtility.computeStateMask(hoverDescs[i].getModifierString()) == stateMask) {
344
					String hoverType = hoverDescs[i].getId();
311
					String hoverType = hoverDescs[i].getId();
345
					if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType))
312
					if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType))
346
						return new JSPBestMatchHoverProcessor();
313
						hover = new JSPBestMatchHoverProcessor();
347
					else if (TextHoverManager.PROBLEM_HOVER.equalsIgnoreCase(hoverType))
314
					else if (TextHoverManager.PROBLEM_HOVER.equalsIgnoreCase(hoverType))
348
						return new ProblemAnnotationHoverProcessor();
315
						hover = new ProblemAnnotationHoverProcessor();
349
					else if (TextHoverManager.ANNOTATION_HOVER.equalsIgnoreCase(hoverType))
316
					else if (TextHoverManager.ANNOTATION_HOVER.equalsIgnoreCase(hoverType))
350
						return new AnnotationHoverProcessor();
317
						hover = new AnnotationHoverProcessor();
351
					else if (TextHoverManager.DOCUMENTATION_HOVER.equalsIgnoreCase(hoverType))
318
					else if (TextHoverManager.DOCUMENTATION_HOVER.equalsIgnoreCase(hoverType))
352
						return new JSPTagInfoHoverProcessor();
319
						hover = new JSPTagInfoHoverProcessor();
353
				}
320
				}
354
				i++;
321
				i++;
355
			}
322
			}
Lines 361-404 Link Here
361
				if (hoverDescs[i].isEnabled() && EditorUtility.computeStateMask(hoverDescs[i].getModifierString()) == stateMask) {
328
				if (hoverDescs[i].isEnabled() && EditorUtility.computeStateMask(hoverDescs[i].getModifierString()) == stateMask) {
362
					String hoverType = hoverDescs[i].getId();
329
					String hoverType = hoverDescs[i].getId();
363
					if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType)) {
330
					if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType)) {
364
						JSPJavaBestMatchHoverProcessor hover = new JSPJavaBestMatchHoverProcessor();
331
						hover = new JSPJavaBestMatchHoverProcessor();
365
						return hover;
366
					} else if (TextHoverManager.PROBLEM_HOVER.equalsIgnoreCase(hoverType))
332
					} else if (TextHoverManager.PROBLEM_HOVER.equalsIgnoreCase(hoverType))
367
						return new ProblemAnnotationHoverProcessor();
333
						hover = new ProblemAnnotationHoverProcessor();
368
					else if (TextHoverManager.ANNOTATION_HOVER.equalsIgnoreCase(hoverType))
334
					else if (TextHoverManager.ANNOTATION_HOVER.equalsIgnoreCase(hoverType))
369
						return new AnnotationHoverProcessor();
335
						hover = new AnnotationHoverProcessor();
370
					else if (TextHoverManager.DOCUMENTATION_HOVER.equalsIgnoreCase(hoverType)) {
336
					else if (TextHoverManager.DOCUMENTATION_HOVER.equalsIgnoreCase(hoverType)) {
371
						JSPJavaJavadocHoverProcessor hover = new JSPJavaJavadocHoverProcessor();
337
						hover = new JSPJavaJavadocHoverProcessor();
372
						return hover;
373
					}
338
					}
374
				}
339
				}
375
				i++;
340
				i++;
376
			}
341
			}
377
		} else if (contentType == IXMLPartitions.XML_DEFAULT) {
342
		} else if (contentType == IXMLPartitions.XML_DEFAULT) {
378
			// XML
343
			hover = getXMLSourceViewerConfiguration().getTextHover(sourceViewer, contentType, stateMask);
379
			TextHoverManager.TextHoverDescriptor[] hoverDescs = SSEUIPlugin.getDefault().getTextHoverManager().getTextHovers();
344
		} else {
380
			int i = 0;
345
			hover = super.getTextHover(sourceViewer, contentType, stateMask);
381
			while (i < hoverDescs.length) {
382
				if (hoverDescs[i].isEnabled() && EditorUtility.computeStateMask(hoverDescs[i].getModifierString()) == stateMask) {
383
					String hoverType = hoverDescs[i].getId();
384
					if (TextHoverManager.COMBINATION_HOVER.equalsIgnoreCase(hoverType)) {
385
						XMLBestMatchHoverProcessor hover = new XMLBestMatchHoverProcessor();
386
						// hover.setEditor(getEditorPart());
387
						return hover;
388
					} else if (TextHoverManager.PROBLEM_HOVER.equalsIgnoreCase(hoverType))
389
						return new ProblemAnnotationHoverProcessor();
390
					else if (TextHoverManager.ANNOTATION_HOVER.equalsIgnoreCase(hoverType))
391
						return new AnnotationHoverProcessor();
392
					else if (TextHoverManager.DOCUMENTATION_HOVER.equalsIgnoreCase(hoverType)) {
393
						XMLTagInfoHoverProcessor hover = new XMLTagInfoHoverProcessor();
394
						// hover.setEditor(getEditorPart());
395
						return hover;
396
					}
397
				}
398
				i++;
399
			}
400
		}
346
		}
401
		return super.getTextHover(sourceViewer, contentType, stateMask);
347
		return hover;
402
	}
348
	}
403
349
404
	public void unConfigure(ISourceViewer viewer) {
350
	public void unConfigure(ISourceViewer viewer) {
Lines 407-412 Link Here
407
		// InformationPresenters
353
		// InformationPresenters
408
		if (fInformationPresenter != null)
354
		if (fInformationPresenter != null)
409
			fInformationPresenter.uninstall();
355
			fInformationPresenter.uninstall();
356
357
		if (fXMLSourceViewerConfiguration != null)
358
			fXMLSourceViewerConfiguration.unConfigure(viewer);
359
		if (fHTMLSourceViewerConfiguration != null)
360
			fHTMLSourceViewerConfiguration.unConfigure(viewer);
410
	}
361
	}
411
362
412
	public IReconciler getReconciler(ISourceViewer sourceViewer) {
363
	public IReconciler getReconciler(ISourceViewer sourceViewer) {
Lines 473-483 Link Here
473
			IPreferenceStore store = PreferenceConstants.getPreferenceStore();
424
			IPreferenceStore store = PreferenceConstants.getPreferenceStore();
474
			JavaTextTools javaTextTools = new JavaTextTools(store);
425
			JavaTextTools javaTextTools = new JavaTextTools(store);
475
			fJavaSourceViewerConfiguration = new JavaSourceViewerConfiguration(javaTextTools.getColorManager(), store, getTextEditor(), IJavaPartitions.JAVA_PARTITIONING);
426
			fJavaSourceViewerConfiguration = new JavaSourceViewerConfiguration(javaTextTools.getColorManager(), store, getTextEditor(), IJavaPartitions.JAVA_PARTITIONING);
476
			//fJavaSourceViewerConfiguration = new JavaSourceViewerConfiguration(javaTextTools, getTextEditor());
427
			// fJavaSourceViewerConfiguration = new
428
			// JavaSourceViewerConfiguration(javaTextTools, getTextEditor());
477
		}
429
		}
478
		return fJavaSourceViewerConfiguration;
430
		return fJavaSourceViewerConfiguration;
479
	}
431
	}
480
432
433
	private StructuredTextViewerConfiguration getXMLSourceViewerConfiguration() {
434
		if (fXMLSourceViewerConfiguration == null) {
435
			fXMLSourceViewerConfiguration = new StructuredTextViewerConfigurationXML(fPreferenceStore);
436
			fXMLSourceViewerConfiguration.setEditorPart(getEditorPart());
437
			fXMLSourceViewerConfiguration.configureOn(fResource);
438
		}
439
		return fXMLSourceViewerConfiguration;
440
	}
441
442
	private StructuredTextViewerConfiguration getHTMLSourceViewerConfiguration() {
443
		if (fHTMLSourceViewerConfiguration == null) {
444
			fHTMLSourceViewerConfiguration = new StructuredTextViewerConfigurationHTML(fPreferenceStore);
445
			fHTMLSourceViewerConfiguration.setEditorPart(getEditorPart());
446
			fHTMLSourceViewerConfiguration.configureOn(fResource);
447
		}
448
		return fHTMLSourceViewerConfiguration;
449
	}
450
481
	/*
451
	/*
482
	 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
452
	 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
483
	 * @since 3.1
453
	 * @since 3.1
Lines 502-505 Link Here
502
		}
472
		}
503
		return (IHyperlinkDetector[]) allDetectors.toArray(new IHyperlinkDetector[0]);
473
		return (IHyperlinkDetector[]) allDetectors.toArray(new IHyperlinkDetector[0]);
504
	}
474
	}
475
476
	public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
477
		String[] indentations = null;
478
479
		if (contentType == IXMLPartitions.XML_DEFAULT)
480
			indentations = getXMLSourceViewerConfiguration().getIndentPrefixes(sourceViewer, contentType);
481
		else
482
			indentations = getHTMLSourceViewerConfiguration().getIndentPrefixes(sourceViewer, contentType);
483
484
		return indentations;
485
	}
505
}
486
}

Return to bug 71271