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
 
  11  **********************************************************************/
 
  12 package net.sourceforge.phpdt.ui.text;
 
  14 import java.util.Vector;
 
  16 import net.sourceforge.phpdt.core.JavaCore;
 
  17 import net.sourceforge.phpdt.internal.ui.text.AbstractJavaScanner;
 
  18 import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
 
  19 import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
 
  20 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
 
  21 import net.sourceforge.phpdt.internal.ui.text.JavaAnnotationHover;
 
  22 import net.sourceforge.phpdt.internal.ui.text.JavaCompositeReconcilingStrategy;
 
  23 import net.sourceforge.phpdt.internal.ui.text.JavaElementProvider;
 
  24 import net.sourceforge.phpdt.internal.ui.text.JavaOutlineInformationControl;
 
  25 import net.sourceforge.phpdt.internal.ui.text.JavaPresentationReconciler;
 
  26 import net.sourceforge.phpdt.internal.ui.text.JavaReconciler;
 
  27 import net.sourceforge.phpdt.internal.ui.text.java.JavaFormattingStrategy;
 
  28 import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategyDQ;
 
  29 import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategySQ;
 
  30 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
 
  31 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy;
 
  32 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaInformationProvider;
 
  33 import net.sourceforge.phpdt.internal.ui.text.phpdoc.JavaDocAutoIndentStrategy;
 
  34 import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCodeScanner;
 
  35 import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCompletionProcessor;
 
  36 import net.sourceforge.phpdt.ui.PreferenceConstants;
 
  37 import net.sourceforge.phpeclipse.IPreferenceConstants;
 
  38 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
  39 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
 
  40 import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
 
  41 import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
 
  42 import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
 
  43 import net.sourceforge.phpeclipse.phpeditor.php.PHPDocumentPartitioner;
 
  44 import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
 
  45 import net.sourceforge.phpeclipse.phpeditor.php.PHPPartitionScanner;
 
  46 import net.sourceforge.phpeclipse.xml.ui.XMLPlugin;
 
  47 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLConfiguration;
 
  48 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLPartitionScanner;
 
  49 import net.sourceforge.phpeclipse.xml.ui.text.XMLTextTools;
 
  51 import org.eclipse.core.runtime.NullProgressMonitor;
 
  52 import org.eclipse.jface.preference.IPreferenceStore;
 
  53 import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
 
  54 import org.eclipse.jface.text.DefaultInformationControl;
 
  55 import org.eclipse.jface.text.IAutoEditStrategy;
 
  56 import org.eclipse.jface.text.IDocument;
 
  57 import org.eclipse.jface.text.IInformationControl;
 
  58 import org.eclipse.jface.text.IInformationControlCreator;
 
  59 import org.eclipse.jface.text.ITextDoubleClickStrategy;
 
  60 import org.eclipse.jface.text.ITextHover;
 
  61 import org.eclipse.jface.text.ITextViewerExtension2;
 
  62 import org.eclipse.jface.text.TextAttribute;
 
  63 import org.eclipse.jface.text.contentassist.ContentAssistant;
 
  64 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
 
  65 import org.eclipse.jface.text.contentassist.IContentAssistant;
 
  66 import org.eclipse.jface.text.formatter.ContentFormatter;
 
  67 import org.eclipse.jface.text.formatter.IContentFormatter;
 
  68 import org.eclipse.jface.text.formatter.IFormattingStrategy;
 
  69 import org.eclipse.jface.text.information.IInformationPresenter;
 
  70 import org.eclipse.jface.text.information.IInformationProvider;
 
  71 import org.eclipse.jface.text.information.InformationPresenter;
 
  72 import org.eclipse.jface.text.presentation.IPresentationDamager;
 
  73 import org.eclipse.jface.text.presentation.IPresentationReconciler;
 
  74 import org.eclipse.jface.text.presentation.IPresentationRepairer;
 
  75 import org.eclipse.jface.text.presentation.PresentationReconciler;
 
  76 import org.eclipse.jface.text.reconciler.IReconciler;
 
  77 import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
 
  78 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
 
  79 import org.eclipse.jface.text.rules.DefaultPartitioner;
 
  80 import org.eclipse.jface.text.rules.RuleBasedScanner;
 
  81 import org.eclipse.jface.text.rules.Token;
 
  82 import org.eclipse.jface.text.source.IAnnotationHover;
 
  83 import org.eclipse.jface.text.source.ISourceViewer;
 
  84 import org.eclipse.jface.text.source.SourceViewerConfiguration;
 
  85 import org.eclipse.jface.util.PropertyChangeEvent;
 
  86 import org.eclipse.swt.SWT;
 
  87 import org.eclipse.swt.widgets.Shell;
 
  88 import org.eclipse.ui.texteditor.ITextEditor;
 
  91  * Configuration for an <code>SourceViewer</code> which shows PHP code.
 
  93 public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
 
  95          * Preference key used to look up display tab width.
 
  99         public final static String PREFERENCE_TAB_WIDTH = PreferenceConstants.EDITOR_TAB_WIDTH;
 
 102          * Preference key for inserting spaces rather than tabs.
 
 106         public final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
 
 108         // public static final String HTML_DEFAULT =
 
 109         // IPHPPartitionScannerConstants.HTML;
 
 110         // IDocument.DEFAULT_CONTENT_TYPE;
 
 111         // private JavaTextTools fJavaTextTools;
 
 113         private ITextEditor fTextEditor;
 
 116          * The document partitioning.
 
 120         private String fDocumentPartitioning;
 
 122         private ContentFormatter fFormatter;
 
 125          * Single token scanner.
 
 127         static class SingleTokenScanner extends BufferedRuleBasedScanner {
 
 128                 public SingleTokenScanner(TextAttribute attribute) {
 
 129                         setDefaultReturnToken(new Token(attribute));
 
 134          * The document partitioning.
 
 138         // private String fDocumentPartitioning;
 
 140          * The Java source code scanner
 
 144         private AbstractJavaScanner fCodeScanner;
 
 147          * The Java multi-line comment scanner
 
 151         private AbstractJavaScanner fMultilineCommentScanner;
 
 154          * The Java single-line comment scanner
 
 158         private AbstractJavaScanner fSinglelineCommentScanner;
 
 161          * The PHP double quoted string scanner
 
 163         private AbstractJavaScanner fStringDQScanner;
 
 166          * The PHP single quoted string scanner
 
 168         private AbstractJavaScanner fStringSQScanner;
 
 171          * The Javadoc scanner
 
 175         private AbstractJavaScanner fJavaDocScanner;
 
 178          * The preference store, can be read-only
 
 182         private IPreferenceStore fPreferenceStore;
 
 189         private IColorManager fColorManager;
 
 191         private XMLTextTools fXMLTextTools;
 
 193         private XMLConfiguration xmlConfiguration;
 
 196          * Creates a new Java source viewer configuration for viewers in the given
 
 197          * editor using the given preference store, the color manager and the
 
 198          * specified document partitioning.
 
 200          * Creates a Java source viewer configuration in the new setup without text
 
 201          * tools. Clients are allowed to call
 
 202          * {@link JavaSourceViewerConfiguration#handlePropertyChangeEvent(PropertyChangeEvent)}and
 
 204          * {@link JavaSourceViewerConfiguration#getPreferenceStore()}on the
 
 205          * resulting Java source viewer configuration.
 
 208          * @param colorManager
 
 210          * @param preferenceStore
 
 211          *            the preference store, can be read-only
 
 213          *            the editor in which the configured viewer(s) will reside
 
 214          * @param partitioning
 
 215          *            the document partitioning for this configuration
 
 218         public PHPSourceViewerConfiguration(IColorManager colorManager,
 
 219                         IPreferenceStore preferenceStore, ITextEditor editor,
 
 220                         String partitioning) {
 
 221                 fColorManager = colorManager;
 
 222                 fPreferenceStore = preferenceStore;
 
 223                 fTextEditor = editor;
 
 224                 fDocumentPartitioning = partitioning;
 
 225                 // fJavaTextTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
 
 226                 fXMLTextTools = XMLPlugin.getDefault().getXMLTextTools();
 
 227                 xmlConfiguration = new XMLConfiguration(fXMLTextTools);
 
 228                 fColorManager = colorManager;
 
 229                 fPreferenceStore = preferenceStore;
 
 230                 fTextEditor = editor;
 
 231                 fDocumentPartitioning = partitioning;
 
 233                 initializeScanners();
 
 237          * Creates a new Java source viewer configuration for viewers in the given
 
 238          * editor using the given Java tools.
 
 241          *            the Java text tools to be used
 
 243          *            the editor in which the configured viewer(s) will reside
 
 245          * @deprecated As of 3.0, replaced by
 
 246          *             {@link JavaSourceViewerConfiguration#JavaSourceViewerConfiguration(IColorManager, IPreferenceStore, ITextEditor, String)}
 
 248         // public PHPSourceViewerConfiguration(JavaTextTools tools, PHPEditor
 
 249         // editor, String partitioning) {
 
 250         // fJavaTextTools = tools;
 
 251         // fColorManager = tools.getColorManager();
 
 252         // fPreferenceStore = createPreferenceStore();
 
 253         // fDocumentPartitioning = partitioning;
 
 254         // fCodeScanner = (AbstractJavaScanner) fJavaTextTools.getCodeScanner();
 
 255         // fMultilineCommentScanner = (AbstractJavaScanner)
 
 256         // fJavaTextTools.getMultilineCommentScanner();
 
 257         // fSinglelineCommentScanner = (AbstractJavaScanner)
 
 258         // fJavaTextTools.getSinglelineCommentScanner();
 
 259         // fStringDQScanner = (AbstractJavaScanner)
 
 260         // fJavaTextTools.getStringScanner();
 
 261         // fJavaDocScanner = (AbstractJavaScanner)
 
 262         // fJavaTextTools.getJavaDocScanner();
 
 263         // fTextEditor = editor;
 
 264         // fXMLTextTools = XMLPlugin.getDefault().getXMLTextTools();
 
 265         // xmlConfiguration = new XMLConfiguration(fXMLTextTools);
 
 268          * Returns the color manager for this configuration.
 
 270          * @return the color manager
 
 272         protected IColorManager getColorManager() {
 
 273                 return fColorManager;
 
 277          * Initializes the scanners.
 
 281         private void initializeScanners() {
 
 282                 // Assert.isTrue(isNewSetup());
 
 283                 fCodeScanner = new PHPCodeScanner(getColorManager(), fPreferenceStore);
 
 284                 fMultilineCommentScanner = new SingleTokenPHPScanner(getColorManager(),
 
 285                                 fPreferenceStore, IPreferenceConstants.PHP_MULTILINE_COMMENT);
 
 286                 fSinglelineCommentScanner = new SingleTokenPHPScanner(
 
 287                                 getColorManager(), fPreferenceStore,
 
 288                                 IPreferenceConstants.PHP_SINGLELINE_COMMENT);
 
 289                 // fStringDQScanner = new SingleTokenPHPScanner(getColorManager(),
 
 290                 // fPreferenceStore, IPreferenceConstants.PHP_STRING_DQ);
 
 291                 fStringDQScanner = new PHPStringDQCodeScanner(getColorManager(),
 
 293                 fStringSQScanner = new SingleTokenPHPScanner(getColorManager(),
 
 294                                 fPreferenceStore, IPreferenceConstants.PHP_STRING_SQ);
 
 295                 fJavaDocScanner = new PHPDocCodeScanner(getColorManager(),
 
 300          * Determines whether the preference change encoded by the given event
 
 301          * changes the behavior of one of its contained components.
 
 304          *            the event to be investigated
 
 305          * @return <code>true</code> if event causes a behavioral change
 
 308         public boolean affectsTextPresentation(PropertyChangeEvent event) {
 
 309                 return fCodeScanner.affectsBehavior(event)
 
 310                                 || fMultilineCommentScanner.affectsBehavior(event)
 
 311                                 || fSinglelineCommentScanner.affectsBehavior(event)
 
 312                                 || fStringDQScanner.affectsBehavior(event)
 
 313                                 || fStringSQScanner.affectsBehavior(event)
 
 314                                 || fJavaDocScanner.affectsBehavior(event);
 
 318          * Adapts the behavior of the contained components to the change encoded in
 
 321          * Clients are not allowed to call this method if the old setup with text
 
 326          *            the event to which to adapt
 
 327          * @see JavaSourceViewerConfiguration#JavaSourceViewerConfiguration(IColorManager,
 
 328          *      IPreferenceStore, ITextEditor, String)
 
 331         public void handlePropertyChangeEvent(PropertyChangeEvent event) {
 
 332                 // Assert.isTrue(isNewSetup());
 
 333                 if (fCodeScanner.affectsBehavior(event))
 
 334                         fCodeScanner.adaptToPreferenceChange(event);
 
 335                 if (fMultilineCommentScanner.affectsBehavior(event))
 
 336                         fMultilineCommentScanner.adaptToPreferenceChange(event);
 
 337                 if (fSinglelineCommentScanner.affectsBehavior(event))
 
 338                         fSinglelineCommentScanner.adaptToPreferenceChange(event);
 
 339                 if (fStringDQScanner.affectsBehavior(event))
 
 340                         fStringDQScanner.adaptToPreferenceChange(event);
 
 341                 if (fStringSQScanner.affectsBehavior(event))
 
 342                         fStringSQScanner.adaptToPreferenceChange(event);
 
 343                 if (fJavaDocScanner.affectsBehavior(event))
 
 344                         fJavaDocScanner.adaptToPreferenceChange(event);
 
 348          * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
 
 350         public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
 
 351                 // if (fFormatter == null) {
 
 352                 // fFormatter = new ContentFormatter();
 
 353                 // fFormattingStrategy = new HTMLFormattingStrategy(this,
 
 355                 // fFormatter.setFormattingStrategy(fFormattingStrategy, HTML_DEFAULT);
 
 356                 // fFormatter.enablePartitionAwareFormatting(false);
 
 357                 // fFormatter.setPartitionManagingPositionCategories(getConfiguredContentTypes(null));
 
 359                 // return fFormatter;
 
 360                 if (fFormatter == null) {
 
 362                         fFormatter = new ContentFormatter();
 
 363                         IFormattingStrategy strategy = new JavaFormattingStrategy(
 
 365                         fFormatter.setFormattingStrategy(strategy,
 
 366                                         IDocument.DEFAULT_CONTENT_TYPE);
 
 367                         fFormatter.enablePartitionAwareFormatting(false);
 
 369                                         .setPartitionManagingPositionCategories(getPartitionManagingPositionCategories());
 
 375          * Returns the names of the document position categories used by the
 
 376          * document partitioners created by this object to manage their partition
 
 377          * information. If the partitioners don't use document position categories,
 
 378          * the returned result is <code>null</code>.
 
 380          * @return the partition managing position categories or <code>null</code>
 
 383         public String[] getPartitionManagingPositionCategories() {
 
 384                 return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
 
 388         // * Returns the names of the document position categories used by the
 
 390         // * partitioners created by this object to manage their partition
 
 392         // * If the partitioners don't use document position categories, the
 
 394         // * result is <code>null</code>.
 
 396         // * @return the partition managing position categories or
 
 398         // * if there is none
 
 400         // private String[] getPartitionManagingPositionCategories() {
 
 401         // return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
 
 403         public ITextEditor getEditor() {
 
 408          * Returns the preference store used by this configuration to initialize the
 
 409          * individual bits and pieces.
 
 411          * @return the preference store used to initialize this configuration
 
 415         protected IPreferenceStore getPreferenceStore() {
 
 416                 return PHPeclipsePlugin.getDefault().getPreferenceStore();
 
 420         // * Method declared on SourceViewerConfiguration
 
 422         // public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
 
 423         // return new PHPAnnotationHover();
 
 426          * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
 
 428         public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
 
 429                 return new JavaAnnotationHover(JavaAnnotationHover.VERTICAL_RULER_HOVER);
 
 433          * @see SourceViewerConfiguration#getOverviewRulerAnnotationHover(ISourceViewer)
 
 436         public IAnnotationHover getOverviewRulerAnnotationHover(
 
 437                         ISourceViewer sourceViewer) {
 
 438                 return new JavaAnnotationHover(JavaAnnotationHover.OVERVIEW_RULER_HOVER);
 
 441         public IAutoEditStrategy[] getAutoEditStrategies(
 
 442                         ISourceViewer sourceViewer, String contentType) {
 
 443                 IAutoEditStrategy strategy = new DefaultIndentLineAutoEditStrategy();
 
 444                 if (IPHPPartitions.PHP_PHPDOC_COMMENT.equals(contentType)
 
 445                                 || IPHPPartitions.PHP_MULTILINE_COMMENT.equals(contentType))
 
 446                         strategy = new JavaDocAutoIndentStrategy(
 
 447                                         getConfiguredDocumentPartitioning(sourceViewer));
 
 448                 else if (IPHPPartitions.PHP_STRING_DQ.equals(contentType))
 
 449                         strategy = new JavaStringAutoIndentStrategyDQ(
 
 450                                         getConfiguredDocumentPartitioning(sourceViewer));
 
 451                 else if (IPHPPartitions.PHP_STRING_SQ.equals(contentType))
 
 452                         strategy = new JavaStringAutoIndentStrategySQ(
 
 453                                         getConfiguredDocumentPartitioning(sourceViewer));
 
 455                         strategy = (PHPDocumentPartitioner.PHP_TEMPLATE_DATA
 
 457                                         || PHPDocumentPartitioner.PHP_SCRIPT_CODE
 
 459                                         || IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)
 
 460                                         || IPHPPartitions.PHP_PARTITIONING.equals(contentType)
 
 461                                         || PHPPartitionScanner.PHP_SCRIPTING_AREA
 
 462                                                         .equals(contentType) ? new PHPAutoIndentStrategy()
 
 463                                         : new DefaultIndentLineAutoEditStrategy());
 
 464                 IAutoEditStrategy[] result = new IAutoEditStrategy[1];
 
 465                 result[0] = strategy;
 
 470          * Returns the PHP source code scanner for this configuration.
 
 472          * @return the PHP source code scanner
 
 474         protected RuleBasedScanner getCodeScanner() {
 
 475                 return fCodeScanner; // fJavaTextTools.getCodeScanner();
 
 479          * Returns the Java multi-line comment scanner for this configuration.
 
 481          * @return the Java multi-line comment scanner
 
 484         protected RuleBasedScanner getMultilineCommentScanner() {
 
 485                 return fMultilineCommentScanner;
 
 489          * Returns the Java single-line comment scanner for this configuration.
 
 491          * @return the Java single-line comment scanner
 
 494         protected RuleBasedScanner getSinglelineCommentScanner() {
 
 495                 return fSinglelineCommentScanner;
 
 499          * Returns the PHP double quoted string scanner for this configuration.
 
 501          * @return the PHP double quoted string scanner
 
 503         protected RuleBasedScanner getStringDQScanner() {
 
 504                 return fStringDQScanner;
 
 508          * Returns the PHP single quoted string scanner for this configuration.
 
 510          * @return the PHP single quoted string scanner
 
 512         protected RuleBasedScanner getStringSQScanner() {
 
 513                 return fStringSQScanner;
 
 517          * Returns the HTML source code scanner for this configuration.
 
 519          * @return the HTML source code scanner
 
 521         // protected RuleBasedScanner getHTMLScanner() {
 
 522         // return fJavaTextTools.getHTMLScanner();
 
 525          * Returns the Smarty source code scanner for this configuration.
 
 527          * @return the Smarty source code scanner
 
 529         // protected RuleBasedScanner getSmartyScanner() {
 
 530         // return fJavaTextTools.getSmartyScanner();
 
 533          * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
 
 536          * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
 
 538         public IReconciler getReconciler(ISourceViewer sourceViewer) {
 
 540                 final ITextEditor editor = getEditor();
 
 541                 if (editor != null && editor.isEditable()) {
 
 543                         JavaCompositeReconcilingStrategy strategy = new JavaCompositeReconcilingStrategy(
 
 544                                         editor, getConfiguredDocumentPartitioning(sourceViewer));
 
 545                         JavaReconciler reconciler = new JavaReconciler(editor, strategy,
 
 547                         reconciler.setIsIncrementalReconciler(false);
 
 548                         reconciler.setProgressMonitor(new NullProgressMonitor());
 
 549                         reconciler.setDelay(500);
 
 557          * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer,
 
 561         public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer,
 
 562                         String contentType) {
 
 563                 JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin
 
 564                                 .getDefault().getJavaEditorTextHoverDescriptors();
 
 565                 int stateMasks[] = new int[hoverDescs.length];
 
 566                 int stateMasksLength = 0;
 
 567                 for (int i = 0; i < hoverDescs.length; i++) {
 
 568                         if (hoverDescs[i].isEnabled()) {
 
 570                                 int stateMask = hoverDescs[i].getStateMask();
 
 571                                 while (j < stateMasksLength) {
 
 572                                         if (stateMasks[j] == stateMask)
 
 576                                 if (j == stateMasksLength)
 
 577                                         stateMasks[stateMasksLength++] = stateMask;
 
 580                 if (stateMasksLength == hoverDescs.length)
 
 582                 int[] shortenedStateMasks = new int[stateMasksLength];
 
 583                 System.arraycopy(stateMasks, 0, shortenedStateMasks, 0,
 
 585                 return shortenedStateMasks;
 
 589          * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
 
 592         public ITextHover getTextHover(ISourceViewer sourceViewer,
 
 593                         String contentType, int stateMask) {
 
 594                 JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin
 
 595                                 .getDefault().getJavaEditorTextHoverDescriptors();
 
 597                 while (i < hoverDescs.length) {
 
 598                         if (hoverDescs[i].isEnabled()
 
 599                                         && hoverDescs[i].getStateMask() == stateMask)
 
 600                                 return new JavaEditorTextHoverProxy(hoverDescs[i], getEditor());
 
 604                 // if (fEditor != null) {
 
 605                 // IEditorInput editorInput = fEditor.getEditorInput();
 
 606                 // if (editorInput instanceof IFileEditorInput) {
 
 608                 // IFile f = ((IFileEditorInput) editorInput).getFile();
 
 609                 // return new PHPTextHover(f.getProject());
 
 610                 // } catch (NullPointerException e) {
 
 611                 // // this exception occurs, if getTextHover is called by
 
 612                 // // preference pages !
 
 616                 // return new PHPTextHover(null);
 
 620          * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
 
 622         public ITextHover getTextHover(ISourceViewer sourceViewer,
 
 623                         String contentType) {
 
 624                 return getTextHover(sourceViewer, contentType,
 
 625                                 ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
 
 629          * Returns the SmartyDoc source code scanner for this configuration.
 
 631          * @return the SmartyDoc source code scanner
 
 633         // protected RuleBasedScanner getSmartyDocScanner() {
 
 634         // return fJavaTextTools.getSmartyDocScanner();
 
 637          * Returns the PHPDoc source code scanner for this configuration.
 
 639          * @return the PHPDoc source code scanner
 
 641         protected RuleBasedScanner getPHPDocScanner() {
 
 642                 return fJavaDocScanner; // fJavaTextTools.getJavaDocScanner();
 
 646          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 648         public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
 
 649                 return new String[] { IDocument.DEFAULT_CONTENT_TYPE,
 
 650                                 PHPPartitionScanner.PHP_SCRIPTING_AREA,
 
 652                                 IPHPPartitions.HTML, IPHPPartitions.HTML_MULTILINE_COMMENT,
 
 653                                 IPHPPartitions.PHP_PARTITIONING,
 
 654                                 IPHPPartitions.PHP_SINGLELINE_COMMENT,
 
 655                                 IPHPPartitions.PHP_MULTILINE_COMMENT,
 
 656                                 IPHPPartitions.PHP_PHPDOC_COMMENT,
 
 657                                 IPHPPartitions.PHP_STRING_DQ, IPHPPartitions.PHP_STRING_SQ,
 
 658                                 IPHPPartitions.PHP_STRING_HEREDOC, IPHPPartitions.CSS,
 
 659                                 IPHPPartitions.CSS_MULTILINE_COMMENT,
 
 660                                 IPHPPartitions.JAVASCRIPT, IPHPPartitions.JS_MULTILINE_COMMENT,
 
 661                                 IPHPPartitions.SMARTY, IPHPPartitions.SMARTY_MULTILINE_COMMENT,
 
 663                                 XMLPartitionScanner.XML_PI, XMLPartitionScanner.XML_COMMENT,
 
 664                                 XMLPartitionScanner.XML_DECL, XMLPartitionScanner.XML_TAG,
 
 665                                 XMLPartitionScanner.XML_ATTRIBUTE,
 
 666                                 XMLPartitionScanner.XML_CDATA,
 
 668                                 XMLPartitionScanner.DTD_INTERNAL,
 
 669                                 XMLPartitionScanner.DTD_INTERNAL_PI,
 
 670                                 XMLPartitionScanner.DTD_INTERNAL_COMMENT,
 
 671                                 XMLPartitionScanner.DTD_INTERNAL_DECL,
 
 673                                 PHPDocumentPartitioner.PHP_TEMPLATE_DATA,
 
 674                                 PHPDocumentPartitioner.PHP_SCRIPT_CODE };
 
 677         public String[] getConfiguredHTMLContentTypes() {
 
 678                 return new String[] { XMLPartitionScanner.XML_PI,
 
 679                                 XMLPartitionScanner.XML_COMMENT, XMLPartitionScanner.XML_DECL,
 
 680                                 XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_ATTRIBUTE,
 
 681                                 XMLPartitionScanner.XML_CDATA,
 
 683                                 XMLPartitionScanner.DTD_INTERNAL,
 
 684                                 XMLPartitionScanner.DTD_INTERNAL_PI,
 
 685                                 XMLPartitionScanner.DTD_INTERNAL_COMMENT,
 
 686                                 XMLPartitionScanner.DTD_INTERNAL_DECL, };
 
 689         public String[] getConfiguredPHPContentTypes() {
 
 690                 return new String[] { IDocument.DEFAULT_CONTENT_TYPE,
 
 691                                 IPHPPartitions.PHP_PARTITIONING,
 
 692                                 IPHPPartitions.PHP_SINGLELINE_COMMENT,
 
 693                                 IPHPPartitions.PHP_MULTILINE_COMMENT,
 
 694                                 IPHPPartitions.PHP_PHPDOC_COMMENT,
 
 695                                 IPHPPartitions.PHP_STRING_DQ, IPHPPartitions.PHP_STRING_SQ,
 
 696                                 IPHPPartitions.PHP_STRING_HEREDOC, IPHPPartitions.CSS,
 
 697                                 IPHPPartitions.CSS_MULTILINE_COMMENT,
 
 698                                 IPHPPartitions.JAVASCRIPT, IPHPPartitions.JS_MULTILINE_COMMENT,
 
 699                                 IPHPPartitions.SMARTY, IPHPPartitions.SMARTY_MULTILINE_COMMENT, };
 
 703          * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
 
 706         public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
 
 707                 if (fDocumentPartitioning != null)
 
 708                         return fDocumentPartitioning;
 
 709                 return super.getConfiguredDocumentPartitioning(sourceViewer);
 
 713          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 715         public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
 
 716                 ContentAssistant assistant = new ContentAssistant();
 
 717                 IContentAssistProcessor processor = new HTMLCompletionProcessor(
 
 720                                 .setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
 
 721                 assistant.setContentAssistProcessor(processor, IPHPPartitions.HTML);
 
 722                 assistant.setContentAssistProcessor(processor,
 
 723                                 IPHPPartitions.HTML_MULTILINE_COMMENT);
 
 725                 assistant.setContentAssistProcessor(processor, IPHPPartitions.CSS);
 
 726                 assistant.setContentAssistProcessor(processor,
 
 727                                 IPHPPartitions.CSS_MULTILINE_COMMENT);
 
 728                 assistant.setContentAssistProcessor(processor,
 
 729                                 IPHPPartitions.JAVASCRIPT);
 
 730                 assistant.setContentAssistProcessor(processor,
 
 731                                 IPHPPartitions.JS_MULTILINE_COMMENT);
 
 732                 // TODO define special smarty partition content assist
 
 733                 assistant.setContentAssistProcessor(processor, IPHPPartitions.SMARTY);
 
 734                 assistant.setContentAssistProcessor(processor,
 
 735                                 IPHPPartitions.SMARTY_MULTILINE_COMMENT);
 
 737                 assistant.setContentAssistProcessor(processor,
 
 738                                 PHPDocumentPartitioner.PHP_TEMPLATE_DATA);
 
 739                 String[] htmlTypes = getConfiguredHTMLContentTypes();
 
 740                 for (int i = 0; i < htmlTypes.length; i++) {
 
 741                         assistant.setContentAssistProcessor(processor, htmlTypes[i]);
 
 743                 processor = new PHPCompletionProcessor(getEditor());
 
 745                 assistant.setContentAssistProcessor(processor,
 
 746                                 PHPDocumentPartitioner.PHP_SCRIPT_CODE);
 
 747                 assistant.setContentAssistProcessor(processor,
 
 748                                 IPHPPartitions.PHP_PARTITIONING);
 
 749                 assistant.setContentAssistProcessor(processor,
 
 750                                 IPHPPartitions.PHP_STRING_DQ);
 
 751                 assistant.setContentAssistProcessor(processor,
 
 752                                 IPHPPartitions.PHP_STRING_SQ);
 
 753                 assistant.setContentAssistProcessor(processor,
 
 754                                 IPHPPartitions.PHP_STRING_HEREDOC);
 
 756                 assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(
 
 757                                 getEditor()), IPHPPartitions.PHP_PHPDOC_COMMENT);
 
 758                 // assistant.enableAutoActivation(true);
 
 759                 // assistant.setAutoActivationDelay(500);
 
 760                 // assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
 
 761                 // ContentAssistPreference.configure(assistant, getPreferenceStore());
 
 762                 // assistant.setContextInformationPopupOrientation(
 
 763                 // ContentAssistant.CONTEXT_INFO_ABOVE);
 
 764                 // assistant.setContextInformationPopupBackground(
 
 765                 // PHPEditorEnvironment.getPHPColorProvider().getColor(
 
 766                 // new RGB(150, 150, 0)));
 
 767                 ContentAssistPreference.configure(assistant, getPreferenceStore());
 
 769                                 .setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
 
 771                                 .setInformationControlCreator(getInformationControlCreator(sourceViewer));
 
 776          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 778         // public String getDefaultPrefix(ISourceViewer sourceViewer, String
 
 780         // return (PHPPartitionScanner.PHP.equals(contentType) ? "//" : null);
 
 782         // // return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" :
 
 783         // null); //$NON-NLS-1$
 
 786          * @see SourceViewerConfiguration#getDefaultPrefix(ISourceViewer, String)
 
 789         public String[] getDefaultPrefixes(ISourceViewer sourceViewer,
 
 790                         String contentType) {
 
 791                 return new String[] { "//", "" }; //$NON-NLS-1$ //$NON-NLS-2$
 
 795          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 797         public ITextDoubleClickStrategy getDoubleClickStrategy(
 
 798                         ISourceViewer sourceViewer, String contentType) {
 
 799                 return new PHPDoubleClickSelector();
 
 803          * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String)
 
 805         public String[] getIndentPrefixes(ISourceViewer sourceViewer,
 
 806                         String contentType) {
 
 807                 Vector vector = new Vector();
 
 808                 // prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
 
 809                 final IPreferenceStore preferences = PHPeclipsePlugin.getDefault()
 
 810                                 .getPreferenceStore();
 
 811                 int tabWidth = preferences.getInt(JavaCore.FORMATTER_TAB_SIZE);
 
 812                 boolean useSpaces = getPreferenceStore().getBoolean(SPACES_FOR_TABS);
 
 813                 for (int i = 0; i <= tabWidth; i++) {
 
 814                         StringBuffer prefix = new StringBuffer();
 
 816                                 for (int j = 0; j + i < tabWidth; j++)
 
 821                                 for (int j = 0; j < i; j++)
 
 826                         vector.add(prefix.toString());
 
 828                 vector.add(""); //$NON-NLS-1$
 
 829                 return (String[]) vector.toArray(new String[vector.size()]);
 
 833          * @return <code>true</code> iff the new setup without text tools is in
 
 838         // private boolean isNewSetup() {
 
 839         // return fJavaTextTools == null;
 
 842          * Creates and returns a preference store which combines the preference
 
 843          * stores from the text tools and which is read-only.
 
 845          * @return the read-only preference store
 
 848         // private IPreferenceStore createPreferenceStore() {
 
 849         // Assert.isTrue(!isNewSetup());
 
 850         // IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
 
 851         // if (fJavaTextTools.getCorePreferenceStore() == null)
 
 852         // return new ChainedPreferenceStore(new IPreferenceStore[] {
 
 853         // fJavaTextTools.getPreferenceStore(), generalTextStore });
 
 855         // return new ChainedPreferenceStore(new IPreferenceStore[] {
 
 856         // fJavaTextTools.getPreferenceStore(),
 
 857         // new PreferencesAdapter(fJavaTextTools.getCorePreferenceStore()),
 
 858         // generalTextStore });
 
 861          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 863         public IPresentationReconciler getPresentationReconciler(
 
 864                         ISourceViewer sourceViewer) {
 
 865                 // PHPColorProvider provider =
 
 866                 // PHPEditorEnvironment.getPHPColorProvider();
 
 867                 // JavaColorManager provider =
 
 868                 // PHPEditorEnvironment.getPHPColorProvider();
 
 869                 PresentationReconciler phpReconciler = new JavaPresentationReconciler();
 
 871                                 .setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
 
 873                 // DefaultDamagerRepairer dr = new
 
 874                 // DefaultDamagerRepairer(getHTMLScanner());
 
 875                 // reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
 
 876                 // reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
 
 877                 // dr = new DefaultDamagerRepairer(getHTMLScanner());
 
 878                 // reconciler.setDamager(dr, IPHPPartitions.HTML);
 
 879                 // reconciler.setRepairer(dr, IPHPPartitions.HTML);
 
 880                 // dr = new DefaultDamagerRepairer(getHTMLScanner());
 
 881                 // reconciler.setDamager(dr, IPHPPartitions.CSS);
 
 882                 // reconciler.setRepairer(dr, IPHPPartitions.CSS);
 
 883                 // dr = new DefaultDamagerRepairer(getHTMLScanner());
 
 884                 // reconciler.setDamager(dr, IPHPPartitions.CSS_MULTILINE_COMMENT);
 
 885                 // reconciler.setRepairer(dr, IPHPPartitions.CSS_MULTILINE_COMMENT);
 
 886                 // dr = new DefaultDamagerRepairer(getHTMLScanner());
 
 887                 // reconciler.setDamager(dr, IPHPPartitions.JAVASCRIPT);
 
 888                 // reconciler.setRepairer(dr, IPHPPartitions.JAVASCRIPT);
 
 889                 // dr = new DefaultDamagerRepairer(getHTMLScanner());
 
 890                 // reconciler.setDamager(dr, IPHPPartitions.JS_MULTILINE_COMMENT);
 
 891                 // reconciler.setRepairer(dr, IPHPPartitions.JS_MULTILINE_COMMENT);
 
 892                 // DefaultDamagerRepairer phpDR = new
 
 893                 // DefaultDamagerRepairer(getSmartyScanner());
 
 894                 // phpReconciler.setDamager(phpDR, IPHPPartitions.SMARTY);
 
 895                 // phpReconciler.setRepairer(phpDR, IPHPPartitions.SMARTY);
 
 896                 // phpDR = new DefaultDamagerRepairer(getSmartyDocScanner());
 
 897                 // phpReconciler.setDamager(phpDR,
 
 898                 // IPHPPartitions.SMARTY_MULTILINE_COMMENT);
 
 899                 // phpReconciler.setRepairer(phpDR,
 
 900                 // IPHPPartitions.SMARTY_MULTILINE_COMMENT);
 
 901                 // dr = new DefaultDamagerRepairer(new SingleTokenScanner(new
 
 902                 // TextAttribute(fJavaTextTools.getColorManager().getColor(
 
 903                 // PHPColorProvider.MULTI_LINE_COMMENT))));
 
 904                 // reconciler.setDamager(dr, IPHPPartitions.HTML_MULTILINE_COMMENT);
 
 905                 // reconciler.setRepairer(dr, IPHPPartitions.HTML_MULTILINE_COMMENT);
 
 907                 DefaultDamagerRepairer phpDR = new DefaultDamagerRepairer(
 
 909                 phpReconciler.setDamager(phpDR, IDocument.DEFAULT_CONTENT_TYPE);
 
 910                 phpReconciler.setRepairer(phpDR, IDocument.DEFAULT_CONTENT_TYPE);
 
 912                 phpDR = new DefaultDamagerRepairer(getCodeScanner());
 
 913                 phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_PARTITIONING);
 
 914                 phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_PARTITIONING);
 
 916                 phpDR = new DefaultDamagerRepairer(getPHPDocScanner());
 
 917                 phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_PHPDOC_COMMENT);
 
 918                 phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_PHPDOC_COMMENT);
 
 920                 phpDR = new DefaultDamagerRepairer(getStringDQScanner());
 
 921                 phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_STRING_DQ);
 
 922                 phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_DQ);
 
 923                 phpDR = new DefaultDamagerRepairer(getStringSQScanner());
 
 924                 phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_STRING_SQ);
 
 925                 phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_SQ);
 
 926                 phpDR = new DefaultDamagerRepairer(getStringDQScanner());
 
 927                 phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_STRING_HEREDOC);
 
 928                 phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_HEREDOC);
 
 929                 phpDR = new DefaultDamagerRepairer(getSinglelineCommentScanner());
 
 930                 phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_SINGLELINE_COMMENT);
 
 931                 phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_SINGLELINE_COMMENT);
 
 932                 phpDR = new DefaultDamagerRepairer(getMultilineCommentScanner());
 
 933                 phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_MULTILINE_COMMENT);
 
 934                 phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_MULTILINE_COMMENT);
 
 936                 PresentationReconciler reconciler = new PresentationReconciler();
 
 938                                 .setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
 
 940                 // JavaTextTools jspTextTools =
 
 941                 // PHPeclipsePlugin.getDefault().getJavaTextTools();
 
 942                 DefaultDamagerRepairer dr = new DefaultDamagerRepairer(
 
 943                                 getPHPDocScanner());// jspTextTools.getJSPTextScanner());
 
 944                 reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
 
 945                 reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
 
 947                 // dr = new DefaultDamagerRepairer(new SingleTokenScanner(new
 
 948                 // TextAttribute(fJavaTextTools.getColorManager().getColor(
 
 949                 // PHPColorProvider.PHPDOC_TAG))));//jspTextTools.getJSPBracketScanner());
 
 950                 // reconciler.setDamager(dr, JSPScriptScanner.JSP_BRACKET);
 
 951                 // reconciler.setRepairer(dr, JSPScriptScanner.JSP_BRACKET);
 
 954                 configureEmbeddedPresentationReconciler(reconciler, xmlConfiguration
 
 955                                 .getPresentationReconciler(sourceViewer), xmlConfiguration
 
 956                                 .getConfiguredContentTypes(sourceViewer),
 
 957                                 PHPDocumentPartitioner.PHP_TEMPLATE_DATA);
 
 960                 configureEmbeddedPresentationReconciler(reconciler, phpReconciler,
 
 961                                 getConfiguredPHPContentTypes(),
 
 962                                 PHPDocumentPartitioner.PHP_SCRIPT_CODE);
 
 967         private void configureEmbeddedPresentationReconciler(
 
 968                         PresentationReconciler reconciler,
 
 969                         IPresentationReconciler embedded, String[] types, String defaultType) {
 
 970                 for (int i = 0; i < types.length; i++) {
 
 971                         String type = types[i];
 
 973                         IPresentationDamager damager = embedded.getDamager(type);
 
 974                         IPresentationRepairer repairer = embedded.getRepairer(type);
 
 976                         if (type == IDocument.DEFAULT_CONTENT_TYPE) {
 
 980                         reconciler.setDamager(damager, type);
 
 981                         reconciler.setRepairer(repairer, type);
 
 986          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 988         public int getTabWidth(ISourceViewer sourceViewer) {
 
 989                 return getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH);
 
 993          * (non-Javadoc) Method declared on SourceViewerConfiguration
 
 995         // public ITextHover getTextHover(ISourceViewer sourceViewer, String
 
 997         // if (fEditor != null) {
 
 998         // IEditorInput editorInput = fEditor.getEditorInput();
 
 999         // if (editorInput instanceof IFileEditorInput) {
 
1001         // IFile f = ((IFileEditorInput) editorInput).getFile();
 
1002         // return new PHPTextHover(f.getProject());
 
1003         // } catch (NullPointerException e) {
 
1004         // // this exception occurs, if getTextHover is called by preference pages
 
1009         // return new PHPTextHover(null);
 
1012          * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
 
1015         public IInformationControlCreator getInformationControlCreator(
 
1016                         ISourceViewer sourceViewer) {
 
1017                 return new IInformationControlCreator() {
 
1018                         public IInformationControl createInformationControl(Shell parent) {
 
1019                                 return new DefaultInformationControl(parent, SWT.NONE,
 
1020                                                 new HTMLTextPresenter(true));
 
1021                                 // return new HoverBrowserControl(parent);
 
1027          * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
 
1030         public IInformationPresenter getInformationPresenter(
 
1031                         ISourceViewer sourceViewer) {
 
1032                 InformationPresenter presenter = new InformationPresenter(
 
1033                                 getInformationPresenterControlCreator(sourceViewer));
 
1035                                 .setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
 
1036                 IInformationProvider provider = new JavaInformationProvider(getEditor());
 
1037                 presenter.setInformationProvider(provider,
 
1038                                 IDocument.DEFAULT_CONTENT_TYPE);
 
1039                 presenter.setInformationProvider(provider,
 
1040                                 IPHPPartitions.PHP_PHPDOC_COMMENT);
 
1041                 // presenter.setInformationProvider(provider,
 
1042                 // IPHPPartitions.JAVA_CHARACTER);
 
1043                 presenter.setSizeConstraints(60, 10, true, true);
 
1048          * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
 
1051         // public IInformationPresenter getInformationPresenter(ISourceViewer
 
1053         // InformationPresenter presenter= new
 
1054         // InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
 
1055         // IInformationProvider provider= new JavaInformationProvider(getEditor());
 
1056         // presenter.setInformationProvider(provider,
 
1057         // IDocument.DEFAULT_CONTENT_TYPE);
 
1058         // presenter.setInformationProvider(provider, IJavaPartitions.JAVA_DOC);
 
1059         // presenter.setSizeConstraints(60, 10, true, true);
 
1060         // return presenter;
 
1063          * Returns the information presenter control creator. The creator is a
 
1064          * factory creating the presenter controls for the given source viewer. This
 
1065          * implementation always returns a creator for
 
1066          * <code>DefaultInformationControl</code> instances.
 
1068          * @param sourceViewer
 
1069          *            the source viewer to be configured by this configuration
 
1070          * @return an information control creator
 
1073         private IInformationControlCreator getInformationPresenterControlCreator(
 
1074                         ISourceViewer sourceViewer) {
 
1075                 return new IInformationControlCreator() {
 
1076                         public IInformationControl createInformationControl(Shell parent) {
 
1077                                 int shellStyle = SWT.RESIZE;
 
1078                                 int style = SWT.V_SCROLL | SWT.H_SCROLL;
 
1079                                 return new DefaultInformationControl(parent, shellStyle, style,
 
1080                                                 new HTMLTextPresenter(false));
 
1081                                 // return new HoverBrowserControl(parent);
 
1087          * Returns the outline presenter control creator. The creator is a factory
 
1088          * creating outline presenter controls for the given source viewer. This
 
1089          * implementation always returns a creator for
 
1090          * <code>JavaOutlineInformationControl</code> instances.
 
1092          * @param sourceViewer
 
1093          *            the source viewer to be configured by this configuration
 
1094          * @return an information control creator
 
1097         private IInformationControlCreator getOutlinePresenterControlCreator(
 
1098                         ISourceViewer sourceViewer) {
 
1099                 return new IInformationControlCreator() {
 
1100                         public IInformationControl createInformationControl(Shell parent) {
 
1101                                 int shellStyle = SWT.RESIZE;
 
1102                                 int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
 
1103                                 return new JavaOutlineInformationControl(parent, shellStyle,
 
1110          * Returns the outline presenter which will determine and shown information
 
1111          * requested for the current cursor position.
 
1113          * @param sourceViewer
 
1114          *            the source viewer to be configured by this configuration
 
1115          * @param doCodeResolve
 
1116          *            a boolean which specifies whether code resolve should be used
 
1117          *            to compute the Java element
 
1118          * @return an information presenter
 
1121         public IInformationPresenter getOutlinePresenter(
 
1122                         ISourceViewer sourceViewer, boolean doCodeResolve) {
 
1123                 InformationPresenter presenter = new InformationPresenter(
 
1124                                 getOutlinePresenterControlCreator(sourceViewer));
 
1125                 presenter.setAnchor(InformationPresenter.ANCHOR_GLOBAL);
 
1126                 IInformationProvider provider = new JavaElementProvider(getEditor(),
 
1128                 presenter.setInformationProvider(provider,
 
1129                                 IDocument.DEFAULT_CONTENT_TYPE);
 
1130                 presenter.setInformationProvider(provider,
 
1131                                 PHPDocumentPartitioner.PHP_SCRIPT_CODE);
 
1132                 presenter.setInformationProvider(provider,
 
1133                                 IPHPPartitions.PHP_PARTITIONING);
 
1134                 presenter.setInformationProvider(provider,
 
1135                                 IPHPPartitions.PHP_PHPDOC_COMMENT);
 
1136                 presenter.setInformationProvider(provider,
 
1137                                 IPHPPartitions.SMARTY_MULTILINE_COMMENT);
 
1138                 presenter.setInformationProvider(provider, IPHPPartitions.HTML);
 
1139                 presenter.setInformationProvider(provider,
 
1140                                 IPHPPartitions.HTML_MULTILINE_COMMENT);
 
1141                 presenter.setSizeConstraints(40, 20, true, false);