Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » Dialog from Handler
Dialog from Handler [message #724327] Mon, 12 September 2011 02:05 Go to next message
Eclipse UserFriend
Hello,
I want to show a Dialog from a Handler, but after
dialog.open()
I get a
org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException
.

This is my Handler:
public class PreferenceHandler {

	@Execute
	public void execute(IEclipseContext context, IWorkbench workbench) {
			
		PreferenceDialog dialog = ContextInjectionFactory.make(PreferenceDialog.class, context);
		dialog.open();
	}
}


and this is my Dialog:
public class PreferenceDialog extends TitleAreaDialog {


	@Inject
	public PreferenceDialog(
		@Named(IServiceConstants.ACTIVE_SHELL) Shell parentShell) {
		super(parentShell);
	}

	@Override
	protected Control createDialogArea(Composite parent) {

		Composite area = (Composite) super.createDialogArea(parent);
		getShell().setText("Connection informations");
		
		return area;
	}
}


My Enviroment:
windows 7
jdk 1.6.0_27 (32 bit)
Eclipse SDK 4.1.0

[Updated on: Mon, 12 September 2011 02:08] by Moderator

Re: Dialog from Handler [message #724333 is a reply to message #724327] Mon, 12 September 2011 02:24 Go to previous messageGo to next message
Eclipse UserFriend
Can we see the complete stacktrace please.

Tom

Am 12.09.11 08:05, schrieb dwestermann:
> Hello,
> I want to show a Dialog from a Handler, but after dialog.open() I get a
> org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException.
> This is my Handler:
> public class PreferenceHandler {
>
> @Execute
> public void execute(IEclipseContext context, IWorkbench workbench) {
>
> PreferenceDialog dialog =
> ContextInjectionFactory.make(PreferenceDialog.class, context);
> dialog.open();
> }
> }
>
> and this is my Dialog:
> public class PreferenceDialog extends TitleAreaDialog {
>
>
> @Inject
> public PreferenceDialog(
> @Named(IServiceConstants.ACTIVE_SHELL) Shell parentShell) {
> super(parentShell);
> }
>
> @Override
> protected Control createDialogArea(Composite parent) {
>
> Composite area = (Composite) super.createDialogArea(parent);
> getShell().setText("Connection informations");
>
> return area;
> }
> }
>
Re: Dialog from Handler [message #724338 is a reply to message #724333] Mon, 12 September 2011 02:37 Go to previous messageGo to next message
Eclipse UserFriend
Wow, rally fast response! Very Happy

@Tom Schindel: The code is from your tutorial.



!SESSION 2011-09-12 08:32:37.328 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_27
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
Framework arguments: -product org.eclipse.e4.demo.mailapp.product
Command-line arguments: -product org.eclipse.e4.demo.mailapp.product -data C:\Users\xxx.yyy\workspace/../runtime-MailDemo-4.0.product -dev file:C:/Users/xxx.yyy/workspace/.metadata/.plugins/org.eclipse.pde.core/MailDemo-4.0.product/dev.properties -os win32 -ws win32 -arch x86 -consoleLog

!ENTRY org.eclipse.e4.ui.workbench 4 0 2011-09-12 08:32:44.247
!MESSAGE Internal Error
!STACK 0
org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:226)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:196)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:86)
at org.eclipse.e4.ui.workbench.renderers.swt.DirectContributionItem.executeItem(DirectContributionItem.java:409)
at org.eclipse.e4.ui.workbench.renderers.swt.DirectContributionItem.handleWidgetSelection(DirectContributionItem.java:334)
at org.eclipse.e4.ui.workbench.renderers.swt.DirectContributionItem.access$1(DirectContributionItem.java:318)
at org.eclipse.e4.ui.workbench.renderers.swt.DirectContributionItem$2.handleEvent(DirectContributionItem.java:283)
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.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:969)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:885)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:87)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:145)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: java.lang.NullPointerException
at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.getShellContext(ShellActivationListener.java:193)
at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.activate(ShellActivationListener.java:114)
at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.handleEvent(ShellActivationListener.java:73)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1262)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
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.Decorations.WM_ACTIVATE(Decorations.java:1647)
at org.eclipse.swt.widgets.Shell.WM_ACTIVATE(Shell.java:2137)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4525)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1610)
at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2061)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4972)
at org.eclipse.swt.internal.win32.OS.BringWindowToTop(Native Method)
at org.eclipse.swt.widgets.Decorations.bringToTop(Decorations.java:230)
at org.eclipse.swt.widgets.Shell.open(Shell.java:1217)
at org.eclipse.jface.window.Window.open(Window.java:797)
at org.eclipse.e4.demo.mailapp.PreferenceHandler.execute(PreferenceHandler.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
... 29 more
java.lang.NullPointerException
at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.getShellContext(ShellActivationListener.java:193)
at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.activate(ShellActivationListener.java:114)
at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.handleEvent(ShellActivationListener.java:73)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1262)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
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.Decorations.WM_ACTIVATE(Decorations.java:1647)
at org.eclipse.swt.widgets.Shell.WM_ACTIVATE(Shell.java:2137)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4525)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1610)
at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2061)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4972)
at org.eclipse.swt.internal.win32.OS.BringWindowToTop(Native Method)
at org.eclipse.swt.widgets.Decorations.bringToTop(Decorations.java:230)
at org.eclipse.swt.widgets.Shell.open(Shell.java:1217)
at org.eclipse.jface.window.Window.open(Window.java:797)
at org.eclipse.jface.dialogs.ErrorDialog.open(ErrorDialog.java:360)
at org.eclipse.e4.ui.internal.workbench.swt.WorkbenchStatusReporter.openDialog(WorkbenchStatusReporter.java:97)
at org.eclipse.e4.ui.internal.workbench.swt.WorkbenchStatusReporter.report(WorkbenchStatusReporter.java:54)
at org.eclipse.e4.core.services.statusreporter.StatusReporter.show(StatusReporter.java:132)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.safeHandle(PartRenderingEngine.java:1006)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.handle(PartRenderingEngine.java:990)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:978)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:885)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:87)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:145)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Re: Dialog from Handler [message #725250 is a reply to message #724327] Wed, 14 September 2011 07:25 Go to previous messageGo to next message
Eclipse UserFriend
i have the same problem with the E4 tutorial of Lars Vogel!

My Enviroment:
Windows 7 64 Bit
jdk 1.6.0_26 (32 bit)
Eclipse SDK 4.1.0 Build id: I20110620-1631


public class ExitDialog extends Dialog {
	@Inject
	public ExitDialog(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
		super(shell);
	}

	@Override
	protected Control createDialogArea(Composite parent) {
		Label label = new Label(parent, SWT.NONE);
		label.setText("Closing this application may result in data loss. Are you sure you want that");
		return parent;
	}
	
}


public class ExitHandlerWithCheck {
	@Execute
	public void execute(IEclipseContext context, IWorkbench workbench) {
		ExitDialog dialog = ContextInjectionFactory.make(ExitDialog.class, context);
		dialog.create();
		if (dialog.open() == Window.OK) {
			workbench.close();
		}
	}
}


Stacktrace:

!SESSION 2011-09-14 13:24:23.781 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_26
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
Framework arguments:  -product de.vogella.e4.todo.product
Command-line arguments:  -product de.vogella.e4.todo.product -data T:\eclipse4\wspace\wspace/../runtime-Todo.product -dev file:T:/eclipse4/wspace/wspace/.metadata/.plugins/org.eclipse.pde.core/Todo.product/dev.properties -os win32 -ws win32 -arch x86 -consoleLog

!ENTRY org.eclipse.e4.ui.workbench 1 0 2011-09-14 13:24:25.699
!MESSAGE Start building UI
TodoOveriew has now the focus.

!ENTRY org.eclipse.e4.ui.workbench 4 0 2011-09-14 13:24:27.895
!MESSAGE Internal Error
!STACK 0
org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:226)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:196)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:86)
	at org.eclipse.e4.ui.workbench.renderers.swt.DirectContributionItem.executeItem(DirectContributionItem.java:409)
	at org.eclipse.e4.ui.workbench.renderers.swt.DirectContributionItem.handleWidgetSelection(DirectContributionItem.java:334)
	at org.eclipse.e4.ui.workbench.renderers.swt.DirectContributionItem.access$1(DirectContributionItem.java:318)
	at org.eclipse.e4.ui.workbench.renderers.swt.DirectContributionItem$2.handleEvent(DirectContributionItem.java:283)
	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.Display.runDeferredEvents(Display.java:4165)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:969)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:885)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:87)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:145)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: java.lang.NullPointerException
	at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.getShellContext(ShellActivationListener.java:193)
	at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.activate(ShellActivationListener.java:114)
	at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.handleEvent(ShellActivationListener.java:73)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1262)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
	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.Decorations.WM_ACTIVATE(Decorations.java:1647)
	at org.eclipse.swt.widgets.Shell.WM_ACTIVATE(Shell.java:2137)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4525)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1610)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2061)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4972)
	at org.eclipse.swt.internal.win32.OS.BringWindowToTop(Native Method)
	at org.eclipse.swt.widgets.Decorations.bringToTop(Decorations.java:230)
	at org.eclipse.swt.widgets.Shell.open(Shell.java:1217)
	at org.eclipse.jface.window.Window.open(Window.java:797)
	at de.vogella.e4.todo.contribute.handler.ExitHandlerWithCheck.execute(ExitHandlerWithCheck.java:16)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	... 29 more
