3m9 compatible;
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPEditor.java
index acf9d5a..c37b2e4 100644 (file)
@@ -24,20 +24,22 @@ import net.sourceforge.phpdt.core.IJavaElement;
 import net.sourceforge.phpdt.core.IMember;
 import net.sourceforge.phpdt.core.ISourceRange;
 import net.sourceforge.phpdt.core.ISourceReference;
-import net.sourceforge.phpdt.core.JavaModelException;
 import net.sourceforge.phpdt.core.JavaCore;
+import net.sourceforge.phpdt.core.JavaModelException;
 import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
+import net.sourceforge.phpdt.internal.ui.actions.FoldingActionGroup;
+import net.sourceforge.phpdt.internal.ui.text.CustomSourceInformationControl;
 import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
+import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
 import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
 import net.sourceforge.phpdt.internal.ui.viewsupport.IViewPartInputProvider;
 import net.sourceforge.phpdt.ui.IContextMenuConstants;
 import net.sourceforge.phpdt.ui.JavaUI;
 import net.sourceforge.phpdt.ui.PreferenceConstants;
-import net.sourceforge.phpdt.ui.actions.GenerateActionGroup;
 import net.sourceforge.phpdt.ui.actions.GotoMatchingBracketAction;
 import net.sourceforge.phpdt.ui.text.JavaTextTools;
+import net.sourceforge.phpdt.ui.text.folding.IJavaFoldingStructureProvider;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.phpeditor.php.IPHPPartitionScannerConstants;
 
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IResource;
@@ -64,7 +66,6 @@ import org.eclipse.jface.text.IInformationControlCreator;
 import org.eclipse.jface.text.IRegion;
 import org.eclipse.jface.text.ITextHover;
 import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextOperationTarget;
 import org.eclipse.jface.text.ITextSelection;
 import org.eclipse.jface.text.ITextViewer;
 import org.eclipse.jface.text.ITextViewerExtension2;
@@ -83,6 +84,8 @@ import org.eclipse.jface.text.source.ISourceViewer;
 import org.eclipse.jface.text.source.IVerticalRuler;
 import org.eclipse.jface.text.source.OverviewRuler;
 import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.text.source.projection.ProjectionSupport;
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.jface.viewers.ISelection;
@@ -127,13 +130,11 @@ import org.eclipse.ui.actions.ActionGroup;
 import org.eclipse.ui.editors.text.DefaultEncodingSupport;
 import org.eclipse.ui.editors.text.IEncodingSupport;
 import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.ui.texteditor.ContentAssistAction;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
 import org.eclipse.ui.texteditor.DefaultRangeIndicator;
-import org.eclipse.ui.texteditor.ExtendedTextEditor;
 import org.eclipse.ui.texteditor.IDocumentProvider;
 import org.eclipse.ui.texteditor.IEditorStatusLine;
 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
 import org.eclipse.ui.texteditor.MarkerAnnotation;
 import org.eclipse.ui.texteditor.ResourceAction;
 import org.eclipse.ui.texteditor.TextEditorAction;
@@ -144,7 +145,7 @@ import org.eclipse.ui.views.tasklist.TaskList;
 /**
  * PHP specific text editor.
  */
