Changeset 5354 in josm


Ignore:
Timestamp:
2012-07-20T18:14:54+02:00 (12 years ago)
Author:
akks
Message:

See #5984: Automatic pasting of IDs or URL into Download Object fields

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r5211 r5354  
    181181        dialog.configureContextsensitiveHelp("/Action/DownloadObject", true /* show help button */);
    182182        cbType.setSelectedIndex(Main.pref.getInteger("downloadprimitive.lasttype", 0));
     183        tfId.setType(cbType.getType());
     184        if (Main.pref.getBoolean("downloadprimitive.autopaste", true)) {
     185            tryToPasteFromClipboard(tfId, cbType);
     186        }
     187       
    183188        dialog.showDialog();
    184189        if (dialog.getValue() != 1) return;
     
    310315            .setContent(p, false);
    311316    }
     317
     318    private void tryToPasteFromClipboard(OsmIdTextField tfId, OsmPrimitiveTypesComboBox cbType) {
     319        String buf = Utils.getClipboardContent();
     320        if (buf.contains("node")) cbType.setSelectedIndex(0);
     321        if (buf.contains("way")) cbType.setSelectedIndex(1);
     322        if (buf.contains("relation")) cbType.setSelectedIndex(2);
     323        String[] res = buf.split("/");
     324        String txt;
     325        if (res.length>0) {
     326            txt = res[res.length-1];
     327            if (txt.isEmpty() && txt.length()>1) txt=res[res.length-2];
     328        } else {
     329            txt=buf;
     330        }
     331        tfId.setText(txt);
     332        tfId.clearTextIfInvalid();
     333    }
    312334}
  • trunk/src/org/openstreetmap/josm/gui/widgets/OsmIdTextField.java

    r5266 r5354  
    1414import org.openstreetmap.josm.data.osm.PrimitiveId;
    1515import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
     16import org.openstreetmap.josm.tools.Utils;
    1617
    1718/**
     
    4344
    4445    public void performValidation() {
     46        validator.validate();
     47    }
     48
     49    public void clearTextIfInvalid() {
     50        if (!validator.isValid())
     51            setText("");
    4552        validator.validate();
    4653    }
Note: See TracChangeset for help on using the changeset viewer.