package net.sourceforge.phpeclipse.phpeditor;
+import java.text.MessageFormat;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.text.AbstractHoverInformationControlManager;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentCommand;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IWidgetTokenKeeper;
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.editors.text.IStorageDocumentProvider;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.texteditor.IDocumentProvider;
* PHP specific text editor.
*/
public class PHPUnitEditor extends PHPEditor {
-
+
interface ITextConverter {
void customizeDocumentCommand(IDocument document, DocumentCommand command);
};
- class AdaptedRulerLayout extends Layout {
-
- protected int fGap;
- protected AdaptedSourceViewer fAdaptedSourceViewer;
-
- protected AdaptedRulerLayout(int gap, AdaptedSourceViewer asv) {
- fGap = gap;
- fAdaptedSourceViewer = asv;
- }
-
- protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
- Control[] children = composite.getChildren();
- Point s = children[children.length - 1].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
- if (fAdaptedSourceViewer.isVerticalRulerVisible())
- s.x += fAdaptedSourceViewer.getVerticalRuler().getWidth() + fGap;
- return s;
- }
-
- protected void layout(Composite composite, boolean flushCache) {
- Rectangle clArea = composite.getClientArea();
- if (fAdaptedSourceViewer.isVerticalRulerVisible()) {
-
- StyledText textWidget = fAdaptedSourceViewer.getTextWidget();
- Rectangle trim = textWidget.computeTrim(0, 0, 0, 0);
- int scrollbarHeight = trim.height;
-
- IVerticalRuler vr = fAdaptedSourceViewer.getVerticalRuler();
- int vrWidth = vr.getWidth();
-
- int orWidth = 0;
- if (fAdaptedSourceViewer.isOverviewRulerVisible()) {
- OverviewRuler or = fAdaptedSourceViewer.getOverviewRuler();
- orWidth = or.getWidth();
- or.getControl().setBounds(clArea.width - orWidth, scrollbarHeight, orWidth, clArea.height - 3 * scrollbarHeight);
- }
-
- textWidget.setBounds(vrWidth + fGap, 0, clArea.width - vrWidth - orWidth - 2 * fGap, clArea.height);
- vr.getControl().setBounds(0, 0, vrWidth, clArea.height - scrollbarHeight);
-
- } else {
- StyledText textWidget = fAdaptedSourceViewer.getTextWidget();
- textWidget.setBounds(0, 0, clArea.width, clArea.height);
- }
- }
- };
-
- class AdaptedSourceViewer extends SourceViewer { // extends JavaCorrectionSourceViewer {
+ // class AdaptedRulerLayout extends Layout {
+ //
+ // protected int fGap;
+ // protected AdaptedSourceViewer fAdaptedSourceViewer;
+ //
+ // protected AdaptedRulerLayout(int gap, AdaptedSourceViewer asv) {
+ // fGap = gap;
+ // fAdaptedSourceViewer = asv;
+ // }
+ //
+ // protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
+ // Control[] children = composite.getChildren();
+ // Point s = children[children.length - 1].computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
+ // if (fAdaptedSourceViewer.isVerticalRulerVisible())
+ // s.x += fAdaptedSourceViewer.getVerticalRuler().getWidth() + fGap;
+ // return s;
+ // }
+ //
+ // protected void layout(Composite composite, boolean flushCache) {
+ // Rectangle clArea = composite.getClientArea();
+ // if (fAdaptedSourceViewer.isVerticalRulerVisible()) {
+ //
+ // StyledText textWidget = fAdaptedSourceViewer.getTextWidget();
+ // Rectangle trim = textWidget.computeTrim(0, 0, 0, 0);
+ // int scrollbarHeight = trim.height;
+ //
+ // IVerticalRuler vr = fAdaptedSourceViewer.getVerticalRuler();
+ // int vrWidth = vr.getWidth();
+ //
+ // int orWidth = 0;
+ // if (fAdaptedSourceViewer.isOverviewRulerVisible()) {
+ // OverviewRuler or = fAdaptedSourceViewer.getOverviewRuler();
+ // orWidth = or.getWidth();
+ // or.getControl().setBounds(clArea.width - orWidth, scrollbarHeight, orWidth, clArea.height - 3 * scrollbarHeight);
+ // }
+ //
+ // textWidget.setBounds(vrWidth + fGap, 0, clArea.width - vrWidth - orWidth - 2 * fGap, clArea.height);
+ // vr.getControl().setBounds(0, 0, vrWidth, clArea.height - scrollbarHeight);
+ //
+ // } else {
+ // StyledText textWidget = fAdaptedSourceViewer.getTextWidget();
+ // textWidget.setBounds(0, 0, clArea.width, clArea.height);
+ // }
+ // }
+ // };
+ //
+ // class AdaptedSourceViewer extends SourceViewer { // extends JavaCorrectionSourceViewer {
+ //
+ // private List fTextConverters;
+ //
+ // private OverviewRuler fOverviewRuler;
+ // private boolean fIsOverviewRulerVisible;
+ // /** The viewer's overview ruler hovering controller */
+ // private AbstractHoverInformationControlManager fOverviewRulerHoveringController;
+ //
+ // private boolean fIgnoreTextConverters = false;
+ //
+ // private IVerticalRuler fCachedVerticalRuler;
+ // private boolean fCachedIsVerticalRulerVisible;
+ //
+ // public AdaptedSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
+ // super(parent, ruler, styles); //, CompilationUnitEditor.this);
+ //
+ // fCachedVerticalRuler = ruler;
+ // fCachedIsVerticalRulerVisible = (ruler != null);
+ // fOverviewRuler = new OverviewRuler(VERTICAL_RULER_WIDTH);
+ //
+ // delayedCreateControl(parent, styles);
+ // }
+ //
+ // /*
+ // * @see ISourceViewer#showAnnotations(boolean)
+ // */
+ // public void showAnnotations(boolean show) {
+ // fCachedIsVerticalRulerVisible = (show && fCachedVerticalRuler != null);
+ // // super.showAnnotations(show);
+ // }
+ //
+ // public IContentAssistant getContentAssistant() {
+ // return fContentAssistant;
+ // }
+ //
+ // /*
+ // * @see ITextOperationTarget#doOperation(int)
+ // */
+ // public void doOperation(int operation) {
+ //
+ // if (getTextWidget() == null)
+ // return;
+ //
+ // switch (operation) {
+ // case CONTENTASSIST_PROPOSALS :
+ // String msg = fContentAssistant.showPossibleCompletions();
+ // setStatusLineErrorMessage(msg);
+ // return;
+ // case UNDO :
+ // fIgnoreTextConverters = true;
+ // break;
+ // case REDO :
+ // fIgnoreTextConverters = true;
+ // break;
+ // }
+ //
+ // super.doOperation(operation);
+ // }
+ //
+ // public void insertTextConverter(ITextConverter textConverter, int index) {
+ // throw new UnsupportedOperationException();
+ // }
+ //
+ // public void addTextConverter(ITextConverter textConverter) {
+ // if (fTextConverters == null) {
+ // fTextConverters = new ArrayList(1);
+ // fTextConverters.add(textConverter);
+ // } else if (!fTextConverters.contains(textConverter))
+ // fTextConverters.add(textConverter);
+ // }
+ //
+ // public void removeTextConverter(ITextConverter textConverter) {
+ // if (fTextConverters != null) {
+ // fTextConverters.remove(textConverter);
+ // if (fTextConverters.size() == 0)
+ // fTextConverters = null;
+ // }
+ // }
+ //
+ // /*
+ // * @see TextViewer#customizeDocumentCommand(DocumentCommand)
+ // */
+ // protected void customizeDocumentCommand(DocumentCommand command) {
+ // super.customizeDocumentCommand(command);
+ // if (!fIgnoreTextConverters && fTextConverters != null) {
+ // for (Iterator e = fTextConverters.iterator(); e.hasNext();)
+ // ((ITextConverter) e.next()).customizeDocumentCommand(getDocument(), command);
+ // }
+ // fIgnoreTextConverters = false;
+ // }
+ //
+ // public IVerticalRuler getVerticalRuler() {
+ // return fCachedVerticalRuler;
+ // }
+ //
+ // public boolean isVerticalRulerVisible() {
+ // return fCachedIsVerticalRulerVisible;
+ // }
+ //
+ // public OverviewRuler getOverviewRuler() {
+ // return fOverviewRuler;
+ // }
+ //
+ // /*
+ // * @see TextViewer#createControl(Composite, int)
+ // */
+ // protected void createControl(Composite parent, int styles) {
+ // // do nothing here
+ // }
+ //
+ // protected void delayedCreateControl(Composite parent, int styles) {
+ // //create the viewer
+ // super.createControl(parent, styles);
+ //
+ // Control control = getControl();
+ // if (control instanceof Composite) {
+ // Composite composite = (Composite) control;
+ // composite.setLayout(new AdaptedRulerLayout(GAP_SIZE, this));
+ // fOverviewRuler.createControl(composite, this);
+ // }
+ // }
+
+ // protected void ensureOverviewHoverManagerInstalled() {
+ // if (fOverviewRulerHoveringController == null && fAnnotationHover != null && fHoverControlCreator != null) {
+ // fOverviewRulerHoveringController =
+ // new OverviewRulerHoverManager(fOverviewRuler, this, fAnnotationHover, fHoverControlCreator);
+ // fOverviewRulerHoveringController.install(fOverviewRuler.getControl());
+ // }
+ // }
+ //
+ // public void hideOverviewRuler() {
+ // fIsOverviewRulerVisible = false;
+ // Control control = getControl();
+ // if (control instanceof Composite) {
+ // Composite composite = (Composite) control;
+ // composite.layout();
+ // }
+ // if (fOverviewRulerHoveringController != null) {
+ // fOverviewRulerHoveringController.dispose();
+ // fOverviewRulerHoveringController = null;
+ // }
+ // }
+ //
+ // public void showOverviewRuler() {
+ // fIsOverviewRulerVisible = true;
+ // Control control = getControl();
+ // if (control instanceof Composite) {
+ // Composite composite = (Composite) control;
+ // composite.layout();
+ // }
+ // ensureOverviewHoverManagerInstalled();
+ // }
+ //
+ // public boolean isOverviewRulerVisible() {
+ // return fIsOverviewRulerVisible;
+ // }
+ //
+ // /*
+ // * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int)
+ // */
+ // public void setDocument(
+ // IDocument document,
+ // IAnnotationModel annotationModel,
+ // int visibleRegionOffset,
+ // int visibleRegionLength) {
+ // super.setDocument(document, annotationModel, visibleRegionOffset, visibleRegionLength);
+ // fOverviewRuler.setModel(annotationModel);
+ // }
+ //
+ // // http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
+ // public void updateIndentationPrefixes() {
+ // SourceViewerConfiguration configuration = getSourceViewerConfiguration();
+ // String[] types = configuration.getConfiguredContentTypes(this);
+ // for (int i = 0; i < types.length; i++) {
+ // String[] prefixes = configuration.getIndentPrefixes(this, types[i]);
+ // if (prefixes != null && prefixes.length > 0)
+ // setIndentPrefixes(prefixes, types[i]);
+ // }
+ // }
+ //
+ // /*
+ // * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
+ // */
+ // public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
+ // if (WorkbenchHelp.isContextHelpDisplayed())
+ // return false;
+ // return super.requestWidgetToken(requester);
+ // }
+ //
+ // /*
+ // * @see org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
+ // */
+ // public void configure(SourceViewerConfiguration configuration) {
+ // super.configure(configuration);
+ // // prependAutoEditStrategy(new SmartBracesAutoEditStrategy(this), IDocument.DEFAULT_CONTENT_TYPE);
+ // }
+ //
+ // protected void handleDispose() {
+ // fOverviewRuler = null;
+ //
+ // if (fOverviewRulerHoveringController != null) {
+ // fOverviewRulerHoveringController.dispose();
+ // fOverviewRulerHoveringController = null;
+ // }
+ //
+ // super.handleDispose();
+ // }
+ //
+ // };
+
+ class AdaptedSourceViewer extends SourceViewer {
private List fTextConverters;
-
- private OverviewRuler fOverviewRuler;
- private boolean fIsOverviewRulerVisible;
- /** The viewer's overview ruler hovering controller */
- private AbstractHoverInformationControlManager fOverviewRulerHoveringController;
-
private boolean fIgnoreTextConverters = false;
+ // private JavaCorrectionAssistant fCorrectionAssistant;
- private IVerticalRuler fCachedVerticalRuler;
- private boolean fCachedIsVerticalRulerVisible;
-
- public AdaptedSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
- super(parent, ruler, styles); //, CompilationUnitEditor.this);
-
- fCachedVerticalRuler = ruler;
- fCachedIsVerticalRulerVisible = (ruler != null);
- fOverviewRuler = new OverviewRuler(VERTICAL_RULER_WIDTH);
-
- delayedCreateControl(parent, styles);
- }
-
- /*
- * @see ISourceViewer#showAnnotations(boolean)
- */
- public void showAnnotations(boolean show) {
- fCachedIsVerticalRulerVisible = (show && fCachedVerticalRuler != null);
- // super.showAnnotations(show);
+ public AdaptedSourceViewer(
+ Composite parent,
+ IVerticalRuler verticalRuler,
+ IOverviewRuler overviewRuler,
+ boolean showAnnotationsOverview,
+ int styles) {
+ super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);
}
public IContentAssistant getContentAssistant() {
String msg = fContentAssistant.showPossibleCompletions();
setStatusLineErrorMessage(msg);
return;
+ // case CORRECTIONASSIST_PROPOSALS:
+ // fCorrectionAssistant.showPossibleCompletions();
+ // return;
case UNDO :
fIgnoreTextConverters = true;
break;
super.doOperation(operation);
}
+ /*
+ * @see ITextOperationTarget#canDoOperation(int)
+ */
+ public boolean canDoOperation(int operation) {
+ // if (operation == CORRECTIONASSIST_PROPOSALS)
+ // return isEditable();
+ return super.canDoOperation(operation);
+ }
+
+ /*
+ * @see TextViewer#handleDispose()
+ */
+ protected void handleDispose() {
+ // if (fCorrectionAssistant != null) {
+ // fCorrectionAssistant.uninstall();
+ // fCorrectionAssistant= null;
+ // }
+ super.handleDispose();
+ }
+
public void insertTextConverter(ITextConverter textConverter, int index) {
throw new UnsupportedOperationException();
}
fIgnoreTextConverters = false;
}
- public IVerticalRuler getVerticalRuler() {
- return fCachedVerticalRuler;
- }
-
- public boolean isVerticalRulerVisible() {
- return fCachedIsVerticalRulerVisible;
- }
-
- public OverviewRuler getOverviewRuler() {
- return fOverviewRuler;
- }
-
- /*
- * @see TextViewer#createControl(Composite, int)
- */
- protected void createControl(Composite parent, int styles) {
- // do nothing here
- }
-
- protected void delayedCreateControl(Composite parent, int styles) {
- //create the viewer
- super.createControl(parent, styles);
-
- Control control = getControl();
- if (control instanceof Composite) {
- Composite composite = (Composite) control;
- composite.setLayout(new AdaptedRulerLayout(GAP_SIZE, this));
- fOverviewRuler.createControl(composite, this);
- }
- }
-
- protected void ensureOverviewHoverManagerInstalled() {
- if (fOverviewRulerHoveringController == null && fAnnotationHover != null && fHoverControlCreator != null) {
- fOverviewRulerHoveringController =
- new OverviewRulerHoverManager(fOverviewRuler, this, fAnnotationHover, fHoverControlCreator);
- fOverviewRulerHoveringController.install(fOverviewRuler.getControl());
- }
- }
-
- public void hideOverviewRuler() {
- fIsOverviewRulerVisible = false;
- Control control = getControl();
- if (control instanceof Composite) {
- Composite composite = (Composite) control;
- composite.layout();
- }
- if (fOverviewRulerHoveringController != null) {
- fOverviewRulerHoveringController.dispose();
- fOverviewRulerHoveringController = null;
- }
- }
-
- public void showOverviewRuler() {
- fIsOverviewRulerVisible = true;
- Control control = getControl();
- if (control instanceof Composite) {
- Composite composite = (Composite) control;
- composite.layout();
- }
- ensureOverviewHoverManagerInstalled();
- }
-
- public boolean isOverviewRulerVisible() {
- return fIsOverviewRulerVisible;
- }
-
- /*
- * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int)
- */
- public void setDocument(
- IDocument document,
- IAnnotationModel annotationModel,
- int visibleRegionOffset,
- int visibleRegionLength) {
- super.setDocument(document, annotationModel, visibleRegionOffset, visibleRegionLength);
- fOverviewRuler.setModel(annotationModel);
- }
-
// http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
public void updateIndentationPrefixes() {
SourceViewerConfiguration configuration = getSourceViewerConfiguration();
*/
public void configure(SourceViewerConfiguration configuration) {
super.configure(configuration);
- // prependAutoEditStrategy(new SmartBracesAutoEditStrategy(this), IDocument.DEFAULT_CONTENT_TYPE);
- }
-
- protected void handleDispose() {
- fOverviewRuler = null;
-
- if (fOverviewRulerHoveringController != null) {
- fOverviewRulerHoveringController.dispose();
- fOverviewRulerHoveringController = null;
- }
-
- super.handleDispose();
+ // fCorrectionAssistant= new JavaCorrectionAssistant(CompilationUnitEditor.this);
+ // fCorrectionAssistant.install(this);
+ //TODO install SmartBracesAutoEditStrategy
+ // prependAutoEditStrategy(new SmartBracesAutoEditStrategy(this), IDocument.DEFAULT_CONTENT_TYPE);
}
-
};
-
static class TabConverter implements ITextConverter {
private int fTabRatio;
}
}
+
+ // private static class BracketLevel {
+ // int fOffset;
+ // int fLength;
+ // LinkedPositionManager fManager;
+ // LinkedPositionUI fEditor;
+ // };
+
private class BracketInserter implements VerifyKeyListener, LinkedPositionUI.ExitListener {
private boolean fCloseBracketsPHP = true;
}
/** The editor's paint manager */
- private PaintManager fPaintManager;
+ // private PaintManager fPaintManager;
/** The editor's bracket painter */
private BracketPainter fBracketPainter;
/** The editor's bracket matcher */
/** The editor's print margin ruler painter */
private PrintMarginPainter fPrintMarginPainter;
/** The editor's problem painter */
- private ProblemPainter fProblemPainter;
+ // private ProblemPainter fProblemPainter;
/** The editor's tab converter */
private TabConverter fTabConverter;
/** History for structure select action */
//private SelectionHistory fSelectionHistory;
/** The preference property change listener for php core. */
- private IPropertyChangeListener fPropertyChangeListener = new PropertyChangeListener();
+ // private IPropertyChangeListener fPropertyChangeListener = new PropertyChangeListener();
/** The remembered selection */
private ITextSelection fRememberedSelection;
/** The remembered php element offset */
/** The bracket inserter. */
private BracketInserter fBracketInserter = new BracketInserter();
- private class PropertyChangeListener implements IPropertyChangeListener {
- /*
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
- handlePreferencePropertyChanged(event);
- }
- }
+ // private class PropertyChangeListener implements IPropertyChangeListener {
+ // /*
+ // * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+ // */
+ // public void propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
+ // handlePreferencePropertyChanged(event);
+ // }
+ // }
/* Preference key for code formatter tab size */
private final static String CODE_FORMATTER_TAB_SIZE = PHPCore.FORMATTER_TAB_SIZE;
/** Preference key for matching brackets */
/** Preference key for smart paste */
private final static String SMART_PASTE = PreferenceConstants.EDITOR_SMART_PASTE;
- private final static class AnnotationInfo {
- public String fColorPreference;
- public String fOverviewRulerPreference;
- public String fEditorPreference;
- };
-
- private final static Map ANNOTATION_MAP;
- static {
-
- AnnotationInfo info;
- ANNOTATION_MAP = new HashMap();
-
- info = new AnnotationInfo();
- info.fColorPreference = TASK_INDICATION_COLOR;
- info.fOverviewRulerPreference = TASK_INDICATION_IN_OVERVIEW_RULER;
- info.fEditorPreference = TASK_INDICATION;
- ANNOTATION_MAP.put(AnnotationType.TASK, info);
-
- info = new AnnotationInfo();
- info.fColorPreference = ERROR_INDICATION_COLOR;
- info.fOverviewRulerPreference = ERROR_INDICATION_IN_OVERVIEW_RULER;
- info.fEditorPreference = ERROR_INDICATION;
- ANNOTATION_MAP.put(AnnotationType.ERROR, info);
-
- info = new AnnotationInfo();
- info.fColorPreference = WARNING_INDICATION_COLOR;
- info.fOverviewRulerPreference = WARNING_INDICATION_IN_OVERVIEW_RULER;
- info.fEditorPreference = WARNING_INDICATION;
- ANNOTATION_MAP.put(AnnotationType.WARNING, info);
-
- info = new AnnotationInfo();
- info.fColorPreference = BOOKMARK_INDICATION_COLOR;
- info.fOverviewRulerPreference = BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
- info.fEditorPreference = BOOKMARK_INDICATION;
- ANNOTATION_MAP.put(AnnotationType.BOOKMARK, info);
-
- info = new AnnotationInfo();
- info.fColorPreference = SEARCH_RESULT_INDICATION_COLOR;
- info.fOverviewRulerPreference = SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
- info.fEditorPreference = SEARCH_RESULT_INDICATION;
- ANNOTATION_MAP.put(AnnotationType.SEARCH_RESULT, info);
-
- info = new AnnotationInfo();
- info.fColorPreference = UNKNOWN_INDICATION_COLOR;
- info.fOverviewRulerPreference = UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
- info.fEditorPreference = UNKNOWN_INDICATION;
- ANNOTATION_MAP.put(AnnotationType.UNKNOWN, info);
- };
-
- private final static AnnotationType[] ANNOTATION_LAYERS =
- new AnnotationType[] {
- AnnotationType.UNKNOWN,
- AnnotationType.BOOKMARK,
- AnnotationType.TASK,
- AnnotationType.SEARCH_RESULT,
- AnnotationType.WARNING,
- AnnotationType.ERROR };
+ // private final static class AnnotationInfo {
+ // public String fColorPreference;
+ // public String fOverviewRulerPreference;
+ // public String fEditorPreference;
+ // };
+
+ // private final static Map ANNOTATION_MAP;
+ // static {
+ //
+ // AnnotationInfo info;
+ // ANNOTATION_MAP = new HashMap();
+ //
+ // info = new AnnotationInfo();
+ // info.fColorPreference = TASK_INDICATION_COLOR;
+ // info.fOverviewRulerPreference = TASK_INDICATION_IN_OVERVIEW_RULER;
+ // info.fEditorPreference = TASK_INDICATION;
+ // ANNOTATION_MAP.put(AnnotationType.TASK, info);
+ //
+ // info = new AnnotationInfo();
+ // info.fColorPreference = ERROR_INDICATION_COLOR;
+ // info.fOverviewRulerPreference = ERROR_INDICATION_IN_OVERVIEW_RULER;
+ // info.fEditorPreference = ERROR_INDICATION;
+ // ANNOTATION_MAP.put(AnnotationType.ERROR, info);
+ //
+ // info = new AnnotationInfo();
+ // info.fColorPreference = WARNING_INDICATION_COLOR;
+ // info.fOverviewRulerPreference = WARNING_INDICATION_IN_OVERVIEW_RULER;
+ // info.fEditorPreference = WARNING_INDICATION;
+ // ANNOTATION_MAP.put(AnnotationType.WARNING, info);
+ //
+ // info = new AnnotationInfo();
+ // info.fColorPreference = BOOKMARK_INDICATION_COLOR;
+ // info.fOverviewRulerPreference = BOOKMARK_INDICATION_IN_OVERVIEW_RULER;
+ // info.fEditorPreference = BOOKMARK_INDICATION;
+ // ANNOTATION_MAP.put(AnnotationType.BOOKMARK, info);
+ //
+ // info = new AnnotationInfo();
+ // info.fColorPreference = SEARCH_RESULT_INDICATION_COLOR;
+ // info.fOverviewRulerPreference = SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER;
+ // info.fEditorPreference = SEARCH_RESULT_INDICATION;
+ // ANNOTATION_MAP.put(AnnotationType.SEARCH, info);
+ //
+ // info = new AnnotationInfo();
+ // info.fColorPreference = UNKNOWN_INDICATION_COLOR;
+ // info.fOverviewRulerPreference = UNKNOWN_INDICATION_IN_OVERVIEW_RULER;
+ // info.fEditorPreference = UNKNOWN_INDICATION;
+ // ANNOTATION_MAP.put(AnnotationType.UNKNOWN, info);
+ // };
+ //
+ // private final static AnnotationType[] ANNOTATION_LAYERS =
+ // new AnnotationType[] {
+ // AnnotationType.UNKNOWN,
+ // AnnotationType.BOOKMARK,
+ // AnnotationType.TASK,
+ // AnnotationType.SEARCH,
+ // AnnotationType.WARNING,
+ // AnnotationType.ERROR };
/**
* Creates a new php unit editor.
*/
public void createPartControl(Composite parent) {
super.createPartControl(parent);
- fPaintManager = new PaintManager(getSourceViewer());
+ // fPaintManager = new PaintManager(getSourceViewer());
LinePainter linePainter;
linePainter = new LinePainter(getSourceViewer());
linePainter.setHighlightColor(new Color(Display.getCurrent(), 225, 235, 224));
- fPaintManager.addPainter(linePainter);
+ // fPaintManager.addPainter(linePainter);
if (isBracketHighlightingEnabled())
startBracketHighlighting();
if (isPrintMarginVisible())
showPrintMargin();
- Iterator e = ANNOTATION_MAP.keySet().iterator();
- while (e.hasNext()) {
- AnnotationType type = (AnnotationType) e.next();
- if (isAnnotationIndicationEnabled(type))
- startAnnotationIndication(type);
- }
+ // Iterator e = ANNOTATION_MAP.keySet().iterator();
+ // while (e.hasNext()) {
+ // AnnotationType type = (AnnotationType) e.next();
+ // if (isAnnotationIndicationEnabled(type))
+ // startAnnotationIndication(type);
+ // }
if (isTabConversionEnabled())
startTabConversion();
- if (isOverviewRulerVisible())
- showOverviewRuler();
-
- Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
- preferences.addPropertyChangeListener(fPropertyChangeListener);
+ // if (isOverviewRulerVisible())
+ // showOverviewRuler();
+ //
+ // Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
+ // preferences.addPropertyChangeListener(fPropertyChangeListener);
IPreferenceStore preferenceStore = getPreferenceStore();
boolean closeBracketsPHP = preferenceStore.getBoolean(CLOSE_BRACKETS_PHP);
ISourceViewer sourceViewer = getSourceViewer();
fBracketPainter = new BracketPainter(sourceViewer);
fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
- fPaintManager.addPainter(fBracketPainter);
+ // fPaintManager.addPainter(fBracketPainter);
}
}
private void stopBracketHighlighting() {
if (fBracketPainter != null) {
- fPaintManager.removePainter(fBracketPainter);
+ // fPaintManager.removePainter(fBracketPainter);
fBracketPainter.deactivate(true);
fBracketPainter.dispose();
fBracketPainter = null;
ISourceViewer sourceViewer = getSourceViewer();
fLinePainter = new LinePainter(sourceViewer);
fLinePainter.setHighlightColor(getColor(CURRENT_LINE_COLOR));
- fPaintManager.addPainter(fLinePainter);
+ // fPaintManager.addPainter(fLinePainter);
}
}
private void stopLineHighlighting() {
if (fLinePainter != null) {
- fPaintManager.removePainter(fLinePainter);
+ // fPaintManager.removePainter(fLinePainter);
fLinePainter.deactivate(true);
fLinePainter.dispose();
fLinePainter = null;
fPrintMarginPainter = new PrintMarginPainter(getSourceViewer());
fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
- fPaintManager.addPainter(fPrintMarginPainter);
+ // fPaintManager.addPainter(fPrintMarginPainter);
}
}
private void hidePrintMargin() {
if (fPrintMarginPainter != null) {
- fPaintManager.removePainter(fPrintMarginPainter);
+ // fPaintManager.removePainter(fPrintMarginPainter);
fPrintMarginPainter.deactivate(true);
fPrintMarginPainter.dispose();
fPrintMarginPainter = null;
return store.getBoolean(PRINT_MARGIN);
}
- private void startAnnotationIndication(AnnotationType annotationType) {
- if (fProblemPainter == null) {
- fProblemPainter = new ProblemPainter(this, getSourceViewer());
- fPaintManager.addPainter(fProblemPainter);
- }
- 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 stopAnnotationIndication(AnnotationType annotationType) {
- if (fProblemPainter != null) {
- fProblemPainter.paintAnnotations(annotationType, false);
- shutdownAnnotationIndication();
- }
- }
-
- 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 boolean isAnnotationIndicationInOverviewRulerEnabled(AnnotationType annotationType) {
- IPreferenceStore store = getPreferenceStore();
- AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(annotationType);
- if (info != null)
- return store.getBoolean(info.fOverviewRulerPreference);
- return false;
- }
-
- 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 setColorInOverviewRuler(AnnotationType annotationType, Color color) {
- AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
- OverviewRuler ruler = asv.getOverviewRuler();
- if (ruler != null) {
- ruler.setColor(annotationType, color);
- ruler.update();
- }
- }
+ // private void startAnnotationIndication(AnnotationType annotationType) {
+ // if (fProblemPainter == null) {
+ // fProblemPainter = new ProblemPainter(this, getSourceViewer());
+ //// fPaintManager.addPainter(fProblemPainter);
+ // }
+ // 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 stopAnnotationIndication(AnnotationType annotationType) {
+ // if (fProblemPainter != null) {
+ // fProblemPainter.paintAnnotations(annotationType, false);
+ // shutdownAnnotationIndication();
+ // }
+ // }
+ //
+ // 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 boolean isAnnotationIndicationInOverviewRulerEnabled(AnnotationType annotationType) {
+ // IPreferenceStore store = getPreferenceStore();
+ // AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(annotationType);
+ // if (info != null)
+ // return store.getBoolean(info.fOverviewRulerPreference);
+ // return false;
+ // }
+ //
+ // 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 setColorInOverviewRuler(AnnotationType annotationType, Color color) {
+ // AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+ // OverviewRuler ruler = asv.getOverviewRuler();
+ // if (ruler != null) {
+ // ruler.setColor(annotationType, color);
+ // ruler.update();
+ // }
+ // }
private void configureTabConverter() {
if (fTabConverter != null) {
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 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 textTools.getColorManager().getColor(rgb);
}
- private Color getColor(AnnotationType annotationType) {
- AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(annotationType);
- if (info != null)
- return getColor(info.fColorPreference);
- return null;
- }
+ // private Color getColor(AnnotationType annotationType) {
+ // AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(annotationType);
+ // if (info != null)
+ // return getColor(info.fColorPreference);
+ // return null;
+ // }
public void dispose() {
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer instanceof ITextViewerExtension)
((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter);
- if (fPropertyChangeListener != null) {
- Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
- preferences.removePropertyChangeListener(fPropertyChangeListener);
- fPropertyChangeListener = null;
- }
+ // if (fPropertyChangeListener != null) {
+ // Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
+ // preferences.removePropertyChangeListener(fPropertyChangeListener);
+ // fPropertyChangeListener = null;
+ // }
// if (fJavaEditorErrorTickUpdater != null) {
// fJavaEditorErrorTickUpdater.dispose();
// if (fSelectionHistory != null)
// fSelectionHistory.dispose();
- if (fPaintManager != null) {
- fPaintManager.dispose();
- fPaintManager = null;
- }
+ // if (fPaintManager != null) {
+ // fPaintManager.dispose();
+ // fPaintManager = null;
+ // }
- if (fActionGroups != null)
+ if (fActionGroups != null) {
fActionGroups.dispose();
+ fActionGroups = null;
+ }
super.dispose();
}
- protected AnnotationType getAnnotationType(String preferenceKey) {
- Iterator e = ANNOTATION_MAP.keySet().iterator();
- while (e.hasNext()) {
- AnnotationType type = (AnnotationType) e.next();
- AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(type);
- if (info != null) {
- if (preferenceKey.equals(info.fColorPreference)
- || preferenceKey.equals(info.fEditorPreference)
- || preferenceKey.equals(info.fOverviewRulerPreference))
- return type;
- }
- }
- return null;
- }
+ // protected AnnotationType getAnnotationType(String preferenceKey) {
+ // Iterator e = ANNOTATION_MAP.keySet().iterator();
+ // while (e.hasNext()) {
+ // AnnotationType type = (AnnotationType) e.next();
+ // AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(type);
+ // if (info != null) {
+ // if (preferenceKey.equals(info.fColorPreference)
+ // || preferenceKey.equals(info.fEditorPreference)
+ // || preferenceKey.equals(info.fOverviewRulerPreference))
+ // return type;
+ // }
+ // }
+ // return null;
+ // }
/*
* @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent)
return;
}
- AnnotationType type = getAnnotationType(p);
- if (type != null) {
-
- AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(type);
- if (info.fColorPreference.equals(p)) {
- Color color = getColor(type);
- if (fProblemPainter != null) {
- fProblemPainter.setColor(type, color);
- fProblemPainter.paint(IPainter.CONFIGURATION);
- }
- setColorInOverviewRuler(type, color);
- return;
- }
-
- if (info.fEditorPreference.equals(p)) {
- if (isAnnotationIndicationEnabled(type))
- startAnnotationIndication(type);
- else
- stopAnnotationIndication(type);
- return;
- }
-
- if (info.fOverviewRulerPreference.equals(p)) {
- if (isAnnotationIndicationInOverviewRulerEnabled(type))
- showAnnotationIndicationInOverviewRuler(type, true);
- else
- showAnnotationIndicationInOverviewRuler(type, false);
- return;
- }
- }
+ // AnnotationType type = getAnnotationType(p);
+ // if (type != null) {
+ //
+ // AnnotationInfo info = (AnnotationInfo) ANNOTATION_MAP.get(type);
+ // if (info.fColorPreference.equals(p)) {
+ // Color color = getColor(type);
+ // if (fProblemPainter != null) {
+ // fProblemPainter.setColor(type, color);
+ // fProblemPainter.paint(IPainter.CONFIGURATION);
+ // }
+ // setColorInOverviewRuler(type, color);
+ // return;
+ // }
+ //
+ // if (info.fEditorPreference.equals(p)) {
+ // if (isAnnotationIndicationEnabled(type))
+ // startAnnotationIndication(type);
+ // else
+ // stopAnnotationIndication(type);
+ // return;
+ // }
+ //
+ // if (info.fOverviewRulerPreference.equals(p)) {
+ // if (isAnnotationIndicationInOverviewRulerEnabled(type))
+ // showAnnotationIndicationInOverviewRuler(type, true);
+ // else
+ // showAnnotationIndicationInOverviewRuler(type, false);
+ // return;
+ // }
+ // }
IContentAssistant c = asv.getContentAssistant();
if (c instanceof ContentAssistant)
}
}
- /**
- * 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
- */
+ /*
+ * @see org.eclipse.jdt.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();
if (asv != null) {
fTabConverter.setNumberOfSpacesPerTab(getTabSize());
}
}
+ super.handlePreferencePropertyChanged(event);
}
+ /**
+ * 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
+ */
+ // protected void handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
+ // AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+ // if (asv != null) {
+ // String p = event.getProperty();
+ // if (CODE_FORMATTER_TAB_SIZE.equals(p)) {
+ // asv.updateIndentationPrefixes();
+ // if (fTabConverter != null)
+ // fTabConverter.setNumberOfSpacesPerTab(getTabSize());
+ // }
+ // }
+ // }
+
/*
* @see PHPEditor#createJavaSourceViewer(Composite, IVerticalRuler, int)
*/
- protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
- return new AdaptedSourceViewer(parent, ruler, styles);
+ protected ISourceViewer createJavaSourceViewer(
+ Composite parent,
+ IVerticalRuler verticalRuler,
+ IOverviewRuler overviewRuler,
+ boolean isOverviewRulerVisible,
+ int styles) {
+ return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler, isOverviewRulerVisible, styles);
}
+ // protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
+ // return new AdaptedSourceViewer(parent, ruler, styles);
+ // }
private boolean isValidSelection(int offset, int length) {
IDocumentProvider provider = getDocumentProvider();
return oldExtension.equals(newExtension);
}
-
- /*
- * @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager)
- */
- public void editorContextMenuAboutToShow(IMenuManager menu) {
- super.editorContextMenuAboutToShow(menu);
-
- ActionContext context= new ActionContext(getSelectionProvider().getSelection());
- fContextMenuGroup.setContext(context);
- fContextMenuGroup.fillContextMenu(menu);
- fContextMenuGroup.setContext(null);
- }
+
+ /*
+ * @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager)
+ */
+ public void editorContextMenuAboutToShow(IMenuManager menu) {
+ super.editorContextMenuAboutToShow(menu);
+
+ ActionContext context = new ActionContext(getSelectionProvider().getSelection());
+ fContextMenuGroup.setContext(context);
+ fContextMenuGroup.fillContextMenu(menu);
+ fContextMenuGroup.setContext(null);
+ }
+
+ /*
+ * @see AbstractTextEditor#doSaveAs
+ */
+ public void doSaveAs() {
+ if (askIfNonWorkbenchEncodingIsOk()) {
+ super.doSaveAs();
+ }
+ }
+
+ /*
+ * @see AbstractTextEditor#doSave(IProgressMonitor)
+ */
+ public void doSave(IProgressMonitor progressMonitor) {
+
+ IDocumentProvider p = getDocumentProvider();
+ if (p == null) {
+ // editor has been closed
+ return;
+ }
+
+ if (!askIfNonWorkbenchEncodingIsOk()) {
+ progressMonitor.setCanceled(true);
+ return;
+ }
+
+ if (p.isDeleted(getEditorInput())) {
+
+ if (isSaveAsAllowed()) {
+
+ /*
+ * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors.
+ * Changed Behavior to make sure that if called inside a regular save (because
+ * of deletion of input element) there is a way to report back to the caller.
+ */
+ // performSaveAs(progressMonitor);
+ super.doSave(progressMonitor);
+ } else {
+
+ /*
+ * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there
+ * Missing resources.
+ */
+ Shell shell = getSite().getShell();
+ MessageDialog.openError(shell, PHPEditorMessages.getString("PHPUnitEditor.error.saving.title1"), PHPEditorMessages.getString("PHPUnitEditor.error.saving.message1")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ } else {
+
+ setStatusLineErrorMessage(null);
+ super.doSave(progressMonitor);
+
+ // IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
+ // ICompilationUnit unit= manager.getWorkingCopy(getEditorInput());
+ //
+ // if (unit != null) {
+ // synchronized (unit) {
+ // performSaveOperation(createSaveOperation(false), progressMonitor);
+ // }
+ // } else
+ // performSaveOperation(createSaveOperation(false), progressMonitor);
+ }
+ }
+ /**
+ * Asks the user if it is ok to store in non-workbench encoding.
+ * @return <true> if the user wants to continue
+ */
+ private boolean askIfNonWorkbenchEncodingIsOk() {
+ IDocumentProvider provider = getDocumentProvider();
+ if (provider instanceof IStorageDocumentProvider) {
+ IEditorInput input = getEditorInput();
+ IStorageDocumentProvider storageProvider = (IStorageDocumentProvider) provider;
+ String encoding = storageProvider.getEncoding(input);
+ String defaultEncoding = storageProvider.getDefaultEncoding();
+ if (encoding != null && !encoding.equals(defaultEncoding)) {
+ Shell shell = getSite().getShell();
+ String title = PHPEditorMessages.getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.title"); //$NON-NLS-1$
+ String msg;
+ if (input != null)
+ msg = MessageFormat.format(PHPEditorMessages.getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message1"), new String[] { input.getName(), encoding }); //$NON-NLS-1$
+ else
+ msg = MessageFormat.format(PHPEditorMessages.getString("PHPUnitEditor.warning.save.nonWorkbenchEncoding.message2"), new String[] { encoding }); //$NON-NLS-1$
+ return MessageDialog.openQuestion(shell, title, msg);
+ }
+ }
+ return true;
+ }
}