Action borrowed from cfeclipse: "remove trailing spaces at end of file"
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPUnitEditor.java
index ae9f4ca..9c99864 100644 (file)
@@ -17,7 +17,10 @@ import net.sourceforge.phpdt.core.JavaCore;
 import net.sourceforge.phpdt.core.JavaModelException;
 import net.sourceforge.phpdt.core.dom.CompilationUnit;
 import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
+import net.sourceforge.phpdt.internal.ui.actions.AddBlockCommentAction;
 import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
+import net.sourceforge.phpdt.internal.ui.actions.IndentAction;
+import net.sourceforge.phpdt.internal.ui.actions.RemoveBlockCommentAction;
 import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
 import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
@@ -33,6 +36,7 @@ import net.sourceforge.phpdt.ui.PreferenceConstants;
 import net.sourceforge.phpdt.ui.actions.GenerateActionGroup;
 import net.sourceforge.phpdt.ui.text.JavaTextTools;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.phpeditor.actions.RTrimAction;
 import net.sourceforge.phpeclipse.ui.editor.ShowExternalPreviewAction;
 
 import org.eclipse.core.internal.runtime.ListenerList;
@@ -104,8 +108,8 @@ import org.eclipse.ui.texteditor.TextOperationAction;
  * the Common Public License v1.0 which accompanies this distribution, and is
  * available at http://www.eclipse.org/legal/cpl-v10.html
  * 
- * Contributors: IBM Corporation - Initial implementation Klaus Hartlage -
- * www.eclipseproject.de
+ * Contributors: IBM Corporation - Initial implementation 
+ * www.phpeclipse.de
  ******************************************************************************/
 /**
  * PHP specific text editor.
@@ -265,7 +269,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
     private boolean fIgnoreTextConverters = false;
 
-//    private JavaCorrectionAssistant fCorrectionAssistant;
+    //    private JavaCorrectionAssistant fCorrectionAssistant;
 
     public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
         boolean showAnnotationsOverview, int styles, IPreferenceStore store) {
@@ -289,10 +293,10 @@ public class PHPUnitEditor extends PHPEditor { //implements
         String msg = fContentAssistant.showPossibleCompletions();
         setStatusLineErrorMessage(msg);
         return;
-//      case CORRECTIONASSIST_PROPOSALS:
-//        msg = fCorrectionAssistant.showPossibleCompletions();
-//        setStatusLineErrorMessage(msg);
-//        return;
+      //      case CORRECTIONASSIST_PROPOSALS:
+      //        msg = fCorrectionAssistant.showPossibleCompletions();
+      //        setStatusLineErrorMessage(msg);
+      //        return;
       case UNDO:
         fIgnoreTextConverters = true;
         super.doOperation(operation);
@@ -312,8 +316,8 @@ public class PHPUnitEditor extends PHPEditor { //implements
      * @see ITextOperationTarget#canDoOperation(int)
      */
     public boolean canDoOperation(int operation) {
-//      if (operation == CORRECTIONASSIST_PROPOSALS)
-//        return isEditable();
+      //      if (operation == CORRECTIONASSIST_PROPOSALS)
+      //        return isEditable();
 
       return super.canDoOperation(operation);
     }
