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.AbstractJavaScanner;
17 import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
18 import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
19 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
20 import net.sourceforge.phpdt.internal.ui.text.JavaAnnotationHover;
21 import net.sourceforge.phpdt.internal.ui.text.JavaElementProvider;
22 import net.sourceforge.phpdt.internal.ui.text.JavaOutlineInformationControl;
23 import net.sourceforge.phpdt.internal.ui.text.JavaPresentationReconciler;
24 import net.sourceforge.phpdt.internal.ui.text.JavaReconciler;
25 import net.sourceforge.phpdt.internal.ui.text.java.JavaFormattingStrategy;
26 import net.sourceforge.phpdt.internal.ui.text.java.JavaReconcilingStrategy;
27 import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategy;
28 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
29 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy;
30 import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCompletionProcessor;
31 import net.sourceforge.phpdt.ui.PreferenceConstants;
32 import net.sourceforge.phpdt.ui.text.IColorManager;
33 import net.sourceforge.phpdt.ui.text.JavaTextTools;
34 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
35 import net.sourceforge.phpeclipse.phpeditor.html.HTMLFormattingStrategy;
36 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
37 import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
38 import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
39 import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
40 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
42 import org.eclipse.core.runtime.NullProgressMonitor;
43 import org.eclipse.jface.preference.IPreferenceStore;
44 import org.eclipse.jface.text.DefaultAutoIndentStrategy;
45 import org.eclipse.jface.text.DefaultInformationControl;
46 import org.eclipse.jface.text.IAutoIndentStrategy;
47 import org.eclipse.jface.text.IDocument;
48 import org.eclipse.jface.text.IInformationControl;
49 import org.eclipse.jface.text.IInformationControlCreator;
50 import org.eclipse.jface.text.ITextDoubleClickStrategy;
51 import org.eclipse.jface.text.ITextHover;
52 import org.eclipse.jface.text.ITextViewerExtension2;
53 import org.eclipse.jface.text.TextAttribute;
54 import org.eclipse.jface.text.contentassist.ContentAssistant;
55 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
56 import org.eclipse.jface.text.contentassist.IContentAssistant;
57 import org.eclipse.jface.text.formatter.ContentFormatter;
58 import org.eclipse.jface.text.formatter.IContentFormatter;
59 import org.eclipse.jface.text.formatter.IFormattingStrategy;
60 import org.eclipse.jface.text.information.IInformationPresenter;
61 import org.eclipse.jface.text.information.IInformationProvider;
62 import org.eclipse.jface.text.information.InformationPresenter;
63 import org.eclipse.jface.text.presentation.IPresentationReconciler;
64 import org.eclipse.jface.text.presentation.PresentationReconciler;
65 import org.eclipse.jface.text.reconciler.IReconciler;
66 import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
67 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
68 import org.eclipse.jface.text.rules.DefaultPartitioner;
69 import org.eclipse.jface.text.rules.RuleBasedScanner;
70 import org.eclipse.jface.text.rules.Token;
71 import org.eclipse.jface.text.source.IAnnotationHover;
72 import org.eclipse.jface.text.source.ISourceViewer;
73 import org.eclipse.jface.text.source.SourceViewerConfiguration;
74 import org.eclipse.jface.util.PropertyChangeEvent;
75 import org.eclipse.swt.SWT;
76 import org.eclipse.swt.widgets.Shell;
77 import org.eclipse.ui.texteditor.ITextEditor;
79 * Configuration for an <code>SourceViewer</code> which shows PHP code.
81 public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
83 * Preference key used to look up display tab width.
87 public final static String PREFERENCE_TAB_WIDTH = PreferenceConstants.EDITOR_TAB_WIDTH;
89 * Preference key for inserting spaces rather than tabs.
93 public final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
94 // public static final String HTML_DEFAULT =
95 // IPHPPartitionScannerConstants.HTML;
96 //IDocument.DEFAULT_CONTENT_TYPE;
97 private JavaTextTools fJavaTextTools;
98 private ITextEditor fTextEditor;
99 private ContentFormatter fFormatter;
100 private HTMLFormattingStrategy fFormattingStrategy;
102 * Single token scanner.
104 static class SingleTokenScanner extends BufferedRuleBasedScanner {
105 public SingleTokenScanner(TextAttribute attribute) {
106 setDefaultReturnToken(new Token(attribute));
110 * The document partitioning.
113 private String fDocumentPartitioning;
115 * The Java source code scanner
118 private AbstractJavaScanner fCodeScanner;
120 * The Java multi-line comment scanner
123 private AbstractJavaScanner fMultilineCommentScanner;
125 * The Java single-line comment scanner
128 private AbstractJavaScanner fSinglelineCommentScanner;
130 * The Java string scanner
133 private AbstractJavaScanner fStringScanner;
135 * The Javadoc scanner
138 private AbstractJavaScanner fJavaDocScanner;
140 * The preference store, can be read-only
143 private IPreferenceStore fPreferenceStore;
148 private IColorManager fColorManager;
151 * Creates a new Java source viewer configuration for viewers in the given editor
152 * using the given preference store, the color manager and the specified document partitioning.
154 * Creates a Java source viewer configuration in the new setup without text tools. Clients are
155 * allowed to call {@link JavaSourceViewerConfiguration#handlePropertyChangeEvent(PropertyChangeEvent)}
156 * and disallowed to call {@link JavaSourceViewerConfiguration#getPreferenceStore()} on the resulting
157 * Java source viewer configuration.
160 * @param colorManager the color manager
161 * @param preferenceStore the preference store, can be read-only
162 * @param editor the editor in which the configured viewer(s) will reside
163 * @param partitioning the document partitioning for this configuration
166 public PHPSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor, String partitioning) {
167 fColorManager= colorManager;
168 fPreferenceStore= preferenceStore;
170 fDocumentPartitioning= partitioning;
171 fJavaTextTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
172 // initializeScanners();
176 * Default constructor.
178 public PHPSourceViewerConfiguration(JavaTextTools textTools,
180 fJavaTextTools = textTools;
181 fTextEditor = editor;
184 * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
186 public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
187 // if (fFormatter == null) {
188 // fFormatter = new ContentFormatter();
189 // fFormattingStrategy = new HTMLFormattingStrategy(this,
191 // fFormatter.setFormattingStrategy(fFormattingStrategy, HTML_DEFAULT);
192 // fFormatter.enablePartitionAwareFormatting(false);
193 // fFormatter.setPartitionManagingPositionCategories(getConfiguredContentTypes(null));
195 // return fFormatter;
196 if (fFormatter == null) {
198 fFormatter = new ContentFormatter();
199 IFormattingStrategy strategy = new JavaFormattingStrategy(
201 fFormatter.setFormattingStrategy(strategy,
202 IDocument.DEFAULT_CONTENT_TYPE);
203 fFormatter.enablePartitionAwareFormatting(false);
205 .setPartitionManagingPositionCategories(getPartitionManagingPositionCategories());
210 * Returns the names of the document position categories used by the
211 * document partitioners created by this object to manage their partition
212 * information. If the partitioners don't use document position categories,
213 * the returned result is <code>null</code>.
215 * @return the partition managing position categories or <code>null</code>
218 public String[] getPartitionManagingPositionCategories() {
219 return new String[]{DefaultPartitioner.CONTENT_TYPES_CATEGORY};
222 // * Returns the names of the document position categories used by the
224 // * partitioners created by this object to manage their partition
226 // * If the partitioners don't use document position categories, the
228 // * result is <code>null</code>.
230 // * @return the partition managing position categories or
232 // * if there is none
234 // private String[] getPartitionManagingPositionCategories() {
235 // return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
237 public ITextEditor getEditor() {
241 * Returns the preference store used by this configuration to initialize
242 * the individual bits and pieces.
244 * @return the preference store used to initialize this configuration
248 protected IPreferenceStore getPreferenceStore() {
249 return PHPeclipsePlugin.getDefault().getPreferenceStore();
252 // * Method declared on SourceViewerConfiguration
254 // public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
255 // return new PHPAnnotationHover();
258 * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
260 public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
261 return new JavaAnnotationHover(JavaAnnotationHover.VERTICAL_RULER_HOVER);
264 * @see SourceViewerConfiguration#getOverviewRulerAnnotationHover(ISourceViewer)
267 public IAnnotationHover getOverviewRulerAnnotationHover(
268 ISourceViewer sourceViewer) {
269 return new JavaAnnotationHover(JavaAnnotationHover.OVERVIEW_RULER_HOVER);
272 * (non-Javadoc) Method declared on SourceViewerConfiguration
274 public IAutoIndentStrategy getAutoIndentStrategy(
275 ISourceViewer sourceViewer, String contentType) {
276 if (IPHPPartitions.PHP_STRING_DQ.equals(contentType))
277 return new JavaStringAutoIndentStrategy(getConfiguredDocumentPartitioning(sourceViewer));
279 return (IPHPPartitions.PHP_PARTITIONING.equals(contentType)
280 ? new PHPAutoIndentStrategy()
281 : new DefaultAutoIndentStrategy());
284 * Returns the PHP source code scanner for this configuration.
286 * @return the PHP source code scanner
288 protected RuleBasedScanner getCodeScanner() {
289 return fJavaTextTools.getCodeScanner();
292 * Returns the HTML source code scanner for this configuration.
294 * @return the HTML source code scanner
296 protected RuleBasedScanner getHTMLScanner() {
297 return fJavaTextTools.getHTMLScanner();
300 * Returns the Smarty source code scanner for this configuration.
302 * @return the Smarty source code scanner
304 protected RuleBasedScanner getSmartyScanner() {
305 return fJavaTextTools.getSmartyScanner();
308 * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
310 public IReconciler getReconciler(ISourceViewer sourceViewer) {
311 if (getEditor() != null && getEditor().isEditable()) {
312 JavaReconciler reconciler = new JavaReconciler(getEditor(),
313 new JavaReconcilingStrategy(getEditor()), false);
314 reconciler.setProgressMonitor(new NullProgressMonitor());
315 reconciler.setDelay(500);
321 * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer,
325 public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer,
326 String contentType) {
327 JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin
328 .getDefault().getJavaEditorTextHoverDescriptors();
329 int stateMasks[] = new int[hoverDescs.length];
330 int stateMasksLength = 0;
331 for (int i = 0; i < hoverDescs.length; i++) {
332 if (hoverDescs[i].isEnabled()) {
334 int stateMask = hoverDescs[i].getStateMask();
335 while (j < stateMasksLength) {
336 if (stateMasks[j] == stateMask)
340 if (j == stateMasksLength)
341 stateMasks[stateMasksLength++] = stateMask;
344 if (stateMasksLength == hoverDescs.length)
346 int[] shortenedStateMasks = new int[stateMasksLength];
347 System.arraycopy(stateMasks, 0, shortenedStateMasks, 0,
349 return shortenedStateMasks;
352 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
355 public ITextHover getTextHover(ISourceViewer sourceViewer,
356 String contentType, int stateMask) {
357 JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin
358 .getDefault().getJavaEditorTextHoverDescriptors();
360 while (i < hoverDescs.length) {
361 if (hoverDescs[i].isEnabled()
362 && hoverDescs[i].getStateMask() == stateMask)
363 return new JavaEditorTextHoverProxy(hoverDescs[i], getEditor());
367 // if (fEditor != null) {
368 // IEditorInput editorInput = fEditor.getEditorInput();
369 // if (editorInput instanceof IFileEditorInput) {
371 // IFile f = ((IFileEditorInput) editorInput).getFile();
372 // return new PHPTextHover(f.getProject());
373 // } catch (NullPointerException e) {
374 // // this exception occurs, if getTextHover is called by
375 // // preference pages !
379 // return new PHPTextHover(null);
382 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
384 public ITextHover getTextHover(ISourceViewer sourceViewer,
385 String contentType) {
386 return getTextHover(sourceViewer, contentType,
387 ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
390 * Returns the SmartyDoc source code scanner for this configuration.
392 * @return the SmartyDoc source code scanner
394 protected RuleBasedScanner getSmartyDocScanner() {
395 return fJavaTextTools.getSmartyDocScanner();
398 * Returns the PHPDoc source code scanner for this configuration.
400 * @return the PHPDoc source code scanner
402 protected RuleBasedScanner getPHPDocScanner() {
403 return fJavaTextTools.getJavaDocScanner();
406 * (non-Javadoc) Method declared on SourceViewerConfiguration
408 public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
409 return new String[]{IPHPPartitions.HTML,
410 IPHPPartitions.HTML_MULTILINE_COMMENT,
411 IPHPPartitions.PHP_PARTITIONING,
412 IPHPPartitions.PHP_PHPDOC_COMMENT,
414 IPHPPartitions.CSS_MULTILINE_COMMENT,
415 IPHPPartitions.JAVASCRIPT,
416 IPHPPartitions.JS_MULTILINE_COMMENT,
417 IPHPPartitions.SMARTY,
418 IPHPPartitions.SMARTY_MULTILINE_COMMENT,
419 IDocument.DEFAULT_CONTENT_TYPE};
422 * (non-Javadoc) Method declared on SourceViewerConfiguration
424 public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
425 ContentAssistant assistant = new ContentAssistant();
426 IContentAssistProcessor processor = new HTMLCompletionProcessor();
427 assistant.setContentAssistProcessor(processor,
428 IPHPPartitions.HTML);
429 assistant.setContentAssistProcessor(processor,
430 IPHPPartitions.HTML_MULTILINE_COMMENT);
431 assistant.setContentAssistProcessor(processor,
432 IDocument.DEFAULT_CONTENT_TYPE);
433 assistant.setContentAssistProcessor(processor,
435 assistant.setContentAssistProcessor(processor,
436 IPHPPartitions.CSS_MULTILINE_COMMENT);
437 assistant.setContentAssistProcessor(processor,
438 IPHPPartitions.JAVASCRIPT);
439 assistant.setContentAssistProcessor(processor,
440 IPHPPartitions.JS_MULTILINE_COMMENT);
441 // TODO define special smarty partition content assist
442 assistant.setContentAssistProcessor(processor,
443 IPHPPartitions.SMARTY);
444 assistant.setContentAssistProcessor(processor,
445 IPHPPartitions.SMARTY_MULTILINE_COMMENT);
446 assistant.setContentAssistProcessor(new PHPCompletionProcessor(),
447 IPHPPartitions.PHP_PARTITIONING);
448 assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(),
449 IPHPPartitions.PHP_PHPDOC_COMMENT);
450 // assistant.enableAutoActivation(true);
451 // assistant.setAutoActivationDelay(500);
452 // assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
453 // ContentAssistPreference.configure(assistant, getPreferenceStore());
454 // assistant.setContextInformationPopupOrientation(
455 // ContentAssistant.CONTEXT_INFO_ABOVE);
456 // assistant.setContextInformationPopupBackground(
457 // PHPEditorEnvironment.getPHPColorProvider().getColor(
458 // new RGB(150, 150, 0)));
459 ContentAssistPreference.configure(assistant, getPreferenceStore());
461 .setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
463 .setInformationControlCreator(getInformationControlCreator(sourceViewer));
467 * (non-Javadoc) Method declared on SourceViewerConfiguration
469 // public String getDefaultPrefix(ISourceViewer sourceViewer, String
471 // return (PHPPartitionScanner.PHP.equals(contentType) ? "//" : null);
473 // // return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" :
474 // null); //$NON-NLS-1$
477 * @see SourceViewerConfiguration#getDefaultPrefix(ISourceViewer, String)
480 public String[] getDefaultPrefixes(ISourceViewer sourceViewer,
481 String contentType) {
482 return new String[]{"//", ""}; //$NON-NLS-1$ //$NON-NLS-2$
485 * (non-Javadoc) Method declared on SourceViewerConfiguration
487 public ITextDoubleClickStrategy getDoubleClickStrategy(
488 ISourceViewer sourceViewer, String contentType) {
489 return new PHPDoubleClickSelector();
492 * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String)
494 public String[] getIndentPrefixes(ISourceViewer sourceViewer,
495 String contentType) {
496 Vector vector = new Vector();
497 // prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
498 final IPreferenceStore preferences = PHPeclipsePlugin.getDefault()
499 .getPreferenceStore();
500 int tabWidth = preferences.getInt(JavaCore.FORMATTER_TAB_SIZE);
501 boolean useSpaces = getPreferenceStore().getBoolean(SPACES_FOR_TABS);
502 for (int i = 0; i <= tabWidth; i++) {
503 StringBuffer prefix = new StringBuffer();
505 for (int j = 0; j + i < tabWidth; j++)
510 for (int j = 0; j < i; j++)
515 vector.add(prefix.toString());
517 vector.add(""); //$NON-NLS-1$
518 return (String[]) vector.toArray(new String[vector.size()]);
521 * (non-Javadoc) Method declared on SourceViewerConfiguration
523 public IPresentationReconciler getPresentationReconciler(
524 ISourceViewer sourceViewer) {
525 // PHPColorProvider provider =
526 // PHPEditorEnvironment.getPHPColorProvider();
527 // JavaColorManager provider =
528 // PHPEditorEnvironment.getPHPColorProvider();
529 PresentationReconciler reconciler= new JavaPresentationReconciler();
530 reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
532 DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getHTMLScanner());
533 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
534 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
535 dr = new DefaultDamagerRepairer(getHTMLScanner());
536 reconciler.setDamager(dr, IPHPPartitions.HTML);
537 reconciler.setRepairer(dr, IPHPPartitions.HTML);
538 dr = new DefaultDamagerRepairer(getHTMLScanner());
539 reconciler.setDamager(dr, IPHPPartitions.CSS);
540 reconciler.setRepairer(dr, IPHPPartitions.CSS);
541 dr = new DefaultDamagerRepairer(getHTMLScanner());
542 reconciler.setDamager(dr,
543 IPHPPartitions.CSS_MULTILINE_COMMENT);
544 reconciler.setRepairer(dr,
545 IPHPPartitions.CSS_MULTILINE_COMMENT);
546 dr = new DefaultDamagerRepairer(getHTMLScanner());
547 reconciler.setDamager(dr, IPHPPartitions.JAVASCRIPT);
548 reconciler.setRepairer(dr, IPHPPartitions.JAVASCRIPT);
549 dr = new DefaultDamagerRepairer(getHTMLScanner());
550 reconciler.setDamager(dr,
551 IPHPPartitions.JS_MULTILINE_COMMENT);
552 reconciler.setRepairer(dr,
553 IPHPPartitions.JS_MULTILINE_COMMENT);
554 dr = new DefaultDamagerRepairer(getSmartyScanner());
555 reconciler.setDamager(dr, IPHPPartitions.SMARTY);
556 reconciler.setRepairer(dr, IPHPPartitions.SMARTY);
557 dr = new DefaultDamagerRepairer(getSmartyDocScanner());
558 reconciler.setDamager(dr,
559 IPHPPartitions.SMARTY_MULTILINE_COMMENT);
560 reconciler.setRepairer(dr,
561 IPHPPartitions.SMARTY_MULTILINE_COMMENT);
562 dr = new DefaultDamagerRepairer(new SingleTokenScanner(
563 new TextAttribute(fJavaTextTools.getColorManager().getColor(
564 PHPColorProvider.MULTI_LINE_COMMENT))));
565 reconciler.setDamager(dr,
566 IPHPPartitions.HTML_MULTILINE_COMMENT);
567 reconciler.setRepairer(dr,
568 IPHPPartitions.HTML_MULTILINE_COMMENT);
569 dr = new DefaultDamagerRepairer(getCodeScanner());
570 reconciler.setDamager(dr, IPHPPartitions.PHP_PARTITIONING);
571 reconciler.setRepairer(dr, IPHPPartitions.PHP_PARTITIONING);
572 dr = new DefaultDamagerRepairer(getPHPDocScanner());
573 reconciler.setDamager(dr,
574 IPHPPartitions.PHP_PHPDOC_COMMENT);
575 reconciler.setRepairer(dr,
576 IPHPPartitions.PHP_PHPDOC_COMMENT);
580 * (non-Javadoc) Method declared on SourceViewerConfiguration
582 public int getTabWidth(ISourceViewer sourceViewer) {
583 return getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH);
586 * (non-Javadoc) Method declared on SourceViewerConfiguration
588 // public ITextHover getTextHover(ISourceViewer sourceViewer, String
590 // if (fEditor != null) {
591 // IEditorInput editorInput = fEditor.getEditorInput();
592 // if (editorInput instanceof IFileEditorInput) {
594 // IFile f = ((IFileEditorInput) editorInput).getFile();
595 // return new PHPTextHover(f.getProject());
596 // } catch (NullPointerException e) {
597 // // this exception occurs, if getTextHover is called by preference pages
602 // return new PHPTextHover(null);
605 * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
608 public IInformationControlCreator getInformationControlCreator(
609 ISourceViewer sourceViewer) {
610 return new IInformationControlCreator() {
611 public IInformationControl createInformationControl(Shell parent) {
612 return new DefaultInformationControl(parent, SWT.NONE,
613 new HTMLTextPresenter(true));
614 // return new HoverBrowserControl(parent);
619 * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
622 // public IInformationPresenter getInformationPresenter(ISourceViewer
624 // InformationPresenter presenter= new
625 // InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
626 // IInformationProvider provider= new JavaInformationProvider(getEditor());
627 // presenter.setInformationProvider(provider,
628 // IDocument.DEFAULT_CONTENT_TYPE);
629 // presenter.setInformationProvider(provider, IJavaPartitions.JAVA_DOC);
630 // presenter.setSizeConstraints(60, 10, true, true);
634 * Returns the information presenter control creator. The creator is a
635 * factory creating the presenter controls for the given source viewer.
636 * This implementation always returns a creator for <code>DefaultInformationControl</code>
639 * @param sourceViewer
640 * the source viewer to be configured by this configuration
641 * @return an information control creator
644 private IInformationControlCreator getInformationPresenterControlCreator(
645 ISourceViewer sourceViewer) {
646 return new IInformationControlCreator() {
647 public IInformationControl createInformationControl(Shell parent) {
648 int shellStyle = SWT.RESIZE;
649 int style = SWT.V_SCROLL | SWT.H_SCROLL;
650 return new DefaultInformationControl(parent, shellStyle, style,
651 new HTMLTextPresenter(false));
652 // return new HoverBrowserControl(parent);
657 * Returns the outline presenter control creator. The creator is a factory
658 * creating outline presenter controls for the given source viewer. This
659 * implementation always returns a creator for <code>JavaOutlineInformationControl</code>
662 * @param sourceViewer
663 * the source viewer to be configured by this configuration
664 * @return an information control creator
667 private IInformationControlCreator getOutlinePresenterControlCreator(
668 ISourceViewer sourceViewer) {
669 return new IInformationControlCreator() {
670 public IInformationControl createInformationControl(Shell parent) {
671 int shellStyle = SWT.RESIZE;
672 int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
673 return new JavaOutlineInformationControl(parent, shellStyle,
679 * Returns the outline presenter which will determine and shown information
680 * requested for the current cursor position.
682 * @param sourceViewer
683 * the source viewer to be configured by this configuration
684 * @param doCodeResolve
685 * a boolean which specifies whether code resolve should be used
686 * to compute the Java element
687 * @return an information presenter
690 public IInformationPresenter getOutlinePresenter(
691 ISourceViewer sourceViewer, boolean doCodeResolve) {
692 InformationPresenter presenter = new InformationPresenter(
693 getOutlinePresenterControlCreator(sourceViewer));
694 presenter.setAnchor(InformationPresenter.ANCHOR_GLOBAL);
695 IInformationProvider provider = new JavaElementProvider(getEditor(),
697 presenter.setInformationProvider(provider,
698 IDocument.DEFAULT_CONTENT_TYPE);
699 presenter.setInformationProvider(provider,
700 IPHPPartitions.PHP_PARTITIONING);
701 presenter.setInformationProvider(provider,
702 IPHPPartitions.PHP_PHPDOC_COMMENT);
703 presenter.setInformationProvider(provider,
704 IPHPPartitions.SMARTY_MULTILINE_COMMENT);
705 presenter.setInformationProvider(provider,
706 IPHPPartitions.HTML);
707 presenter.setInformationProvider(provider,
708 IPHPPartitions.HTML_MULTILINE_COMMENT);
709 presenter.setSizeConstraints(40, 20, true, false);