Ignore:
Timestamp:
2013-06-28T03:23:46+02:00 (11 years ago)
Author:
donvip
Message:

[josm_directupload] update eclipse project, build.xml, fix EDT violations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadDataGui.java

    r29631 r29718  
    3939import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    4040import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     41import org.openstreetmap.josm.gui.util.GuiHelper;
    4142import org.openstreetmap.josm.gui.widgets.HistoryComboBox;
    4243import org.openstreetmap.josm.io.GpxWriter;
     
    242243            if (canceled) {
    243244                conn.disconnect();
    244                 OutputDisplay.setText(tr("Upload canceled"));
    245                 buttons.get(0).setEnabled(true);
     245                GuiHelper.runInEDT(new Runnable() {
     246                    @Override public void run() {
     247                        OutputDisplay.setText(tr("Upload canceled"));
     248                        buttons.get(0).setEnabled(true);
     249                    }
     250                });
    246251                canceled = false;
    247252            }
    248253            else {
    249                 boolean success = finishUpConnection(conn);
    250                 buttons.get(0).setEnabled(!success);
    251                 if (success) {
    252                     buttons.get(1).setText(tr("Close"));
     254                final boolean success = finishUpConnection(conn);
     255                GuiHelper.runInEDT(new Runnable() {
     256                    @Override public void run() {
     257                        buttons.get(0).setEnabled(!success);
     258                        if (success) {
     259                            buttons.get(1).setText(tr("Close"));
     260                        }
     261                    }
     262                });
     263            }
     264        }
     265        catch (Exception e) {
     266            GuiHelper.runInEDT(new Runnable() {
     267                @Override public void run() {
     268                    OutputDisplay.setText(tr("Error while uploading"));
    253269                }
    254             }
    255         }
    256         catch (Exception e) {
    257             OutputDisplay.setText(tr("Error while uploading"));
     270            });
    258271            e.printStackTrace();
    259272        }
     
    300313    private boolean finishUpConnection(HttpURLConnection c) throws Exception {
    301314        String returnMsg = c.getResponseMessage();
    302         boolean success = returnMsg.equals("OK");
     315        final boolean success = returnMsg.equals("OK");
    303316
    304317        if (c.getResponseCode() != 200) {
     
    306319                returnMsg += "\n" + c.getHeaderField("Error");
    307320        }
    308 
    309         OutputDisplay.setText(success
    310             ? tr("GPX upload was successful")
    311             : tr("Upload failed. Server returned the following message: ") + returnMsg);
     321       
     322        final String returnMsgEDT = returnMsg;
     323
     324        GuiHelper.runInEDT(new Runnable() {
     325            @Override public void run() {
     326                OutputDisplay.setText(success
     327                        ? tr("GPX upload was successful")
     328                        : tr("Upload failed. Server returned the following message: ") + returnMsgEDT);
     329            }
     330        });
    312331
    313332        c.disconnect();
     
    385404            errors += tr("No GPX layer selected. Cannot upload a trace.");
    386405
    387         OutputDisplay.setText(errors);
     406        final String errorsEDT = errors;
     407       
     408        GuiHelper.runInEDT(new Runnable() {
     409            @Override public void run() {
     410                OutputDisplay.setText(errorsEDT);
     411            }
     412        });
     413       
    388414        return errors.length() > 0;
    389415    }
Note: See TracChangeset for help on using the changeset viewer.