@@ -323,10 +327,10 @@ public class PHPUnitEditor extends PHPEditor { //implements
      * @since 3.0
      */
     public void unconfigure() {
-//      if (fCorrectionAssistant != null) {
-//        fCorrectionAssistant.uninstall();
-//        fCorrectionAssistant = null;
-//      }
+      //      if (fCorrectionAssistant != null) {
+      //        fCorrectionAssistant.uninstall();
+      //        fCorrectionAssistant = null;
+      //      }
       super.unconfigure();
     }
 
@@ -396,8 +400,8 @@ public class PHPUnitEditor extends PHPEditor { //implements
      */
     public void configure(SourceViewerConfiguration configuration) {
       super.configure(configuration);
-//      fCorrectionAssistant = new JavaCorrectionAssistant(CompilationUnitEditor.this);
-//      fCorrectionAssistant.install(this);
+      //      fCorrectionAssistant = new JavaCorrectionAssistant(CompilationUnitEditor.this);
+      //      fCorrectionAssistant.install(this);
       IAutoEditStrategy smartSemi = new SmartSemicolonAutoEditStrategy(IPHPPartitions.PHP_PARTITIONING);
       prependAutoEditStrategy(smartSemi, IDocument.DEFAULT_CONTENT_TYPE);
       prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_DQ);
@@ -1159,17 +1163,14 @@ public class PHPUnitEditor extends PHPEditor { //implements
   /** The editor's paint manager */
   //  private PaintManager fPaintManager;
   /** The editor's bracket painter */
-//  private BracketPainter fBracketPainter;
-
+  //  private BracketPainter fBracketPainter;
   /** The editor's bracket matcher */
   private PHPPairMatcher fBracketMatcher;
 
   /** The editor's line painter */
-//  private LinePainter fLinePainter;
-
+  //  private LinePainter fLinePainter;
   /** The editor's print margin ruler painter */
-//  private PrintMarginPainter fPrintMarginPainter;
-
+  //  private PrintMarginPainter fPrintMarginPainter;
   /** The editor's problem painter */
   //  private ProblemPainter fProblemPainter;
   /** The editor's tab converter */
@@ -1215,26 +1216,19 @@ public class PHPUnitEditor extends PHPEditor { //implements
   private final static String CODE_FORMATTER_TAB_SIZE = JavaCore.FORMATTER_TAB_SIZE;
 
   /** Preference key for matching brackets */
-//  private final static String MATCHING_BRACKETS = PreferenceConstants.EDITOR_MATCHING_BRACKETS;
-
+  //  private final static String MATCHING_BRACKETS = PreferenceConstants.EDITOR_MATCHING_BRACKETS;
   /** Preference key for matching brackets color */
-//  private final static String MATCHING_BRACKETS_COLOR = PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
-
+  //  private final static String MATCHING_BRACKETS_COLOR = PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
   /** Preference key for highlighting current line */
-//  private final static String CURRENT_LINE = PreferenceConstants.EDITOR_CURRENT_LINE;
-
+  //  private final static String CURRENT_LINE = PreferenceConstants.EDITOR_CURRENT_LINE;
   /** Preference key for highlight color of current line */
-//  private final static String CURRENT_LINE_COLOR = PreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
-
+  //  private final static String CURRENT_LINE_COLOR = PreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
   /** Preference key for showing print marging ruler */
-//  private final static String PRINT_MARGIN = PreferenceConstants.EDITOR_PRINT_MARGIN;
-
+  //  private final static String PRINT_MARGIN = PreferenceConstants.EDITOR_PRINT_MARGIN;
   /** Preference key for print margin ruler color */
-//  private final static String PRINT_MARGIN_COLOR = PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
-
+  //  private final static String PRINT_MARGIN_COLOR = PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
   /** Preference key for print margin ruler column */
-//  private final static String PRINT_MARGIN_COLUMN = PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
-
+  //  private final static String PRINT_MARGIN_COLUMN = PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
   /** Preference key for inserting spaces rather than tabs */
   private final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
 
@@ -1305,8 +1299,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   private final static String CLOSE_STRINGS_SQ_PHP = PreferenceConstants.EDITOR_CLOSE_STRINGS_SQ_PHP;
 
   /** Preference key for automatically wrapping Java strings */
-//  private final static String WRAP_STRINGS = PreferenceConstants.EDITOR_WRAP_STRINGS_DQ;
-
+  //  private final static String WRAP_STRINGS = PreferenceConstants.EDITOR_WRAP_STRINGS_DQ;
   /** Preference key for automatically closing brackets and parenthesis */
   private final static String CLOSE_BRACKETS_PHP = PreferenceConstants.EDITOR_CLOSE_BRACKETS_PHP;
 
@@ -1317,8 +1310,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   private final static String ADD_JAVADOC_TAGS = PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS;
 
   /** Preference key for automatically formatting phpdocs */
-  private final static String FORMAT_JAVADOCS = PreferenceConstants.EDITOR_FORMAT_JAVADOCS;
-
+  //  private final static String FORMAT_JAVADOCS = PreferenceConstants.EDITOR_FORMAT_JAVADOCS;
   /** Preference key for automatically closing strings */
   private final static String CLOSE_STRINGS_HTML = PreferenceConstants.EDITOR_CLOSE_STRINGS_HTML;
 
@@ -1515,6 +1507,33 @@ public class PHPUnitEditor extends PHPEditor { //implements
     //         markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$
     //         markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$
     //         
+
+    action = new AddBlockCommentAction(PHPEditorMessages.getResourceBundle(), "AddBlockComment.", this); //$NON-NLS-1$
+    action.setActionDefinitionId(PHPEditorActionDefinitionIds.ADD_BLOCK_COMMENT);
+    setAction("AddBlockComment", action); //$NON-NLS-1$
+    markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$
+    markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$             
+    // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
+
+    action = new RemoveBlockCommentAction(PHPEditorMessages.getResourceBundle(), "RemoveBlockComment.", this); //$NON-NLS-1$
+    action.setActionDefinitionId(PHPEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT);
+    setAction("RemoveBlockComment", action); //$NON-NLS-1$
+    markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
+    markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$          
+    // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.REMOVE_BLOCK_COMMENT_ACTION);
+
+    // action= new IndentAction(PHPEditorMessages.getResourceBundle(), "Indent.", this, false); //$NON-NLS-1$
+    // action.setActionDefinitionId(PHPEditorActionDefinitionIds.INDENT);
+    // setAction("Indent", action); //$NON-NLS-1$
+    // markAsStateDependentAction("Indent", true); //$NON-NLS-1$
+    // markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
+    //// WorkbenchHelp.setHelp(action, IJavaHelpContextIds.INDENT_ACTION);
+    // 
+    action = new IndentAction(PHPEditorMessages.getResourceBundle(), "Indent.", this, true); //$NON-NLS-1$
+    setAction("IndentOnTab", action); //$NON-NLS-1$
+    markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$
+    markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$
+
     if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) {
       // don't replace Shift Right - have to make sure their enablement is
       // mutually exclusive
@@ -1522,14 +1541,16 @@ public class PHPUnitEditor extends PHPEditor { //implements
       setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
     }
     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)});
+    //    ActionGroup rg= new RefactorActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
+
+    // fActionGroups.addGroup(rg);
+    fActionGroups.addGroup(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)
+        });
 
   }
 
