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());
292 if (fEditor != null) {
293 IEditorInput editorInput = fEditor.getEditorInput();
294 if (editorInput instanceof IFileEditorInput) {
296 IFile f = ((IFileEditorInput) editorInput).getFile();
297 return new PHPTextHover(f.getProject());
298 } catch (NullPointerException e) {
299 // this exception occurs, if getTextHover is called by
300 // preference pages !
304 return new PHPTextHover(null);
307 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
309 public ITextHover getTextHover(ISourceViewer sourceViewer,
310 String contentType) {
311 return getTextHover(sourceViewer, contentType,
312 ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
315 * Returns the SmartyDoc source code scanner for this configuration.
317 * @return the SmartyDoc source code scanner
319 protected RuleBasedScanner getSmartyDocScanner() {
320 return fJavaTextTools.getSmartyDocScanner();
323 * Returns the PHPDoc source code scanner for this configuration.
325 * @return the PHPDoc source code scanner
327 protected RuleBasedScanner getPHPDocScanner() {
328 return fJavaTextTools.getJavaDocScanner();
331 * (non-Javadoc) Method declared on SourceViewerConfiguration
333 public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
334 return new String[]{IPHPPartitionScannerConstants.HTML,
335 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT,
336 IPHPPartitionScannerConstants.PHP,
337 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT,
338 IPHPPartitionScannerConstants.CSS,
339 IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT,
340 IPHPPartitionScannerConstants.JAVASCRIPT,
341 IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT,
342 IPHPPartitionScannerConstants.SMARTY,
343 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT,
344 IDocument.DEFAULT_CONTENT_TYPE};
347 * (non-Javadoc) Method declared on SourceViewerConfiguration
349 public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
350 ContentAssistant assistant = new ContentAssistant();
351 IContentAssistProcessor processor = new HTMLCompletionProcessor();
352 assistant.setContentAssistProcessor(processor,
353 IPHPPartitionScannerConstants.HTML);
354 assistant.setContentAssistProcessor(processor,
355 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
356 assistant.setContentAssistProcessor(processor,
357 IDocument.DEFAULT_CONTENT_TYPE);
358 assistant.setContentAssistProcessor(processor,
359 IPHPPartitionScannerConstants.CSS);
360 assistant.setContentAssistProcessor(processor,
361 IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
362 assistant.setContentAssistProcessor(processor,
363 IPHPPartitionScannerConstants.JAVASCRIPT);
364 assistant.setContentAssistProcessor(processor,
365 IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
366 // TODO define special smarty partition content assist
367 assistant.setContentAssistProcessor(processor,
368 IPHPPartitionScannerConstants.SMARTY);
369 assistant.setContentAssistProcessor(processor,
370 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
371 assistant.setContentAssistProcessor(new PHPCompletionProcessor(),
372 IPHPPartitionScannerConstants.PHP);
373 assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(),
374 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
375 // assistant.enableAutoActivation(true);
376 // assistant.setAutoActivationDelay(500);
377 // assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
378 // ContentAssistPreference.configure(assistant, getPreferenceStore());
379 // assistant.setContextInformationPopupOrientation(
380 // ContentAssistant.CONTEXT_INFO_ABOVE);
381 // assistant.setContextInformationPopupBackground(
382 // PHPEditorEnvironment.getPHPColorProvider().getColor(
383 // new RGB(150, 150, 0)));
384 ContentAssistPreference.configure(assistant, getPreferenceStore());
386 .setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
388 .setInformationControlCreator(getInformationControlCreator(sourceViewer));
392 * (non-Javadoc) Method declared on SourceViewerConfiguration
394 // public String getDefaultPrefix(ISourceViewer sourceViewer, String
396 // return (PHPPartitionScanner.PHP.equals(contentType) ? "//" : null);
398 // // return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" :
399 // null); //$NON-NLS-1$
402 * @see SourceViewerConfiguration#getDefaultPrefix(ISourceViewer, String)
405 public String[] getDefaultPrefixes(ISourceViewer sourceViewer,
406 String contentType) {
407 return new String[]{"//", ""}; //$NON-NLS-1$ //$NON-NLS-2$
410 * (non-Javadoc) Method declared on SourceViewerConfiguration
412 public ITextDoubleClickStrategy getDoubleClickStrategy(
413 ISourceViewer sourceViewer, String contentType) {
414 return new PHPDoubleClickSelector();
417 * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String)
419 public String[] getIndentPrefixes(ISourceViewer sourceViewer,
420 String contentType) {
421 Vector vector = new Vector();
422 // prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
423 final IPreferenceStore preferences = PHPeclipsePlugin.getDefault()
424 .getPreferenceStore();
425 int tabWidth = preferences.getInt(PHPCore.FORMATTER_TAB_SIZE);
426 boolean useSpaces = getPreferenceStore().getBoolean(SPACES_FOR_TABS);
427 for (int i = 0; i <= tabWidth; i++) {
428 StringBuffer prefix = new StringBuffer();
430 for (int j = 0; j + i < tabWidth; j++)
435 for (int j = 0; j < i; j++)
440 vector.add(prefix.toString());
442 vector.add(""); //$NON-NLS-1$
443 return (String[]) vector.toArray(new String[vector.size()]);
446 * (non-Javadoc) Method declared on SourceViewerConfiguration
448 public IPresentationReconciler getPresentationReconciler(
449 ISourceViewer sourceViewer) {
450 // PHPColorProvider provider =
451 // PHPEditorEnvironment.getPHPColorProvider();
452 // JavaColorManager provider =
453 // PHPEditorEnvironment.getPHPColorProvider();
454 PresentationReconciler reconciler = new PresentationReconciler();
455 DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getHTMLScanner());
456 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
457 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
458 dr = new DefaultDamagerRepairer(getHTMLScanner());
459 reconciler.setDamager(dr, IPHPPartitionScannerConstants.HTML);
460 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.HTML);
461 dr = new DefaultDamagerRepairer(getHTMLScanner());
462 reconciler.setDamager(dr, IPHPPartitionScannerConstants.CSS);
463 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.CSS);
464 dr = new DefaultDamagerRepairer(getHTMLScanner());
465 reconciler.setDamager(dr,
466 IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
467 reconciler.setRepairer(dr,
468 IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
469 dr = new DefaultDamagerRepairer(getHTMLScanner());
470 reconciler.setDamager(dr, IPHPPartitionScannerConstants.JAVASCRIPT);
471 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.JAVASCRIPT);
472 dr = new DefaultDamagerRepairer(getHTMLScanner());
473 reconciler.setDamager(dr,
474 IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
475 reconciler.setRepairer(dr,
476 IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
477 dr = new DefaultDamagerRepairer(getSmartyScanner());
478 reconciler.setDamager(dr, IPHPPartitionScannerConstants.SMARTY);
479 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.SMARTY);
480 dr = new DefaultDamagerRepairer(getSmartyDocScanner());
481 reconciler.setDamager(dr,
482 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
483 reconciler.setRepairer(dr,
484 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
485 dr = new DefaultDamagerRepairer(new SingleTokenScanner(
486 new TextAttribute(fJavaTextTools.getColorManager().getColor(
487 PHPColorProvider.MULTI_LINE_COMMENT))));
488 reconciler.setDamager(dr,
489 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
490 reconciler.setRepairer(dr,
491 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
492 dr = new DefaultDamagerRepairer(getCodeScanner());
493 reconciler.setDamager(dr, IPHPPartitionScannerConstants.PHP);
494 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.PHP);
495 dr = new DefaultDamagerRepairer(getPHPDocScanner());
496 reconciler.setDamager(dr,
497 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
498 reconciler.setRepairer(dr,
499 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
503 * (non-Javadoc) Method declared on SourceViewerConfiguration
505 public int getTabWidth(ISourceViewer sourceViewer) {
506 return getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH);
509 * (non-Javadoc) Method declared on SourceViewerConfiguration
511 // public ITextHover getTextHover(ISourceViewer sourceViewer, String
513 // if (fEditor != null) {
514 // IEditorInput editorInput = fEditor.getEditorInput();
515 // if (editorInput instanceof IFileEditorInput) {
517 // IFile f = ((IFileEditorInput) editorInput).getFile();
518 // return new PHPTextHover(f.getProject());
519 // } catch (NullPointerException e) {
520 // // this exception occurs, if getTextHover is called by preference pages
525 // return new PHPTextHover(null);
528 * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
531 public IInformationControlCreator getInformationControlCreator(
532 ISourceViewer sourceViewer) {
533 return new IInformationControlCreator() {
534 public IInformationControl createInformationControl(Shell parent) {
535 return new DefaultInformationControl(parent, SWT.NONE,
536 new HTMLTextPresenter(true));
537 // return new HoverBrowserControl(parent);
542 * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
545 // public IInformationPresenter getInformationPresenter(ISourceViewer
547 // InformationPresenter presenter= new
548 // InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
549 // IInformationProvider provider= new JavaInformationProvider(getEditor());
550 // presenter.setInformationProvider(provider,
551 // IDocument.DEFAULT_CONTENT_TYPE);
552 // presenter.setInformationProvider(provider, IJavaPartitions.JAVA_DOC);
553 // presenter.setSizeConstraints(60, 10, true, true);
557 * Returns the information presenter control creator. The creator is a
558 * factory creating the presenter controls for the given source viewer.
559 * This implementation always returns a creator for <code>DefaultInformationControl</code>
562 * @param sourceViewer
563 * the source viewer to be configured by this configuration
564 * @return an information control creator
567 private IInformationControlCreator getInformationPresenterControlCreator(
568 ISourceViewer sourceViewer) {
569 return new IInformationControlCreator() {
570 public IInformationControl createInformationControl(Shell parent) {
571 int shellStyle = SWT.RESIZE;
572 int style = SWT.V_SCROLL | SWT.H_SCROLL;
573 return new DefaultInformationControl(parent, shellStyle, style,
574 new HTMLTextPresenter(false));
575 // return new HoverBrowserControl(parent);
580 * Returns the outline presenter control creator. The creator is a factory
581 * creating outline presenter controls for the given source viewer. This
582 * implementation always returns a creator for <code>JavaOutlineInformationControl</code>
585 * @param sourceViewer
586 * the source viewer to be configured by this configuration
587 * @return an information control creator
590 private IInformationControlCreator getOutlinePresenterControlCreator(
591 ISourceViewer sourceViewer) {
592 return new IInformationControlCreator() {
593 public IInformationControl createInformationControl(Shell parent) {
594 int shellStyle = SWT.RESIZE;
595 int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
596 return new JavaOutlineInformationControl(parent, shellStyle,
602 * Returns the outline presenter which will determine and shown information
603 * requested for the current cursor position.
605 * @param sourceViewer
606 * the source viewer to be configured by this configuration
607 * @param doCodeResolve
608 * a boolean which specifies whether code resolve should be used
609 * to compute the Java element
610 * @return an information presenter
613 public IInformationPresenter getOutlinePresenter(
614 ISourceViewer sourceViewer, boolean doCodeResolve) {
615 InformationPresenter presenter = new InformationPresenter(
616 getOutlinePresenterControlCreator(sourceViewer));
617 presenter.setAnchor(InformationPresenter.ANCHOR_GLOBAL);
618 IInformationProvider provider = new JavaElementProvider(getEditor(),
620 presenter.setInformationProvider(provider,
621 IDocument.DEFAULT_CONTENT_TYPE);
622 presenter.setInformationProvider(provider,
623 IPHPPartitionScannerConstants.PHP);
624 presenter.setInformationProvider(provider,
625 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
626 presenter.setInformationProvider(provider,
627 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
628 presenter.setInformationProvider(provider,
629 IPHPPartitionScannerConstants.HTML);
630 presenter.setInformationProvider(provider,
631 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
632 presenter.setSizeConstraints(40, 20, true, false);