java.lang.NullPointerException
	at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.getShellContext(ShellActivationListener.java:193)
	at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.activate(ShellActivationListener.java:114)
	at org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.handleEvent(ShellActivationListener.java:73)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1262)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
	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.Decorations.WM_ACTIVATE(Decorations.java:1647)
	at org.eclipse.swt.widgets.Shell.WM_ACTIVATE(Shell.java:2137)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4525)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1610)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2061)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4972)
	at org.eclipse.swt.internal.win32.OS.BringWindowToTop(Native Method)
	at org.eclipse.swt.widgets.Decorations.bringToTop(Decorations.java:230)
	at org.eclipse.swt.widgets.Shell.open(Shell.java:1217)
	at org.eclipse.jface.window.Window.open(Window.java:797)
	at org.eclipse.jface.dialogs.ErrorDialog.open(ErrorDialog.java:360)
	at org.eclipse.e4.ui.internal.workbench.swt.WorkbenchStatusReporter.openDialog(WorkbenchStatusReporter.java:97)
	at org.eclipse.e4.ui.internal.workbench.swt.WorkbenchStatusReporter.report(WorkbenchStatusReporter.java:54)
	at org.eclipse.e4.core.services.statusreporter.StatusReporter.show(StatusReporter.java:132)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.safeHandle(PartRenderingEngine.java:1006)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.handle(PartRenderingEngine.java:990)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:978)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:885)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:87)
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:145)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Re: Dialog from Handler [message #725254 is a reply to message #724327] Wed, 14 September 2011 07:29 Go to previous messageGo to next message
Eclipse UserFriend
sorry for double post.

[Updated on: Wed, 14 September 2011 07:32] by Moderator

Re: Dialog from Handler [message #725270 is a reply to message #725250] Wed, 14 September 2011 07:36 Go to previous messageGo to next message
Eclipse UserFriend
To me this looks like a problem in the ShellActivationListener. Please
file a bugzilla if one does not already exist.

Tom

Am 14.09.11 13:25, schrieb krazun:
> i have the same problem with the E4 tutorial of Lars Vogel!
>
> My Enviroment:
> Windows 7 64 Bit
> jdk 1.6.0_26 (32 bit)
> Eclipse SDK 4.1.0 Build id: I20110620-1631
>
>
> public class ExitDialog extends Dialog {
> @Inject
> public ExitDialog(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
> super(shell);
> }
>
> @Override
> protected Control createDialogArea(Composite parent) {
> Label label = new Label(parent, SWT.NONE);
> label.setText("Closing this application may result in data loss.
> Are you sure you want that");
> return parent;
> }
>
> }
>
> public class ExitHandlerWithCheck {
> @Execute
> public void execute(IEclipseContext context, IWorkbench workbench) {
> ExitDialog dialog =
> ContextInjectionFactory.make(ExitDialog.class, context);
> dialog.create();
> if (dialog.open() == Window.OK) {
> workbench.close();
> }
> }
> }
>
> Stacktrace:
>
> !SESSION 2011-09-14 13:24:23.781
> -----------------------------------------------
> eclipse.buildId=unknown
> java.version=1.6.0_26
> java.vendor=Sun Microsystems Inc.
> BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
> Framework arguments: -product de.vogella.e4.todo.product
> Command-line arguments: -product de.vogella.e4.todo.product -data
> T:\eclipse4\wspace\wspace/../runtime-Todo.product -dev
> file:T:/eclipse4/wspace/wspace/.metadata/.plugins/org.eclipse.pde.core/Todo.product/dev.properties
> -os win32 -ws win32 -arch x86 -consoleLog
>
> !ENTRY org.eclipse.e4.ui.workbench 1 0 2011-09-14 13:24:25.699
> !MESSAGE Start building UI
> TodoOveriew has now the focus.
>
> !ENTRY org.eclipse.e4.ui.workbench 4 0 2011-09-14 13:24:27.895
> !MESSAGE Internal Error
> !STACK 0
> org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException
> at
> org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
>
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:226)
>
> at
> org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:196)
> at
> org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:86)
>
> at
> org.eclipse.e4.ui.workbench.renderers.swt.DirectContributionItem.executeItem(DirectContributionItem.java:409)
>
> at
> org.eclipse.e4.ui.workbench.renderers.swt.DirectContributionItem.handleWidgetSelection(DirectContributionItem.java:334)
>
> at
> org.eclipse.e4.ui.workbench.renderers.swt.DirectContributionItem.access$1(DirectContributionItem.java:318)
>
> at
> org.eclipse.e4.ui.workbench.renderers.swt.DirectContributionItem$2.handleEvent(DirectContributionItem.java:283)
>
> 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.Display.runDeferredEvents(Display.java:4165)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:969)
>
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:885)
>
> at
> org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:87)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:145)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
> Caused by: java.lang.NullPointerException
> at
> org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.getShellContext(ShellActivationListener.java:193)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.activate(ShellActivationListener.java:114)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.handleEvent(ShellActivationListener.java:73)
>
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1262)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
> 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.Decorations.WM_ACTIVATE(Decorations.java:1647)
> at org.eclipse.swt.widgets.Shell.WM_ACTIVATE(Shell.java:2137)
> at org.eclipse.swt.widgets.Control.windowProc(Control.java:4525)
> at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
> at
> org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1610)
> at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2061)
> at org.eclipse.swt.widgets.Display.windowProc(Display.java:4972)
> at org.eclipse.swt.internal.win32.OS.BringWindowToTop(Native Method)
> at org.eclipse.swt.widgets.Decorations.bringToTop(Decorations.java:230)
> at org.eclipse.swt.widgets.Shell.open(Shell.java:1217)
> at org.eclipse.jface.window.Window.open(Window.java:797)
> at
> de.vogella.e4.todo.contribute.handler.ExitHandlerWithCheck.execute(ExitHandlerWithCheck.java:16)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
>
> ... 29 more
> java.lang.NullPointerException
> at
> org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.getShellContext(ShellActivationListener.java:193)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.activate(ShellActivationListener.java:114)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.ShellActivationListener.handleEvent(ShellActivationListener.java:73)
>
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1262)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
> 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.Decorations.WM_ACTIVATE(Decorations.java:1647)
> at org.eclipse.swt.widgets.Shell.WM_ACTIVATE(Shell.java:2137)
> at org.eclipse.swt.widgets.Control.windowProc(Control.java:4525)
> at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
> at
> org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1610)
> at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2061)
> at org.eclipse.swt.widgets.Display.windowProc(Display.java:4972)
> at org.eclipse.swt.internal.win32.OS.BringWindowToTop(Native Method)
> at org.eclipse.swt.widgets.Decorations.bringToTop(Decorations.java:230)
> at org.eclipse.swt.widgets.Shell.open(Shell.java:1217)
> at org.eclipse.jface.window.Window.open(Window.java:797)
> at org.eclipse.jface.dialogs.ErrorDialog.open(ErrorDialog.java:360)
> at
> org.eclipse.e4.ui.internal.workbench.swt.WorkbenchStatusReporter.openDialog(WorkbenchStatusReporter.java:97)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.WorkbenchStatusReporter.report(WorkbenchStatusReporter.java:54)
>
> at
> org.eclipse.e4.core.services.statusreporter.StatusReporter.show(StatusReporter.java:132)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.safeHandle(PartRenderingEngine.java:1006)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.handle(PartRenderingEngine.java:990)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:978)
>
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:885)
>
> at
> org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:87)
>
> at
> org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:145)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
>
Re: Dialog from Handler [message #725273 is a reply to message #724327] Wed, 14 September 2011 08:06 Go to previous messageGo to next message
Eclipse UserFriend
After comparing the minimal project which is generated by the E4 Application Project Wizard with the "de.vogella.e4.todo" project where the following code works fine:

public class QuitHandler {
	@Execute
	public void execute(IWorkbench workbench, IEclipseContext context,
			@Named(IServiceConstants.ACTIVE_SHELL) Shell shell)
			throws InvocationTargetException, InterruptedException {
		if (MessageDialog.openConfirm(shell, "Confirmation",
				"Do you want to exit?")) {
			workbench.close();
		}
	}
}


i found out that the NPE can fixed by adding the addons from the Wizard-Project to the Application.e4xmi:

platform:/plugin/org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon

platform:/plugin/org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon

platform:/plugin/org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon

platform:/plugin/org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon

platform:/plugin/org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon

platform:/plugin/org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon



does someone knows a tutorial where i can read what E4 Addons are and how to use them?
Re: Dialog from Handler [message #725279 is a reply to message #725273] Wed, 14 September 2011 08:19 Go to previous messageGo to next message
Eclipse UserFriend
Yes, that works!
Re: Dialog from Handler [message #725311 is a reply to message #725279] Wed, 14 September 2011 09:47 Go to previous messageGo to next message
Eclipse UserFriend
If one creates an "e4 Application Project" with the e4 Project Wizard, the application.e4xml is correct. But if one creates a Plugin Project and later adds a "New Application Model" with the wizard, the *Addon entries are missing.
Re: Dialog from Handler [message #725324 is a reply to message #725311] Wed, 14 September 2011 09:55 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Well technically addons are not needed. E.g. you don't need a
CommandAddon if you are NOT using commands and handlers.

I think the NPE you get if you are NOT adding the addons is a bug
because the workbench-code itself should NOT expect an addon to be there.

So while it might be the case 99% of the time that you need addons
there's not must. The "e4 Application Project"-wizard creates them
because there commands, ... are used whereas the "New Application Model"
does not because it creates a completely empty model IIRC.

It might make sense to add a checkbox to the allow the wizard to insert
the standard fragments or give you a list of commonly known addons. Can
you please file a bugzilla and cc me on it.

Tom

Am 14.09.11 15:47, schrieb dwestermann:
> If one creates an "e4 Application Project" with the e4 Project Wizard,
> the application.e4xml is correct. But if one creates a Plugin Project
> and later adds a "New Application Model" with the wizard, the *Addon
> entries are missing.
Re: Dialog from Handler [message #725330 is a reply to message #725324] Wed, 14 September 2011 10:27 Go to previous messageGo to next message
Eclipse UserFriend
I´ve filled a Bugzilla.
Id is 351421
Re: Dialog from Handler [message #725345 is a reply to message #725330] Wed, 14 September 2011 10:33 Go to previous messageGo to next message
Eclipse UserFriend
This is not the correct id.

Tom

Am 14.09.11 16:27, schrieb dwestermann:
> I´ve filled a Bugzilla.
> Id is 351421
Re: Dialog from Handler [message #728368 is a reply to message #725345] Fri, 23 September 2011 02:51 Go to previous messageGo to next message
Eclipse UserFriend
I get the below error while while running the application(eclipse.exe) file generated using product export wizard on E4 platform. Can some body help me
Parvez
-----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_11
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments: -os win32 -ws win32 -arch x86

!ENTRY org.eclipse.equinox.app 0 0 2011-09-23 11:07:50.609
!MESSAGE Product org.cord.client.dms.mainapp.e4.product could not be found.

!ENTRY org.eclipse.osgi 4 0 2011-09-23 11:07:50.625
!MESSAGE Application error
!STACK 1
java.lang.NullPointerException
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:126)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)

[Updated on: Fri, 12 August 2022 12:44] by Moderator

Re: Dialog from Handler [message #728385 is a reply to message #728368] Fri, 23 September 2011 03:18 Go to previous messageGo to next message
Eclipse UserFriend
Please don't hijack unrelated threads! You've hijacked 2 threads and
opened a 3rd one! I already answered in "problem opening
Application.e4xmi in e4 windows 64bit".

Tom

Am 23.09.11 08:51, schrieb Parvez Ahmad Hakim:
> I get the below error while while running the application(eclipse.exe)
> file generated using product export wizard on E4 platform. Can some body
> help me
>
> Parvez Ahmad Hakim
> Srinagar Kashmir
> http://www.abobjects.com
> -----------------------------------------------
> eclipse.buildId=unknown
> java.version=1.6.0_11
> java.vendor=Sun Microsystems Inc.
> BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
> Command-line arguments: -os win32 -ws win32 -arch x86
>
> !ENTRY org.eclipse.equinox.app 0 0 2011-09-23 11:07:50.609
> !MESSAGE Product org.cord.client.dms.mainapp.e4.product could not be found.
>
> !ENTRY org.eclipse.osgi 4 0 2011-09-23 11:07:50.625
> !MESSAGE Application error
> !STACK 1
> java.lang.NullPointerException
> at
> org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:126)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
Re: Dialog from Handler [message #742297 is a reply to message #728385] Thu, 20 October 2011 07:15 Go to previous messageGo to next message
Eclipse UserFriend
Hello Tom
The problem got solved by adding plugins manually to exported product.
we are showing progress dialogs in non-ui code in classes.

for some code, i made below change:
I created a Shell shell
Showed a progress dialo
closed shell
code:
// PlatformUI.getWorkbench().getActiveWorkbenchWindow(); // old code
// Shell shell = win != null ? win.getShell() : null; / old code
Shell shell = new Shell();
if (showProgress) {
new ProgressMonitorDialog(shell).run(true, true, op);
} else {
op.run(null);
}
shell.close();


I do not want to create and close shell.

I do not feel that this may be good idea, to do it at every place in code.
So can we get E4 display/shell in non-UI code or just use Display.asyn....

Can we get the shell of running E4 plugin at run-time using any inject logic.

I searched google but no luck in that so far.

Please help

regards
Parvez Ahmad Hakim

[Updated on: Fri, 12 August 2022 12:43] by Moderator

Re: Dialog from Handler [message #937858 is a reply to message #724333] Tue, 09 October 2012 06:28 Go to previous message
Eclipse UserFriend
any solution so far

[Updated on: Fri, 12 August 2022 12:45] by Moderator

Previous Topic:Views not created
Next Topic:Renaming default commands
Goto Forum:
  


Current Time: Tue Jul 08 12:08:46 EDT 2025

Powered by FUDForum. Page generated in 0.06046 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top