-public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPartInputProvider {
+public abstract class PHPEditor  extends AbstractDecoratedTextEditor implements IViewPartInputProvider {
 //extends StatusTextEditor implements IViewPartInputProvider { // extends TextEditor {
   /**
         * "Smart" runnable for updating the outline page's selection.
@@ -1132,6 +1133,12 @@ public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPart
   protected JavaOutlinePage fOutlinePage;
   /** Outliner context menu Id */
   protected String fOutlinerContextMenuId;
+       /**
+        * The editor selection changed listener.
+        * 
+        * @since 3.0
+        */
+//  private EditorSelectionChangedListener fEditorSelectionChangedListener;
   /** Indicates whether this editor should react on outline page selection changes */
   private int fIgnoreOutlinePageSelection;
   
@@ -1155,10 +1162,25 @@ public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPart
   private MouseClickListener fMouseListener;
 
   protected CompositeActionGroup fActionGroups;
-  /** The standard action groups added to the menu */
-  protected GenerateActionGroup fGenerateActionGroup;
   protected CompositeActionGroup fContextMenuGroup;
 
+  /** 
+        * This editor's projection support 
+        * @since 3.0
+        */
+       private ProjectionSupport fProjectionSupport;
+       /** 
+        * This editor's projection model updater 
+        * @since 3.0
+        */
+       private IJavaFoldingStructureProvider fProjectionModelUpdater;
+  /**
+        * The action group for folding.
+        *  
+        * @since 3.0
+        */
+       private FoldingActionGroup fFoldingGroup;
+       
   /** The information presenter. */
   private InformationPresenter fInformationPresenter;
   /** The annotation access */
@@ -1193,32 +1215,20 @@ public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPart
    */
   public PHPEditor() {
     super();
-    JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
-    setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools, this));
-    setRangeIndicator(new DefaultRangeIndicator());
-    setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
-
-    // don't activate this scope without synchronizing plugin.xml !!!
-    //    setKeyBindingScopes(new String[] { "net.sourceforge.phpdt.ui.phpEditorScope" }); //$NON-NLS-1$
-
-        if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))
-          fUpdater= new OutlinePageSelectionUpdater();
+       JavaTextTools textTools= PHPeclipsePlugin.getDefault().getJavaTextTools();
+       setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools, this)); //, IJavaPartitions.JAVA_PARTITIONING));
+       setRangeIndicator(new DefaultRangeIndicator());
+       IPreferenceStore store= PHPeclipsePlugin.getDefault().getPreferenceStore();
+       setPreferenceStore(store);
+       setKeyBindingScopes(new String[] { "net.sourceforge.phpdt.ui.phpEditorScope" });  //$NON-NLS-1$
+//     fMarkOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
+//     fStickyOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES);
+    
+       // TODO changed in 3.x ?
+    if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))
+      fUpdater= new OutlinePageSelectionUpdater();
   }
-  //
-  //   /**
-  //    * @see IMember#getCompilationUnit()
-  //    */
-  //   public ICompilationUnit getCompilationUnit() {
-  //           return this; 
-  //   }
-  //   /**
-  //    * @see org.phpeclipse.phpdt.internal.compiler.env.ICompilationUnit#getContents()
-  //    */
-  //   public char[] getContents() {
-  //           IDocument doc = this.getDocumentProvider().getDocument(this.getEditorInput());
-  //   
-  //           return doc.get().toCharArray();
-  //   }
   /*
    * @see org.eclipse.ui.texteditor.AbstractTextEditor#updatePropertyDependentActions()
    */
@@ -1274,6 +1284,9 @@ public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPart
     super.doSetSelection(selection);
     synchronizeOutlinePageSelection();
   }
