Ignore:
Timestamp:
2011-12-27T12:56:27+01:00 (12 years ago)
Author:
jttt
Message:

Add posibility to run please wait runnable tasks in background

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r4681 r4718  
    2222import java.util.Collection;
    2323import java.util.Iterator;
    24 import java.util.LinkedList;
    2524import java.util.List;
    2625import java.util.Map;
    2726import java.util.StringTokenizer;
    2827import java.util.concurrent.ExecutorService;
    29 import java.util.concurrent.Executors;
    3028import java.util.concurrent.Future;
    3129import java.util.regex.Matcher;
     
    4139import javax.swing.JTextArea;
    4240import javax.swing.KeyStroke;
     41import javax.swing.RepaintManager;
    4342import javax.swing.UIManager;
    4443
     44import org.jdesktop.swinghelper.debug.CheckThreadViolationRepaintManager;
    4545import org.openstreetmap.gui.jmapviewer.FeatureAdapter;
    4646import org.openstreetmap.josm.actions.JosmAction;
     
    7676import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference;
    7777import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
     78import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
     79import org.openstreetmap.josm.gui.progress.ProgressMonitorExecutor;
    7880import org.openstreetmap.josm.io.OsmApi;
    7981import org.openstreetmap.josm.plugins.PluginHandler;
     
    116118     * and sequential.
    117119     */
    118     public final static ExecutorService worker = Executors.newSingleThreadExecutor();
     120    public final static ExecutorService worker = new ProgressMonitorExecutor();
    119121    /**
    120122     * Global application preferences
     
    143145
    144146    public UndoRedoHandler undoRedo = new UndoRedoHandler();
     147
     148    public static PleaseWaitProgressMonitor currentProgressMonitor;
    145149
    146150    /**
     
    208212
    209213        PluginHandler.notifyMapFrameChanged(old, map);
     214        if (map == null && currentProgressMonitor != null) {
     215            currentProgressMonitor.showForegroundDialog();
     216        }
    210217    }
    211218
     
    238245        isOpenjdk = System.getProperty("java.vm.name").toUpperCase().indexOf("OPENJDK") != -1;
    239246
    240         if (initListener != null)
     247        if (initListener != null) {
    241248            initListener.updateStatus(tr("Executing platform startup hook"));
     249        }
    242250        platform.startupHook();
    243251
     
    245253        // capabilities are already known to the editor instance. However
    246254        // if it goes wrong that's not critical at this stage.
    247         if (initListener != null)
     255        if (initListener != null) {
    248256            initListener.updateStatus(tr("Initializing OSM API"));
     257        }
    249258        try {
    250259            OsmApi.getOsmApi().initialize(null, true);
     
    253262        }
    254263
    255         if (initListener != null)
     264        if (initListener != null) {
    256265            initListener.updateStatus(tr("Building main menu"));
     266        }
    257267        contentPanePrivate.add(panel, BorderLayout.CENTER);
    258268        panel.add(gettingStarted, BorderLayout.CENTER);
     
    267277                KeyEvent.VK_F1, Shortcut.GROUP_DIRECT));
    268278
    269         if (initListener != null)
     279        if (initListener != null) {
    270280            initListener.updateStatus(tr("Initializing presets"));
     281        }
    271282        TaggingPresetPreference.initialize();
    272283
    273         if (initListener != null)
     284        if (initListener != null) {
    274285            initListener.updateStatus(tr("Initializing map styles"));
     286        }
    275287        MapPaintPreference.initialize();
    276288
    277         if (initListener != null)
     289        if (initListener != null) {
    278290            initListener.updateStatus(tr("Loading imagery preferences"));
     291        }
    279292        ImageryPreference.initialize();
    280293
    281         if (initListener != null)
     294        if (initListener != null) {
    282295            initListener.updateStatus(tr("Initializing validator"));
     296        }
    283297        validator = new OsmValidator();
    284298        MapView.addLayerChangeListener(validator);
     
    293307        FeatureAdapter.registerTranslationAdapter(I18n.getTranslationAdapter());
    294308
    295         if (initListener != null)
     309        if (initListener != null) {
    296310            initListener.updateStatus(tr("Updating user interface"));
     311        }
    297312
    298313        toolbar.refreshToolbarControl();
     
    527542                                tr("Warning"),
    528543                                JOptionPane.WARNING_MESSAGE
    529                         );
     544                                );
    530545                    }
    531546                    if (f!=null) {
     
    560575                            tr("Warning"),
    561576                            JOptionPane.WARNING_MESSAGE
    562                     );
     577                            );
    563578                }
    564579            }
     
    647662                    tr("Warning"),
    648663                    JOptionPane.WARNING_MESSAGE
    649             );
     664                    );
    650665        } else {
    651666            downloadFromParamBounds(rawGps, b);
     
    664679                    new LatLon(Double.parseDouble(st.nextToken()),Double.parseDouble(st.nextToken())),
    665680                    new LatLon(Double.parseDouble(st.nextToken()),Double.parseDouble(st.nextToken()))
    666             );
     681                    );
    667682            downloadFromParamBounds(rawGps, b);
    668683        }
Note: See TracChangeset for help on using the changeset viewer.