@@ -1590,12 +1611,12 @@ public class PHPUnitEditor extends PHPEditor { //implements
     linePainter = new LinePainter(getSourceViewer());
     linePainter.setHighlightColor(new Color(Display.getCurrent(), 225, 235, 224));
     //    fPaintManager.addPainter(linePainter);
-//    if (isBracketHighlightingEnabled())
-//      startBracketHighlighting();
-//    if (isLineHighlightingEnabled())
-//      startLineHighlighting();
-//    if (isPrintMarginVisible())
-//      showPrintMargin();
+    //    if (isBracketHighlightingEnabled())
+    //      startBracketHighlighting();
+    //    if (isLineHighlightingEnabled())
+    //      startLineHighlighting();
+    //    if (isPrintMarginVisible())
+    //      showPrintMargin();
     //    Iterator e = ANNOTATION_MAP.keySet().iterator();
     //    while (e.hasNext()) {
     //      AnnotationType type = (AnnotationType) e.next();
@@ -1645,148 +1666,75 @@ public class PHPUnitEditor extends PHPEditor { //implements
     }
   }
 
-//  private void startBracketHighlighting() {
-//    if (fBracketPainter == null) {
-//      ISourceViewer sourceViewer = getSourceViewer();
-//      fBracketPainter = new BracketPainter(sourceViewer);
-//      fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
-//      //      fPaintManager.addPainter(fBracketPainter);
-//    }
-//  }
-//
-//  private void stopBracketHighlighting() {
-//    if (fBracketPainter != null) {
-//      //      fPaintManager.removePainter(fBracketPainter);
-//      fBracketPainter.deactivate(true);
-//      fBracketPainter.dispose();
-//      fBracketPainter = null;
-//    }
-//  }
-
-//  private boolean isBracketHighlightingEnabled() {
-//    IPreferenceStore store = getPreferenceStore();
-//    return store.getBoolean(MATCHING_BRACKETS);
-//  }
-
-//  private void startLineHighlighting() {
-//    if (fLinePainter == null) {
-//      ISourceViewer sourceViewer = getSourceViewer();
-//      fLinePainter = new LinePainter(sourceViewer);
-//      fLinePainter.setHighlightColor(getColor(CURRENT_LINE_COLOR));
-//      //      fPaintManager.addPainter(fLinePainter);
-//    }
-//  }
-
-//  private void stopLineHighlighting() {
-//    if (fLinePainter != null) {
-//      //      fPaintManager.removePainter(fLinePainter);
-//      fLinePainter.deactivate(true);
-//      fLinePainter.dispose();
-//      fLinePainter = null;
-//    }
-//  }
-
-//  private boolean isLineHighlightingEnabled() {
-//    IPreferenceStore store = getPreferenceStore();
-//    return store.getBoolean(CURRENT_LINE);
-//  }
-
-//  private void showPrintMargin() {
-//    if (fPrintMarginPainter == null) {
-//      fPrintMarginPainter = new PrintMarginPainter(getSourceViewer());
-//      fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
-//      fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
-//      //      fPaintManager.addPainter(fPrintMarginPainter);
-//    }
-//  }
-
-//  private void hidePrintMargin() {
-//    if (fPrintMarginPainter != null) {
-//      //      fPaintManager.removePainter(fPrintMarginPainter);
-//      fPrintMarginPainter.deactivate(true);
-//      fPrintMarginPainter.dispose();
-//      fPrintMarginPainter = null;
-//    }
-//  }
-
-//  private boolean isPrintMarginVisible() {
-//    IPreferenceStore store = getPreferenceStore();
-//    return store.getBoolean(PRINT_MARGIN);
-//  }
-
-  //  private void startAnnotationIndication(AnnotationType annotationType) {
-  //    if (fProblemPainter == null) {
-  //      fProblemPainter = new ProblemPainter(this, getSourceViewer());
-  //// fPaintManager.addPainter(fProblemPainter);
+  //  private void startBracketHighlighting() {
+  //    if (fBracketPainter == null) {
+  //      ISourceViewer sourceViewer = getSourceViewer();
+  //      fBracketPainter = new BracketPainter(sourceViewer);
+  //      fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
+  //      // fPaintManager.addPainter(fBracketPainter);
   //    }