+       boolean isFoldingEnabled() {
+               return PHPeclipsePlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
+       }
   /*
    * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.
    * widgets.Composite)
@@ -1283,9 +1296,27 @@ public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPart
 
     //fSourceViewerDecorationSupport.install(getPreferenceStore());
 
-    Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
+    ProjectionViewer projectionViewer= (ProjectionViewer) getSourceViewer();
+       
+       fProjectionSupport= new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors());
+       fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$
+       fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$
+       fProjectionSupport.setHoverControlCreator(new IInformationControlCreator() {
+               public IInformationControl createInformationControl(Shell shell) {
+                       return new CustomSourceInformationControl(shell, IDocument.DEFAULT_CONTENT_TYPE);
+               }
+       });
+    fProjectionSupport.install();
+       
+       fProjectionModelUpdater= PHPeclipsePlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
+       if (fProjectionModelUpdater != null)
+               fProjectionModelUpdater.install(this, projectionViewer);
+                       
+       if (isFoldingEnabled())
+               projectionViewer.doOperation(ProjectionViewer.TOGGLE);
+       Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
     preferences.addPropertyChangeListener(fPropertyChangeListener);
-
+    
     IInformationControlCreator informationControlCreator = new IInformationControlCreator() {
       public IInformationControl createInformationControl(Shell parent) {
         boolean cutDown = false;
@@ -1334,70 +1365,119 @@ public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPart
    */
   protected void createActions() {
     super.createActions();
-
-    ResourceAction resAction = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "ShowJavaDoc.", this, ISourceViewer.INFORMATION, true); //$NON-NLS-1$
-    resAction = new InformationDispatchAction(PHPEditorMessages.getResourceBundle(), "ShowJavaDoc.", (TextOperationAction) resAction); //$NON-NLS-1$
-    resAction.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_JAVADOC);
-    setAction("ShowJavaDoc", resAction); //$NON-NLS-1$
-    //                                         WorkbenchHelp.setHelp(resAction, IJavaHelpContextIds.SHOW_JAVADOC_ACTION);
-
-    Action action;
-
-    setAction(
-      "ContentAssistTip",
-      new TextOperationAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION));
-
-    action = new ContentAssistAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$
-    action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
-    setAction("ContentAssistProposal", action); //$NON-NLS-1$
-    markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
-    // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.CONTENT_ASSIST_ACTION);
-
-    fEncodingSupport = new DefaultEncodingSupport();
-    fEncodingSupport.initialize(this);
-
-    action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX); //$NON-NLS-1$
-    action.setActionDefinitionId(PHPEditorActionDefinitionIds.COMMENT);
-    setAction("Comment", action); //$NON-NLS-1$
-    markAsStateDependentAction("Comment", true); //$NON-NLS-1$
-    //         WorkbenchHelp.setHelp(action, IJavaHelpContextIds.COMMENT_ACTION);
-
-    action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); //$NON-NLS-1$
-    action.setActionDefinitionId(PHPEditorActionDefinitionIds.UNCOMMENT);
-    setAction("Uncomment", action); //$NON-NLS-1$
-    markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$
-    //         WorkbenchHelp.setHelp(action, IJavaHelpContextIds.UNCOMMENT_ACTION);
-
-    action = new TextOperationAction(PHPEditorMessages.getResourceBundle(), "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
-    action.setActionDefinitionId(PHPEditorActionDefinitionIds.FORMAT);
-    setAction("Format", action); //$NON-NLS-1$
-    markAsStateDependentAction("Format", true); //$NON-NLS-1$
-    markAsSelectionDependentAction("Format", true); //$NON-NLS-1$              
-    // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.FORMAT_ACTION);
-
-    action = new GotoMatchingBracketAction(this);
-    action.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
-    setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action);
-
-    fGenerateActionGroup = new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
-
-    fActionGroups = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup });
-
-    // We have to keep the context menu group separate to have better control over positioning
-    fContextMenuGroup = new CompositeActionGroup(new ActionGroup[] { fGenerateActionGroup });
-    //      rg, 
-    //      new LocalHistoryActionGroup(this, ITextEditorActionConstants.GROUP_EDIT)});
+    
+    fFoldingGroup= new FoldingActionGroup(this, getViewer());
+    
+       ResourceAction resAction= new TextOperationAction(PHPEditorMessages.getResourceBundle(), "ShowJavaDoc.", this, ISourceViewer.INFORMATION, true); //$NON-NLS-1$
+       resAction= new InformationDispatchAction(PHPEditorMessages.getResourceBundle(), "ShowJavaDoc.", (TextOperationAction) resAction); //$NON-NLS-1$
+       resAction.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_JAVADOC);
+       setAction("ShowJavaDoc", resAction); //$NON-NLS-1$
+//     WorkbenchHelp.setHelp(resAction, IJavaHelpContextIds.SHOW_JAVADOC_ACTION);
+       
+       Action action= new GotoMatchingBracketAction(this);
+       action.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);                               
+       setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action);
+               
+//     action= new TextOperationAction(PHPEditorMessages.getResourceBundle(),"ShowOutline.", this, JavaSourceViewer.SHOW_OUTLINE, true); //$NON-NLS-1$
+//     action.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_OUTLINE);
+//     setAction(PHPEditorActionDefinitionIds.SHOW_OUTLINE, action);
+////   WorkbenchHelp.setHelp(action, IJavaHelpContextIds.SHOW_OUTLINE_ACTION);
+//
+//     action= new TextOperationAction(PHPEditorMessages.getResourceBundle(),"OpenStructure.", this, JavaSourceViewer.OPEN_STRUCTURE, true); //$NON-NLS-1$
+//     action.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_OUTLINE.OPEN_STRUCTURE);
+//     setAction(PHPEditorActionDefinitionIds.SHOW_OUTLINE.OPEN_STRUCTURE, action);
+////   WorkbenchHelp.setHelp(action, IJavaHelpContextIds.OPEN_STRUCTURE_ACTION);
+//     
+//     action= new TextOperationAction(PHPEditorMessages.getResourceBundle(),"OpenHierarchy.", this, JavaSourceViewer.SHOW_HIERARCHY, true); //$NON-NLS-1$
+//     action.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_OUTLINE.OPEN_HIERARCHY);
+//     setAction(PHPEditorActionDefinitionIds.SHOW_OUTLINE.OPEN_HIERARCHY, action);
+////   WorkbenchHelp.setHelp(action, IJavaHelpContextIds.OPEN_HIERARCHY_ACTION);
+       
+       fEncodingSupport= new DefaultEncodingSupport();
+       fEncodingSupport.initialize(this);
+       
+//     fSelectionHistory= new SelectionHistory(this);
+//
+//     action= new StructureSelectEnclosingAction(this, fSelectionHistory);
+//     action.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_ENCLOSING);                            
+//     setAction(StructureSelectionAction.ENCLOSING, action);
+//
+//     action= new StructureSelectNextAction(this, fSelectionHistory);
+//     action.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_NEXT);
+//     setAction(StructureSelectionAction.NEXT, action);
+//
+//     action= new StructureSelectPreviousAction(this, fSelectionHistory);
+//     action.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_PREVIOUS);
+//     setAction(StructureSelectionAction.PREVIOUS, action);
+//
+//     StructureSelectHistoryAction historyAction= new StructureSelectHistoryAction(this, fSelectionHistory);
+//     historyAction.setActionDefinitionId(PHPEditorActionDefinitionIds.SELECT_LAST);          
+//     setAction(StructureSelectionAction.HISTORY, historyAction);
+//     fSelectionHistory.setHistoryAction(historyAction);
+//                     
+//     action= GoToNextPreviousMemberAction.newGoToNextMemberAction(this);
+//     action.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_NEXT_MEMBER);                            
+//     setAction(GoToNextPreviousMemberAction.NEXT_MEMBER, action);
+//
+//     action= GoToNextPreviousMemberAction.newGoToPreviousMemberAction(this);
+//     action.setActionDefinitionId(PHPEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);                                
+//     setAction(GoToNextPreviousMemberAction.PREVIOUS_MEMBER, action);
+//     
+//     action= new QuickFormatAction();
+//     action.setActionDefinitionId(PHPEditorActionDefinitionIds.QUICK_FORMAT);
+//     setAction(IJavaEditorActionDefinitionIds.QUICK_FORMAT, action);
+//
+//     action= new RemoveOccurrenceAnnotations(this);
+//     action.setActionDefinitionId(PHPEditorActionDefinitionIds.REMOVE_OCCURRENCE_ANNOTATIONS);
+//     setAction("RemoveOccurrenceAnnotations", action); //$NON-NLS-1$
 
        // add annotation actions
        action= new JavaSelectMarkerRulerAction2(PHPEditorMessages.getResourceBundle(), "Editor.RulerAnnotationSelection.", this); //$NON-NLS-1$
        setAction("AnnotationAction", action); //$NON-NLS-1$
   }
 
