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

Last change on this file since 9665 was 9665, checked in by stoecker, 8 years ago

fix eol-style issues and similar formating stuff, see #12410

  • 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.Main;
9import org.openstreetmap.josm.tools.Utils;
10
11/**
12 * Executor that displays the progress monitor to the user.
13 *
14 * Similar to Executors.newSingleThreadExecutor(), but displays the
15 * progress monitor whenever a new task is executed.
16 */
17public class ProgressMonitorExecutor extends ThreadPoolExecutor {
18
19 /**
20 * Creates a new {@code ProgressMonitorExecutor}
21 * @param nameFormat see {@link Utils#newThreadFactory(String, int)}
22 * @param threadPriority see {@link Utils#newThreadFactory(String, int)}
23 */
24 public ProgressMonitorExecutor(final String nameFormat, final int threadPriority) {
25 super(1, 1, 0L, TimeUnit.MILLISECONDS,
26 new LinkedBlockingQueue<Runnable>(),
27 Utils.newThreadFactory(nameFormat, threadPriority));
28 }
29
30 @Override
31 public void execute(Runnable command) {
32 if (Main.currentProgressMonitor != null) {
33 //TODO show only if this can't be in background or better if always in background is not checked
34 Main.currentProgressMonitor.showForegroundDialog();
35 }
36 super.execute(command);
37 }
38
39}
Note: See TracBrowser for help on using the repository browser.