Syntax highlighting is changeable.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPEditor.java
index d7b5126..ed584d5 100644 (file)
@@ -42,6 +42,7 @@ import net.sourceforge.phpdt.ui.JavaUI;
 import net.sourceforge.phpdt.ui.PreferenceConstants;
 import net.sourceforge.phpdt.ui.actions.GotoMatchingBracketAction;
 import net.sourceforge.phpdt.ui.text.JavaTextTools;
+import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration;
 import net.sourceforge.phpdt.ui.text.folding.IJavaFoldingStructureProvider;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
@@ -140,7 +141,6 @@ import org.eclipse.ui.editors.text.EditorsUI;
 import org.eclipse.ui.editors.text.IEncodingSupport;
 import org.eclipse.ui.part.IShowInTargetList;
 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
-import org.eclipse.ui.texteditor.AnnotationPreference;
 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
 import org.eclipse.ui.texteditor.DefaultRangeIndicator;
 import org.eclipse.ui.texteditor.IDocumentProvider;
@@ -148,6 +148,7 @@ import org.eclipse.ui.texteditor.IEditorStatusLine;
 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
 import org.eclipse.ui.texteditor.MarkerAnnotation;
 import org.eclipse.ui.texteditor.ResourceAction;
+import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
 import org.eclipse.ui.texteditor.TextEditorAction;
 import org.eclipse.ui.texteditor.TextOperationAction;
 import org.eclipse.ui.views.contentoutline.ContentOutline;
@@ -1680,7 +1681,11 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
    * @since 3.0
    */
   private IJavaFoldingStructureProvider fProjectionModelUpdater;
-
+  /**
+        * The override and implements indicator manager for this editor.
+        * @since 3.0
+        */
+//     protected OverrideIndicatorManager fOverrideIndicatorManager;
   /**
    * The action group for folding.
    * 
@@ -1740,18 +1745,16 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
    */
   protected void initializeEditor() {
     //jsurfer old code
-    JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
-    setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools, this)); //, IJavaPartitions.JAVA_PARTITIONING));
-    setRangeIndicator(new DefaultRangeIndicator());
-    //         IPreferenceStore store=
-    // PHPeclipsePlugin.getDefault().getPreferenceStore();
-    //         setPreferenceStore(store);
-    IPreferenceStore store = createCombinedPreferenceStore(null);
-    setPreferenceStore(store);
-
+//    JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
+//    setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools, this, IPHPPartitions.PHP_PARTITIONING)); //, IJavaPartitions.JAVA_PARTITIONING));
+    IPreferenceStore store= createCombinedPreferenceStore(null);
+       setPreferenceStore(store);
+    JavaTextTools textTools= PHPeclipsePlugin.getDefault().getJavaTextTools();
+       setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools.getColorManager(), store, this, IPHPPartitions.PHP_PARTITIONING));
     // TODO changed in 3.x ?
-    if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))
-      fUpdater = new OutlinePageSelectionUpdater();
+//    setRangeIndicator(new DefaultRangeIndicator());
+//    if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))
+//      fUpdater = new OutlinePageSelectionUpdater();
     // jsurfer end
 
     //         IPreferenceStore store= createCombinedPreferenceStore(null);
@@ -1893,6 +1896,14 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
     // getEditorSite().getShell().addShellListener(fActivationListener);
   }
 
+  protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
+       
+       support.setCharacterPairMatcher(fBracketMatcher);
+       support.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR);
+       
+       super.configureSourceViewerDecorationSupport(support);
+  }
+       
   /**
    * Returns this document's complete text.
    * 
@@ -2659,14 +2670,11 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
         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_SYNC_OUTLINE_ON_CURSOR_MOVE.equals(property)) {
+               if ((event.getNewValue() instanceof Boolean) && ((Boolean)event.getNewValue()).booleanValue())
+                       selectionChanged();
+               return;
+         } 
 
       if (PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE.equals(property)) {
         if (event.getNewValue() instanceof Boolean) {
@@ -2706,6 +2714,20 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
       //                       }
       //               }
       //       }
+      
+      ((PHPSourceViewerConfiguration)getSourceViewerConfiguration()).handlePropertyChangeEvent(event);
+               
+//             if (affectsOverrideIndicatorAnnotations(event)) {
+//                     if (isShowingOverrideIndicators()) {
+//                             if (fOverrideIndicatorManager == null)
+//                                     installOverrideIndicator(true);
+//                     } else {
+//                             if (fOverrideIndicatorManager != null)
+//                                     uninstallOverrideIndicator();
+//                     }
+//                     return;
+//             }
+               
       if (PreferenceConstants.EDITOR_FOLDING_PROVIDER.equals(property)) {
         if (sourceViewer instanceof ProjectionViewer) {
           ProjectionViewer projectionViewer = (ProjectionViewer) sourceViewer;
@@ -2980,19 +3002,19 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
   protected final static String MATCHING_BRACKETS_COLOR = PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
 
   /** Preference key for highlighting current line */
-  protected final static String CURRENT_LINE = PreferenceConstants.EDITOR_CURRENT_LINE;
+//  protected final static String CURRENT_LINE = PreferenceConstants.EDITOR_CURRENT_LINE;
 
   /** Preference key for highlight color of current line */
-  protected final static String CURRENT_LINE_COLOR = PreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
+//  protected final static String CURRENT_LINE_COLOR = PreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
 
   /** Preference key for showing print marging ruler */
-  protected final static String PRINT_MARGIN = PreferenceConstants.EDITOR_PRINT_MARGIN;
+//  protected final static String PRINT_MARGIN = PreferenceConstants.EDITOR_PRINT_MARGIN;
 
   /** Preference key for print margin ruler color */
-  protected final static String PRINT_MARGIN_COLOR = PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
+//  protected final static String PRINT_MARGIN_COLOR = PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
 
   /** Preference key for print margin ruler column */
-  protected final static String PRINT_MARGIN_COLUMN = PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
+//  protected final static String PRINT_MARGIN_COLUMN = PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
 
   /** Preference key for error indication */
   //  protected final static String ERROR_INDICATION =
@@ -3387,7 +3409,17 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
 
     return viewer;
   }
-
+  /*
+        * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)
+        */
+       protected boolean affectsTextPresentation(PropertyChangeEvent event) {
+               return ((PHPSourceViewerConfiguration)getSourceViewerConfiguration()).affectsTextPresentation(event) || super.affectsTextPresentation(event);
+       }
+//
+//       protected boolean affectsTextPresentation(PropertyChangeEvent event) {
+//         JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
+//         return textTools.affectsBehavior(event);
+//       }
   /**
    * Creates and returns the preference store for this Java editor with the given input.
    * 
@@ -3423,23 +3455,6 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
     return new ChainedPreferenceStore((IPreferenceStore[]) stores.toArray(new IPreferenceStore[stores.size()]));
   }
 
-  /*
-   * @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)
-   */
-  protected boolean affectsTextPresentation(PropertyChangeEvent event) {
-    JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
-    return textTools.affectsBehavior(event);
-  }
-
   /**
    * Jumps to the error next according to the given direction.
    */