X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java index 49f7d5f..aacb78d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java @@ -36,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; @@ -89,11 +90,11 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.dialogs.SaveAsDialog; import org.eclipse.ui.editors.text.IStorageDocumentProvider; -import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.ContentAssistAction; @@ -106,8 +107,8 @@ import org.eclipse.ui.texteditor.TextOperationAction; * program and the accompanying materials are made available under the terms of * 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 + * + * Contributors: IBM Corporation - Initial implementation * www.phpeclipse.de ******************************************************************************/ /** @@ -268,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) { @@ -292,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); @@ -315,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); } @@ -326,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(); } @@ -376,35 +377,40 @@ public class PHPUnitEditor extends PHPEditor { //implements } /* - * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper) - */ - public boolean requestWidgetToken(IWidgetTokenKeeper requester) { - if (WorkbenchHelp.isContextHelpDisplayed()) - return false; - return super.requestWidgetToken(requester); - } + * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper) + */ + public boolean requestWidgetToken(IWidgetTokenKeeper requester) { + if (PlatformUI.getWorkbench().getHelpSystem() + .isContextHelpDisplayed()) + return false; + return super.requestWidgetToken(requester); + } /* - * @see IWidgetTokenOwnerExtension#requestWidgetToken(IWidgetTokenKeeper, int) - * @since 3.0 - */ - public boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority) { - if (WorkbenchHelp.isContextHelpDisplayed()) - return false; - return super.requestWidgetToken(requester, priority); - } + * @see IWidgetTokenOwnerExtension#requestWidgetToken(IWidgetTokenKeeper, + * int) + * @since 3.0 + */ + public boolean requestWidgetToken(IWidgetTokenKeeper requester, + int priority) { + if (PlatformUI.getWorkbench().getHelpSystem() + .isContextHelpDisplayed()) + return false; + return super.requestWidgetToken(requester, priority); + } /* * @see org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration) */ 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); prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_SQ); + prependAutoEditStrategy(smartSemi, IPHPPartitions.PHP_STRING_HEREDOC); } /* @@ -431,7 +437,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Remembers data related to the current selection to be able to restore it later. - * + * * @since 3.0 */ private class RememberedSelection { @@ -541,7 +547,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Remembers additional data for a given offset to be able restore it later. - * + * * @since 3.0 */ private class RememberedOffset { @@ -559,7 +565,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Store visual properties of the given offset. - * + * * @param offset * Offset in the document */ @@ -591,7 +597,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Return offset recomputed from stored visual properties. - * + * * @return Offset in the document */ public int getOffset() { @@ -607,7 +613,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Return offset recomputed from stored visual properties. - * + * * @param newElement * Enclosing element * @return Offset in the document @@ -656,7 +662,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Returns the offset used to reveal the given element based on the given selection offset. - * + * * @param element * the element * @param offset @@ -682,7 +688,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Return Java element recomputed from stored visual properties. - * + * * @return Java element */ public IJavaElement getElement() { @@ -704,7 +710,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Does the given Java element contain the given offset? - * + * * @param element * Java element * @param offset @@ -720,7 +726,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Returns the offset of the given Java element. - * + * * @param element * Java element * @return Offset of the given Java element @@ -740,7 +746,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Returns the length of the given Java element. - * + * * @param element * Java element * @return Length of the given Java element @@ -760,7 +766,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Returns the updated java element for the old java element. - * + * * @param element * Old Java element * @return Updated Java element @@ -1162,17 +1168,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 */ @@ -1188,7 +1191,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * The remembered selection. - * + * * @since 3.0 */ private RememberedSelection fRememberedSelection = new RememberedSelection(); @@ -1218,26 +1221,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; @@ -1308,8 +1304,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; @@ -1320,8 +1315,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; @@ -1394,7 +1388,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Reconciling listeners. - * + * * @since 3.0 */ private ListenerList fReconcilingListeners = new ListenerList(); @@ -1483,7 +1477,7 @@ public class PHPUnitEditor extends PHPEditor { //implements action.setActionDefinitionId(PHPEditorActionDefinitionIds.FORMAT); setAction("Format", action); //$NON-NLS-1$ markAsStateDependentAction("Format", true); //$NON-NLS-1$ - markAsSelectionDependentAction("Format", true); //$NON-NLS-1$ + markAsSelectionDependentAction("Format", true); //$NON-NLS-1$ // WorkbenchHelp.setHelp(action, IJavaHelpContextIds.FORMAT_ACTION); // action = new AddBlockCommentAction(PHPEditorMessages.getResourceBundle(), @@ -1511,58 +1505,57 @@ public class PHPUnitEditor extends PHPEditor { //implements // 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$ - // - - 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$ - + // + + 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 // removeActionActivationCode(ITextEditorActionConstants.SHIFT_RIGHT); setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$ } - fGenerateActionGroup= new GenerateActionGroup(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) - }); + fGenerateActionGroup = new GenerateActionGroup(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) + }); } @@ -1577,7 +1570,7 @@ public class PHPUnitEditor extends PHPEditor { //implements * Returns the most narrow element including the given offset. If reconcile is true the editor's * input element is reconciled in advance. If it is false this method only returns a result if the editor's input * element does not need to be reconciled. - * + * * @param offset * the offset included by the retrieved element * @param reconcile @@ -1623,12 +1616,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(); @@ -1678,75 +1671,74 @@ 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 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 int getTabSize() { Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences(); @@ -1851,49 +1843,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(); @@ -1960,7 +1952,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Handles a property change event describing a change of the php core's preferences and updates the preference related editor * properties. - * + * * @param event * the property change event */ @@ -2085,6 +2077,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); @@ -2110,7 +2107,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * The compilation unit editor implementation of this AbstractTextEditor method asks the user for the workspace * path of a file resource and saves the document there. See http://dev.eclipse.org/bugs/show_bug.cgi?id=6295 - * + * * @param progressMonitor * the progress monitor */ @@ -2205,13 +2202,13 @@ public class PHPUnitEditor extends PHPEditor { //implements // IJavaElement inputElement= getInputJavaElement(); // if (model == null || inputElement == null) // return; - // + // // fOverrideIndicatorManager= new OverrideIndicatorManager(model, // inputElement, null); // addReconcileListener(fOverrideIndicatorManager); // } // } - // + // // /* // * @see // net.sourceforge.phpdt.internal.ui.javaeditor.JavaEditor#uninstallOverrideIndicator() @@ -2225,7 +2222,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Configures the toggle comment action - * + * * @since 3.0 */ private void configureToggleCommentAction() { @@ -2246,15 +2243,16 @@ public class PHPUnitEditor extends PHPEditor { //implements // } // } // } - private void configureTabConverter() { - if (fTabConverter != null) { - IDocumentProvider provider= getDocumentProvider(); - if (provider instanceof ICompilationUnitDocumentProvider) { - ICompilationUnitDocumentProvider cup= (ICompilationUnitDocumentProvider) provider; - fTabConverter.setLineTracker(cup.createLineTracker(getEditorInput())); - } - } - } + private void configureTabConverter() { + if (fTabConverter != null) { + IDocumentProvider provider = getDocumentProvider(); + if (provider instanceof ICompilationUnitDocumentProvider) { + ICompilationUnitDocumentProvider cup = (ICompilationUnitDocumentProvider) provider; + fTabConverter.setLineTracker(cup.createLineTracker(getEditorInput())); + } + } + } + private void startTabConversion() { if (fTabConverter == null) { fTabConverter = new TabConverter(); @@ -2281,33 +2279,33 @@ 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 ICompilationUnitDocumentProvider) { - ICompilationUnitDocumentProvider cp= (ICompilationUnitDocumentProvider) p; - cp.setSavePolicy(fSavePolicy); - } - try { - super.performSave(overwrite, progressMonitor); - } finally { - if (p instanceof ICompilationUnitDocumentProvider) { - ICompilationUnitDocumentProvider cp= (ICompilationUnitDocumentProvider) p; - cp.setSavePolicy(null); - } - } + // 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 ICompilationUnitDocumentProvider) { + ICompilationUnitDocumentProvider cp = (ICompilationUnitDocumentProvider) p; + cp.setSavePolicy(fSavePolicy); + } + try { + super.performSave(overwrite, progressMonitor); + } finally { + if (p instanceof ICompilationUnitDocumentProvider) { + ICompilationUnitDocumentProvider cp = (ICompilationUnitDocumentProvider) p; + cp.setSavePolicy(null); + } + } } /* @@ -2321,7 +2319,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Asks the user if it is ok to store in non-workbench encoding. - * + * * @return if the user wants to continue */ private boolean askIfNonWorkbenchEncodingIsOk() { @@ -2363,7 +2361,8 @@ public class PHPUnitEditor extends PHPEditor { //implements } /* - * @see net.sourceforge.phpdt.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) { @@ -2452,7 +2451,7 @@ public class PHPUnitEditor extends PHPEditor { //implements // } /** * Tells whether this is the active editor in the active page. - * + * * @return true if this is the active editor in the active page * @see IWorkbenchPage#getActiveEditor(); */ @@ -2467,7 +2466,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Adds the given listener. Has no effect if an identical listener was not already registered. - * + * * @param listener * The reconcile listener to be added * @since 3.0 @@ -2480,7 +2479,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /** * Removes the given listener. Has no effect if an identical listener was not already registered. - * + * * @param listener * the reconcile listener to be removed * @since 3.0 @@ -2563,7 +2562,7 @@ public class PHPUnitEditor extends PHPEditor { //implements *

* TODO remove once the underlying problem is solved. *

- * + * * @return the lock reconcilers may use to synchronize on */ public Object getReconcilerLock() { @@ -2572,7 +2571,7 @@ public class PHPUnitEditor extends PHPEditor { //implements /* * (non-Javadoc) - * + * * @see org.eclipse.ui.texteditor.AbstractTextEditor#editorSaved() */ protected void editorSaved() {