Ignore:
Timestamp:
08.09.2009 22:56:02 (3 years ago)
Author:
Gubaer
Message:

fixed #3393: loooong delay when using presets with a large osm file - further improvement; next step could be to turn UploadHooks into an asynchronous task; ApiPreconditionChecker loops over all keys in all upload primitives!
fixed #3435: Switching the changeset type deletes any changeset tags that have been set
fixed #3430: Entering comment=* manually in the changeset tags dialog gets ignored
fixed #3431: Upload dialog pops up again if no comment is provided
fixed #3429: created_by=* includes the wrong language when uploading from a new layer

File:
1 edited

Legend:

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

    r2035 r2081  
    44 
    55import java.util.Collection; 
    6 import java.util.LinkedList; 
    7 import java.util.List; 
     6import java.util.Collections; 
    87import java.util.Map.Entry; 
    98 
     
    1211import org.openstreetmap.josm.Main; 
    1312import org.openstreetmap.josm.actions.UploadAction.UploadHook; 
     13import org.openstreetmap.josm.data.APIDataSet; 
    1414import org.openstreetmap.josm.data.osm.OsmPrimitive; 
    1515import org.openstreetmap.josm.data.osm.Way; 
     
    2121public class ApiPreconditionChecker implements UploadHook { 
    2222 
    23     public boolean checkUpload(Collection<OsmPrimitive> add, Collection<OsmPrimitive> update, 
    24             Collection<OsmPrimitive> delete) { 
     23    public boolean checkUpload(APIDataSet apiData) { 
    2524        OsmApi api = OsmApi.getOsmApi(); 
    2625        try { 
     
    3635 
    3736            if (maxNodes > 0) { 
    38                 if( !checkMaxNodes(add, maxNodes)) 
     37                if( !checkMaxNodes(apiData.getPrimitivesToAdd(), maxNodes)) 
    3938                    return false; 
    40                 if( !checkMaxNodes(update, maxNodes)) 
     39                if( !checkMaxNodes(apiData.getPrimitivesToUpdate(), maxNodes)) 
    4140                    return false; 
    42                 if( !checkMaxNodes(delete, maxNodes)) 
     41                if( !checkMaxNodes(apiData.getPrimitivesToDelete(), maxNodes)) 
    4342                    return false; 
    4443            } 
     
    4645            if (maxElements  > 0) { 
    4746                int total = 0; 
    48                 total = add.size() + update.size() + delete.size(); 
     47                total = apiData.getPrimitivesToAdd().size() + apiData.getPrimitivesToUpdate().size() + apiData.getPrimitivesToDelete().size(); 
    4948                if(total > maxElements) { 
    5049                    JOptionPane.showMessageDialog( 
     
    6766    } 
    6867 
    69     private boolean checkMaxNodes(Collection<OsmPrimitive> add, long maxNodes) { 
    70         for (OsmPrimitive osmPrimitive : add) { 
     68    private boolean checkMaxNodes(Collection<OsmPrimitive> primitives, long maxNodes) { 
     69        for (OsmPrimitive osmPrimitive : primitives) { 
    7170            for (Entry<String,String> e : osmPrimitive.entrySet()) { 
    7271                if(e.getValue().length() > 255) { 
     
    9089                            JOptionPane.ERROR_MESSAGE 
    9190                    ); 
    92                     List<OsmPrimitive> newNodes = new LinkedList<OsmPrimitive>(); 
    93                     newNodes.add(osmPrimitive); 
    94                     Main.main.getCurrentDataSet().setSelected(newNodes); 
     91                    Main.main.getCurrentDataSet().setSelected(Collections.singleton(osmPrimitive)); 
    9592                    return false; 
    9693                } 
     
    109106                        JOptionPane.ERROR_MESSAGE 
    110107                ); 
    111                 List<OsmPrimitive> newNodes = new LinkedList<OsmPrimitive>(); 
    112                 newNodes.add(osmPrimitive); 
    113  
    114                 Main.main.getCurrentDataSet().setSelected(newNodes); 
     108                Main.main.getCurrentDataSet().setSelected(Collections.singleton(osmPrimitive)); 
    115109                return false; 
    116110            } 
Note: See TracChangeset for help on using the changeset viewer.