Changeset 4106 in josm for trunk/src/org


Ignore:
Timestamp:
2011-06-01T20:23:46+02:00 (13 years ago)
Author:
stoecker
Message:

fix #6410 - patch by bilbo - add two additional entries to popup dialog for relation entries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r4102 r4106  
    2727import java.util.Comparator;
    2828import java.util.HashMap;
     29import java.util.HashSet;
    2930import java.util.Iterator;
    3031import java.util.List;
     
    3334import java.util.TreeMap;
    3435import java.util.Vector;
     36import java.util.Set;
    3537
    3638import javax.swing.AbstractAction;
     
    8183import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
    8284import org.openstreetmap.josm.gui.dialogs.properties.PresetListPanel.PresetHandler;
     85import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask;
    8386import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor;
    8487import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    606609                    menu.add(new SelectRelationAction(relation, true));
    607610                    menu.add(new SelectRelationAction(relation, false));
     611                    menu.add(new SelectRelationMembersAction(relation));
     612                    menu.add(new DownloadIncompleteMembersAction(relation));
    608613                    menu.addSeparator();
    609614                    menu.add(helpAction);
     
    11831188        }
    11841189    }
     1190
     1191
     1192    /**
     1193     * Sets the current selection to the members of selected relation
     1194     *
     1195     */
     1196    class SelectRelationMembersAction extends AbstractAction {
     1197        Relation relation;
     1198        public SelectRelationMembersAction(Relation r) {
     1199            relation = r;
     1200            putValue(SHORT_DESCRIPTION,tr("Select the members of selected relation"));
     1201            putValue(SMALL_ICON, ImageProvider.get("selectall"));
     1202            putValue(NAME, tr("Select members"));
     1203        }
     1204
     1205        public void actionPerformed(ActionEvent e) {
     1206            HashSet<OsmPrimitive> members = new HashSet<OsmPrimitive>();
     1207            members.addAll(relation.getMemberPrimitives());
     1208            Main.map.mapView.getEditLayer().data.setSelected(members);
     1209        }
     1210
     1211    }
     1212
     1213    /**
     1214     * Action for downloading incomplete members of selected relation
     1215     *
     1216     */
     1217    class DownloadIncompleteMembersAction extends AbstractAction {
     1218        Relation relation;
     1219        public DownloadIncompleteMembersAction(Relation r) {
     1220            relation = r;
     1221            putValue(SHORT_DESCRIPTION, tr("Download incomplete members of selected relations"));
     1222            putValue(SMALL_ICON, ImageProvider.get("dialogs/relation", "downloadincompleteselected"));
     1223            putValue(NAME, tr("Download incomplete members"));
     1224        }
     1225
     1226        public Set<OsmPrimitive> buildSetOfIncompleteMembers(Relation r) {
     1227            Set<OsmPrimitive> ret = new HashSet<OsmPrimitive>();
     1228            ret.addAll(r.getIncompleteMembers());
     1229            return ret;
     1230        }
     1231
     1232        public void actionPerformed(ActionEvent e) {
     1233            if (!relation.hasIncompleteMembers()) return;
     1234            ArrayList<Relation> rels = new ArrayList<Relation>();
     1235            rels.add(relation);
     1236            Main.worker.submit(new DownloadRelationMemberTask(
     1237                    rels,
     1238                    buildSetOfIncompleteMembers(relation),
     1239                    Main.map.mapView.getEditLayer()
     1240            ));
     1241        }
     1242    }
     1243
     1244
    11851245}
Note: See TracChangeset for help on using the changeset viewer.