-  //    fProblemPainter.setColor(annotationType, getColor(annotationType));
-  //    fProblemPainter.paintAnnotations(annotationType, true);
-  //    fProblemPainter.paint(IPainter.CONFIGURATION);
   //  }
   //
-  //  private void shutdownAnnotationIndication() {
-  //    if (fProblemPainter != null) {
-  //
-  //      if (!fProblemPainter.isPaintingAnnotations()) {
-  //// fPaintManager.removePainter(fProblemPainter);
-  //        fProblemPainter.deactivate(true);
-  //        fProblemPainter.dispose();
-  //        fProblemPainter = null;
-  //      } else {
-  //        fProblemPainter.paint(IPainter.CONFIGURATION);
-  //      }
+  //  private void stopBracketHighlighting() {
+  //    if (fBracketPainter != null) {
+  //      // fPaintManager.removePainter(fBracketPainter);
+  //      fBracketPainter.deactivate(true);
+  //      fBracketPainter.dispose();
+  //      fBracketPainter = null;
   //    }
   //  }
-  //
-  //  private void stopAnnotationIndication(AnnotationType annotationType) {
-  //    if (fProblemPainter != null) {
-  //      fProblemPainter.paintAnnotations(annotationType, false);
-  //      shutdownAnnotationIndication();
+
+  //  private boolean isBracketHighlightingEnabled() {
+  //    IPreferenceStore store = getPreferenceStore();
+  //    return store.getBoolean(MATCHING_BRACKETS);
+  //  }
+
+  //  private void startLineHighlighting() {
+  //    if (fLinePainter == null) {
+  //      ISourceViewer sourceViewer = getSourceViewer();
+  //      fLinePainter = new LinePainter(sourceViewer);
+  //      fLinePainter.setHighlightColor(getColor(CURRENT_LINE_COLOR));
+  //      // fPaintManager.addPainter(fLinePainter);
   //    }
   //  }
-  //
-  //  private boolean isAnnotationIndicationEnabled(AnnotationType
-  // annotationType) {
-  //    IPreferenceStore store = getPreferenceStore();
-  //    AnnotationInfo info = (AnnotationInfo)
-  // ANNOTATION_MAP.get(annotationType);
-  //    if (info != null)
-  //      return store.getBoolean(info.fEditorPreference);
-  //    return false;
+
+  //  private void stopLineHighlighting() {
+  //    if (fLinePainter != null) {
+  //      // fPaintManager.removePainter(fLinePainter);
+  //      fLinePainter.deactivate(true);
+  //      fLinePainter.dispose();
+  //      fLinePainter = null;
+  //    }
   //  }