+       private void internalDoSetInput(IEditorInput input) throws CoreException {
+               super.doSetInput(input);
+               
+               if (fEncodingSupport != null)
+                       fEncodingSupport.reset();
+               
+               setOutlinePageInput(fOutlinePage, input);
+                               
+               if (fProjectionModelUpdater != null)
+                       fProjectionModelUpdater.initialize();
+               
+//             if (isShowingOverrideIndicators())
+//                     installOverrideIndicator(true);
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractTextEditor#setPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)
+        * @since 3.0
+        */
+       protected void setPreferenceStore(IPreferenceStore store) {
+               super.setPreferenceStore(store);
+               if (getSourceViewerConfiguration() instanceof PHPSourceViewerConfiguration) {
+                       JavaTextTools textTools= PHPeclipsePlugin.getDefault().getJavaTextTools();
+                       setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools.getColorManager(), store, this, IPHPPartitions.PHP_PARTITIONING));
+               }
+               if (getSourceViewer() instanceof JavaSourceViewer)
+                       ((JavaSourceViewer)getSourceViewer()).setPreferenceStore(store);
+       }
   /** The <code>PHPEditor</code> implementation of this 
    * <code>AbstractTextEditor</code> method performs any extra 
    * disposal actions required by the php editor.
    */
   public void dispose() {
+       if (fProjectionModelUpdater != null) {
+               fProjectionModelUpdater.uninstall();
+               fProjectionModelUpdater= null;
+       }
+       
+       if (fProjectionSupport != null) {
+               fProjectionSupport.dispose();
+               fProjectionSupport= null;
+       }
     //   PHPEditorEnvironment.disconnect(this);
     if (fOutlinePage != null)
       fOutlinePage.setInput(null);
@@ -1622,10 +1702,6 @@ public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPart
       fOutlinePage.addSelectionChangedListener(fSelectionChangedListener);
     }
   }
