Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Haftstein2015-08-03 08:26:24 +0000
committerMarcel Bruch2015-08-03 10:08:36 +0000
commit34ad9b1cdea7837d8d087352eb1434cec10571b8 (patch)
tree20ca551057f2c187b19045872527233b9c0fd14b
parent02e3727b72bb39a95cfd946686893c855f1cfab4 (diff)
downloadorg.eclipse.epp.logging-34ad9b1cdea7837d8d087352eb1434cec10571b8.tar.gz
org.eclipse.epp.logging-34ad9b1cdea7837d8d087352eb1434cec10571b8.tar.xz
org.eclipse.epp.logging-34ad9b1cdea7837d8d087352eb1434cec10571b8.zip
Skip report notifications if eclipse has no focus
Bug: 472704 Change-Id: Id0aa5f0d3d194c44a2cfaf154b497289d21a8c6a Signed-off-by: Daniel Haftstein <haftsteind@gmail.com>
-rw-r--r--bundles/org.eclipse.epp.logging.aeri.ui/src/org/eclipse/epp/internal/logging/aeri/ui/ReportingController.java9
-rw-r--r--bundles/org.eclipse.epp.logging.aeri.ui/src/org/eclipse/epp/internal/logging/aeri/ui/utils/Shells.java25
2 files changed, 32 insertions, 2 deletions
diff --git a/bundles/org.eclipse.epp.logging.aeri.ui/src/org/eclipse/epp/internal/logging/aeri/ui/ReportingController.java b/bundles/org.eclipse.epp.logging.aeri.ui/src/org/eclipse/epp/internal/logging/aeri/ui/ReportingController.java
index 47ec92362..1c3ff0272 100644
--- a/bundles/org.eclipse.epp.logging.aeri.ui/src/org/eclipse/epp/internal/logging/aeri/ui/ReportingController.java
+++ b/bundles/org.eclipse.epp.logging.aeri.ui/src/org/eclipse/epp/internal/logging/aeri/ui/ReportingController.java
@@ -132,11 +132,16 @@ public class ReportingController {
return;
}
+ if (!Shells.hasActiveWindow()) {
+ // skip event for the moment if eclipse has no focus
+ return;
+ }
+
ProblemStatus status = problemsDb.seen(report).or(UNKNOWN_STATUS);
switch (status.getAction()) {
case NEEDINFO: {
requestShowNeedInfoRequest(report, status);
- // TODO if this popu dialog fades out, what should we do?
+ // TODO if this popup dialog fades out, what should we do?
// handling this case is not very clean yet
// we also do not store that this problem was seen, right?
// needs intensive unit tests...
@@ -144,7 +149,7 @@ public class ReportingController {
}
case FIXED: {
requestShowFixedInfo(report, status);
- // TODO if this popu dialog fades out, what should we do?
+ // TODO if this popup dialog fades out, what should we do?
// handling this case is not very clean yet
// we also do not store that this problem was seen, right?
// needs intensive unit tests...
diff --git a/bundles/org.eclipse.epp.logging.aeri.ui/src/org/eclipse/epp/internal/logging/aeri/ui/utils/Shells.java b/bundles/org.eclipse.epp.logging.aeri.ui/src/org/eclipse/epp/internal/logging/aeri/ui/utils/Shells.java
index b53a0496f..44006f983 100644
--- a/bundles/org.eclipse.epp.logging.aeri.ui/src/org/eclipse/epp/internal/logging/aeri/ui/utils/Shells.java
+++ b/bundles/org.eclipse.epp.logging.aeri.ui/src/org/eclipse/epp/internal/logging/aeri/ui/utils/Shells.java
@@ -12,6 +12,8 @@ package org.eclipse.epp.internal.logging.aeri.ui.utils;
import static com.google.common.base.Optional.*;
+import java.util.concurrent.atomic.AtomicBoolean;
+
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
@@ -52,4 +54,27 @@ public class Shells {
}
return of(display);
}
+
+ public static boolean hasActiveWindow() {
+ final Display display = getDisplay().orNull();
+ if (display == null) {
+ return false;
+ }
+ if (isUIThread()) {
+ return display.getActiveShell() != null;
+ }
+ // else
+ final AtomicBoolean res = new AtomicBoolean(false);
+ display.syncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (display.getActiveShell() == null) {
+ res.set(false);
+ } else {
+ res.set(true);
+ }
+ }
+ });
+ return res.get();
+ }
}

Back to the top