-  //
-  //  private boolean
-  // isAnnotationIndicationInOverviewRulerEnabled(AnnotationType
-  // annotationType) {
+
+  //  private boolean isLineHighlightingEnabled() {
   //    IPreferenceStore store = getPreferenceStore();
-  //    AnnotationInfo info = (AnnotationInfo)
-  // ANNOTATION_MAP.get(annotationType);
-  //    if (info != null)
-  //      return store.getBoolean(info.fOverviewRulerPreference);
-  //    return false;
+  //    return store.getBoolean(CURRENT_LINE);
   //  }
-  //
-  //  private void showAnnotationIndicationInOverviewRuler(AnnotationType
-  // annotationType, boolean show) {
-  //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
-  //    OverviewRuler ruler = asv.getOverviewRuler();
-  //    if (ruler != null) {
-  //      ruler.setColor(annotationType, getColor(annotationType));
-  //      ruler.showAnnotation(annotationType, show);
-  //      ruler.update();
+
+  //  private void showPrintMargin() {
+  //    if (fPrintMarginPainter == null) {
+  //      fPrintMarginPainter = new PrintMarginPainter(getSourceViewer());
+  //      fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
+  //      fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
+  //      // fPaintManager.addPainter(fPrintMarginPainter);
   //    }
   //  }
-  //
-  //  private void setColorInOverviewRuler(AnnotationType annotationType, Color
-  // color) {
-  //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
-  //    OverviewRuler ruler = asv.getOverviewRuler();
-  //    if (ruler != null) {
-  //      ruler.setColor(annotationType, color);
-  //      ruler.update();
+
+  //  private void hidePrintMargin() {
+  //    if (fPrintMarginPainter != null) {
+  //      // fPaintManager.removePainter(fPrintMarginPainter);
+  //      fPrintMarginPainter.deactivate(true);
+  //      fPrintMarginPainter.dispose();
+  //      fPrintMarginPainter = null;
   //    }
   //  }
 
