Fixed "textEditor==null" bug
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPActionContributor.java
index 5a35c88..66656e2 100644 (file)
@@ -178,30 +178,34 @@ public class PHPActionContributor extends BasicTextEditorActionContributor {
       ActionGroup group = cuEditor.getActionGroup();
       if (group != null)
         group.fillActionBars(bars);
-    } 
+    }
     //    fTogglePresentation.setEditor(editor);
     //    fTogglePresentation.update();
 
-    IFile file = null;
-    IEditorInput editorInput = textEditor.getEditorInput();
+    if (textEditor != null) {
 
-    if (editorInput instanceof IFileEditorInput) {
-      file = ((IFileEditorInput) editorInput).getFile();
-    }
+      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();
+      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();
+        }
       }
     }
+    
   }
 
   /*