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

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

see #15182 - move the Swing-based ProgressMonitor implementations from gui.progress to gui.progress.swing. Progress monitor concept is used in very large parts of JOSM, a console-based implementation could be added later

  • 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.swing;
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 * @since 12675 (moved from {@code gui.progress} package}
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 (PleaseWaitProgressMonitor.currentProgressMonitor != null) {
33 //TODO show only if this can't be in background or better if always in background is not checked
34 PleaseWaitProgressMonitor.currentProgressMonitor.showForegroundDialog();
35 }
36 super.execute(command);
37 }
38
39}
Note: See TracBrowser for help on using the repository browser.