aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2012-02-01 10:53:56 (EST)
committerOleg Besedin2012-02-01 10:54:26 (EST)
commitf876fcac1d5c3d445342f1ea15d31dc9f5e1bd86 (patch)
tree920c4107be2a110209283f7997942e43967655d2
parent1802d811faf2d561e456718abe3bb727510f9085 (diff)
downloadeclipse.platform.ui-f876fcac1d5c3d445342f1ea15d31dc9f5e1bd86.zip
eclipse.platform.ui-f876fcac1d5c3d445342f1ea15d31dc9f5e1bd86.tar.gz
eclipse.platform.ui-f876fcac1d5c3d445342f1ea15d31dc9f5e1bd86.tar.bz2
Bug 370214 - Throw Exception in @PostContruct leads tov20120201-1554
org.eclipse.e4.core.di.InjectionException
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/WorkbenchStatusReporter.java35
1 files changed, 29 insertions, 6 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/WorkbenchStatusReporter.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/WorkbenchStatusReporter.java
index 044b9c5..99983ed 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/WorkbenchStatusReporter.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/WorkbenchStatusReporter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2012 IBM Corporation and others.
* 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
@@ -14,6 +14,7 @@ package org.eclipse.e4.ui.internal.workbench.swt;
import javax.inject.Inject;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.services.log.Logger;
import org.eclipse.e4.core.services.statusreporter.StatusReporter;
@@ -29,6 +30,7 @@ import org.osgi.framework.BundleContext;
public class WorkbenchStatusReporter extends StatusReporter {
@Inject
+ @Optional
IShellProvider shellProvider;
@Inject
Logger logger;
@@ -37,6 +39,9 @@ public class WorkbenchStatusReporter extends StatusReporter {
BundleContext bundleContext;
ErrorDialog dialog;
+ @Inject
+ private IEclipseContext context;
+
public void report(IStatus status, int style, Object... information) {
int action = style & (IGNORE | LOG | SHOW | BLOCK);
if (action == 0) {
@@ -77,11 +82,29 @@ public class WorkbenchStatusReporter extends StatusReporter {
log(status);
return;
}
- final Status exceptionStatus = new Status(status.getSeverity(), status
- .getPlugin(), status.getException() == null ? status
- .getMessage() : status.getException().toString(), status
- .getException());
- dialog = new ErrorDialog(shellProvider.getShell(), "Internal Error",
+ final Status exceptionStatus = new Status(status.getSeverity(),
+ status.getPlugin(),
+ status.getException() == null ? status.getMessage() : status
+ .getException().toString(), status.getException());
+
+ // TBD this code should really be in IShellProvider which should be
+ // available at the application context level.
+ Shell myShell = null;
+ if (shellProvider != null)
+ myShell = shellProvider.getShell();
+ else {
+ IEclipseContext activeLeaf = context.getActiveLeaf();
+ if (activeLeaf != null) {
+ IShellProvider provider = activeLeaf.get(IShellProvider.class);
+ if (provider != null)
+ myShell = provider.getShell();
+ }
+ }
+ if (myShell == null) {
+ myShell = new Shell();
+ }
+
+ dialog = new ErrorDialog(myShell, "Internal Error",
status.getMessage(),
status.getException() != null ? exceptionStatus : status, ERROR
| WARNING | INFO) {