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.IPHPPartitions;
19 import net.sourceforge.phpdt.internal.ui.text.JavaAnnotationHover;
20 import net.sourceforge.phpdt.internal.ui.text.JavaElementProvider;
21 import net.sourceforge.phpdt.internal.ui.text.JavaOutlineInformationControl;
22 import net.sourceforge.phpdt.internal.ui.text.JavaReconciler;
23 import net.sourceforge.phpdt.internal.ui.text.java.JavaFormattingStrategy;
24 import net.sourceforge.phpdt.internal.ui.text.java.JavaReconcilingStrategy;
25 import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategy;
26 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
27 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy;
28 import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCompletionProcessor;
29 import net.sourceforge.phpdt.ui.PreferenceConstants;
30 import net.sourceforge.phpdt.ui.text.JavaTextTools;
31 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
32 import net.sourceforge.phpeclipse.phpeditor.html.HTMLFormattingStrategy;
33 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
34 import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
35 import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
36 import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
37 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
39 import org.eclipse.core.runtime.NullProgressMonitor;
40 import org.eclipse.jface.preference.IPreferenceStore;
41 import org.eclipse.jface.text.DefaultAutoIndentStrategy;
42 import org.eclipse.jface.text.DefaultInformationControl;
43 import org.eclipse.jface.text.IAutoIndentStrategy;
44 import org.eclipse.jface.text.IDocument;
45 import org.eclipse.jface.text.IInformationControl;
46 import org.eclipse.jface.text.IInformationControlCreator;
47 import org.eclipse.jface.text.ITextDoubleClickStrategy;
48 import org.eclipse.jface.text.ITextHover;
49 import org.eclipse.jface.text.ITextViewerExtension2;
50 import org.eclipse.jface.text.TextAttribute;
51 import org.eclipse.jface.text.contentassist.ContentAssistant;
52 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
53 import org.eclipse.jface.text.contentassist.IContentAssistant;
54 import org.eclipse.jface.text.formatter.ContentFormatter;
55 import org.eclipse.jface.text.formatter.IContentFormatter;
56 import org.eclipse.jface.text.formatter.IFormattingStrategy;
57 import org.eclipse.jface.text.information.IInformationPresenter;
58 import org.eclipse.jface.text.information.IInformationProvider;
59 import org.eclipse.jface.text.information.InformationPresenter;
60 import org.eclipse.jface.text.presentation.IPresentationReconciler;
61 import org.eclipse.jface.text.presentation.PresentationReconciler;
62 import org.eclipse.jface.text.reconciler.IReconciler;
63 import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
64 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
65 import org.eclipse.jface.text.rules.DefaultPartitioner;
66 import org.eclipse.jface.text.rules.RuleBasedScanner;
67 import org.eclipse.jface.text.rules.Token;
68 import org.eclipse.jface.text.source.IAnnotationHover;
69 import org.eclipse.jface.text.source.ISourceViewer;
70 import org.eclipse.jface.text.source.SourceViewerConfiguration;
71 import org.eclipse.swt.SWT;
72 import org.eclipse.swt.widgets.Shell;
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 if (IPHPPartitions.PHP_STRING_DQ.equals(contentType))
206 return new JavaStringAutoIndentStrategy(getConfiguredDocumentPartitioning(sourceViewer));
208 return (IPHPPartitions.PHP_PARTITIONING.equals(contentType)
209 ? new PHPAutoIndentStrategy()
210 : new DefaultAutoIndentStrategy());
213 * Returns the PHP source code scanner for this configuration.
215 * @return the PHP source code scanner
217 protected RuleBasedScanner getCodeScanner() {
218 return fJavaTextTools.getCodeScanner();
221 * Returns the HTML source code scanner for this configuration.
223 * @return the HTML source code scanner
225 protected RuleBasedScanner getHTMLScanner() {
226 return fJavaTextTools.getHTMLScanner();
229 * Returns the Smarty source code scanner for this configuration.
231 * @return the Smarty source code scanner
233 protected RuleBasedScanner getSmartyScanner() {
234 return fJavaTextTools.getSmartyScanner();
237 * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
239 public IReconciler getReconciler(ISourceViewer sourceViewer) {
240 if (getEditor() != null && getEditor().isEditable()) {
241 JavaReconciler reconciler = new JavaReconciler(getEditor(),
242 new JavaReconcilingStrategy(getEditor()), false);
243 reconciler.setProgressMonitor(new NullProgressMonitor());
244 reconciler.setDelay(500);
250 * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer,
254 public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer,
255 String contentType) {
256 JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin
257 .getDefault().getJavaEditorTextHoverDescriptors();
258 int stateMasks[] = new int[hoverDescs.length];
259 int stateMasksLength = 0;
260 for (int i = 0; i < hoverDescs.length; i++) {
261 if (hoverDescs[i].isEnabled()) {
263 int stateMask = hoverDescs[i].getStateMask();
264 while (j < stateMasksLength) {
265 if (stateMasks[j] == stateMask)
269 if (j == stateMasksLength)
270 stateMasks[stateMasksLength++] = stateMask;
273 if (stateMasksLength == hoverDescs.length)
275 int[] shortenedStateMasks = new int[stateMasksLength];
276 System.arraycopy(stateMasks, 0, shortenedStateMasks, 0,
278 return shortenedStateMasks;
281 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
284 public ITextHover getTextHover(ISourceViewer sourceViewer,
285 String contentType, int stateMask) {
286 JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin
287 .getDefault().getJavaEditorTextHoverDescriptors();
289 while (i < hoverDescs.length) {
290 if (hoverDescs[i].isEnabled()
291 && hoverDescs[i].getStateMask() == stateMask)
292 return new JavaEditorTextHoverProxy(hoverDescs[i], getEditor());
296 // if (fEditor != null) {
297 // IEditorInput editorInput = fEditor.getEditorInput();
298 // if (editorInput instanceof IFileEditorInput) {
300 // IFile f = ((IFileEditorInput) editorInput).getFile();
301 // return new PHPTextHover(f.getProject());
302 // } catch (NullPointerException e) {
303 // // this exception occurs, if getTextHover is called by
304 // // preference pages !
308 // return new PHPTextHover(null);
311 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
313 public ITextHover getTextHover(ISourceViewer sourceViewer,
314 String contentType) {
315 return getTextHover(sourceViewer, contentType,
316 ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
319 * Returns the SmartyDoc source code scanner for this configuration.
321 * @return the SmartyDoc source code scanner
323 protected RuleBasedScanner getSmartyDocScanner() {
324 return fJavaTextTools.getSmartyDocScanner();
327 * Returns the PHPDoc source code scanner for this configuration.
329 * @return the PHPDoc source code scanner
331 protected RuleBasedScanner getPHPDocScanner() {
332 return fJavaTextTools.getJavaDocScanner();
335 * (non-Javadoc) Method declared on SourceViewerConfiguration
337 public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
338 return new String[]{IPHPPartitions.HTML,
339 IPHPPartitions.HTML_MULTILINE_COMMENT,
340 IPHPPartitions.PHP_PARTITIONING,
341 IPHPPartitions.PHP_PHPDOC_COMMENT,
343 IPHPPartitions.CSS_MULTILINE_COMMENT,
344 IPHPPartitions.JAVASCRIPT,
345 IPHPPartitions.JS_MULTILINE_COMMENT,
346 IPHPPartitions.SMARTY,
347 IPHPPartitions.SMARTY_MULTILINE_COMMENT,
348 IDocument.DEFAULT_CONTENT_TYPE};
351 * (non-Javadoc) Method declared on SourceViewerConfiguration
353 public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
354 ContentAssistant assistant = new ContentAssistant();
355 IContentAssistProcessor processor = new HTMLCompletionProcessor();
356 assistant.setContentAssistProcessor(processor,
357 IPHPPartitions.HTML);
358 assistant.setContentAssistProcessor(processor,
359 IPHPPartitions.HTML_MULTILINE_COMMENT);
360 assistant.setContentAssistProcessor(processor,
361 IDocument.DEFAULT_CONTENT_TYPE);
362 assistant.setContentAssistProcessor(processor,
364 assistant.setContentAssistProcessor(processor,
365 IPHPPartitions.CSS_MULTILINE_COMMENT);
366 assistant.setContentAssistProcessor(processor,
367 IPHPPartitions.JAVASCRIPT);
368 assistant.setContentAssistProcessor(processor,
369 IPHPPartitions.JS_MULTILINE_COMMENT);
370 // TODO define special smarty partition content assist
371 assistant.setContentAssistProcessor(processor,
372 IPHPPartitions.SMARTY);
373 assistant.setContentAssistProcessor(processor,
374 IPHPPartitions.SMARTY_MULTILINE_COMMENT);
375 assistant.setContentAssistProcessor(new PHPCompletionProcessor(),
376 IPHPPartitions.PHP_PARTITIONING);
377 assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(),
378 IPHPPartitions.PHP_PHPDOC_COMMENT);
379 // assistant.enableAutoActivation(true);
380 // assistant.setAutoActivationDelay(500);
381 // assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
382 // ContentAssistPreference.configure(assistant, getPreferenceStore());
383 // assistant.setContextInformationPopupOrientation(
384 // ContentAssistant.CONTEXT_INFO_ABOVE);
385 // assistant.setContextInformationPopupBackground(
386 // PHPEditorEnvironment.getPHPColorProvider().getColor(
387 // new RGB(150, 150, 0)));
388 ContentAssistPreference.configure(assistant, getPreferenceStore());
390 .setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
392 .setInformationControlCreator(getInformationControlCreator(sourceViewer));
396 * (non-Javadoc) Method declared on SourceViewerConfiguration
398 // public String getDefaultPrefix(ISourceViewer sourceViewer, String
400 // return (PHPPartitionScanner.PHP.equals(contentType) ? "//" : null);
402 // // return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" :
403 // null); //$NON-NLS-1$
406 * @see SourceViewerConfiguration#getDefaultPrefix(ISourceViewer, String)
409 public String[] getDefaultPrefixes(ISourceViewer sourceViewer,
410 String contentType) {
411 return new String[]{"//", ""}; //$NON-NLS-1$ //$NON-NLS-2$
414 * (non-Javadoc) Method declared on SourceViewerConfiguration
416 public ITextDoubleClickStrategy getDoubleClickStrategy(
417 ISourceViewer sourceViewer, String contentType) {
418 return new PHPDoubleClickSelector();
421 * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String)
423 public String[] getIndentPrefixes(ISourceViewer sourceViewer,
424 String contentType) {
425 Vector vector = new Vector();
426 // prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
427 final IPreferenceStore preferences = PHPeclipsePlugin.getDefault()
428 .getPreferenceStore();
429 int tabWidth = preferences.getInt(JavaCore.FORMATTER_TAB_SIZE);
430 boolean useSpaces = getPreferenceStore().getBoolean(SPACES_FOR_TABS);
431 for (int i = 0; i <= tabWidth; i++) {
432 StringBuffer prefix = new StringBuffer();
434 for (int j = 0; j + i < tabWidth; j++)
439 for (int j = 0; j < i; j++)
444 vector.add(prefix.toString());
446 vector.add(""); //$NON-NLS-1$
447 return (String[]) vector.toArray(new String[vector.size()]);
450 * (non-Javadoc) Method declared on SourceViewerConfiguration
452 public IPresentationReconciler getPresentationReconciler(
453 ISourceViewer sourceViewer) {
454 // PHPColorProvider provider =
455 // PHPEditorEnvironment.getPHPColorProvider();
456 // JavaColorManager provider =
457 // PHPEditorEnvironment.getPHPColorProvider();
458 PresentationReconciler reconciler = new PresentationReconciler();
459 DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getHTMLScanner());
460 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
461 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
462 dr = new DefaultDamagerRepairer(getHTMLScanner());
463 reconciler.setDamager(dr, IPHPPartitions.HTML);
464 reconciler.setRepairer(dr, IPHPPartitions.HTML);
465 dr = new DefaultDamagerRepairer(getHTMLScanner());
466 reconciler.setDamager(dr, IPHPPartitions.CSS);
467 reconciler.setRepairer(dr, IPHPPartitions.CSS);
468 dr = new DefaultDamagerRepairer(getHTMLScanner());
469 reconciler.setDamager(dr,
470 IPHPPartitions.CSS_MULTILINE_COMMENT);
471 reconciler.setRepairer(dr,
472 IPHPPartitions.CSS_MULTILINE_COMMENT);
473 dr = new DefaultDamagerRepairer(getHTMLScanner());
474 reconciler.setDamager(dr, IPHPPartitions.JAVASCRIPT);
475 reconciler.setRepairer(dr, IPHPPartitions.JAVASCRIPT);
476 dr = new DefaultDamagerRepairer(getHTMLScanner());
477 reconciler.setDamager(dr,
478 IPHPPartitions.JS_MULTILINE_COMMENT);
479 reconciler.setRepairer(dr,
480 IPHPPartitions.JS_MULTILINE_COMMENT);
481 dr = new DefaultDamagerRepairer(getSmartyScanner());
482 reconciler.setDamager(dr, IPHPPartitions.SMARTY);
483 reconciler.setRepairer(dr, IPHPPartitions.SMARTY);
484 dr = new DefaultDamagerRepairer(getSmartyDocScanner());
485 reconciler.setDamager(dr,
486 IPHPPartitions.SMARTY_MULTILINE_COMMENT);
487 reconciler.setRepairer(dr,
488 IPHPPartitions.SMARTY_MULTILINE_COMMENT);
489 dr = new DefaultDamagerRepairer(new SingleTokenScanner(
490 new TextAttribute(fJavaTextTools.getColorManager().getColor(
491 PHPColorProvider.MULTI_LINE_COMMENT))));
492 reconciler.setDamager(dr,
493 IPHPPartitions.HTML_MULTILINE_COMMENT);
494 reconciler.setRepairer(dr,
495 IPHPPartitions.HTML_MULTILINE_COMMENT);
496 dr = new DefaultDamagerRepairer(getCodeScanner());
497 reconciler.setDamager(dr, IPHPPartitions.PHP_PARTITIONING);
498 reconciler.setRepairer(dr, IPHPPartitions.PHP_PARTITIONING);
499 dr = new DefaultDamagerRepairer(getPHPDocScanner());
500 reconciler.setDamager(dr,
501 IPHPPartitions.PHP_PHPDOC_COMMENT);
502 reconciler.setRepairer(dr,
503 IPHPPartitions.PHP_PHPDOC_COMMENT);
507 * (non-Javadoc) Method declared on SourceViewerConfiguration
509 public int getTabWidth(ISourceViewer sourceViewer) {
510 return getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH);
513 * (non-Javadoc) Method declared on SourceViewerConfiguration
515 // public ITextHover getTextHover(ISourceViewer sourceViewer, String
517 // if (fEditor != null) {
518 // IEditorInput editorInput = fEditor.getEditorInput();
519 // if (editorInput instanceof IFileEditorInput) {
521 // IFile f = ((IFileEditorInput) editorInput).getFile();
522 // return new PHPTextHover(f.getProject());
523 // } catch (NullPointerException e) {
524 // // this exception occurs, if getTextHover is called by preference pages
529 // return new PHPTextHover(null);
532 * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
535 public IInformationControlCreator getInformationControlCreator(
536 ISourceViewer sourceViewer) {
537 return new IInformationControlCreator() {
538 public IInformationControl createInformationControl(Shell parent) {
539 return new DefaultInformationControl(parent, SWT.NONE,
540 new HTMLTextPresenter(true));
541 // return new HoverBrowserControl(parent);
546 * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
549 // public IInformationPresenter getInformationPresenter(ISourceViewer
551 // InformationPresenter presenter= new
552 // InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
553 // IInformationProvider provider= new JavaInformationProvider(getEditor());
554 // presenter.setInformationProvider(provider,
555 // IDocument.DEFAULT_CONTENT_TYPE);
556 // presenter.setInformationProvider(provider, IJavaPartitions.JAVA_DOC);
557 // presenter.setSizeConstraints(60, 10, true, true);
561 * Returns the information presenter control creator. The creator is a
562 * factory creating the presenter controls for the given source viewer.
563 * This implementation always returns a creator for <code>DefaultInformationControl</code>
566 * @param sourceViewer
567 * the source viewer to be configured by this configuration
568 * @return an information control creator
571 private IInformationControlCreator getInformationPresenterControlCreator(
572 ISourceViewer sourceViewer) {
573 return new IInformationControlCreator() {
574 public IInformationControl createInformationControl(Shell parent) {
575 int shellStyle = SWT.RESIZE;
576 int style = SWT.V_SCROLL | SWT.H_SCROLL;
577 return new DefaultInformationControl(parent, shellStyle, style,
578 new HTMLTextPresenter(false));
579 // return new HoverBrowserControl(parent);
584 * Returns the outline presenter control creator. The creator is a factory
585 * creating outline presenter controls for the given source viewer. This
586 * implementation always returns a creator for <code>JavaOutlineInformationControl</code>
589 * @param sourceViewer
590 * the source viewer to be configured by this configuration
591 * @return an information control creator
594 private IInformationControlCreator getOutlinePresenterControlCreator(
595 ISourceViewer sourceViewer) {
596 return new IInformationControlCreator() {
597 public IInformationControl createInformationControl(Shell parent) {
598 int shellStyle = SWT.RESIZE;
599 int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
600 return new JavaOutlineInformationControl(parent, shellStyle,
606 * Returns the outline presenter which will determine and shown information
607 * requested for the current cursor position.
609 * @param sourceViewer
610 * the source viewer to be configured by this configuration
611 * @param doCodeResolve
612 * a boolean which specifies whether code resolve should be used
613 * to compute the Java element
614 * @return an information presenter
617 public IInformationPresenter getOutlinePresenter(
618 ISourceViewer sourceViewer, boolean doCodeResolve) {
619 InformationPresenter presenter = new InformationPresenter(
620 getOutlinePresenterControlCreator(sourceViewer));
621 presenter.setAnchor(InformationPresenter.ANCHOR_GLOBAL);
622 IInformationProvider provider = new JavaElementProvider(getEditor(),
624 presenter.setInformationProvider(provider,
625 IDocument.DEFAULT_CONTENT_TYPE);
626 presenter.setInformationProvider(provider,
627 IPHPPartitions.PHP_PARTITIONING);
628 presenter.setInformationProvider(provider,
629 IPHPPartitions.PHP_PHPDOC_COMMENT);
630 presenter.setInformationProvider(provider,
631 IPHPPartitions.SMARTY_MULTILINE_COMMENT);
632 presenter.setInformationProvider(provider,
633 IPHPPartitions.HTML);
634 presenter.setInformationProvider(provider,
635 IPHPPartitions.HTML_MULTILINE_COMMENT);
636 presenter.setSizeConstraints(40, 20, true, false);