Bug 529635 - [sonar] Resolve "Possible null pointer dereference"

Change-Id: I2d445f9e52fa07ade342c7252ff5154737cedd48
Signed-off-by: René Purrio <rpurrio@itemis.de>
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
index f707818..1d66666 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
@@ -1043,7 +1043,7 @@
 				}
 			};
 			File[] configFiles = directory.listFiles(configFilter);
-			if (configFiles.length > 0) {
+			if (configFiles != null && configFiles.length > 0) {
 				LaunchConfiguration config = null;
 				for (int i = 0; i < configFiles.length; i++) {
 					config = new LaunchConfiguration(LaunchConfiguration.getSimpleName(configFiles[i].getName()), null, false);
@@ -1057,7 +1057,7 @@
 				}
 			};
 			File[] prototypeFiles = directory.listFiles(prototypeFilter);
-			if (prototypeFiles.length > 0) {
+			if (prototypeFiles != null && prototypeFiles.length > 0) {
 				LaunchConfiguration config = null;
 				for (int i = 0; i < prototypeFiles.length; i++) {
 					config = new LaunchConfiguration(LaunchConfiguration.getSimpleName(prototypeFiles[i].getName()), null, true);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ExportBreakpoints.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ExportBreakpoints.java
index f3d9f9c..3ac125d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ExportBreakpoints.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ExportBreakpoints.java
@@ -15,26 +15,24 @@
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.internal.ui.DebugUIPlugin;
 import org.eclipse.debug.internal.ui.actions.AbstractDebugActionDelegate;
-import org.eclipse.debug.ui.IDebugUIConstants;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IViewPart;
 
 /**
  * <p>
- * This class provides the aciton event for both the context menu in breakpoints view
- * and the drop down menu inn the breakpoints view.
+ * This class provides the action event for both the context menu in breakpoints
+ * view and the drop down menu in the breakpoints view.
  * </p>
  * <p>
- *  The action simply calls the wizard to export breakpoints.
- *  </p>
- *  @see WizardExportBreakpoints
- *  @see WizardExportBreakpointsPage
+ * The action simply calls the wizard to export breakpoints.
+ * </p>
+ * 
+ * @see WizardExportBreakpoints
+ * @see WizardExportBreakpointsPage
  *
- *  @since 3.2
+ * @since 3.2
  */
 public class ExportBreakpoints extends AbstractDebugActionDelegate {
 
@@ -45,9 +43,8 @@
 	 */
 	@Override
 	public void run(IAction action) {
-		IViewPart fViewpart = DebugUIPlugin.getActiveWorkbenchWindow().getActivePage().findView(IDebugUIConstants.ID_BREAKPOINT_VIEW);
 		WizardExportBreakpoints wiz = new WizardExportBreakpoints();
-		wiz.init(DebugUIPlugin.getDefault().getWorkbench(), (IStructuredSelection)fViewpart.getViewSite().getSelectionProvider().getSelection());
+		wiz.init(DebugUIPlugin.getDefault().getWorkbench(), getSelection());
 		WizardDialog wizdialog = new WizardDialog(DebugUIPlugin.getShell(), wiz);
 		wizdialog.setBlockOnOpen(true);
 		wizdialog.open();
@@ -58,6 +55,7 @@
 	 */
 	@Override
 	protected void update(IAction action, ISelection s) {
+		super.update(action, s);
 		getAction().setEnabled(DebugPlugin.getDefault().getBreakpointManager().hasBreakpoints());
 	}
 
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportBreakpoints.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportBreakpoints.java
index a2e1c0e..9644867 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportBreakpoints.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/ImportBreakpoints.java
@@ -58,6 +58,7 @@
 	 */
 	@Override
 	protected void update(IAction action, ISelection s) {
+		super.update(action, s);
 		getAction().setEnabled(true);
 	}
 
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextService.java
index 5d4f44c..2ba16a0 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextService.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextService.java
@@ -524,7 +524,7 @@
 
 					// Don't bring a minimized or fast view to front
 					IViewReference partRef = page.findViewReference(viewId);
-					if (partRef.isFastView() || IWorkbenchPage.STATE_MINIMIZED == page.getPartState(partRef)) {
+					if (partRef != null && (partRef.isFastView() || IWorkbenchPage.STATE_MINIMIZED == page.getPartState(partRef))) {
 						return;
 					}