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;
15 import net.sourceforge.phpdt.core.JavaCore;
16 import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
17 import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
18 import net.sourceforge.phpdt.internal.ui.text.JavaAnnotationHover;
19 import net.sourceforge.phpdt.internal.ui.text.JavaElementProvider;
20 import net.sourceforge.phpdt.internal.ui.text.JavaOutlineInformationControl;
21 import net.sourceforge.phpdt.internal.ui.text.JavaReconciler;
22 import net.sourceforge.phpdt.internal.ui.text.java.JavaFormattingStrategy;
23 import net.sourceforge.phpdt.internal.ui.text.java.JavaReconcilingStrategy;
24 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
25 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy;
26 import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCompletionProcessor;
27 import net.sourceforge.phpdt.ui.PreferenceConstants;
28 import net.sourceforge.phpdt.ui.text.JavaTextTools;
29 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
30 import net.sourceforge.phpeclipse.phpeditor.html.HTMLFormattingStrategy;
31 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
32 import net.sourceforge.phpeclipse.phpeditor.php.IPHPPartitionScannerConstants;
33 import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
34 import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
35 import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
36 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
37 import org.eclipse.core.resources.IFile;
38 import org.eclipse.core.runtime.NullProgressMonitor;
39 import org.eclipse.jface.preference.IPreferenceStore;
40 import org.eclipse.jface.text.DefaultAutoIndentStrategy;
41 import org.eclipse.jface.text.DefaultInformationControl;
42 import org.eclipse.jface.text.IAutoIndentStrategy;
43 import org.eclipse.jface.text.IDocument;
44 import org.eclipse.jface.text.IInformationControl;
45 import org.eclipse.jface.text.IInformationControlCreator;
46 import org.eclipse.jface.text.ITextDoubleClickStrategy;
47 import org.eclipse.jface.text.ITextHover;
48 import org.eclipse.jface.text.ITextViewerExtension2;
49 import org.eclipse.jface.text.TextAttribute;
50 import org.eclipse.jface.text.contentassist.ContentAssistant;
51 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
52 import org.eclipse.jface.text.contentassist.IContentAssistant;
53 import org.eclipse.jface.text.formatter.ContentFormatter;
54 import org.eclipse.jface.text.formatter.IContentFormatter;
55 import org.eclipse.jface.text.formatter.IFormattingStrategy;
56 import org.eclipse.jface.text.information.IInformationPresenter;
57 import org.eclipse.jface.text.information.IInformationProvider;
58 import org.eclipse.jface.text.information.InformationPresenter;
59 import org.eclipse.jface.text.presentation.IPresentationReconciler;
60 import org.eclipse.jface.text.presentation.PresentationReconciler;
61 import org.eclipse.jface.text.reconciler.IReconciler;
62 import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
63 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
64 import org.eclipse.jface.text.rules.DefaultPartitioner;
65 import org.eclipse.jface.text.rules.RuleBasedScanner;
66 import org.eclipse.jface.text.rules.Token;
67 import org.eclipse.jface.text.source.IAnnotationHover;
68 import org.eclipse.jface.text.source.ISourceViewer;
69 import org.eclipse.jface.text.source.SourceViewerConfiguration;
70 import org.eclipse.swt.SWT;
71 import org.eclipse.swt.widgets.Shell;
72 import org.eclipse.ui.IEditorInput;
73 import org.eclipse.ui.IFileEditorInput;
75 * Configuration for an <code>SourceViewer</code> which shows PHP code.
77 public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
79 * Preference key used to look up display tab width.
83 public final static String PREFERENCE_TAB_WIDTH = PreferenceConstants.EDITOR_TAB_WIDTH;
85 * Preference key for inserting spaces rather than tabs.
89 public final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
90 // public static final String HTML_DEFAULT =
91 // IPHPPartitionScannerConstants.HTML;
92 //IDocument.DEFAULT_CONTENT_TYPE;
93 private JavaTextTools fJavaTextTools;
94 private PHPEditor fEditor;
95 private ContentFormatter fFormatter;
96 private HTMLFormattingStrategy fFormattingStrategy;
98 * Single token scanner.
100 static class SingleTokenScanner extends BufferedRuleBasedScanner {
101 public SingleTokenScanner(TextAttribute attribute) {
102 setDefaultReturnToken(new Token(attribute));
106 * Default constructor.
108 public PHPSourceViewerConfiguration(JavaTextTools textTools,
110 fJavaTextTools = textTools;
114 * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
116 public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
117 // if (fFormatter == null) {
118 // fFormatter = new ContentFormatter();
119 // fFormattingStrategy = new HTMLFormattingStrategy(this,
121 // fFormatter.setFormattingStrategy(fFormattingStrategy, HTML_DEFAULT);
122 // fFormatter.enablePartitionAwareFormatting(false);
123 // fFormatter.setPartitionManagingPositionCategories(getConfiguredContentTypes(null));
125 // return fFormatter;
126 if (fFormatter == null) {
128 fFormatter = new ContentFormatter();
129 IFormattingStrategy strategy = new JavaFormattingStrategy(
131 fFormatter.setFormattingStrategy(strategy,
132 IDocument.DEFAULT_CONTENT_TYPE);
133 fFormatter.enablePartitionAwareFormatting(false);
135 .setPartitionManagingPositionCategories(getPartitionManagingPositionCategories());
140 * Returns the names of the document position categories used by the
141 * document partitioners created by this object to manage their partition
142 * information. If the partitioners don't use document position categories,
143 * the returned result is <code>null</code>.
145 * @return the partition managing position categories or <code>null</code>
148 public String[] getPartitionManagingPositionCategories() {
149 return new String[]{DefaultPartitioner.CONTENT_TYPES_CATEGORY};
152 // * Returns the names of the document position categories used by the
154 // * partitioners created by this object to manage their partition
156 // * If the partitioners don't use document position categories, the
158 // * result is <code>null</code>.
160 // * @return the partition managing position categories or
162 // * if there is none
164 // private String[] getPartitionManagingPositionCategories() {
165 // return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
167 public PHPEditor getEditor() {
171 * Returns the preference store used by this configuration to initialize
172 * the individual bits and pieces.
174 * @return the preference store used to initialize this configuration
178 protected IPreferenceStore getPreferenceStore() {
179 return PHPeclipsePlugin.getDefault().getPreferenceStore();
182 // * Method declared on SourceViewerConfiguration
184 // public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
185 // return new PHPAnnotationHover();
188 * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
190 public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
191 return new JavaAnnotationHover(JavaAnnotationHover.VERTICAL_RULER_HOVER);
194 * @see SourceViewerConfiguration#getOverviewRulerAnnotationHover(ISourceViewer)
197 public IAnnotationHover getOverviewRulerAnnotationHover(
198 ISourceViewer sourceViewer) {
199 return new JavaAnnotationHover(JavaAnnotationHover.OVERVIEW_RULER_HOVER);
202 * (non-Javadoc) Method declared on SourceViewerConfiguration
204 public IAutoIndentStrategy getAutoIndentStrategy(
205 ISourceViewer sourceViewer, String contentType) {
206 return (IPHPPartitionScannerConstants.PHP.equals(contentType)
207 ? new PHPAutoIndentStrategy()
208 : new DefaultAutoIndentStrategy());
211 * Returns the PHP source code scanner for this configuration.
213 * @return the PHP source code scanner
215 protected RuleBasedScanner getCodeScanner() {
216 return fJavaTextTools.getCodeScanner();
219 * Returns the HTML source code scanner for this configuration.
221 * @return the HTML source code scanner
223 protected RuleBasedScanner getHTMLScanner() {
224 return fJavaTextTools.getHTMLScanner();
227 * Returns the Smarty source code scanner for this configuration.
229 * @return the Smarty source code scanner
231 protected RuleBasedScanner getSmartyScanner() {
232 return fJavaTextTools.getSmartyScanner();
235 * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
237 public IReconciler getReconciler(ISourceViewer sourceViewer) {
238 if (getEditor() != null && getEditor().isEditable()) {
239 JavaReconciler reconciler = new JavaReconciler(getEditor(),
240 new JavaReconcilingStrategy(getEditor()), false);
241 reconciler.setProgressMonitor(new NullProgressMonitor());
242 reconciler.setDelay(500);
248 * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer,
252 public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer,
253 String contentType) {
254 JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin
255 .getDefault().getJavaEditorTextHoverDescriptors();
256 int stateMasks[] = new int[hoverDescs.length];
257 int stateMasksLength = 0;
258 for (int i = 0; i < hoverDescs.length; i++) {
259 if (hoverDescs[i].isEnabled()) {
261 int stateMask = hoverDescs[i].getStateMask();
262 while (j < stateMasksLength) {
263 if (stateMasks[j] == stateMask)
267 if (j == stateMasksLength)
268 stateMasks[stateMasksLength++] = stateMask;
271 if (stateMasksLength == hoverDescs.length)
273 int[] shortenedStateMasks = new int[stateMasksLength];
274 System.arraycopy(stateMasks, 0, shortenedStateMasks, 0,
276 return shortenedStateMasks;
279 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
282 public ITextHover getTextHover(ISourceViewer sourceViewer,
283 String contentType, int stateMask) {
284 JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin
285 .getDefault().getJavaEditorTextHoverDescriptors();
287 while (i < hoverDescs.length) {
288 if (hoverDescs[i].isEnabled()
289 && hoverDescs[i].getStateMask() == stateMask)
290 return new JavaEditorTextHoverProxy(hoverDescs[i], getEditor());
294 // if (fEditor != null) {
295 // IEditorInput editorInput = fEditor.getEditorInput();
296 // if (editorInput instanceof IFileEditorInput) {
298 // IFile f = ((IFileEditorInput) editorInput).getFile();
299 // return new PHPTextHover(f.getProject());
300 // } catch (NullPointerException e) {
301 // // this exception occurs, if getTextHover is called by
302 // // preference pages !
306 // return new PHPTextHover(null);
309 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
311 public ITextHover getTextHover(ISourceViewer sourceViewer,
312 String contentType) {
313 return getTextHover(sourceViewer, contentType,
314 ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
317 * Returns the SmartyDoc source code scanner for this configuration.
319 * @return the SmartyDoc source code scanner
321 protected RuleBasedScanner getSmartyDocScanner() {
322 return fJavaTextTools.getSmartyDocScanner();
325 * Returns the PHPDoc source code scanner for this configuration.
327 * @return the PHPDoc source code scanner
329 protected RuleBasedScanner getPHPDocScanner() {
330 return fJavaTextTools.getJavaDocScanner();
333 * (non-Javadoc) Method declared on SourceViewerConfiguration
335 public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
336 return new String[]{IPHPPartitionScannerConstants.HTML,
337 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT,
338 IPHPPartitionScannerConstants.PHP,
339 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT,
340 IPHPPartitionScannerConstants.CSS,
341 IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT,
342 IPHPPartitionScannerConstants.JAVASCRIPT,
343 IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT,
344 IPHPPartitionScannerConstants.SMARTY,
345 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT,
346 IDocument.DEFAULT_CONTENT_TYPE};
349 * (non-Javadoc) Method declared on SourceViewerConfiguration
351 public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
352 ContentAssistant assistant = new ContentAssistant();
353 IContentAssistProcessor processor = new HTMLCompletionProcessor();
354 assistant.setContentAssistProcessor(processor,
355 IPHPPartitionScannerConstants.HTML);
356 assistant.setContentAssistProcessor(processor,
357 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
358 assistant.setContentAssistProcessor(processor,
359 IDocument.DEFAULT_CONTENT_TYPE);
360 assistant.setContentAssistProcessor(processor,
361 IPHPPartitionScannerConstants.CSS);
362 assistant.setContentAssistProcessor(processor,
363 IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
364 assistant.setContentAssistProcessor(processor,
365 IPHPPartitionScannerConstants.JAVASCRIPT);
366 assistant.setContentAssistProcessor(processor,
367 IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
368 // TODO define special smarty partition content assist
369 assistant.setContentAssistProcessor(processor,
370 IPHPPartitionScannerConstants.SMARTY);
371 assistant.setContentAssistProcessor(processor,
372 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
373 assistant.setContentAssistProcessor(new PHPCompletionProcessor(),
374 IPHPPartitionScannerConstants.PHP);
375 assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(),
376 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
377 // assistant.enableAutoActivation(true);
378 // assistant.setAutoActivationDelay(500);
379 // assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
380 // ContentAssistPreference.configure(assistant, getPreferenceStore());
381 // assistant.setContextInformationPopupOrientation(
382 // ContentAssistant.CONTEXT_INFO_ABOVE);
383 // assistant.setContextInformationPopupBackground(
384 // PHPEditorEnvironment.getPHPColorProvider().getColor(
385 // new RGB(150, 150, 0)));
386 ContentAssistPreference.configure(assistant, getPreferenceStore());
388 .setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
390 .setInformationControlCreator(getInformationControlCreator(sourceViewer));
394 * (non-Javadoc) Method declared on SourceViewerConfiguration
396 // public String getDefaultPrefix(ISourceViewer sourceViewer, String
398 // return (PHPPartitionScanner.PHP.equals(contentType) ? "//" : null);
400 // // return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" :
401 // null); //$NON-NLS-1$
404 * @see SourceViewerConfiguration#getDefaultPrefix(ISourceViewer, String)
407 public String[] getDefaultPrefixes(ISourceViewer sourceViewer,
408 String contentType) {
409 return new String[]{"//", ""}; //$NON-NLS-1$ //$NON-NLS-2$
412 * (non-Javadoc) Method declared on SourceViewerConfiguration
414 public ITextDoubleClickStrategy getDoubleClickStrategy(
415 ISourceViewer sourceViewer, String contentType) {
416 return new PHPDoubleClickSelector();
419 * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String)
421 public String[] getIndentPrefixes(ISourceViewer sourceViewer,
422 String contentType) {
423 Vector vector = new Vector();
424 // prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
425 final IPreferenceStore preferences = PHPeclipsePlugin.getDefault()
426 .getPreferenceStore();
427 int tabWidth = preferences.getInt(JavaCore.FORMATTER_TAB_SIZE);
428 boolean useSpaces = getPreferenceStore().getBoolean(SPACES_FOR_TABS);
429 for (int i = 0; i <= tabWidth; i++) {
430 StringBuffer prefix = new StringBuffer();
432 for (int j = 0; j + i < tabWidth; j++)
437 for (int j = 0; j < i; j++)
442 vector.add(prefix.toString());
444 vector.add(""); //$NON-NLS-1$
445 return (String[]) vector.toArray(new String[vector.size()]);
448 * (non-Javadoc) Method declared on SourceViewerConfiguration
450 public IPresentationReconciler getPresentationReconciler(
451 ISourceViewer sourceViewer) {
452 // PHPColorProvider provider =
453 // PHPEditorEnvironment.getPHPColorProvider();
454 // JavaColorManager provider =
455 // PHPEditorEnvironment.getPHPColorProvider();
456 PresentationReconciler reconciler = new PresentationReconciler();
457 DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getHTMLScanner());
458 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
459 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
460 dr = new DefaultDamagerRepairer(getHTMLScanner());
461 reconciler.setDamager(dr, IPHPPartitionScannerConstants.HTML);
462 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.HTML);
463 dr = new DefaultDamagerRepairer(getHTMLScanner());
464 reconciler.setDamager(dr, IPHPPartitionScannerConstants.CSS);
465 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.CSS);
466 dr = new DefaultDamagerRepairer(getHTMLScanner());
467 reconciler.setDamager(dr,
468 IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
469 reconciler.setRepairer(dr,
470 IPHPPartitionScannerConstants.CSS_MULTILINE_COMMENT);
471 dr = new DefaultDamagerRepairer(getHTMLScanner());
472 reconciler.setDamager(dr, IPHPPartitionScannerConstants.JAVASCRIPT);
473 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.JAVASCRIPT);
474 dr = new DefaultDamagerRepairer(getHTMLScanner());
475 reconciler.setDamager(dr,
476 IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
477 reconciler.setRepairer(dr,
478 IPHPPartitionScannerConstants.JS_MULTILINE_COMMENT);
479 dr = new DefaultDamagerRepairer(getSmartyScanner());
480 reconciler.setDamager(dr, IPHPPartitionScannerConstants.SMARTY);
481 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.SMARTY);
482 dr = new DefaultDamagerRepairer(getSmartyDocScanner());
483 reconciler.setDamager(dr,
484 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
485 reconciler.setRepairer(dr,
486 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
487 dr = new DefaultDamagerRepairer(new SingleTokenScanner(
488 new TextAttribute(fJavaTextTools.getColorManager().getColor(
489 PHPColorProvider.MULTI_LINE_COMMENT))));
490 reconciler.setDamager(dr,
491 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
492 reconciler.setRepairer(dr,
493 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
494 dr = new DefaultDamagerRepairer(getCodeScanner());
495 reconciler.setDamager(dr, IPHPPartitionScannerConstants.PHP);
496 reconciler.setRepairer(dr, IPHPPartitionScannerConstants.PHP);
497 dr = new DefaultDamagerRepairer(getPHPDocScanner());
498 reconciler.setDamager(dr,
499 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
500 reconciler.setRepairer(dr,
501 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
505 * (non-Javadoc) Method declared on SourceViewerConfiguration
507 public int getTabWidth(ISourceViewer sourceViewer) {
508 return getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH);
511 * (non-Javadoc) Method declared on SourceViewerConfiguration
513 // public ITextHover getTextHover(ISourceViewer sourceViewer, String
515 // if (fEditor != null) {
516 // IEditorInput editorInput = fEditor.getEditorInput();
517 // if (editorInput instanceof IFileEditorInput) {
519 // IFile f = ((IFileEditorInput) editorInput).getFile();
520 // return new PHPTextHover(f.getProject());
521 // } catch (NullPointerException e) {
522 // // this exception occurs, if getTextHover is called by preference pages
527 // return new PHPTextHover(null);
530 * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
533 public IInformationControlCreator getInformationControlCreator(
534 ISourceViewer sourceViewer) {
535 return new IInformationControlCreator() {
536 public IInformationControl createInformationControl(Shell parent) {
537 return new DefaultInformationControl(parent, SWT.NONE,
538 new HTMLTextPresenter(true));
539 // return new HoverBrowserControl(parent);
544 * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
547 // public IInformationPresenter getInformationPresenter(ISourceViewer
549 // InformationPresenter presenter= new
550 // InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
551 // IInformationProvider provider= new JavaInformationProvider(getEditor());
552 // presenter.setInformationProvider(provider,
553 // IDocument.DEFAULT_CONTENT_TYPE);
554 // presenter.setInformationProvider(provider, IJavaPartitions.JAVA_DOC);
555 // presenter.setSizeConstraints(60, 10, true, true);
559 * Returns the information presenter control creator. The creator is a
560 * factory creating the presenter controls for the given source viewer.
561 * This implementation always returns a creator for <code>DefaultInformationControl</code>
564 * @param sourceViewer
565 * the source viewer to be configured by this configuration
566 * @return an information control creator
569 private IInformationControlCreator getInformationPresenterControlCreator(
570 ISourceViewer sourceViewer) {
571 return new IInformationControlCreator() {
572 public IInformationControl createInformationControl(Shell parent) {
573 int shellStyle = SWT.RESIZE;
574 int style = SWT.V_SCROLL | SWT.H_SCROLL;
575 return new DefaultInformationControl(parent, shellStyle, style,
576 new HTMLTextPresenter(false));
577 // return new HoverBrowserControl(parent);
582 * Returns the outline presenter control creator. The creator is a factory
583 * creating outline presenter controls for the given source viewer. This
584 * implementation always returns a creator for <code>JavaOutlineInformationControl</code>
587 * @param sourceViewer
588 * the source viewer to be configured by this configuration
589 * @return an information control creator
592 private IInformationControlCreator getOutlinePresenterControlCreator(
593 ISourceViewer sourceViewer) {
594 return new IInformationControlCreator() {
595 public IInformationControl createInformationControl(Shell parent) {
596 int shellStyle = SWT.RESIZE;
597 int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
598 return new JavaOutlineInformationControl(parent, shellStyle,
604 * Returns the outline presenter which will determine and shown information
605 * requested for the current cursor position.
607 * @param sourceViewer
608 * the source viewer to be configured by this configuration
609 * @param doCodeResolve
610 * a boolean which specifies whether code resolve should be used
611 * to compute the Java element
612 * @return an information presenter
615 public IInformationPresenter getOutlinePresenter(
616 ISourceViewer sourceViewer, boolean doCodeResolve) {
617 InformationPresenter presenter = new InformationPresenter(
618 getOutlinePresenterControlCreator(sourceViewer));
619 presenter.setAnchor(InformationPresenter.ANCHOR_GLOBAL);
620 IInformationProvider provider = new JavaElementProvider(getEditor(),
622 presenter.setInformationProvider(provider,
623 IDocument.DEFAULT_CONTENT_TYPE);
624 presenter.setInformationProvider(provider,
625 IPHPPartitionScannerConstants.PHP);
626 presenter.setInformationProvider(provider,
627 IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT);
628 presenter.setInformationProvider(provider,
629 IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT);
630 presenter.setInformationProvider(provider,
631 IPHPPartitionScannerConstants.HTML);
632 presenter.setInformationProvider(provider,
633 IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT);
634 presenter.setSizeConstraints(40, 20, true, false);