Skip to content

Commit

Permalink
[1963] NullPointerException in AbstractLocateInWorkbenchPartHandler
Browse files Browse the repository at this point in the history
Bug: 1963
Change-Id: Icaaa4de49eb1f9dfd2a82974e1e3adde55b3706e
Signed-off-by: cong-bang.do <docongbang1993@gmail.com>
  • Loading branch information
bang-dc committed Feb 19, 2018
1 parent 6a0069c commit a370116
Showing 1 changed file with 22 additions and 6 deletions.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2016 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2018 THALES GLOBAL SERVICES.
* 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
Expand All @@ -13,8 +13,10 @@

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;

/**
Expand All @@ -34,9 +36,23 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
if (null == activePart) {
return null;
}
// Get the current selection from the active part.
handleSelection(activePart.getSite().getSelectionProvider()
.getSelection(), activePart, event);
// Get the current selection from the active part.
IWorkbenchPartSite site = activePart.getSite();
if (null == site) {
return null;
}

ISelectionProvider selectionProvider = site.getSelectionProvider();
if (null == selectionProvider) {
return null;
}

ISelection selection = selectionProvider.getSelection();
if (null == selection) {
return null;
}

handleSelection(selection, activePart, event);
return null;
}

Expand Down

0 comments on commit a370116

Please sign in to comment.