Bug 334387 [Compatibility] NPE thrown when opening preferences dialog from inline refactoring menu
1. Place your text cursor on a field. 2. Alt+Shift+R 3. Wait for the balloon popup to appear then click the dropdown > Preferences... 4. An NPE is thrown. org.eclipse.swt.SWTException: Widget is disposed at org.eclipse.swt.SWT.error(SWT.java:4093) at org.eclipse.swt.SWT.error(SWT.java:4008) at org.eclipse.swt.SWT.error(SWT.java:3979) at org.eclipse.swt.widgets.Widget.error(Widget.java:468) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:340) at org.eclipse.swt.widgets.Control.getParent(Control.java:1387) at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.deactivate(ShellActivationListener.java:132) at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.access$0(ShellActivationListener.java:131) at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener$4.widgetDisposed(ShellActivationListener.java:197) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:123) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1058) at org.eclipse.swt.widgets.Widget.release(Widget.java:808) at org.eclipse.swt.widgets.Widget.dispose(Widget.java:446) at org.eclipse.swt.widgets.Decorations.dispose(Decorations.java:447) at org.eclipse.swt.widgets.Shell.dispose(Shell.java:714) at org.eclipse.swt.widgets.Decorations.closeWidget(Decorations.java:309) at org.eclipse.swt.widgets.Shell.close(Shell.java:537) at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameInformationPopup.close(RenameInformationPopup.java:354) at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameLinkedMode.linkedModeLeft(RenameLinkedMode.java:584) at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameLinkedMode.access$2(RenameLinkedMode.java:581) at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameLinkedMode$EditorSynchronizer.left(RenameLinkedMode.java:117) at org.eclipse.jface.text.link.LinkedModeModel.exit(LinkedModeModel.java:341) at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameLinkedMode.cancel(RenameLinkedMode.java:386) at org.eclipse.jdt.internal.ui.refactoring.reorg.RenameInformationPopup$14.run(RenameInformationPopup.java:770) at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/ShellActivationListener.java
*            the shell of interest, must not be <code>null</code>
	 * @param parentContext
	 *            the parent context that the shell's context should be created
	 *            off of if it doesn't have one, must not be <code>null</code>
	 * @return the shell's eclipse context
	 */
	private IEclipseContext getShellContext(final Shell shell,
			IEclipseContext parentContext) {
		IEclipseContext shellContext = (IEclipseContext) shell
				.getData(ECLIPSE_CONTEXT_SHELL_CONTEXT);
		if (shellContext != null) {
			return shellContext;
		}
		final IEclipseContext context = parentContext
				.createChild(EBindingService.DIALOG_CONTEXT_ID);
		context.set(E4Workbench.LOCAL_ACTIVE_SHELL, shell);
		
		shell.setData(ECLIPSE_CONTEXT_SHELL_CONTEXT, context);
		EContextService contextService = context.get(EContextService.class);
		contextService.activateContext(EBindingService.DIALOG_CONTEXT_ID);
		shell.addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent e) {
				deactivate(shell);
				context.dispose();
			}
		});
		return context;
	}
}