Ignore:
Timestamp:
2010-02-14T13:07:03+01:00 (14 years ago)
Author:
Gubaer
Message:

fixed #4386: "There are unsolved conflicts in layer X" holds up any uploading from the layer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r2598 r2979  
    1818import org.openstreetmap.josm.data.APIDataSet;
    1919import org.openstreetmap.josm.data.conflict.ConflictCollection;
     20import org.openstreetmap.josm.gui.HelpAwareOptionPane;
     21import org.openstreetmap.josm.gui.help.HelpUtil;
    2022import org.openstreetmap.josm.gui.io.UploadDialog;
    2123import org.openstreetmap.josm.gui.io.UploadPrimitivesTask;
     
    101103    }
    102104
     105    protected void alertUnresolvedConflicts(OsmDataLayer layer) {
     106        HelpAwareOptionPane.showOptionDialog(
     107                Main.parent,
     108                tr("<html>The data to be uploaded participates in unresolved conflicts of layer ''{0}''.<br>"
     109                        + "You have to resolve them first.</html>", layer.getName()
     110                ),
     111                tr("Warning"),
     112                JOptionPane.WARNING_MESSAGE,
     113                HelpUtil.ht("/Action/Upload#PrimitivesParticipateInConflicts")
     114        );
     115    }
     116
     117    /**
     118     * Check whether the preconditions are met to upload data in <code>apiData</code>.
     119     * Makes sure primitives in <code>apiData</code> don't participate in conflicts and
     120     * runs the installed {@see UploadHook}s.
     121     *
     122     * @param layer the source layer of the data to be uploaded
     123     * @param apiData the data to be uploaded
     124     * @return true, if the preconditions are met; false, otherwise
     125     */
    103126    public boolean checkPreUploadConditions(OsmDataLayer layer, APIDataSet apiData) {
    104127        ConflictCollection conflicts = layer.getConflicts();
    105         if (conflicts !=null && !conflicts.isEmpty()) {
    106             JOptionPane.showMessageDialog(
    107                     Main.parent,
    108                     tr("<html>There are unresolved conflicts in layer ''{0}''.<br>"
    109                             + "You have to resolve them first.</html>", layer.getName()),
    110                             tr("Warning"),
    111                             JOptionPane.WARNING_MESSAGE
    112             );
     128        if (apiData.participatesInConflict(conflicts)) {
     129            alertUnresolvedConflicts(layer);
    113130            return false;
    114131        }
    115         // Call all upload hooks in sequence. The upload confirmation dialog
    116         // is one of these.
     132        // Call all upload hooks in sequence.
     133        // FIXME: this should become an asynchronous task
     134        //
    117135        for(UploadHook hook : uploadHooks)
    118136            if(!hook.checkUpload(apiData))
     
    122140    }
    123141
     142    /**
     143     * Uploads data to the OSM API.
     144     *
     145     * @param layer the source layer for the data to upload
     146     * @param apiData the primitives to be added, updated, or deleted
     147     */
    124148    public void uploadData(OsmDataLayer layer, APIDataSet apiData) {
    125149        if (apiData.isEmpty()) {
Note: See TracChangeset for help on using the changeset viewer.