Adding new code for feature save on unfocus. This is from ticket #542. It also adds...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPEditor.java
index 4eb14da..a3605cb 100644 (file)
@@ -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();
        }