Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Leicht2012-09-11 17:54:34 +0000
committerStephan Leicht2012-09-11 17:54:34 +0000
commitba502430f51422900f9ee0a598647b0fafe0fa40 (patch)
tree16939c2c03fffebd586d6ae39ae4d756ebb67920
parentcfececc22948831aa2a20f8ec3f03d869257d943 (diff)
downloadorg.eclipse.scout.rt-ba502430f51422900f9ee0a598647b0fafe0fa40.tar.gz
org.eclipse.scout.rt-ba502430f51422900f9ee0a598647b0fafe0fa40.tar.xz
org.eclipse.scout.rt-ba502430f51422900f9ee0a598647b0fafe0fa40.zip
RESOLVED - bug 388008: RAP: Nullpointer Exception during failed startup
https://bugs.eclipse.org/bugs/show_bug.cgi?id=388008 Contributed by Ken Lee <kle@bsiag.com>
-rw-r--r--org.eclipse.scout.rt.ui.rap.workbench/src/org/eclipse/scout/rt/ui/rap/workbench/AbstractRwtWorkbenchEnvironment.java38
-rw-r--r--org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/AbstractRwtEnvironment.java8
-rw-r--r--org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/AbstractStandaloneRwtEnvironment.java43
-rw-r--r--org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/util/RwtUtility.java43
4 files changed, 82 insertions, 50 deletions
diff --git a/org.eclipse.scout.rt.ui.rap.workbench/src/org/eclipse/scout/rt/ui/rap/workbench/AbstractRwtWorkbenchEnvironment.java b/org.eclipse.scout.rt.ui.rap.workbench/src/org/eclipse/scout/rt/ui/rap/workbench/AbstractRwtWorkbenchEnvironment.java
index 10e5eba7d5..51bc494521 100644
--- a/org.eclipse.scout.rt.ui.rap.workbench/src/org/eclipse/scout/rt/ui/rap/workbench/AbstractRwtWorkbenchEnvironment.java
+++ b/org.eclipse.scout.rt.ui.rap.workbench/src/org/eclipse/scout/rt/ui/rap/workbench/AbstractRwtWorkbenchEnvironment.java
@@ -17,12 +17,15 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.TreeMap;
import javax.security.auth.Subject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.scout.commons.CompareUtility;
+import org.eclipse.scout.commons.CompositeLong;
import org.eclipse.scout.commons.OptimisticLock;
import org.eclipse.scout.commons.StringUtility;
import org.eclipse.scout.commons.logger.IScoutLogger;
@@ -35,11 +38,13 @@ import org.eclipse.scout.rt.client.ui.form.IForm;
import org.eclipse.scout.rt.client.ui.wizard.IWizard;
import org.eclipse.scout.rt.ui.rap.AbstractRwtEnvironment;
import org.eclipse.scout.rt.ui.rap.basic.WidgetPrinter;
+import org.eclipse.scout.rt.ui.rap.util.RwtUtility;
import org.eclipse.scout.rt.ui.rap.workbench.window.editor.AbstractScoutEditorPart;
import org.eclipse.scout.rt.ui.rap.workbench.window.editor.ScoutFormEditorInput;
import org.eclipse.scout.rt.ui.rap.workbench.window.view.AbstractScoutView;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IPerspectiveDescriptor;
@@ -333,6 +338,39 @@ public abstract class AbstractRwtWorkbenchEnvironment extends AbstractRwtEnviron
getDisplay().asyncExec(new P_HideScoutViews());
}
+ @Override
+ public Shell getParentShellIgnoringPopups(int modalities) {
+ Shell shell = Display.getCurrent().getActiveShell();
+ if (shell == null) {
+ if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
+ shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ }
+ }
+ if (shell != null) {
+ while (RwtUtility.isPopupShell(shell) && shell.getParent() instanceof Shell) {
+ shell = (Shell) shell.getParent();
+ }
+ }
+ // traverse complete tree
+ if (shell == null) {
+ TreeMap<CompositeLong, Shell> map = new TreeMap<CompositeLong, Shell>();
+ for (IWorkbenchWindow w : PlatformUI.getWorkbench().getWorkbenchWindows()) {
+ RwtUtility.visitShellTreeRec(w.getShell(), modalities, 0, map);
+ }
+ if (map.size() > 0) {
+ shell = map.get(map.firstKey());
+ }
+ }
+
+ if (shell != null && shell.getData() instanceof ProgressMonitorDialog) {
+ // do also ignore the ProgressMonitorDialog, otherwise there will be some strange behaviors
+ // when displaying a shell on top of the ProgressMonitorDialog-shell (f.e. when the
+ // ProgressMonitorDialog-shell disappears)
+ shell = (Shell) shell.getParent();
+ }
+ return shell;
+ }
+
private class P_HideScoutViews implements Runnable {
@Override
public void run() {
diff --git a/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/AbstractRwtEnvironment.java b/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/AbstractRwtEnvironment.java
index 7738b8492b..5488b21d24 100644
--- a/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/AbstractRwtEnvironment.java
+++ b/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/AbstractRwtEnvironment.java
@@ -1179,14 +1179,6 @@ public abstract class AbstractRwtEnvironment implements IRwtEnvironment {
}
}
- /**
- * {@inheritDoc}
- */
- @Override
- public Shell getParentShellIgnoringPopups(int modalities) {
- return RwtUtility.getParentShellIgnoringPopups(modalities);
- }
-
@Override
public IClientSession getClientSession() {
return m_clientSession;
diff --git a/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/AbstractStandaloneRwtEnvironment.java b/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/AbstractStandaloneRwtEnvironment.java
index fab2c142ec..a66d2edc90 100644
--- a/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/AbstractStandaloneRwtEnvironment.java
+++ b/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/AbstractStandaloneRwtEnvironment.java
@@ -12,12 +12,15 @@ package org.eclipse.scout.rt.ui.rap;
import java.lang.reflect.Field;
import java.security.AccessController;
+import java.util.TreeMap;
import javax.security.auth.Subject;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.rwt.RWT;
import org.eclipse.rwt.lifecycle.UICallBack;
import org.eclipse.rwt.service.SettingStoreException;
+import org.eclipse.scout.commons.CompositeLong;
import org.eclipse.scout.commons.LocaleThreadLocal;
import org.eclipse.scout.commons.StringUtility;
import org.eclipse.scout.commons.logger.IScoutLogger;
@@ -45,6 +48,7 @@ public abstract class AbstractStandaloneRwtEnvironment extends AbstractRwtEnviro
private static final IScoutLogger LOG = ScoutLogManager.getLogger(AbstractStandaloneRwtEnvironment.class);
private Display m_display;
+ private Shell m_rootShell;
private RwtScoutDesktop m_uiDesktop;
private RwtScoutFormButtonBar m_uiButtonArea;
@@ -107,6 +111,7 @@ public abstract class AbstractStandaloneRwtEnvironment extends AbstractRwtEnviro
}
Shell shell = new Shell(m_display, SWT.NO_TRIM);
+ m_rootShell = shell;
createApplicationContent(shell);
createNonmodalFormButtonArea(shell);
//layout
@@ -144,6 +149,7 @@ public abstract class AbstractStandaloneRwtEnvironment extends AbstractRwtEnviro
}
}
});
+
while (!shell.isDisposed()) {
if (getClientSession() != null) {
LocaleThreadLocal.set(getClientSession().getLocale());
@@ -153,6 +159,7 @@ public abstract class AbstractStandaloneRwtEnvironment extends AbstractRwtEnviro
}
}
m_display.dispose();
+ m_rootShell = null;
return 0;
}
@@ -255,4 +262,40 @@ public abstract class AbstractStandaloneRwtEnvironment extends AbstractRwtEnviro
}
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Shell getParentShellIgnoringPopups(int modalities) {
+ Shell shell = Display.getCurrent().getActiveShell();
+ if (shell != null) {
+ while (RwtUtility.isPopupShell(shell) && shell.getParent() instanceof Shell) {
+ shell = (Shell) shell.getParent();
+ }
+ }
+ // traverse available shells
+ if (shell == null) {
+ TreeMap<CompositeLong, Shell> map = new TreeMap<CompositeLong, Shell>();
+ for (Shell s : Display.getCurrent().getShells()) {
+ RwtUtility.visitShellTreeRec(s, modalities, 0, map);
+ }
+ if (map.size() > 0) {
+ shell = map.get(map.firstKey());
+ }
+ }
+
+ if (shell != null && shell.getData() instanceof ProgressMonitorDialog) {
+ // do also ignore the ProgressMonitorDialog, otherwise there will be some strange behaviors
+ // when displaying a shell on top of the ProgressMonitorDialog-shell (f.e. when the
+ // ProgressMonitorDialog-shell disappears)
+ shell = (Shell) shell.getParent();
+ }
+
+ if (shell == null) {
+ shell = m_rootShell;
+ }
+
+ return shell;
+ }
}
diff --git a/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/util/RwtUtility.java b/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/util/RwtUtility.java
index b6061e79f8..b35026dff8 100644
--- a/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/util/RwtUtility.java
+++ b/org.eclipse.scout.rt.ui.rap/src/org/eclipse/scout/rt/ui/rap/util/RwtUtility.java
@@ -25,7 +25,6 @@ import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.rwt.RWT;
import org.eclipse.scout.commons.CompositeLong;
@@ -68,8 +67,6 @@ import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
import org.osgi.framework.Version;
public final class RwtUtility {
@@ -1616,44 +1613,6 @@ public final class RwtUtility {
}
/**
- * @param modalities
- * combination of {@link SWT#SYSTEM_MODAL}, {@link SWT#APPLICATION_MODAL}, {@link SWT#MODELESS}
- * @return best effort to get the "current" parent shell
- * <p>
- * Never null
- */
- public static Shell getParentShellIgnoringPopups(int modalities) {
- Shell shell = Display.getCurrent().getActiveShell();
- if (shell == null) {
- if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
- shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- }
- }
- if (shell != null) {
- while (isPopupShell(shell) && shell.getParent() instanceof Shell) {
- shell = (Shell) shell.getParent();
- }
- }
- // traverse complete tree
- if (shell == null) {
- TreeMap<CompositeLong, Shell> map = new TreeMap<CompositeLong, Shell>();
- for (IWorkbenchWindow w : PlatformUI.getWorkbench().getWorkbenchWindows()) {
- visitShellTreeRec(w.getShell(), modalities, 0, map);
- }
- if (map.size() > 0) {
- shell = map.get(map.firstKey());
- }
- }
- if (shell != null && shell.getData() instanceof ProgressMonitorDialog) {
- // do also ignore the ProgressMonitorDialog, otherwise there will be some strange behaviors
- // when displaying a shell on top of the ProgressMonitorDialog-shell (f.e. when the
- // ProgressMonitorDialog-shell disappears)
- shell = (Shell) shell.getParent();
- }
- return shell;
- }
-
- /**
* Visit the complete workbench shell tree.
* Ignore popup shells and shells
* with extendedStyle popup
@@ -1662,7 +1621,7 @@ public final class RwtUtility {
* 1. system modal before application modal before modeless<br>
* 2. sub shells before parent shells before top level shells
*/
- private static void visitShellTreeRec(Shell shell, int modalities, int level, TreeMap<CompositeLong, Shell> out) {
+ public static void visitShellTreeRec(Shell shell, int modalities, int level, TreeMap<CompositeLong, Shell> out) {
if (shell == null) {
return;
}

Back to the top