From: Edward Mann Date: Tue, 22 Jan 2008 16:41:28 +0000 (+0000) Subject: Adding new code for feature save on unfocus. This is from ticket #542. It also adds... X-Git-Url: http://git.phpeclipse.com Adding new code for feature save on unfocus. This is from ticket #542. It also adds new Editor page in the Preferences. Moved Remove trailing spaces on editor save from PHP-> Typing tab to Editor page. --- diff --git a/net.sourceforge.phpeclipse/plugin.properties b/net.sourceforge.phpeclipse/plugin.properties index 4d7c321..6e8cb8c 100644 --- a/net.sourceforge.phpeclipse/plugin.properties +++ b/net.sourceforge.phpeclipse/plugin.properties @@ -40,6 +40,7 @@ todoTaskPrefName= Task Tags templatePageName= Templates spellingPrefName= Spelling codeAssistPageName= Code Assist +editorPageName= Editor editorMarkOccurrencesPage= Mark Occurrences # diff --git a/net.sourceforge.phpeclipse/plugin.xml b/net.sourceforge.phpeclipse/plugin.xml index 1a3aee8..a433151 100644 --- a/net.sourceforge.phpeclipse/plugin.xml +++ b/net.sourceforge.phpeclipse/plugin.xml @@ -847,7 +847,12 @@ class="net.sourceforge.phpdt.internal.ui.preferences.CodeAssistPreferencePage" id="net.sourceforge.phpdt.internal.ui.preferences.CodeAssistPreferencePage"> - + + + * Value is of type Boolean. + *

+ * + * @since 3.0 + */ + public static final String EDITOR_SAVE_ON_BLUR = "save_on_blur"; //$NON-NLS-1$ + + /** * A named preference that controls the "smart semicolon" smart typing * handler *

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..a3605cb 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java @@ -61,7 +61,9 @@ 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.ui.IPreferenceConstants; import net.sourceforge.phpeclipse.ui.editor.BrowserUtil; +import net.sourceforge.phpeclipse.ui.overlaypages.ProjectPrefUtil; import net.sourceforge.phpeclipse.webbrowser.views.BrowserView; import org.eclipse.core.resources.IMarker; @@ -2370,7 +2372,7 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements } } - + /** * Finds the next position after the given position. * @@ -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(); }