Ticket #6542: 6542.patch

File 6542.patch, 7.0 KB (added by simon04, 13 years ago)
  • src/org/openstreetmap/josm/actions/DownloadPrimitiveAction.java

    diff --git a/src/org/openstreetmap/josm/actions/DownloadPrimitiveAction.java b/src/org/openstreetmap/josm/actions/DownloadPrimitiveAction.java
    index b6af62e..c2abb91 100644
    a b import static org.openstreetmap.josm.tools.I18n.trn;  
    99import java.awt.Font;
    1010import java.awt.GridBagLayout;
    1111import java.awt.event.ActionEvent;
     12import java.awt.event.ActionListener;
    1213import java.awt.event.KeyEvent;
    1314import java.lang.reflect.InvocationTargetException;
    1415import java.util.Collections;
    public class DownloadPrimitiveAction extends JosmAction {  
    9394        layout.setAutoCreateContainerGaps(true);
    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"));
    99100        JLabel lbl2 = new JLabel(tr("Object ID:"));
    public class DownloadPrimitiveAction extends JosmAction {  
    112113        JCheckBox layer = new JCheckBox(tr("Separate Layer"));
    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>"
    120125                + " In mixed mode, specify objects like this: <b>w123, n110, w12, r15</b><br/>"));
    public class DownloadPrimitiveAction extends JosmAction {  
    128133                .addComponent(lbl2)
    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        );
    134140
     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        });
     150
    135151        layout.setHorizontalGroup(layout.createParallelGroup()
    136152            .addGroup(layout.createSequentialGroup()
    137153                .addGroup(layout.createParallelGroup()
    public class DownloadPrimitiveAction extends JosmAction {  
    143159                    .addComponent(cbId))
    144160                )
    145161            .addComponent(referrers)
     162            .addComponent(full)
    146163            .addComponent(layer)
    147164            .addComponent(help)
    148165        );
    public class DownloadPrimitiveAction extends JosmAction {  
    178195            return;
    179196        }
    180197        remindPrimitivesHistory(cbId);
    181         processItems(layer.isSelected(), tfId.getIds(), referrers.isSelected());
     198        processItems(layer.isSelected(), tfId.getIds(), referrers.isSelected(), full.isSelected());
    182199    }
    183200
    184     void processItems(boolean newLayer, final List<PrimitiveId> ids, boolean downloadReferrers) {
     201    void processItems(boolean newLayer, final List<PrimitiveId> ids, boolean downloadReferrers, boolean full) {
    185202        OsmDataLayer layer = getEditLayer();
    186203        if ((layer == null) || newLayer) {
    187204            layer = new OsmDataLayer(new DataSet(), OsmDataLayer.createNewName(), null);
    188205            Main.main.addLayer(layer);
    189206        }
    190         final DownloadPrimitivesTask task = new DownloadPrimitivesTask(layer, ids);
     207        final DownloadPrimitivesTask task = new DownloadPrimitivesTask(layer, ids, full);
    191208        Main.worker.submit(task);
    192209
    193210        if (downloadReferrers) {
  • src/org/openstreetmap/josm/gui/io/DownloadPrimitivesTask.java

    diff --git a/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesTask.java b/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesTask.java
    index 2cd6764..c1433d6 100644
    a b public class DownloadPrimitivesTask extends PleaseWaitRunnable {  
    3838    private Set<PrimitiveId> missingPrimitives;
    3939
    4040    private OsmDataLayer layer;
     41    private boolean fullRelation;
    4142    private MultiFetchServerObjectReader multiObjectReader;
    4243    private OsmServerObjectReader objectReader;
    4344
    public class DownloadPrimitivesTask extends PleaseWaitRunnable {  
    4748     * @param layer the layer in which primitives are updated. Must not be null.
    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
    5963    @Override
    public class DownloadPrimitivesTask extends PleaseWaitRunnable {  
    144148                if (r.hasIncompleteMembers()) {
    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));
    150154                    synchronized (this) {