Ignore:
Timestamp:
2012-08-18T19:21:29+02:00 (12 years ago)
Author:
Don-vip
Message:

Code refactorisation on EDT calls

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesTask.java

    r4497 r5452  
    66
    77import java.io.IOException;
    8 import java.lang.reflect.InvocationTargetException;
    98import java.util.List;
    109import java.util.Set;
    11 
    12 import javax.swing.SwingUtilities;
    1310
    1411import org.openstreetmap.josm.actions.AutoScaleAction;
     
    2522import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2623import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     24import org.openstreetmap.josm.gui.util.GuiHelper;
    2725import org.openstreetmap.josm.io.MultiFetchServerObjectReader;
    2826import org.openstreetmap.josm.io.OsmServerObjectReader;
     
    8280            return;
    8381        }
    84         Runnable r = new Runnable() {
     82        GuiHelper.runInEDTAndWait(new Runnable() {
    8583            public void run() {
    8684                layer.mergeFrom(ds);
     
    8886                layer.onPostDownloadFromServer();
    8987            }
    90         };
    91 
    92         if (SwingUtilities.isEventDispatchThread()) {
    93             r.run();
    94         } else {
    95             try {
    96                 SwingUtilities.invokeAndWait(r);
    97             } catch(InterruptedException e) {
    98                 e.printStackTrace();
    99             } catch(InvocationTargetException e) {
    100                 e.printStackTrace();
    101             }
    102         }
     88        });
    10389    }
    10490
  • trunk/src/org/openstreetmap/josm/gui/io/UpdatePrimitivesTask.java

    r4191 r5452  
    2323import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2424import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     25import org.openstreetmap.josm.gui.util.GuiHelper;
    2526import org.openstreetmap.josm.io.MultiFetchServerObjectReader;
    2627import org.openstreetmap.josm.io.OsmServerObjectReader;
     
    8081            return;
    8182        }
    82         Runnable r = new Runnable() {
     83        GuiHelper.runInEDTAndWait(new Runnable() {
    8384            public void run() {
    8485                layer.mergeFrom(ds);
    8586                layer.onPostDownloadFromServer();
    8687            }
    87         };
    88 
    89         if (SwingUtilities.isEventDispatchThread()) {
    90             r.run();
    91         } else {
    92             try {
    93                 SwingUtilities.invokeAndWait(r);
    94             } catch(InterruptedException e) {
    95                 e.printStackTrace();
    96             } catch(InvocationTargetException e) {
    97                 e.printStackTrace();
    98             }
    99         }
     88        });
    10089    }
    10190
  • trunk/src/org/openstreetmap/josm/gui/io/UploadPrimitivesTask.java

    r5057 r5452  
    2828import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2929import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     30import org.openstreetmap.josm.gui.util.GuiHelper;
    3031import org.openstreetmap.josm.io.ChangesetClosedException;
    3132import org.openstreetmap.josm.io.OsmApi;
     
    316317        // - to the Upload Dialog
    317318        // - to map editing
    318         Runnable r = new Runnable() {
     319        GuiHelper.runInEDT(new Runnable() {
    319320            public void run() {
    320321                // if the changeset is still open after this upload we want it to
     
    357358                }
    358359            }
    359         };
    360         if (SwingUtilities.isEventDispatchThread()) {
    361             r.run();
    362         } else {
    363             SwingUtilities.invokeLater(r);
    364         }
     360        });
    365361    }
    366362
  • trunk/src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java

    r5422 r5452  
    2424import javax.swing.JTabbedPane;
    2525import javax.swing.JTextField;
    26 import javax.swing.SwingUtilities;
    2726import javax.swing.event.DocumentEvent;
    2827import javax.swing.event.DocumentListener;
     
    3837import org.openstreetmap.josm.gui.SideButton;
    3938import org.openstreetmap.josm.gui.help.HelpUtil;
     39import org.openstreetmap.josm.gui.util.GuiHelper;
    4040import org.openstreetmap.josm.gui.widgets.AbstractTextComponentValidator;
    4141import org.openstreetmap.josm.gui.widgets.HtmlPanel;
     
    519519            };
    520520            e.printStackTrace();
    521             if (SwingUtilities.isEventDispatchThread()) {
    522                 r.run();
    523             } else {
    524                 SwingUtilities.invokeLater(r);
    525             }
     521            GuiHelper.runInEDT(r);
    526522        }
    527523
     
    552548                getProgressMonitor().worked(1);
    553549                if (canceled)return;
    554                 Runnable r = new Runnable() {
     550                GuiHelper.runInEDT(new Runnable() {
    555551                    public void run() {
    556552                        prepareUIForResultDisplay();
    557553                        setAccessToken(accessToken);
    558554                    }
    559                 };
    560                 if (SwingUtilities.isEventDispatchThread()) {
    561                     r.run();
    562                 } else {
    563                     SwingUtilities.invokeLater(r);
    564                 }
     555                });
    565556            } catch(final OsmOAuthAuthorizationException e) {
    566557                handleException(e);
  • trunk/src/org/openstreetmap/josm/gui/progress/SwingRenderingProgressMonitor.java

    r5266 r5452  
    44import java.awt.Component;
    55
    6 import javax.swing.SwingUtilities;
    7 
    86import org.openstreetmap.josm.Main;
     7import org.openstreetmap.josm.gui.util.GuiHelper;
    98import org.openstreetmap.josm.tools.CheckParameterUtil;
    109
     
    3231    }
    3332
    34     private void doInEDT(Runnable runnable) {
    35         if (SwingUtilities.isEventDispatchThread()) {
    36             runnable.run();
    37         } else {
    38             SwingUtilities.invokeLater(runnable);
    39         }
    40     }
    41 
    4233    @Override
    4334    public void doBeginTask() {
    44         doInEDT(new Runnable() {
     35        GuiHelper.runInEDT(new Runnable() {
    4536            public void run() {
    4637                delegate.setCustomText("");
     
    6051        if (newValue != currentProgressValue) {
    6152            currentProgressValue = newValue;
    62             doInEDT(new Runnable() {
     53            GuiHelper.runInEDT(new Runnable() {
    6354                public void run() {
    6455                    delegate.setValue(currentProgressValue);
     
    7162    protected void doSetCustomText(final String title) {
    7263        checkState(State.IN_TASK, State.IN_SUBTASK);
    73         doInEDT(new Runnable() {
     64        GuiHelper.runInEDT(new Runnable() {
    7465            public void run() {
    7566                delegate.setCustomText(title);
     
    8172    protected void doSetTitle(final String title) {
    8273        checkState(State.IN_TASK, State.IN_SUBTASK);
    83         doInEDT(new Runnable() {
     74        GuiHelper.runInEDT(new Runnable() {
    8475            public void run() {
    8576                delegate.setTaskTitle(title);
     
    9081    @Override
    9182    protected void doSetIntermediate(final boolean value) {
    92         doInEDT(new Runnable() {
     83        GuiHelper.runInEDT(new Runnable() {
    9384            public void run() {
    9485                delegate.setIndeterminate(value);
Note: See TracChangeset for help on using the changeset viewer.