First submit for debug plugin
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPActionContributor.java
index 5fa5d64..66656e2 100644 (file)
@@ -21,6 +21,7 @@ import net.sourceforge.phpdt.ui.actions.GotoMatchingBracketAction;
 import net.sourceforge.phpdt.ui.actions.PHPdtActionConstants;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
+import org.eclipse.core.resources.IFile;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.IToolBarManager;
@@ -28,7 +29,9 @@ import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.swt.SWT;
 import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
 import org.eclipse.ui.IWorkbenchActionConstants;
 import org.eclipse.ui.actions.ActionGroup;
 import org.eclipse.ui.actions.RetargetAction;
@@ -78,7 +81,7 @@ public class PHPActionContributor extends BasicTextEditorActionContributor {
     //  fTogglePresentation = new PresentationAction();
 
     fParserAction = PHPParserAction.getInstance();
-   
+
     if (SWT.getPlatform().equals("win32")) {
       fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
     }
@@ -179,20 +182,30 @@ public class PHPActionContributor extends BasicTextEditorActionContributor {
     //    fTogglePresentation.setEditor(editor);
     //    fTogglePresentation.update();
 
-    PHPeclipsePlugin.getDefault().setTextEditor(textEditor);
-    fParserAction.setEditor(textEditor);
-    fParserAction.update();
-    if (SWT.getPlatform().equals("win32") &&
-        textEditor instanceof AbstractTextEditor) {
-      fShowExternalPreviewAction.setEditor(textEditor);
-      fShowExternalPreviewAction.update();
-      IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
-      if (store.getBoolean(PHPeclipsePlugin.SHOW_EXTERNAL_PREVIEW_PREF)) {
-        IAction a = ShowExternalPreviewAction.getInstance();
-        if (a != null)
-          a.run();
+    if (textEditor != null) {
+
+      IFile file = null;
+      IEditorInput editorInput = textEditor.getEditorInput();
+
+      if (editorInput instanceof IFileEditorInput) {
+        file = ((IFileEditorInput) editorInput).getFile();
+      }
+
+      PHPeclipsePlugin.getDefault().setLastEditorFile(file);
+      fParserAction.setEditor(textEditor);
+      fParserAction.update();
+      if (SWT.getPlatform().equals("win32") && textEditor instanceof AbstractTextEditor) {
+        fShowExternalPreviewAction.setEditor(textEditor);
+        fShowExternalPreviewAction.update();
+        IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
+        if (store.getBoolean(PHPeclipsePlugin.SHOW_EXTERNAL_PREVIEW_PREF)) {
+          IAction a = ShowExternalPreviewAction.getInstance();
+          if (a != null)
+            a.run();
+        }
       }
     }
+    
   }
 
   /*