first version of external tools
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPActionContributor.java
index 9cbd2c9..501813f 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;
@@ -50,8 +53,8 @@ public class PHPActionContributor extends BasicTextEditorActionContributor {
   private RetargetTextEditorAction fGotoMatchingBracket;
   private List fRetargetToolbarActions = new ArrayList();
 
-  protected PHPParserAction parserAction;
-  protected ShowExternalPreviewAction showExternalPreviewAction;
+  protected PHPParserAction fParserAction;
+  protected ShowExternalPreviewAction fShowExternalPreviewAction;
 
   /**
    * Default constructor.
@@ -77,9 +80,10 @@ public class PHPActionContributor extends BasicTextEditorActionContributor {
     //  fContentAssistTip = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$
     //  fTogglePresentation = new PresentationAction();
 
-    parserAction = PHPParserAction.getInstance();
+    fParserAction = PHPParserAction.getInstance();
+
     if (SWT.getPlatform().equals("win32")) {
-      showExternalPreviewAction = ShowExternalPreviewAction.getInstance();
+      fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
     }
   }
 
@@ -178,12 +182,19 @@ public class PHPActionContributor extends BasicTextEditorActionContributor {
     //    fTogglePresentation.setEditor(editor);
     //    fTogglePresentation.update();
 
-    parserAction.setEditor(textEditor);
-    parserAction.update();
-    if (SWT.getPlatform().equals("win32") &&
-        textEditor instanceof AbstractTextEditor) {
-      showExternalPreviewAction.setEditor(textEditor);
-      showExternalPreviewAction.update();
+    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();