-  protected void updateStateDependentActions() {
-    super.updateStateDependentActions();
-    fGenerateActionGroup.editorStateChanged();
-  }
 
   protected void setSelection(ISourceReference reference, boolean moveCursor) {
 
@@ -1776,7 +1852,12 @@ public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPart
 
       };
     }
-
+    if (fProjectionSupport != null) {
+               Object adapter= fProjectionSupport.getAdapter(getSourceViewer(), required);
+               if (adapter != null)
+                       return adapter;
+       }
+               
     return super.getAdapter(required);
   }
   //  public Object getAdapter(Class required) {
@@ -1943,6 +2024,57 @@ public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPart
         return;
       }
 
+//      if (PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE.equals(property)) {
+//             if ((event.getNewValue() instanceof Boolean) && ((Boolean)event.getNewValue()).booleanValue())
+//                     fEditorSelectionChangedListener.selectionChanged();
+//             return;
+//     }
+       
+       if (PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE.equals(property)) {
+               if (event.getNewValue() instanceof Boolean) {
+                       Boolean disable= (Boolean) event.getNewValue();
+                       enableOverwriteMode(!disable.booleanValue());
+               }
+               return;
+       }
+       
+//     if (PreferenceConstants.EDITOR_MARK_OCCURRENCES.equals(property)) {
+//             if (event.getNewValue() instanceof Boolean) {
+//                     boolean markOccurrenceAnnotations= ((Boolean)event.getNewValue()).booleanValue();
+//                     if (markOccurrenceAnnotations != fMarkOccurrenceAnnotations) {
+//                             fMarkOccurrenceAnnotations= markOccurrenceAnnotations;
+//                             if (!fMarkOccurrenceAnnotations)
+//                                     uninstallOccurrencesFinder();
+//                             else
+//                                     installOccurrencesFinder();
+//                     }
+//             }
+//     }
+//     if (PreferenceConstants.EDITOR_STICKY_OCCURRENCES.equals(property)) {
+//             if (event.getNewValue() instanceof Boolean) {
+//                     boolean stickyOccurrenceAnnotations= ((Boolean)event.getNewValue()).booleanValue();
+//                     if (stickyOccurrenceAnnotations != fStickyOccurrenceAnnotations) {
+//                             fStickyOccurrenceAnnotations= stickyOccurrenceAnnotations;
+////                           if (!fMarkOccurrenceAnnotations)
+////                                   uninstallOccurrencesFinder();
+////                           else
+////                                   installOccurrencesFinder();
+//                     }
+//             }
+//     }
+       if (PreferenceConstants.EDITOR_FOLDING_PROVIDER.equals(property)) {
+               if (sourceViewer instanceof ProjectionViewer) {
+                       ProjectionViewer projectionViewer= (ProjectionViewer) sourceViewer;
+                       if (fProjectionModelUpdater != null)
+                               fProjectionModelUpdater.uninstall();
+                       // either freshly enabled or provider changed
+                       fProjectionModelUpdater= PHPeclipsePlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
+                       if (fProjectionModelUpdater != null) {
+                               fProjectionModelUpdater.install(this, projectionViewer);
+                       }
+               }
+               return;
+       }
     } finally {
       super.handlePreferenceStoreChanged(event);
     }
