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


Ignore:
Timestamp:
2013-03-24T08:30:57+01:00 (11 years ago)
Author:
akks
Message:

Properties toggle dialog: allow to select and copy/delete multiple keys/values, see #7846
fix #6917, fix #7895 - select multiple "member of" (fixed one non-working action in previous revision)

File:
1 edited

Legend:

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

    r5799 r5800  
    395395                }
    396396                selectRelationAction.setRelations(rels);
    397                 addMembersToSelectionAction.setRelations(rels);
     397                addRelationToSelectionAction.setRelations(rels);
    398398                addMembersToSelectionAction.setRelations(rels);
    399399                downloadSelectedIncompleteMembersAction.setRelations(rels);
     
    422422                Point p = evt.getPoint();
    423423                int row = propertyTable.rowAtPoint(p);
    424                 if (row > -1) {
     424                int selectedCount = propertyTable.getSelectedRowCount();
     425                // if nothing or one row is selected, select row under mouse instead
     426                if (selectedCount<2 && row>-1) {
    425427                    propertyTable.changeSelection(row, 0, false, false);
     428                }
     429                if (selectedCount>=2 || row>-1) {
    426430                    propertyMenu.show(propertyTable, p.x, p.y-3);
    427431                }
     
    554558        }
    555559
    556         String selectedTag = null;
     560        String selectedTag;
    557561        Relation selectedRelation = null;
    558562        selectedTag = editHelper.getChangedKey(); // select last added or last edited key by default
     
    624628        List<Relation> sortedRelations = new ArrayList<Relation>(roles.keySet());
    625629        Collections.sort(sortedRelations, new Comparator<Relation>() {
    626             public int compare(Relation o1, Relation o2) {
     630            @Override public int compare(Relation o1, Relation o2) {
    627631                int comp = Boolean.valueOf(o1.isDisabledAndHidden()).compareTo(o2.isDisabledAndHidden());
    628632                if (comp == 0) {
     
    11211125        @Override
    11221126        public void actionPerformed(ActionEvent ae) {
    1123             if (propertyTable.getSelectedRowCount() != 1)
    1124                 return;
    1125             String key = propertyData.getValueAt(propertyTable.getSelectedRow(), 0).toString();
     1127            int rows[] = propertyTable.getSelectedRows();
     1128            Set<String> values = new TreeSet<String>();
    11261129            Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected();
    1127             if (sel.isEmpty())
    1128                 return;
    1129             Set<String> values = new TreeSet<String>();
    1130             for (OsmPrimitive p : sel) {
    1131                 Collection<String> s = getString(p,key);
    1132                 if (s != null) {
    1133                     values.addAll(s);
    1134                 }
    1135             }
    1136             Utils.copyToClipboard(Utils.join("\n", values));
     1130            if (rows.length == 0 || sel.isEmpty()) return;
     1131
     1132            for (int row: rows) {
     1133                String key = propertyData.getValueAt(row, 0).toString();
     1134                if (sel.isEmpty())
     1135                    return;
     1136                for (OsmPrimitive p : sel) {
     1137                    Collection<String> s = getString(p,key);
     1138                    if (s != null) {
     1139                        values.addAll(s);
     1140                    }
     1141                }
     1142            }
     1143            if (!values.isEmpty()) {
     1144                Utils.copyToClipboard(Utils.join("\n", values));
     1145            }
    11371146        }
    11381147    }
Note: See TracChangeset for help on using the changeset viewer.