* @param selectionListener
*/
public static void notifySelectionChangedWithCurrentSelection(
ISelectionListener selectionListener, IServiceLocator serviceLocator) {
IHandlerService handlerService = CommonUtils.getService(serviceLocator, IHandlerService.class);
IEvaluationContext state = handlerService.getCurrentState();
// This seems to be the most reliable way to get the active part, it
// also returns a part when it is called while creating a view that is
// being shown.Getting the active part through the active workbench
// window returned null in that case.
Object partObject = state.getVariable(ISources.ACTIVE_PART_NAME);
Object selectionObject = state
.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
if (partObject instanceof IWorkbenchPart
&& selectionObject instanceof ISelection) {
IWorkbenchPart part = (IWorkbenchPart) partObject;
ISelection selection = (ISelection) selectionObject;