@@ -2093,7 +2225,14 @@ public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPart
                if (!isEditingScriptRunning() && fUpdater != null)
                        fUpdater.post();
        }
-       
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractTextEditor#handleElementContentReplaced()
+        */
+       protected void handleElementContentReplaced() {
+               super.handleElementContentReplaced();
+               if (fProjectionModelUpdater != null)
+                       fProjectionModelUpdater.initialize();
+       }
   /**
    * Initializes the given line number ruler column from the preference store.
    * @param rulerColumn the ruler column to be initialized
@@ -2393,7 +2532,7 @@ public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPart
 
     List segmentation = new ArrayList();
     for (int i = 0; i < linePartitioning.length; i++) {
-      if (IPHPPartitionScannerConstants.PHP_STRING.equals(linePartitioning[i].getType()))
+      if (IPHPPartitions.PHP_STRING_DQ.equals(linePartitioning[i].getType()))
         segmentation.add(linePartitioning[i]);
     }
 
@@ -2472,45 +2611,6 @@ public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPart
        return getSourceViewer();
   }
   
-  protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRuler verticalRuler, int styles) {
-       ISourceViewer viewer= createJavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles);
-       
-       StyledText text= viewer.getTextWidget();
-       text.addBidiSegmentListener(new  BidiSegmentListener() {
-               public void lineGetSegments(BidiSegmentEvent event) {
-                       event.segments= getBidiLineSegments(event.lineOffset, event.lineText);
-               }
-       });
-       
-//     JavaUIHelp.setHelp(this, text, IJavaHelpContextIds.JAVA_EDITOR);
-
-       // ensure source viewer decoration support has been created and configured
-       getSourceViewerDecorationSupport(viewer);                               
-       
-       return viewer;
-       
-//    ISharedTextColors sharedColors = PHPeclipsePlugin.getDefault().getJavaTextTools().getColorManager();
-//
-//    fOverviewRuler = new OverviewRuler(fAnnotationAccess, VERTICAL_RULER_WIDTH, sharedColors);
-//    fOverviewRuler.addHeaderAnnotationType(AnnotationType.WARNING);
-//    fOverviewRuler.addHeaderAnnotationType(AnnotationType.ERROR);
-//
-//    ISourceViewer viewer = createJavaSourceViewer(parent, verticalRuler, fOverviewRuler, isOverviewRulerVisible(), styles);
-//
-//    StyledText text = viewer.getTextWidget();
-//    text.addBidiSegmentListener(new BidiSegmentListener() {
-//      public void lineGetSegments(BidiSegmentEvent event) {
-//        event.segments = getBidiLineSegments(event.lineOffset, event.lineText);
-//      }
-//    });
-//
-//    //               JavaUIHelp.setHelp(this, text, IJavaHelpContextIds.JAVA_EDITOR);
-//
-//    fSourceViewerDecorationSupport = new SourceViewerDecorationSupport(viewer, fOverviewRuler, fAnnotationAccess, sharedColors);
-//    configureSourceViewerDecorationSupport();
-//
-//    return viewer;
-  }
 
 //  protected void showOverviewRuler() {
 //    if (fOverviewRuler != null) {
@@ -2543,13 +2643,39 @@ public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPart
 //    int styles) {
 //    return new SourceViewer(parent, ruler, overviewRuler, isOverviewRulerVisible(), styles);
 //  }
-  
+       /*
+        * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
+        */
+       protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
+               return new JavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles, store);
+       }
   /*
         * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
         */
