Ignore:
Timestamp:
2009-07-19T17:38:55+02:00 (15 years ago)
Author:
jttt
Message:

PleaseWait refactoring. Progress is now reported using ProgressMonitor interface, that is available through PleaseWaitRunnable.

File:
1 edited

Legend:

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

    r1787 r1811  
    2828import javax.swing.JTable;
    2929import javax.swing.ListSelectionModel;
    30 import javax.swing.SwingUtilities;
    3130import javax.swing.event.ListSelectionEvent;
    3231import javax.swing.event.ListSelectionListener;
     
    8786     * unregisters a {@see HistoryBrowserDialog}
    8887     * @param id the id of the primitive whose history dialog is to be unregistered
    89      * 
     88     *
    9089     */
    9190    public static void unregisterHistoryBrowserDialog(long id) {
     
    9897     * replies the history dialog for the primitive with id <code>id</code>; null, if
    9998     * no such {@see HistoryBrowserDialog} is currently showing
    100      * 
     99     *
    101100     * @param id the id of the primitive
    102101     * @return the dialog; null, if no such dialog is showing
     
    119118    /**
    120119     * builds the row with the command buttons
    121      * 
     120     *
    122121     * @return the rows with the command buttons
    123122     */
     
    209208    /**
    210209     * shows the {@see HistoryBrowserDialog} for a given {@see History}
    211      * 
     210     *
    212211     * @param h the history. Must not be null.
    213212     * @exception IllegalArgumentException thrown, if h is null
     
    225224    /**
    226225     * invoked after the asynchronous {@see HistoryLoadTask} is finished.
    227      * 
     226     *
    228227     * @param task the task which is calling back.
    229228     */
     
    261260    /**
    262261     * The table model with the history items
    263      * 
     262     *
    264263     */
    265264    class HistoryItemDataModel extends DefaultTableModel implements SelectionChangedListener{
     
    397396        }
    398397
    399         /**
    400          * update the title of the {@see PleaseWaitDialog} with information about
    401          * which primitive is currently loaded
    402          *
    403          * @param primitive the primitive to be loaded
    404          */
    405         protected void notifyStartLoadingHistory(final OsmPrimitive primitive) {
    406             SwingUtilities.invokeLater(
    407                     new Runnable() {
    408                         public void run() {
    409                             Main.pleaseWaitDlg.setTitle(
    410                                     tr("Loading history for {0} with id {1}",
    411                                             OsmPrimitiveType.from(primitive).getLocalizedDisplayNameSingular(),
    412                                             Long.toString(primitive.id)
    413                                     )
    414                             );
    415                         }
    416                     }
    417             );
    418         }
    419 
    420         /**
    421          * enables/disables interminate progress indication in the {@see PleaseWaitDialog}
    422          *
    423          * @param enabled true, if interminate progress indication is to enabled; false, otherwise
    424          */
    425         protected void setInterminateEnabled(final boolean enabled) {
    426             SwingUtilities.invokeLater(
    427                     new Runnable() {
    428                         public void run() {
    429                             Main.pleaseWaitDlg.setIndeterminate(enabled);
    430                         }
    431                     }
    432             );
    433         }
    434 
    435398        @Override
    436399        protected void realRun() throws SAXException, IOException, OsmTransferException {
    437400            Collection<OsmPrimitive> selection = Main.ds.getSelected();
    438401            Iterator<OsmPrimitive> it = selection.iterator();
    439             setInterminateEnabled(true);
    440402            try {
    441403                while(it.hasNext()) {
     
    447409                        continue;
    448410                    }
    449                     notifyStartLoadingHistory(primitive);
     411                    progressMonitor.indeterminateSubTask(tr("Loading history for {0} with id {1}",
     412                            OsmPrimitiveType.from(primitive).getLocalizedDisplayNameSingular(),
     413                            Long.toString(primitive.id)));
    450414                    OsmServerHistoryReader reader = null;
    451415                    HistoryDataSet ds = null;
    452416                    try {
    453417                        reader = new OsmServerHistoryReader(OsmPrimitiveType.from(primitive), primitive.id);
    454                         ds = reader.parseHistory();
     418                        ds = reader.parseHistory(progressMonitor.createSubTaskMonitor(1, false));
    455419                    } catch(OsmTransferException e) {
    456420                        if (cancelled)
     
    463427                lastException = e;
    464428                return;
    465             } finally {
    466                 setInterminateEnabled(false);
    467429            }
    468430        }
Note: See TracChangeset for help on using the changeset viewer.