X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java index 4eb14da..cc75aed 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java @@ -34,6 +34,7 @@ import net.sourceforge.phpdt.core.ISourceReference; import net.sourceforge.phpdt.core.JavaCore; import net.sourceforge.phpdt.core.JavaModelException; import net.sourceforge.phpdt.core.compiler.ITerminalSymbols; +import net.sourceforge.phpdt.core.compiler.ITerminalSymbols.TokenName; import net.sourceforge.phpdt.core.compiler.InvalidInputException; import net.sourceforge.phpdt.internal.compiler.parser.Scanner; import net.sourceforge.phpdt.internal.compiler.parser.SyntaxError; @@ -61,15 +62,19 @@ import net.sourceforge.phpdt.ui.text.JavaTextTools; import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration; import net.sourceforge.phpdt.ui.text.folding.IJavaFoldingStructureProvider; import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import net.sourceforge.phpeclipse.builder.ExternalEditorInput; import net.sourceforge.phpeclipse.ui.editor.BrowserUtil; import net.sourceforge.phpeclipse.webbrowser.views.BrowserView; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; @@ -124,7 +129,9 @@ import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.jface.text.source.projection.ProjectionSupport; import org.eclipse.jface.text.source.projection.ProjectionViewer; import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.ListenerList; +//incastrix +//import org.eclipse.jface.util.ListenerList; +import org.eclipse.core.runtime.ListenerList; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; @@ -176,6 +183,7 @@ import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.editors.text.DefaultEncodingSupport; import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.editors.text.IEncodingSupport; +import org.eclipse.ui.ide.FileStoreEditorInput; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.part.IShowInSource; import org.eclipse.ui.part.IShowInTargetList; @@ -2370,7 +2378,7 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements } } - + /** * Finds the next position after the given position. * @@ -3059,12 +3067,6 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements */ private boolean fStickyOccurrenceAnnotations; - /** Preference key for showing the line number ruler */ - // private final static String LINE_NUMBER_RULER = - // PreferenceConstants.EDITOR_LINE_NUMBER_RULER; - /** Preference key for the foreground color of the line numbers */ - // private final static String LINE_NUMBER_COLOR = - // PreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR; /** Preference key for the link color */ private final static String LINK_COLOR = PreferenceConstants.EDITOR_LINK_COLOR; @@ -3198,7 +3200,7 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements * Default constructor. */ public PHPEditor() { - super(); + super(); } /* @@ -3226,7 +3228,7 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools .getColorManager(), store, this, IPHPPartitions.PHP_PARTITIONING)); - + // TODO changed in 3.x ? // setRangeIndicator(new DefaultRangeIndicator()); // if @@ -3373,7 +3375,6 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements Preferences preferences = PHPeclipsePlugin.getDefault() .getPluginPreferences(); preferences.addPropertyChangeListener(fPropertyChangeListener); - IInformationControlCreator informationControlCreator = new IInformationControlCreator() { public IInformationControl createInformationControl(Shell parent) { boolean cutDown = false; @@ -3402,7 +3403,32 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements installOccurrencesFinder(); PlatformUI.getWorkbench().addWindowListener(fActivationListener); - + + /* + * start of EDITOR_SAVE_ON_BLUR + * ed_mann + */ + final PHPEditor editor = this; + FocusListener focusListener = new FocusListener() { + + public void focusGained(FocusEvent e) { + return; + } + + public void focusLost(FocusEvent e) { + //viewer.get + if(editor.isDirty() && PHPeclipsePlugin.getDefault().getPreferenceStore() + .getBoolean(PreferenceConstants.EDITOR_SAVE_ON_BLUR)){ + editor.doSave(null); + } + } + }; + projectionViewer.getTextWidget().addFocusListener(focusListener); + /* + * end of EDITOR_SAVE_ON_BLUR + * ed_mann + */ + setWordWrap(); } @@ -3566,7 +3592,7 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements protected void createActions() { super.createActions(); - ActionGroup oeg, ovg, jsg, sg; + ActionGroup oeg/*, ovg, jsg, sg*/; fActionGroups = new CompositeActionGroup( new ActionGroup[] { oeg = new OpenEditorActionGroup(this), // sg= new ShowActionGroup(this), @@ -5177,17 +5203,16 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements throws BadLocationException { IRegion line = document.getLineInformationOfOffset(lineOffset); - ITypedRegion[] linePartitioning = document.computePartitioning( - lineOffset, line.getLength()); + ITypedRegion[] linePartitioning = document.computePartitioning (lineOffset, line.getLength()); List segmentation = new ArrayList(); + for (int i = 0; i < linePartitioning.length; i++) { - if (IPHPPartitions.PHP_STRING_DQ.equals(linePartitioning[i] - .getType())) { - segmentation.add(linePartitioning[i]); - } else if (IPHPPartitions.PHP_STRING_HEREDOC - .equals(linePartitioning[i].getType())) { - segmentation.add(linePartitioning[i]); + if (IPHPPartitions.PHP_STRING_DQ.equals (linePartitioning[i].getType())) { + segmentation.add (linePartitioning[i]); + } + else if (IPHPPartitions.PHP_STRING_HEREDOC.equals (linePartitioning[i].getType())) { + segmentation.add (linePartitioning[i]); } } @@ -5577,9 +5602,9 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements * is true * @since 3.0 */ - private boolean getBoolean(IPreferenceStore store, String key) { - return key != null && store.getBoolean(key); - } +// private boolean getBoolean(IPreferenceStore store, String key) { +// return key != null && store.getBoolean(key); +// } protected boolean isPrefQuickDiffAlwaysOn() { return false; // never show change ruler for the non-editable java @@ -5848,13 +5873,25 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements } public ShowInContext getShowInContext() { - FileEditorInput fei = (FileEditorInput) getEditorInput(); - ShowInContext context = BrowserUtil.getShowInContext(fei.getFile(), + IFile file = null; + if(getEditorInput() instanceof FileStoreEditorInput){ + FileStoreEditorInput fei = (FileStoreEditorInput) getEditorInput(); + file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fei.getURI().getPath())); + } else if (getEditorInput() instanceof FileEditorInput) { + FileEditorInput fei = (FileEditorInput) getEditorInput(); + // added to fix ticket 637 + file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fei.getURI().getPath())); + } else if (getEditorInput() instanceof ExternalEditorInput) { + ExternalEditorInput fei = (ExternalEditorInput) getEditorInput(); + file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fei.getFullPath()/* .getURI().getPath()*/)); + } + + ShowInContext context = BrowserUtil.getShowInContext(file, false, ""); if (context != null) { return context; } - return new ShowInContext(fei.getFile(), null); + return new ShowInContext(file, null); } public String[] getShowInTargetIds() { @@ -5927,15 +5964,15 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements fMarkOccurrenceTargetRegion.getLength()); if (wordStr != null) { word = wordStr.toCharArray(); - int fToken = ITerminalSymbols.TokenNameEOF; + TokenName fToken = ITerminalSymbols.TokenName.EOF; try { fToken = fScanner.getNextToken(); - while (fToken != ITerminalSymbols.TokenNameEOF) { // && + while (fToken != ITerminalSymbols.TokenName.EOF) { // && // fToken // != - // TokenNameERROR) { - if (fToken == ITerminalSymbols.TokenNameVariable - || fToken == ITerminalSymbols.TokenNameIdentifier) { + // TokenName.ERROR) { + if (fToken == ITerminalSymbols.TokenName.VARIABLE + || fToken == ITerminalSymbols.TokenName.IDENTIFIER) { // global variable if (fScanner.equalsCurrentTokenSource(word)) { matches