Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » Callback for EventLoopException
Callback for EventLoopException [message #915940] Tue, 18 September 2012 04:56 Go to next message
Eclipse UserFriend
Hello,

we are implementing our first application on the eclipse 4 rcp and everything works fine so far.

Can anybody please tell me what's the e4 way of handling an UnexpectedEventLoopException? In eclipse 3.x there was the class ApplicationWorkbenchAdvisor and a callback method.

public void eventLoopException(final Throwable exception) {}


This callback we used to open an error dialog. How can I configure a callback in e4?

Thank you in advance,
Rudi

Re: Callback for EventLoopException [message #917932 is a reply to message #915940] Thu, 20 September 2012 11:17 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
this is very important for me. Maybe I should reformulate my question:

How do you handle an UnexpectedEventloopException in e4? By default the exception is written to the log-file but the users dosn't get any feedback. How do you handle this?

Please help...
Rudi
Re: Callback for EventLoopException [message #921824 is a reply to message #917932] Mon, 24 September 2012 09:14 Go to previous messageGo to next message
Eclipse UserFriend
It's internal right now, but you can provide your own implementation of org.eclipse.e4.ui.internal.workbench.swt.IEventLoopAdvisor to the application context. You should be able to set this instance from the @PostContextCreate life cycle annotation.

Brian.
Re: Callback for EventLoopException [message #922980 is a reply to message #921824] Tue, 25 September 2012 10:07 Go to previous messageGo to next message
Eclipse UserFriend
Hi Brian,

thank you very much! Do you know coincidentally if another solution will be provided in the future because this is accessing internal packages?

For all those for which IEventLoopAdvisor is not daily business Wink I paste my code here:

public class StartupLifeCycleHandler {

	private static final Logger logger = LogManager.getLogger(StartupLifeCycleHandler.class);

	@PostContextCreate
	public void startUp(final IEclipseContext context, final IApplicationContext applicationContext) {

		final IEventLoopAdvisor eventLoopAdvisor = new IEventLoopAdvisor() {

			@Override
			public void eventLoopIdle(final Display display) {

			}

			@Override
			public void eventLoopException(final Throwable exception) {

				StartupLifeCycleHandler.logger.error(exception.getMessage(), exception);
				MessageDialog.openError(Display.getCurrent().getActiveShell(), "Unexpected Eventloop Exception", StartupLifeCycleHandler.this.getCustomStackTrace(exception));
			}
		};

		StartupLifeCycleHandler.logger.debug("registering custom EventLoopAdvisor");
		context.set(IEventLoopAdvisor.class, eventLoopAdvisor);
	}

	private String getCustomStackTrace(final Throwable throwable) {

		final String newLine = "\n";
		final StringBuilder result = new StringBuilder();
		result.append(throwable.toString());
		result.append(newLine);
		for (final StackTraceElement element : throwable.getStackTrace()) {
			result.append(element);
			result.append(newLine);
		}
		return result.toString();
	}
}


How to register the handler you can find here: marcteufel.wordpress.com/2011/05/05/231/

Regards,
Rudi
Re: Callback for EventLoopException [message #1706374 is a reply to message #922980] Wed, 26 August 2015 07:12 Go to previous messageGo to next message
Eclipse UserFriend
Hi - we've tried using this IEventLoopAdvisor mechanism and even with no processing inside the methods it results in very high CPU usage so doesn't appear to be practically usable (in Eclipse 4.4.1 on Windows Server 2008).

Does anyone know if this has been addressed since 4.4.1 ?

[Updated on: Wed, 26 August 2015 07:13] by Moderator

Re: Callback for EventLoopException [message #1712838 is a reply to message #1706374] Wed, 28 October 2015 12:28 Go to previous message
Eclipse UserFriend
Missing name Mising name wrote on Wed, 26 August 2015 11:12
Hi - we've tried using this IEventLoopAdvisor mechanism and even with no processing inside the methods it results in very high CPU usage so doesn't appear to be practically usable (in Eclipse 4.4.1 on Windows Server 2008).

Does anyone know if this has been addressed since 4.4.1 ?


You should not leave eventLoopIdle(Display display) method empty. call display.sleep() instead:

@Override
public void eventLoopIdle(Display display) {
    display.sleep();
}

Previous Topic:Cannot Access Plugins in Eclipse 4.3.2
Next Topic:Dependency Injection - JSR-299?
Goto Forum:
  


Current Time: Wed Jul 23 17:22:05 EDT 2025

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

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

Back to the top