Merge "Bug 459345 - NPE in quick outline "
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/quickoutline/QuickOutlinePopupDialog.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/quickoutline/QuickOutlinePopupDialog.java
index f5db0f4..8d3a323 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/quickoutline/QuickOutlinePopupDialog.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/quickoutline/QuickOutlinePopupDialog.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * Copyright (c) 2010, 2016 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -63,11 +63,11 @@
 /**
  * Popup dialog that contains the filtering input and the outline
  * view of the editor's input.
- * 
+ *
  * <p>
  * Based on {@link org.eclipse.jdt.internal.ui.text.AbstractInformationControl}
  * </p>
- * 
+ *
  */
 public class QuickOutlinePopupDialog extends PopupDialog implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, DisposeListener {
 
@@ -89,7 +89,7 @@
 	private IContentSelectionProvider fSelectionProvider;
 
 	private StringPatternFilter fFilter;
-	
+
 	public QuickOutlinePopupDialog(Shell parent, int shellStyle, IStructuredModel model, AbstractQuickOutlineConfiguration configuration) {
 		super(parent, shellStyle, true, true, true, true, true, null, null);
 		fContentProvider = configuration.getContentProvider();
@@ -208,7 +208,7 @@
 				if (result != null)
 					return result;
 			}
-				
+
 		}
 		return result;
 	}
@@ -224,9 +224,12 @@
 	private void gotoSelectedElement() {
 		Object element = getSelectedElement();
 		dispose();
-		ITextEditor editor = getActiveTextEditor();
-		if (editor != null) {
-			editor.selectAndReveal(((IndexedRegion) element).getStartOffset(), ((IndexedRegion) element).getEndOffset() - ((IndexedRegion) element).getStartOffset());
+		if (element != null) {
+			ITextEditor editor = getActiveTextEditor();
+			if (editor != null) {
+				editor.selectAndReveal(((IndexedRegion) element).getStartOffset(),
+						((IndexedRegion) element).getEndOffset() - ((IndexedRegion) element).getStartOffset());
+			}
 		}
 	}