|
11 | 11 | package org.jboss.tools.usage.event; |
12 | 12 |
|
13 | 13 | import java.util.Set; |
| 14 | +import java.util.concurrent.CountDownLatch; |
14 | 15 | import java.util.concurrent.locks.Lock; |
15 | 16 | import java.util.concurrent.locks.ReentrantLock; |
16 | 17 |
|
@@ -353,21 +354,28 @@ private void askUser() { |
353 | 354 | * @return the boolean |
354 | 355 | */ |
355 | 356 | protected Boolean askUserForEnablement() { |
| 357 | + final CountDownLatch latch = new CountDownLatch(1); |
356 | 358 | final Boolean[] userResponse = new Boolean[1]; |
357 | | - Display.getDefault().syncExec(new Runnable() { |
| 359 | + Display.getDefault().asyncExec(new Runnable() { |
358 | 360 | public void run() { |
359 | | - Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(); |
360 | | - UsageReportEnablementDialog dialog = |
361 | | - new UsageReportEnablementDialog( |
362 | | - shell, |
363 | | - JBossToolsUsageActivator.getDefault().getUsageBranding()); |
364 | | - if (dialog.open() == Window.OK) { |
365 | | - userResponse[0] = dialog.isReportEnabled(); |
366 | | - } else { |
| 361 | + try { |
367 | 362 | userResponse[0] = false; |
| 363 | + Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(); |
| 364 | + UsageReportEnablementDialog dialog = new UsageReportEnablementDialog( |
| 365 | + shell, JBossToolsUsageActivator.getDefault().getUsageBranding()); |
| 366 | + if (dialog.open() == Window.OK) { |
| 367 | + userResponse[0] = dialog.isReportEnabled(); |
| 368 | + } |
| 369 | + } finally { |
| 370 | + latch.countDown(); |
368 | 371 | } |
369 | 372 | } |
370 | 373 | }); |
| 374 | + try { |
| 375 | + latch.await(); // main thread is waiting on CountDownLatch to finish |
| 376 | + } catch (InterruptedException ie) { |
| 377 | + // Error already logged by the asyncExec |
| 378 | + } |
371 | 379 | return userResponse[0]; |
372 | 380 | } |
373 | 381 |
|
|
0 commit comments