Ignore:
Timestamp:
2009-10-25T18:22:28+01:00 (15 years ago)
Author:
Gubaer
Message:

fixed #3725: JOSM doesn't provide indication during upload that the server is sending 410 Gone errors
Progress dialog now includes a small log window for use cases like this. Use appendLogMessage() on the progress monitor.

Location:
trunk/src/org/openstreetmap/josm/gui/progress
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/progress/AbstractProgressMonitor.java

    r1875 r2319  
    6060    protected void checkState(State... expectedStates) {
    6161        for (State s:expectedStates) {
    62             if (s == state) {
     62            if (s == state)
    6363                return;
    64             }
    6564        }
    6665        throw new ProgressException("Expected states are %s but current state is %s", Arrays.asList(expectedStates).toString(), state);
     
    154153            resetState();
    155154        }
     155    }
     156
     157    /**
     158     * Default implementation is empty. Override in subclasses to display the log messages.
     159     */
     160    public void appendLogMessage(String message) {
     161        // do nothing
    156162    }
    157163
     
    327333    private Request getRequest(AbstractProgressMonitor child) {
    328334        for (Request request:requests) {
    329             if (request.originator == child) {
     335            if (request.originator == child)
    330336                return request;
    331             }
    332337        }
    333338        throw new ProgressException("Subtask %s not found", child);
  • trunk/src/org/openstreetmap/josm/gui/progress/NullProgressMonitor.java

    r1812 r2319  
    6060    }
    6161
     62    public void appendLogMessage(String message) {
     63    }
     64
    6265    public void setSilent(boolean value) {
    6366    }
  • trunk/src/org/openstreetmap/josm/gui/progress/PleaseWaitProgressMonitor.java

    r2057 r2319  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.progress;
    3 
    4 import static org.openstreetmap.josm.tools.I18n.tr;
    53
    64import java.awt.Dialog;
     
    1311import java.awt.event.WindowEvent;
    1412import java.awt.event.WindowListener;
    15 import java.lang.reflect.InvocationTargetException;
    1613
    1714import javax.swing.JOptionPane;
     
    3532
    3633    public PleaseWaitProgressMonitor(String windowTitle) {
    37         this(JOptionPane.getFrameForComponent(Main.map));
     34        this(JOptionPane.getFrameForComponent(Main.parent));
    3835        this.windowTitle = windowTitle;
    3936    }
     
    5350        @Override public void windowClosing(WindowEvent e) {
    5451            cancel();
    55             closeDialog();
    5652        }
    5753    };
    58 
    59     private void closeDialog() {
    60         try {
    61             Runnable runnable = new Runnable(){
    62                 public void run() {
    63                 }
    64             };
    65 
    66             // make sure, this is called in the dispatcher thread ASAP
    67             if (EventQueue.isDispatchThread()) {
    68                 runnable.run();
    69             } else {
    70                 EventQueue.invokeAndWait(runnable);
    71             }
    72 
    73         } catch (InterruptedException e) {
    74         } catch (InvocationTargetException e) {
    75             throw new RuntimeException(e);
    76         }
    77     }
    7854
    7955    private void doInEDT(Runnable runnable) {
     
    8561        doInEDT(new Runnable() {
    8662            public void run() {
    87                 if (dialogParent instanceof Frame) {
    88                     dialog = new PleaseWaitDialog((Frame)dialogParent);
    89                 } else if (dialogParent instanceof Dialog) {
    90                     dialog = new PleaseWaitDialog((Dialog)dialogParent);
     63                if (dialogParent instanceof Frame && dialog == null) {
     64                    dialog = new PleaseWaitDialog(dialogParent);
     65                } else if (dialogParent instanceof Dialog && dialog == null) {
     66                    dialog = new PleaseWaitDialog(dialogParent);
    9167                } else
    9268                    throw new ProgressException("PleaseWaitDialog parent must be either Frame or Dialog");
     
    9571                    dialog.setTitle(windowTitle);
    9672                }
    97                 dialog.cancel.setEnabled(true);
     73                dialog.setCancelEnabled(true);
     74                dialog.setCancelCallback(cancelListener);
    9875                dialog.setCustomText("");
    99                 dialog.cancel.addActionListener(cancelListener);
    10076                dialog.addWindowListener(windowListener);
    10177                dialog.progress.setMaximum(PROGRESS_BAR_MAX);
     
    10783    @Override
    10884    public void doFinishTask() {
    109         doInEDT(new Runnable() {
    110             public void run() {
    111                 if (dialog != null) {
    112                     dialog.setVisible(false);
    113                     dialog.dispose();
    114                     dialog.removeWindowListener(windowListener);
    115                     dialog.cancel.removeActionListener(cancelListener);
    116                     if (getErrorMessage() != null) {
    117                         JOptionPane.showMessageDialog(
    118                                 Main.parent, getErrorMessage(),
    119                                 tr("Error"),
    120                                 JOptionPane.ERROR_MESSAGE);
    121                     }
    122                     dialog = null;
    123                 }
    124             }
    125         });
     85        // do nothing
    12686    }
    12787
     
    164124            public void run() {
    165125                if (value && dialog.progress.getValue() == 0) {
    166                     // Enable only if progress is at the begging. Doing intermediate progress in the middle
     126                    // Enable only if progress is at the beginning. Doing intermediate progress in the middle
    167127                    // will hide already reached progress
    168128                    dialog.setIndeterminate(true);
     
    179139    }
    180140
     141    @Override
     142    public void appendLogMessage(final String message) {
     143        doInEDT(new Runnable() {
     144            public void run() {
     145                dialog.appendLogMessage(message);
     146            }
     147        });
     148    }
     149
     150    public void close() {
     151        dialog.setVisible(false);
     152        dialog.setCancelCallback(null);
     153        dialog.removeWindowListener(windowListener);
     154        dialog.dispose();
     155        dialog = null;
     156    }
    181157}
  • trunk/src/org/openstreetmap/josm/gui/progress/ProgressMonitor.java

    r1875 r2319  
    123123    void setErrorMessage(String message);
    124124    String getErrorMessage();
     125
     126    /**
     127     * Appends a message to the log managed by the progress monitor.
     128     *
     129     * @param message the log message. Ignored if null or white space only.
     130     */
     131    void appendLogMessage(String message);
    125132}
Note: See TracChangeset for help on using the changeset viewer.