source: josm/trunk/src/org/openstreetmap/josm/gui/progress/ProgressMonitorExecutor.java@ 12638

Last change on this file since 12638 was 12638, checked in by Don-vip, 7 years ago

see #15182 - remove Main.currentProgressMonitor. Replacement: PleaseWaitProgressMonitor.getCurrent()

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.progress;
3
4import java.util.concurrent.LinkedBlockingQueue;
5import java.util.concurrent.ThreadPoolExecutor;
6import java.util.concurrent.TimeUnit;
7
8import org.openstreetmap.josm.tools.Utils;
9
10/**
11 * Executor that displays the progress monitor to the user.
12 *
13 * Similar to Executors.newSingleThreadExecutor(), but displays the
14 * progress monitor whenever a new task is executed.
15 */
16public class ProgressMonitorExecutor extends ThreadPoolExecutor {
17
18 /**
19 * Creates a new {@code ProgressMonitorExecutor}
20 * @param nameFormat see {@link Utils#newThreadFactory(String, int)}
21 * @param threadPriority see {@link Utils#newThreadFactory(String, int)}
22 */
23 public ProgressMonitorExecutor(final String nameFormat, final int threadPriority) {
24 super(1, 1, 0L, TimeUnit.MILLISECONDS,
25 new LinkedBlockingQueue<Runnable>(),
26 Utils.newThreadFactory(nameFormat, threadPriority));
27 }
28
29 @Override
30 public void execute(Runnable command) {
31 if (PleaseWaitProgressMonitor.currentProgressMonitor != null) {
32 //TODO show only if this can't be in background or better if always in background is not checked
33 PleaseWaitProgressMonitor.currentProgressMonitor.showForegroundDialog();
34 }
35 super.execute(command);
36 }
37
38}
Note: See TracBrowser for help on using the repository browser.