Changeset 4497 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2011-10-07T21:50:14+02:00 (13 years ago)
Author:
simon04
Message:

fix #6542 - option to download relation without its members for "Download object" dialog

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

Legend:

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

    r4343 r4497  
    1010import java.awt.GridBagLayout;
    1111import java.awt.event.ActionEvent;
     12import java.awt.event.ActionListener;
    1213import java.awt.event.KeyEvent;
    1314import java.lang.reflect.InvocationTargetException;
     
    9495
    9596        JLabel lbl1 = new JLabel(tr("Object type:"));
    96         OsmPrimitiveTypesComboBox cbType = new OsmPrimitiveTypesComboBox();
     97        final OsmPrimitiveTypesComboBox cbType = new OsmPrimitiveTypesComboBox();
    9798        cbType.addItem(trc("osm object types", "mixed"));
    9899        cbType.setToolTipText(tr("Choose the OSM object type"));
     
    113114        layer.setToolTipText(tr("Select if the data should be downloaded into a new layer"));
    114115        layer.setSelected(Main.pref.getBoolean("download.newlayer"));
    115         JCheckBox referrers = new JCheckBox(tr("Download referrers"));
    116         referrers.setToolTipText(tr("Select if the referrers of the object should be downloaded as well"));
     116        final JCheckBox referrers = new JCheckBox(tr("Download referrers (parent relations)"));
     117        referrers.setToolTipText(tr("Select if the referrers of the object should be downloaded as well, i.e.,"
     118                + "parent relations and for nodes, additionally, parent ways"));
    117119        referrers.setSelected(Main.pref.getBoolean("downloadprimitive.referrers"));
     120        JCheckBox full = new JCheckBox(tr("Download relation members"));
     121        full.setToolTipText(tr("Select if the members of a relation should be downloaded as well"));
     122        full.setSelected(Main.pref.getBoolean("downloadprimitive.full", true));
    118123        HtmlPanel help = new HtmlPanel(tr("Object IDs can be separated by comma or space.<br/>"
    119124                + " Examples: <b><ul><li>1 2 5</li><li>1,2,5</li></ul><br/></b>"
     
    129134                .addComponent(cbId, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
    130135            .addComponent(referrers)
     136            .addComponent(full)
    131137            .addComponent(layer)
    132138            .addComponent(help)
    133139        );
     140
     141        cbType.addActionListener(new ActionListener() {
     142
     143            @Override
     144            public void actionPerformed(ActionEvent ae) {
     145                referrers.setText(cbType.getType() == OsmPrimitiveType.NODE
     146                        ? tr("Download referrers (parent relations and ways)")
     147                        : tr("Download referrers (parent relations)"));
     148            }
     149        });
    134150
    135151        layout.setHorizontalGroup(layout.createParallelGroup()
     
    144160                )
    145161            .addComponent(referrers)
     162            .addComponent(full)
    146163            .addComponent(layer)
    147164            .addComponent(help)
     
    165182        Main.pref.putInteger("downloadprimitive.lasttype", cbType.getSelectedIndex());
    166183        Main.pref.put("downloadprimitive.referrers", referrers.isSelected());
     184        Main.pref.put("downloadprimitive.full", full.isSelected());
    167185        Main.pref.put("download.newlayer", layer.isSelected());
    168186
     
    179197        }
    180198        remindPrimitivesHistory(cbId);
    181         processItems(layer.isSelected(), tfId.getIds(), referrers.isSelected());
    182     }
    183 
    184     void processItems(boolean newLayer, final List<PrimitiveId> ids, boolean downloadReferrers) {
     199        processItems(layer.isSelected(), tfId.getIds(), referrers.isSelected(), full.isSelected());
     200    }
     201
     202    void processItems(boolean newLayer, final List<PrimitiveId> ids, boolean downloadReferrers, boolean full) {
    185203        OsmDataLayer layer = getEditLayer();
    186204        if ((layer == null) || newLayer) {
     
    188206            Main.main.addLayer(layer);
    189207        }
    190         final DownloadPrimitivesTask task = new DownloadPrimitivesTask(layer, ids);
     208        final DownloadPrimitivesTask task = new DownloadPrimitivesTask(layer, ids, full);
    191209        Main.worker.submit(task);
    192210
  • trunk/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesTask.java

    r4191 r4497  
    3939
    4040    private OsmDataLayer layer;
     41    private boolean fullRelation;
    4142    private MultiFetchServerObjectReader multiObjectReader;
    4243    private OsmServerObjectReader objectReader;
     
    4849     * @param toUpdate a collection of primitives to update from the server. Set to
    4950     * the empty collection if null.
     51     * @param fullRelation true if a full download is required, i.e.,
     52     * a download including the immediate children of a relation.
    5053     * @throws IllegalArgumentException thrown if layer is null.
    5154     */
    52     public DownloadPrimitivesTask(OsmDataLayer layer, List<PrimitiveId>  ids) throws IllegalArgumentException {
     55    public DownloadPrimitivesTask(OsmDataLayer layer, List<PrimitiveId>  ids, boolean fullRelation) throws IllegalArgumentException {
    5356        super(tr("Download objects"), false /* don't ignore exception */);
    5457        ensureParameterNotNull(layer, "layer");
    5558        this.ids = ids;
    5659        this.layer = layer;
     60        this.fullRelation = fullRelation;
    5761    }
    5862
     
    145149                    synchronized(this) {
    146150                        if (canceled) return;
    147                         objectReader = new OsmServerObjectReader(r.getId(), OsmPrimitiveType.RELATION, true /* full */);
     151                        objectReader = new OsmServerObjectReader(r.getId(), OsmPrimitiveType.RELATION, fullRelation);
    148152                    }
    149153                    theirDataSet = objectReader.parseOsm(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
Note: See TracChangeset for help on using the changeset viewer.