Fixed: [Issue 139] Reopening Eclipse when active editor has a .proto
file outside workspace results in NPE.
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Resources.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Resources.java
index c350afb..472e1ee 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Resources.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/util/Resources.java
@@ -23,6 +23,7 @@
  *
  * @author alruiz@google.com (Alex Ruiz)
  */
+@SuppressWarnings("deprecation") 
 @Singleton
 public class Resources {
 
@@ -40,8 +41,7 @@
   }
 
   public IProject activeProject() {
-    IViewReference[] references = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
-    for (IViewReference reference : references) {
+    for (IViewReference reference : viewReferencesInActivePage()) {
       IViewPart part = reference.getView(false);
       if (!(part instanceof ResourceNavigator)) continue;
       ResourceNavigator navigator = (ResourceNavigator) part;
@@ -52,6 +52,12 @@
     return null;
   }
 
+  private IViewReference[] viewReferencesInActivePage() {
+    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+    if (activePage == null) return new IViewReference[0];
+    return activePage.getViewReferences();
+  }
+  
   /**
    * Indicates whether the given URI belongs to an existing file.
    * @param fileUri the URI to check, as a {@code String}.