1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
9 IBM Corporation - Initial implementation
10 Klaus Hartlage - www.eclipseproject.de
11 **********************************************************************/
12 package net.sourceforge.phpeclipse.phpeditor;
13 import java.util.Vector;
14 import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
15 import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
16 import net.sourceforge.phpdt.internal.ui.text.JavaAnnotationHover;
17 import net.sourceforge.phpdt.internal.ui.text.JavaElementProvider;
18 import net.sourceforge.phpdt.internal.ui.text.JavaOutlineInformationControl;
19 import net.sourceforge.phpdt.internal.ui.text.JavaReconciler;
20 import net.sourceforge.phpdt.internal.ui.text.java.JavaFormattingStrategy;
21 import net.sourceforge.phpdt.internal.ui.text.java.JavaReconcilingStrategy;
22 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
23 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy;
24 import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCompletionProcessor;
25 import net.sourceforge.phpdt.ui.PreferenceConstants;
26 import net.sourceforge.phpdt.ui.text.JavaTextTools;
27 import net.sourceforge.phpeclipse.PHPCore;
28 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
29 import net.sourceforge.phpeclipse.phpeditor.html.HTMLFormattingStrategy;
30 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
31 import net.sourceforge.phpeclipse.phpeditor.php.IPHPPartitionScannerConstants;
32 import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
33 import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
34 import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
35 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
36 import org.eclipse.core.resources.IFile;
37 import org.eclipse.core.runtime.NullProgressMonitor;
38 import org.eclipse.jface.preference.IPreferenceStore;
39 import org.eclipse.jface.text.DefaultAutoIndentStrategy;
40 import org.eclipse.jface.text.DefaultInformationControl;
41 import org.eclipse.jface.text.IAutoIndentStrategy;
42 import org.eclipse.jface.text.IDocument;
43 import org.eclipse.jface.text.IInformationControl;
44 import org.eclipse.jface.text.IInformationControlCreator;
45 import org.eclipse.jface.text.ITextDoubleClickStrategy;
46 import org.eclipse.jface.text.ITextHover;
47 import org.eclipse.jface.text.ITextViewerExtension2;
48 import org.eclipse.jface.text.TextAttribute;
49 import org.eclipse.jface.text.contentassist.ContentAssistant;
50 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
51 import org.eclipse.jface.text.contentassist.IContentAssistant;
52 import org.eclipse.jface.text.formatter.ContentFormatter;
53 import org.eclipse.jface.text.formatter.IContentFormatter;
54 import org.eclipse.jface.text.formatter.IFormattingStrategy;
55 import org.eclipse.jface.text.information.IInformationPresenter;
56 import org.eclipse.jface.text.information.IInformationProvider;
57 import org.eclipse.jface.text.information.InformationPresenter;
58 import org.eclipse.jface.text.presentation.IPresentationReconciler;
59 import org.eclipse.jface.text.presentation.PresentationReconciler;
60 import org.eclipse.jface.text.reconciler.IReconciler;
61 import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
62 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
63 import org.eclipse.jface.text.rules.DefaultPartitioner;
64 import org.eclipse.jface.text.rules.RuleBasedScanner;
65 import org.eclipse.jface.text.rules.Token;
66 import org.eclipse.jface.text.source.IAnnotationHover;
67 import org.eclipse.jface.text.source.ISourceViewer;
68 import org.eclipse.jface.text.source.SourceViewerConfiguration;
69 import org.eclipse.swt.SWT;
70 import org.eclipse.swt.widgets.Shell;
71 import org.eclipse.ui.IEditorInput;
72 import org.eclipse.ui.IFileEditorInput;
74 * Configuration for an <code>SourceViewer</code> which shows PHP code.
76 public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
78 * Preference key used to look up display tab width.
82 public final static String PREFERENCE_TAB_WIDTH = PreferenceConstants.EDITOR_TAB_WIDTH;
84 * Preference key for inserting spaces rather than tabs.
88 public final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
89 // public static final String HTML_DEFAULT =
90 // IPHPPartitionScannerConstants.HTML;
91 //IDocument.DEFAULT_CONTENT_TYPE;
92 private JavaTextTools fJavaTextTools;
93 private PHPEditor fEditor;
94 private ContentFormatter fFormatter;
95 private HTMLFormattingStrategy fFormattingStrategy;
97 * Single token scanner.
99 static class SingleTokenScanner extends BufferedRuleBasedScanner {
100 public SingleTokenScanner(TextAttribute attribute) {
101 setDefaultReturnToken(new Token(attribute));
105 * Default constructor.
107 public PHPSourceViewerConfiguration(JavaTextTools textTools,
109 fJavaTextTools = textTools;
113 * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
115 public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
116 // if (fFormatter == null) {
117 // fFormatter = new ContentFormatter();
118 // fFormattingStrategy = new HTMLFormattingStrategy(this,
120 // fFormatter.setFormattingStrategy(fFormattingStrategy, HTML_DEFAULT);
121 // fFormatter.enablePartitionAwareFormatting(false);
122 // fFormatter.setPartitionManagingPositionCategories(getConfiguredContentTypes(null));
124 // return fFormatter;
125 if (fFormatter == null) {
127 fFormatter = new ContentFormatter();
128 IFormattingStrategy strategy = new JavaFormattingStrategy(
130 fFormatter.setFormattingStrategy(strategy,
131 IDocument.DEFAULT_CONTENT_TYPE);
132 fFormatter.enablePartitionAwareFormatting(false);
134 .setPartitionManagingPositionCategories(getPartitionManagingPositionCategories());
139 * Returns the names of the document position categories used by the
140 * document partitioners created by this object to manage their partition
141 * information. If the partitioners don't use document position categories,
142 * the returned result is <code>null</code>.
144 * @return the partition managing position categories or <code>null</code>
147 public String[] getPartitionManagingPositionCategories() {
148 return new String[]{DefaultPartitioner.CONTENT_TYPES_CATEGORY};
151 // * Returns the names of the document position categories used by the
153 // * partitioners created by this object to manage their partition
155 // * If the partitioners don't use document position categories, the
157 // * result is <code>null</code>.
159 // * @return the partition managing position categories or
161 // * if there is none
163 // private String[] getPartitionManagingPositionCategories() {
164 // return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
166 public PHPEditor getEditor() {
170 * Returns the preference store used by this configuration to initialize
171 * the individual bits and pieces.
173 * @return the preference store used to initialize this configuration
177 protected IPreferenceStore getPreferenceStore() {
178 return PHPeclipsePlugin.getDefault().getPreferenceStore();
181 // * Method declared on SourceViewerConfiguration
183 // public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
184 // return new PHPAnnotationHover();
187 * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
189 public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
190 return new JavaAnnotationHover(JavaAnnotationHover.VERTICAL_RULER_HOVER);
193 * @see SourceViewerConfiguration#getOverviewRulerAnnotationHover(ISourceViewer)
196 public IAnnotationHover getOverviewRulerAnnotationHover(
197 ISourceViewer sourceViewer) {
198 return new JavaAnnotationHover(JavaAnnotationHover.OVERVIEW_RULER_HOVER);
201 * (non-Javadoc) Method declared on SourceViewerConfiguration
203 public IAutoIndentStrategy getAutoIndentStrategy(
204 ISourceViewer sourceViewer, String contentType) {
205 return (IPHPPartitionScannerConstants.PHP.equals(contentType)
206 ? new PHPAutoIndentStrategy()
207 : new DefaultAutoIndentStrategy());
210 * Returns the PHP source code scanner for this configuration.
212 * @return the PHP source code scanner
214 protected RuleBasedScanner getCodeScanner() {
215 return fJavaTextTools.getCodeScanner();
218 * Returns the HTML source code scanner for this configuration.
220 * @return the HTML source code scanner
222 protected RuleBasedScanner getHTMLScanner() {
223 return fJavaTextTools.getHTMLScanner();
226 * Returns the Smarty source code scanner for this configuration.
228 * @return the Smarty source code scanner
230 protected RuleBasedScanner getSmartyScanner() {
231 return fJavaTextTools.getSmartyScanner();
234 * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
236 public IReconciler getReconciler(ISourceViewer sourceViewer) {
237 if (getEditor() != null && getEditor().isEditable()) {
238 JavaReconciler reconciler = new JavaReconciler(getEditor(),
239 new JavaReconcilingStrategy(getEditor()), false);
240 reconciler.setProgressMonitor(new NullProgressMonitor());
241 reconciler.setDelay(500);
247 * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer,
251 public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer,
252 String contentType) {
253 JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin
254 .getDefault().getJavaEditorTextHoverDescriptors();
255 int stateMasks[] = new int[hoverDescs.length];
256 int stateMasksLength = 0;
257 for (int i = 0; i < hoverDescs.length; i++) {
258 if (hoverDescs[i].isEnabled()) {
260 int stateMask = hoverDescs[i].getStateMask();
261 while (j < stateMasksLength) {
262 if (stateMasks[j] == stateMask)
266 if (j == stateMasksLength)
267 stateMasks[stateMasksLength++] = stateMask;
270 if (stateMasksLength == hoverDescs.length)
272 int[] shortenedStateMasks = new int[stateMasksLength];
273 System.arraycopy(stateMasks, 0, shortenedStateMasks, 0,
275 return shortenedStateMasks;
278 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
281 public ITextHover getTextHover(ISourceViewer sourceViewer,
282 String contentType, int stateMask) {
283 JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin
284 .getDefault().getJavaEditorTextHoverDescriptors();
286 while (i < hoverDescs.length) {
287 if (hoverDescs[i].isEnabled()
288 && hoverDescs[i].getStateMask() == stateMask)
289 return new JavaEditorTextHoverProxy(hoverDescs[i], getEditor());
293 // if (fEditor != null) {
294 // IEditorInput editorInput = fEditor.getEditorInput();
295 // if (editorInput instanceof IFileEditorInput) {
297 // IFile f = ((IFileEditorInput) editorInput).getFile();
298 // return new PHPTextHover(f.getProject());
299 // } catch (NullPointerException e) {
300 // // this exception occurs, if getTextHover is called by
301 // // preference pages !
305 // return new PHPTextHover(null);
308 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
310 public ITextHover getTextHover(ISourceViewer sourceViewer,
311 String contentType) {
312 return getTextHover(sourceViewer, contentType,
313 ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
316 * Returns the SmartyDoc source code scanner for this configuration.
318 * @return the SmartyDoc source code scanner
320 protected RuleBasedScanner getSmartyDocScanner() {
321 return fJavaTextTools.getSmartyDocScanner();
324 * Returns the PHPDoc source code scanner for this configuration.
326 * @return the PHPDoc source code scanner
328 protected RuleBasedScanner getPHPDocScanner() {
329 return fJavaTextTools.getJavaDocScanner();
332 * (non-Javadoc) Method declared on SourceViewerConfiguration
334 public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
335 return new String[]{IPHPPartitionScannerConstants.HTML,
336 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT,
337 IPHPPartitionScannerConstants.PHP,
338 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT,
339 IPHPPartitionScannerConstants.CSS,
340 IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT,
341 IPHPPartitionScannerConstants.JAVASCRIPT,
342 IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT,
343 IPHPPartitionScannerConstants.SMARTY,
344 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT,
345 IDocument.DEFAULT_CONTENT_TYPE};
348 * (non-Javadoc) Method declared on SourceViewerConfiguration
350 public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
351 ContentAssistant assistant = new ContentAssistant();
352 IContentAssistProcessor processor = new HTMLCompletionProcessor();
353 assistant.setContentAssistProcessor(processor,
354 IPHPPartitionScannerConstants.HTML);
355 assistant.setContentAssistProcessor(processor,
356 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
357 assistant.setContentAssistProcessor(processor,
358 IDocument.DEFAULT_CONTENT_TYPE);
359 assistant.setContentAssistProcessor(processor,
360 IPHPPartitionScannerConstants.CSS);
361 assistant.setContentAssistProcessor(processor,
362 IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
363 assistant.setContentAssistProcessor(processor,
364 IPHPPartitionScannerConstants.JAVASCRIPT);
365 assistant.setContentAssistProcessor(processor,
366 IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
367 // TODO define special smarty partition content assist
368 assistant.setContentAssistProcessor(processor,
369 IPHPPartitionScannerConstants.SMARTY);
370 assistant.setContentAssistProcessor(processor,
371 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
372 assistant.setContentAssistProcessor(new PHPCompletionProcessor(),
373 IPHPPartitionScannerConstants.PHP);
374 assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(),
375 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
376 // assistant.enableAutoActivation(true);
377 // assistant.setAutoActivationDelay(500);
378 // assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
379 // ContentAssistPreference.configure(assistant, getPreferenceStore());
380 // assistant.setContextInformationPopupOrientation(
381 // ContentAssistant.CONTEXT_INFO_ABOVE);
382 // assistant.setContextInformationPopupBackground(
383 // PHPEditorEnvironment.getPHPColorProvider().getColor(
384 // new RGB(150, 150, 0)));
385 ContentAssistPreference.configure(assistant, getPreferenceStore());
387 .setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
389 .setInformationControlCreator(getInformationControlCreator(sourceViewer));
393 * (non-Javadoc) Method declared on SourceViewerConfiguration
395 // public String getDefaultPrefix(ISourceViewer sourceViewer, String
397 // return (PHPPartitionScanner.PHP.equals(contentType) ? "//" : null);
399 // // return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" :
400 // null); //$NON-NLS-1$
403 * @see SourceViewerConfiguration#getDefaultPrefix(ISourceViewer, String)
406 public String[] getDefaultPrefixes(ISourceViewer sourceViewer,
407 String contentType) {
408 return new String[]{"//", ""}; //$NON-NLS-1$ //$NON-NLS-2$
411 * (non-Javadoc) Method declared on SourceViewerConfiguration
413 public ITextDoubleClickStrategy getDoubleClickStrategy(
414 ISourceViewer sourceViewer, String contentType) {
415 return new PHPDoubleClickSelector();
418 * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String)
420 public String[] getIndentPrefixes(ISourceViewer sourceViewer,
421 String contentType) {
422 Vector vector = new Vector();
423 // prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
424 final IPreferenceStore preferences = PHPeclipsePlugin.getDefault()
425 .getPreferenceStore();
426 int tabWidth = preferences.getInt(PHPCore.FORMATTER_TAB_SIZE);
427 boolean useSpaces = getPreferenceStore().getBoolean(SPACES_FOR_TABS);
428 for (int i = 0; i <= tabWidth; i++) {
429 StringBuffer prefix = new StringBuffer();
431 for (int j = 0; j + i < tabWidth; j++)
436 for (int j = 0; j < i; j++)
441 vector.add(prefix.toString());
443 vector.add(""); //$NON-NLS-1$
444 return (String[]) vector.toArray(new String[vector.size()]);
447 * (non-Javadoc) Method declared on SourceViewerConfiguration
449 public IPresentationReconciler getPresentationReconciler(
450 ISourceViewer sourceViewer) {
451 // PHPColorProvider provider =
452 // PHPEditorEnvironment.getPHPColorProvider();
453 // JavaColorManager provider =
454 // PHPEditorEnvironment.getPHPColorProvider();
455 PresentationReconciler reconciler = new PresentationReconciler();
456 DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getHTMLScanner());
457 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
458 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
459 dr = new DefaultDamagerRepairer(getHTMLScanner());
460 reconciler.setDamager(dr, IPHPPartitionScannerConstants.HTML);
461 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.HTML);
462 dr = new DefaultDamagerRepairer(getHTMLScanner());
463 reconciler.setDamager(dr, IPHPPartitionScannerConstants.CSS);
464 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.CSS);
465 dr = new DefaultDamagerRepairer(getHTMLScanner());
466 reconciler.setDamager(dr,
467 IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
468 reconciler.setRepairer(dr,
469 IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
470 dr = new DefaultDamagerRepairer(getHTMLScanner());
471 reconciler.setDamager(dr, IPHPPartitionScannerConstants.JAVASCRIPT);
472 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.JAVASCRIPT);
473 dr = new DefaultDamagerRepairer(getHTMLScanner());
474 reconciler.setDamager(dr,
475 IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
476 reconciler.setRepairer(dr,
477 IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
478 dr = new DefaultDamagerRepairer(getSmartyScanner());
479 reconciler.setDamager(dr, IPHPPartitionScannerConstants.SMARTY);
480 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.SMARTY);
481 dr = new DefaultDamagerRepairer(getSmartyDocScanner());
482 reconciler.setDamager(dr,
483 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
484 reconciler.setRepairer(dr,
485 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
486 dr = new DefaultDamagerRepairer(new SingleTokenScanner(
487 new TextAttribute(fJavaTextTools.getColorManager().getColor(
488 PHPColorProvider.MULTI_LINE_COMMENT))));
489 reconciler.setDamager(dr,
490 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
491 reconciler.setRepairer(dr,
492 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
493 dr = new DefaultDamagerRepairer(getCodeScanner());
494 reconciler.setDamager(dr, IPHPPartitionScannerConstants.PHP);
495 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.PHP);
496 dr = new DefaultDamagerRepairer(getPHPDocScanner());
497 reconciler.setDamager(dr,
498 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
499 reconciler.setRepairer(dr,
500 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
504 * (non-Javadoc) Method declared on SourceViewerConfiguration
506 public int getTabWidth(ISourceViewer sourceViewer) {
507 return getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH);
510 * (non-Javadoc) Method declared on SourceViewerConfiguration
512 // public ITextHover getTextHover(ISourceViewer sourceViewer, String
514 // if (fEditor != null) {
515 // IEditorInput editorInput = fEditor.getEditorInput();
516 // if (editorInput instanceof IFileEditorInput) {
518 // IFile f = ((IFileEditorInput) editorInput).getFile();
519 // return new PHPTextHover(f.getProject());
520 // } catch (NullPointerException e) {
521 // // this exception occurs, if getTextHover is called by preference pages
526 // return new PHPTextHover(null);
529 * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
532 public IInformationControlCreator getInformationControlCreator(
533 ISourceViewer sourceViewer) {
534 return new IInformationControlCreator() {
535 public IInformationControl createInformationControl(Shell parent) {
536 return new DefaultInformationControl(parent, SWT.NONE,
537 new HTMLTextPresenter(true));
538 // return new HoverBrowserControl(parent);
543 * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
546 // public IInformationPresenter getInformationPresenter(ISourceViewer
548 // InformationPresenter presenter= new
549 // InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
550 // IInformationProvider provider= new JavaInformationProvider(getEditor());
551 // presenter.setInformationProvider(provider,
552 // IDocument.DEFAULT_CONTENT_TYPE);
553 // presenter.setInformationProvider(provider, IJavaPartitions.JAVA_DOC);
554 // presenter.setSizeConstraints(60, 10, true, true);
558 * Returns the information presenter control creator. The creator is a
559 * factory creating the presenter controls for the given source viewer.
560 * This implementation always returns a creator for <code>DefaultInformationControl</code>
563 * @param sourceViewer
564 * the source viewer to be configured by this configuration
565 * @return an information control creator
568 private IInformationControlCreator getInformationPresenterControlCreator(
569 ISourceViewer sourceViewer) {
570 return new IInformationControlCreator() {
571 public IInformationControl createInformationControl(Shell parent) {
572 int shellStyle = SWT.RESIZE;
573 int style = SWT.V_SCROLL | SWT.H_SCROLL;
574 return new DefaultInformationControl(parent, shellStyle, style,
575 new HTMLTextPresenter(false));
576 // return new HoverBrowserControl(parent);
581 * Returns the outline presenter control creator. The creator is a factory
582 * creating outline presenter controls for the given source viewer. This
583 * implementation always returns a creator for <code>JavaOutlineInformationControl</code>
586 * @param sourceViewer
587 * the source viewer to be configured by this configuration
588 * @return an information control creator
591 private IInformationControlCreator getOutlinePresenterControlCreator(
592 ISourceViewer sourceViewer) {
593 return new IInformationControlCreator() {
594 public IInformationControl createInformationControl(Shell parent) {
595 int shellStyle = SWT.RESIZE;
596 int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
597 return new JavaOutlineInformationControl(parent, shellStyle,
603 * Returns the outline presenter which will determine and shown information
604 * requested for the current cursor position.
606 * @param sourceViewer
607 * the source viewer to be configured by this configuration
608 * @param doCodeResolve
609 * a boolean which specifies whether code resolve should be used
610 * to compute the Java element
611 * @return an information presenter
614 public IInformationPresenter getOutlinePresenter(
615 ISourceViewer sourceViewer, boolean doCodeResolve) {
616 InformationPresenter presenter = new InformationPresenter(
617 getOutlinePresenterControlCreator(sourceViewer));
618 presenter.setAnchor(InformationPresenter.ANCHOR_GLOBAL);
619 IInformationProvider provider = new JavaElementProvider(getEditor(),
621 presenter.setInformationProvider(provider,
622 IDocument.DEFAULT_CONTENT_TYPE);
623 presenter.setInformationProvider(provider,
624 IPHPPartitionScannerConstants.PHP);
625 presenter.setInformationProvider(provider,
626 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
627 presenter.setInformationProvider(provider,
628 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
629 presenter.setInformationProvider(provider,
630 IPHPPartitionScannerConstants.HTML);
631 presenter.setInformationProvider(provider,
632 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
633 presenter.setSizeConstraints(40, 20, true, false);