Changeset 4739 in josm


Ignore:
Timestamp:
2011-12-29T13:04:12+01:00 (8 years ago)
Author:
jttt
Message:
  • fix #7202 Downloading Data window harder to read since r4718
  • update display correctly when progress monitor is moved to background/foreground
Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

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

    r4718 r4739  
    126126        }
    127127
    128         public void setTitle(String text) {
     128        public void setCurrentAction(String text) {
    129129            this.title = text;
    130130            updateText();
  • trunk/src/org/openstreetmap/josm/gui/PleaseWaitDialog.java

    r4718 r4739  
    112112    }
    113113
     114    public void setCurrentAction(String text) {
     115        currentAction.setText(text);
     116    }
     117
    114118    /**
    115119     * Appends a log message to the progress dialog. If the log area isn't visible yet
     
    166170     *
    167171     * @param callback the cancel callback
    168      */   
     172     */
    169173    public void setInBackgroundCallback(ActionListener callback) {
    170174        if (callback == null) {
  • trunk/src/org/openstreetmap/josm/gui/progress/PleaseWaitProgressMonitor.java

    r4718 r4739  
    2121public class PleaseWaitProgressMonitor extends AbstractProgressMonitor {
    2222
    23         /**
    24         * Implemented by both foreground dialog and background progress dialog (in status bar)
    25         */
     23    /**
     24    * Implemented by both foreground dialog and background progress dialog (in status bar)
     25    */
    2626    public interface ProgressMonitorDialog {
    2727        void setVisible(boolean visible);
    2828        void updateProgress(int progress);
    2929        void setCustomText(String text);
    30         void setTitle(String text);
     30        void setCurrentAction(String text);
    3131        void setIndeterminate(boolean newValue);
    32         void appendLogMessage(String message);
     32        void appendLogMessage(String message); //TODO Not implemented properly in background monitor, log message will get lost if progress runs in background
    3333    }
    3434
    3535    public static final int PROGRESS_BAR_MAX = 100;
    3636    private final Window dialogParent;
     37
    3738    private int currentProgressValue = 0;
     39    private String customText;
     40    private String title;
     41    private boolean indeterminate;
    3842
    3943    private boolean isInBackground;
     
    110114            ProgressMonitorDialog dialog = getDialog();
    111115            if (dialog != null) {
     116                reset();
    112117                dialog.setVisible(true);
    113118            }
     
    179184    protected void doSetCustomText(final String title) {
    180185        checkState(State.IN_TASK, State.IN_SUBTASK);
     186        this.customText = title;
    181187        doInEDT(new Runnable() {
    182188            public void run() {
     
    192198    protected void doSetTitle(final String title) {
    193199        checkState(State.IN_TASK, State.IN_SUBTASK);
     200        this.title = title;
    194201        doInEDT(new Runnable() {
    195202            public void run() {
    196203                ProgressMonitorDialog dialog = getDialog();
    197204                if (dialog != null) {
    198                     dialog.setTitle(title);
     205                    dialog.setCurrentAction(title);
    199206                }
    200207            }
     
    204211    @Override
    205212    protected void doSetIntermediate(final boolean value) {
     213        this.indeterminate = value;
    206214        doInEDT(new Runnable() {
    207215            public void run() {
     
    210218                ProgressMonitorDialog dialog = getDialog();
    211219                if (dialog != null) {
    212                     dialog.setIndeterminate(value && PleaseWaitProgressMonitor.this.dialog.progress.getValue() == 0);
     220                    dialog.setIndeterminate(value && currentProgressValue == 0);
    213221                }
    214222            }
     
    226234            }
    227235        });
     236    }
     237
     238    public void reset() {
     239        if (dialog != null) {
     240            dialog.setTitle(title);
     241            dialog.setCustomText(customText);
     242            dialog.updateProgress(currentProgressValue);
     243            dialog.setIndeterminate(indeterminate && currentProgressValue == 0);
     244        }
     245        BackgroundProgressMonitor backgroundMonitor = null;
     246        MapFrame map = Main.map;
     247        if (map != null) {
     248            backgroundMonitor = map.statusLine.progressMonitor;
     249        }
     250        if (backgroundMonitor != null) {
     251            backgroundMonitor.setCurrentAction(title);
     252            backgroundMonitor.setCustomText(customText);
     253            backgroundMonitor.updateProgress(currentProgressValue);
     254            backgroundMonitor.setIndeterminate(indeterminate && currentProgressValue == 0);
     255        }
     256
    228257    }
    229258
     
    253282            public void run() {
    254283                dialog.setInBackgroundPossible(PleaseWaitProgressMonitor.this.taskId != null && Main.isDisplayingMapView());
     284                reset();
    255285                getDialog();
    256286            }
Note: See TracChangeset for help on using the changeset viewer.