+  //  private boolean isPrintMarginVisible() {
+  //    IPreferenceStore store = getPreferenceStore();
+  //    return store.getBoolean(PRINT_MARGIN);
+  //  }
+
   private int getTabSize() {
     Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
     return preferences.getInt(CODE_FORMATTER_TAB_SIZE);
@@ -1797,30 +1745,6 @@ public class PHPUnitEditor extends PHPEditor { //implements
     return store.getBoolean(SPACES_FOR_TABS);
   }
 
-  //  private void showOverviewRuler() {
-  //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
-  //    asv.showOverviewRuler();
-  //
-  //    OverviewRuler overviewRuler = asv.getOverviewRuler();
-  //    if (overviewRuler != null) {
-  //      for (int i = 0; i < ANNOTATION_LAYERS.length; i++) {
-  //        AnnotationType type = ANNOTATION_LAYERS[i];
-  //        overviewRuler.setLayer(type, i);
-  //        if (isAnnotationIndicationInOverviewRulerEnabled(type))
-  //          showAnnotationIndicationInOverviewRuler(type, true);
-  //      }
-  //    }
-  //  }
-  //
-  //  private void hideOverviewRuler() {
-  //    AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
-  //    asv.hideOverviewRuler();
-  //  }
-  //
-  //  private boolean isOverviewRulerVisible() {
-  //    IPreferenceStore store = getPreferenceStore();
-  //    return store.getBoolean(OVERVIEW_RULER);
-  //  }
   private Color getColor(String key) {
     RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key);
     return getColor(rgb);
@@ -1914,49 +1838,49 @@ public class PHPUnitEditor extends PHPEditor { //implements
             stopTabConversion();
           return;
         }
-//        if (MATCHING_BRACKETS.equals(p)) {
-//          if (isBracketHighlightingEnabled())
-//            startBracketHighlighting();
-//          else
-//            stopBracketHighlighting();
-//          return;
-//        }
-//        if (MATCHING_BRACKETS_COLOR.equals(p)) {
-//          if (fBracketPainter != null)
-//            fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
-//          return;
-//        }
-//        if (CURRENT_LINE.equals(p)) {
-//          if (isLineHighlightingEnabled())
-//            startLineHighlighting();
-//          else
-//            stopLineHighlighting();
-//          return;
-//        }
-//        if (CURRENT_LINE_COLOR.equals(p)) {
-//          if (fLinePainter != null) {
-//            stopLineHighlighting();
-//            startLineHighlighting();
-//          }
-//          return;
-//        }
-//        if (PRINT_MARGIN.equals(p)) {
-//          if (isPrintMarginVisible())
-//            showPrintMargin();
-//          else
-//            hidePrintMargin();
-//          return;
-//        }
-//        if (PRINT_MARGIN_COLOR.equals(p)) {
-//          if (fPrintMarginPainter != null)
-//            fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
-//          return;
-//        }
-//        if (PRINT_MARGIN_COLUMN.equals(p)) {
-//          if (fPrintMarginPainter != null)
-//            fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
-//          return;
-//        }
+        //        if (MATCHING_BRACKETS.equals(p)) {
+        //          if (isBracketHighlightingEnabled())
+        //            startBracketHighlighting();
+        //          else
+        //            stopBracketHighlighting();
+        //          return;
+        //        }
+        //        if (MATCHING_BRACKETS_COLOR.equals(p)) {
+        //          if (fBracketPainter != null)
+        //            fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
+        //          return;
+        //        }
+        //        if (CURRENT_LINE.equals(p)) {
+        //          if (isLineHighlightingEnabled())
+        //            startLineHighlighting();
+        //          else
+        //            stopLineHighlighting();
+        //          return;
+        //        }
+        //        if (CURRENT_LINE_COLOR.equals(p)) {
+        //          if (fLinePainter != null) {
+        //            stopLineHighlighting();
+        //            startLineHighlighting();
+        //          }
+        //          return;
+        //        }
+        //        if (PRINT_MARGIN.equals(p)) {
+        //          if (isPrintMarginVisible())
+        //            showPrintMargin();
+        //          else
+        //            hidePrintMargin();
+        //          return;
+        //        }
+        //        if (PRINT_MARGIN_COLOR.equals(p)) {
+        //          if (fPrintMarginPainter != null)
+        //            fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
+        //          return;
+        //        }
+        //        if (PRINT_MARGIN_COLUMN.equals(p)) {
+        //          if (fPrintMarginPainter != null)
+        //            fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
+        //          return;
+        //        }
         //        if (OVERVIEW_RULER.equals(p)) {
         //          if (isOverviewRulerVisible())
         //            showOverviewRuler();
@@ -2005,7 +1929,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   }
 
   /*
-   * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
+   * @see net.sourceforge.phpdt.internal.ui.javaeditor.JavaEditor#handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
    */
   protected void handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
     AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
@@ -2041,7 +1965,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   //    }
   //  }
   /*
-   * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#createJavaSourceViewer(org.eclipse.swt.widgets.Composite,
+   * @see net.sourceforge.phpdt.internal.ui.javaeditor.JavaEditor#createJavaSourceViewer(org.eclipse.swt.widgets.Composite,
    *      org.eclipse.jface.text.source.IVerticalRuler, org.eclipse.jface.text.source.IOverviewRuler, boolean, int)
    */
   protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
@@ -2067,7 +1991,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   }
 
   /*
-   * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#getInputElement()
+   * @see net.sourceforge.phpdt.internal.ui.javaeditor.JavaEditor#getInputElement()
    */
   protected IJavaElement getInputJavaElement() {
     return PHPeclipsePlugin.getDefault().getWorkingCopyManager().getWorkingCopy(getEditorInput());
@@ -2148,6 +2072,11 @@ public class PHPUnitEditor extends PHPEditor { //implements
       }
 
     } else {
+      if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_P_RTRIM_ON_SAVE)) {
+        RTrimAction trimAction = new RTrimAction();
+        trimAction.setActiveEditor(null, getSite().getPage().getActiveEditor());
+        trimAction.run(null);  
+      }
 
       setStatusLineErrorMessage(null);
 
@@ -2255,7 +2184,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
 
   //   /*
   //    * @see
-  // org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#installOverrideIndicator(boolean)
+  // net.sourceforge.phpdt.internal.ui.javaeditor.JavaEditor#installOverrideIndicator(boolean)
   //    * @since 3.0
   //    */
   //   protected void installOverrideIndicator(boolean waitForReconcilation) {
@@ -2277,7 +2206,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   //   
   //   /*
   //    * @see
