Changeset 8194 in josm


Ignore:
Timestamp:
2015-04-14T23:10:19+02:00 (10 years ago)
Author:
simon04
Message:

Download objects: prefill ids from copied objects

The syntax from CopyAction is e.g. node 123 and has not been parsed yet.

Location:
trunk
Files:
1 added
3 edited

Legend:

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

    r6920 r8194  
    5757    public static void copy(OsmDataLayer source, Collection<OsmPrimitive> primitives) {
    5858        /* copy ids to the clipboard */
     59        String ids = getCopyString(primitives);
     60        Utils.copyToClipboard(ids);
     61
     62        Main.pasteBuffer.makeCopy(primitives);
     63        Main.pasteSource = source;
     64    }
     65
     66    public static String getCopyString(Collection<? extends OsmPrimitive> primitives) {
    5967        StringBuilder idsBuilder = new StringBuilder();
    6068        for (OsmPrimitive p : primitives) {
     
    6270            idsBuilder.append(p.getId()).append(",");
    6371        }
    64         String ids = idsBuilder.substring(0, idsBuilder.length() - 1);
    65         Utils.copyToClipboard(ids);
    66 
    67         Main.pasteBuffer.makeCopy(primitives);
    68         Main.pasteSource = source;
     72        return idsBuilder.substring(0, idsBuilder.length() - 1);
    6973    }
    7074
  • trunk/src/org/openstreetmap/josm/data/osm/SimplePrimitiveId.java

    r7005 r8194  
    1212    private final OsmPrimitiveType type;
    1313
    14     public static final Pattern ID_PATTERN = Pattern.compile("((n(ode)?|w(ay)?|r(el(ation)?)?)/?)(\\d+)");
     14    public static final Pattern ID_PATTERN = Pattern.compile("((n(ode)?|w(ay)?|r(el(ation)?)?)[ /]?)(\\d+)");
    1515
    1616    public SimplePrimitiveId(long id, OsmPrimitiveType type) {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/SimplePrimitiveIdTest.groovy

    r7938 r8194  
    2828        assert SimplePrimitiveId.fuzzyParse("foo relation/123 and way/345 but also node/789").toString() == "[relation 123, way 345, node 789]"
    2929    }
     30
     31    void testFromCopyAction() {
     32        assert SimplePrimitiveId.fromString("node 123") == new SimplePrimitiveId(123, OsmPrimitiveType.NODE)
     33        assert SimplePrimitiveId.fromString("way 123") == new SimplePrimitiveId(123, OsmPrimitiveType.WAY)
     34        assert SimplePrimitiveId.fromString("relation 123") == new SimplePrimitiveId(123, OsmPrimitiveType.RELATION)
     35    }
    3036}
Note: See TracChangeset for help on using the changeset viewer.