-       protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles) {
-               return new JavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles);
+       protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRuler verticalRuler, int styles) {
+               
+               ISourceViewer viewer= createJavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles, getPreferenceStore());
+               
+               StyledText text= viewer.getTextWidget();
+               text.addBidiSegmentListener(new  BidiSegmentListener() {
+                       public void lineGetSegments(BidiSegmentEvent event) {
+                               event.segments= getBidiLineSegments(event.lineOffset, event.lineText);
+                       }
+               });
+               
+//             JavaUIHelp.setHelp(this, text, IJavaHelpContextIds.JAVA_EDITOR);
+
+               // ensure source viewer decoration support has been created and configured
+               getSourceViewerDecorationSupport(viewer);                               
+               
+               return viewer;
        }
+         /*
+        * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
+        */
+//     protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles) {
+//             return new JavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles);
+//     }
   /*
    * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)
    */
@@ -2672,4 +2798,59 @@ public abstract class PHPEditor  extends ExtendedTextEditor implements IViewPart
                fOccurrenceAnnotations= null;
        }
 }
+//  protected void uninstallOverrideIndicator() {
+//     if (fOverrideIndicatorManager != null) {
+//             fOverrideIndicatorManager.removeAnnotations();
+//             fOverrideIndicatorManager= null;
+//     }
+//}
+
+protected void installOverrideIndicator(boolean waitForReconcilation) {
+//     uninstallOverrideIndicator();
+       IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
+//     IJavaElement inputElement= getInputJavaElement();
+
+//     if (model == null || inputElement == null)
+//             return;
+
+//     CompilationUnit ast= PHPeclipsePlugin.getDefault().getASTProvider().getAST(inputElement, true, null);
+//     fOverrideIndicatorManager= new OverrideIndicatorManager(model, inputElement, ast);              
+}
+
+/**
+ * Tells whether override indicators are shown.
+ * 
+ * @return <code>true</code> if the override indicators are shown
+ * @since 3.0
+ */
+//protected boolean isShowingOverrideIndicators() {
+//     AnnotationPreference preference= getAnnotationPreferenceLookup().getAnnotationPreference(OverrideIndicatorManager.ANNOTATION_TYPE);
+//     IPreferenceStore store= getPreferenceStore();
+//     return getBoolean(store, preference.getHighlightPreferenceKey())
+//             || getBoolean(store, preference.getVerticalRulerPreferenceKey())
+//             || getBoolean(store, preference.getOverviewRulerPreferenceKey())
+//             || getBoolean(store, preference.getTextPreferenceKey());
+//}
+
+/**
+ * Returns the boolean preference for the given key.
+ * 
+ * @param store the preference store
+ * @param key the preference key
+ * @return <code>true</code> if the key exists in the store and its value is <code>true</code>
+ * @since 3.0
+ */
+private boolean getBoolean(IPreferenceStore store, String key) {
+       return key != null && store.getBoolean(key);
+}
+
+  /**
+        * Returns the folding action group, or <code>null</code> if there is none.
+        * 
+        * @return the folding action group, or <code>null</code> if there is none
+        * @since 3.0
+        */
+       protected FoldingActionGroup getFoldingActionGroup() {
+               return fFoldingGroup;
+       }
 }