-  // org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#uninstallOverrideIndicator()
+  // net.sourceforge.phpdt.internal.ui.javaeditor.JavaEditor#uninstallOverrideIndicator()
   //    * @since 3.0
   //    */
   //   protected void uninstallOverrideIndicator() {
@@ -2300,11 +2229,20 @@ public class PHPUnitEditor extends PHPEditor { //implements
     }
   }
 
+  //  private void configureTabConverter() {
+  //    if (fTabConverter != null) {
+  //      IDocumentProvider provider = getDocumentProvider();
+  //      if (provider instanceof PHPDocumentProvider) {
+  //        PHPDocumentProvider cup = (PHPDocumentProvider) provider;
+  //        fTabConverter.setLineTracker(cup.createLineTracker(getEditorInput()));
+  //      }
+  //    }
+  //  }
   private void configureTabConverter() {
     if (fTabConverter != null) {
       IDocumentProvider provider = getDocumentProvider();
-      if (provider instanceof PHPDocumentProvider) {
-        PHPDocumentProvider cup = (PHPDocumentProvider) provider;
+      if (provider instanceof ICompilationUnitDocumentProvider) {
+        ICompilationUnitDocumentProvider cup = (ICompilationUnitDocumentProvider) provider;
         fTabConverter.setLineTracker(cup.createLineTracker(getEditorInput()));
       }
     }
@@ -2336,16 +2274,30 @@ public class PHPUnitEditor extends PHPEditor { //implements
    * @see org.eclipse.ui.texteditor.AbstractTextEditor#performSave(boolean, org.eclipse.core.runtime.IProgressMonitor)
    */
   protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) {
+    //    IDocumentProvider p = getDocumentProvider();
+    //    if (p instanceof PHPDocumentProvider) {
+    //      PHPDocumentProvider cp = (PHPDocumentProvider) p;
+    //      cp.setSavePolicy(fSavePolicy);
+    //    }
+    //    try {
+    //      super.performSave(overwrite, progressMonitor);
+    //    } finally {
+    //      if (p instanceof PHPDocumentProvider) {
+    //        PHPDocumentProvider cp = (PHPDocumentProvider) p;
+    //        cp.setSavePolicy(null);
+    //      }
+    //    }
+
     IDocumentProvider p = getDocumentProvider();
-    if (p instanceof PHPDocumentProvider) {
-      PHPDocumentProvider cp = (PHPDocumentProvider) p;
+    if (p instanceof ICompilationUnitDocumentProvider) {
+      ICompilationUnitDocumentProvider cp = (ICompilationUnitDocumentProvider) p;
       cp.setSavePolicy(fSavePolicy);
     }
     try {
       super.performSave(overwrite, progressMonitor);
     } finally {
-      if (p instanceof PHPDocumentProvider) {
-        PHPDocumentProvider cp = (PHPDocumentProvider) p;
+      if (p instanceof ICompilationUnitDocumentProvider) {
+        ICompilationUnitDocumentProvider cp = (ICompilationUnitDocumentProvider) p;
         cp.setSavePolicy(null);
       }
     }
@@ -2389,7 +2341,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   }
 
   /*
-   * @see org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled()
+   * @see net.sourceforge.phpdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled()
    * @since 3.0
    */
   public void aboutToBeReconciled() {
@@ -2404,7 +2356,8 @@ public class PHPUnitEditor extends PHPEditor { //implements
   }
 
   /*
-   * @see org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#reconciled(CompilationUnit, boolean, IProgressMonitor)
+   * @see net.sourceforge.phpdt.internal.ui.text.java.IJavaReconcilingListener#reconciled(CompilationUnit, boolean,
+   *      IProgressMonitor)
    * @since 3.0
    */
   public void reconciled(CompilationUnit ast, boolean forced, IProgressMonitor progressMonitor) {
@@ -2430,10 +2383,6 @@ public class PHPUnitEditor extends PHPEditor { //implements
     }
   }
 
-  private boolean synchronizeOutlineOnCursorMove() {
-    return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE);
-  }
-
   /**
    * Returns the updated java element for the old java element.
    */
@@ -2591,7 +2540,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
   }
 
   /*
-   * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#getAdapter(java.lang.Class)
+   * @see net.sourceforge.phpdt.internal.ui.javaeditor.JavaEditor#getAdapter(java.lang.Class)
    */
   public Object getAdapter(Class required) {
     if (SmartBackspaceManager.class.equals(required)) {