Changeset 6546 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2013-12-27T15:03:59+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r6535 r6546 51 51 import org.openstreetmap.josm.actions.downloadtasks.DownloadTask; 52 52 import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler; 53 import org.openstreetmap.josm.actions.mapmode.DrawAction; 53 54 import org.openstreetmap.josm.actions.mapmode.MapMode; 54 55 import org.openstreetmap.josm.actions.search.SearchAction; … … 60 61 import org.openstreetmap.josm.data.coor.LatLon; 61 62 import org.openstreetmap.josm.data.osm.DataSet; 63 import org.openstreetmap.josm.data.osm.OsmPrimitive; 62 64 import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy; 63 65 import org.openstreetmap.josm.data.projection.Projection; … … 591 593 return getEditLayer().data; 592 594 } 595 596 /** 597 * Replies the current selected primitives, from a end-user point of view. 598 * It is not always technically the same collection of primitives than {@link DataSet#getSelected()}. 599 * Indeed, if the user is currently in drawing mode, only the way currently being drawn is returned, 600 * see {@link DrawAction#getInProgressSelection()}. 601 * 602 * @return The current selected primitives, from a end-user point of view. Can be {@code null}. 603 * @since 6546 604 */ 605 public Collection<OsmPrimitive> getInProgressSelection() { 606 if (map != null && map.mapMode instanceof DrawAction) { 607 return ((DrawAction) map.mapMode).getInProgressSelection(); 608 } else { 609 DataSet ds = getCurrentDataSet(); 610 if (ds == null) return null; 611 return ds.getSelected(); 612 } 613 } 593 614 594 615 /** -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r6542 r6546 186 186 needsRepaint = true; 187 187 } else if (!alt && continueFrom != null && !continueFrom.isSelected()) { 188 addRemoveSelection(currentDataSet, continueFrom, currentBaseNode);188 currentDataSet.addSelected(continueFrom); 189 189 needsRepaint = true; 190 190 } … … 1256 1256 * 1257 1257 * While drawing a way, technically the last node is selected. 1258 * This is inconvenient when the user tries to add tags to the1259 * way using a keyboard shortcut. In that case, this method returns1260 * t he current way as selection, to work around this issue.1258 * This is inconvenient when the user tries to add/edit tags to the way. 1259 * For this case, this method returns the current way as selection, 1260 * to work around this issue. 1261 1261 * Otherwise the normal selection of the current data layer is returned. 1262 1262 */ … … 1266 1266 if (currentBaseNode != null && !ds.getSelected().isEmpty()) { 1267 1267 Way continueFrom = getWayForNode(currentBaseNode); 1268 if ( alt &&continueFrom != null)1268 if (continueFrom != null) 1269 1269 return Collections.<OsmPrimitive>singleton(continueFrom); 1270 1270 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r6507 r6546 942 942 943 943 /** 944 * Determine pr mitive to be selected and build cycleList944 * Determine primitive to be selected and build cycleList 945 945 * @param nearest primitive found by simple method 946 946 * @param p point where user clicked -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r6365 r6546 212 212 @Override public Collection<OsmPrimitive> getSelection() { 213 213 if (Main.main == null) return null; 214 if (Main.main.getCurrentDataSet() == null) return null; 215 return Main.main.getCurrentDataSet().getSelected(); 214 return Main.main.getInProgressSelection(); 216 215 } 217 216 }; … … 499 498 */ 500 499 private void updateSelection() { 501 if (Main.main.getCurrentDataSet() == null) { 502 selectionChanged(Collections.<OsmPrimitive>emptyList()); 503 } else { 504 selectionChanged(Main.main.getCurrentDataSet().getSelected()); 505 } 500 // Parameter is ignored in this class 501 selectionChanged(null); 506 502 } 507 503 … … 535 531 super.setVisible(b); 536 532 if (b && Main.main.getCurrentDataSet() != null) { 537 selectionChanged(Main.main.getCurrentDataSet().getSelected());533 updateSelection(); 538 534 } 539 535 } … … 560 556 if (tagTable.getCellEditor() != null) { 561 557 tagTable.getCellEditor().cancelCellEditing(); 558 } 559 560 // Discard parameter as we do not want to operate always on real selection here, especially in draw mode 561 newSelection = Main.main.getInProgressSelection(); 562 if (newSelection == null) { 563 newSelection = Collections.<OsmPrimitive>emptyList(); 562 564 } 563 565 … … 875 877 } 876 878 877 Collection<OsmPrimitive> sel = Main.main.get CurrentDataSet().getSelected();879 Collection<OsmPrimitive> sel = Main.main.getInProgressSelection(); 878 880 Main.main.undoRedo.add(new ChangePropertyCommand(sel, tags)); 879 881 … … 905 907 906 908 Relation rel = new Relation(cur); 907 Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); 908 for (OsmPrimitive primitive: sel) { 909 for (OsmPrimitive primitive: Main.main.getInProgressSelection()) { 909 910 rel.removeMembersFor(primitive); 910 911 } … … 1108 1109 return; 1109 1110 String key = tagData.getValueAt(tagTable.getSelectedRow(), 0).toString(); 1110 Collection<OsmPrimitive> sel = Main.main.get CurrentDataSet().getSelected();1111 Collection<OsmPrimitive> sel = Main.main.getInProgressSelection(); 1111 1112 String clipboard = Utils.getClipboardContent(); 1112 1113 if (sel.isEmpty() || clipboard == null) … … 1124 1125 int[] rows = tagTable.getSelectedRows(); 1125 1126 Set<String> values = new TreeSet<String>(); 1126 Collection<OsmPrimitive> sel = Main.main.get CurrentDataSet().getSelected();1127 Collection<OsmPrimitive> sel = Main.main.getInProgressSelection(); 1127 1128 if (rows.length == 0 || sel.isEmpty()) return; 1128 1129 … … 1208 1209 return; 1209 1210 String key = tagData.getValueAt(tagTable.getSelectedRow(), 0).toString(); 1210 Collection<OsmPrimitive> sel = Main.main.get CurrentDataSet().getSelected();1211 Collection<OsmPrimitive> sel = Main.main.getInProgressSelection(); 1211 1212 if (sel.isEmpty()) 1212 1213 return; … … 1243 1244 if ("display.discardable-keys".equals(e.getKey()) && Main.main.getCurrentDataSet() != null) { 1244 1245 // Re-load data when display preference change 1245 selectionChanged(Main.main.getCurrentDataSet().getSelected());1246 updateSelection(); 1246 1247 } 1247 1248 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r6403 r6546 57 57 import org.openstreetmap.josm.Main; 58 58 import org.openstreetmap.josm.actions.JosmAction; 59 import org.openstreetmap.josm.actions.mapmode.DrawAction;60 59 import org.openstreetmap.josm.command.ChangePropertyCommand; 61 60 import org.openstreetmap.josm.command.Command; 62 61 import org.openstreetmap.josm.command.SequenceCommand; 63 import org.openstreetmap.josm.data.osm.DataSet;64 62 import org.openstreetmap.josm.data.osm.OsmPrimitive; 65 63 import org.openstreetmap.josm.data.osm.Tag; … … 105 103 public static final int MAX_LRU_TAGS_NUMBER = 30; 106 104 107 // LRU cache for recently added tags (http://java-planet.blogspot.com/2005/08/how-to-set-up-simple-lru-cache-using.html) 105 // LRU cache for recently added tags (http://java-planet.blogspot.com/2005/08/how-to-set-up-simple-lru-cache-using.html) 108 106 private final Map<Tag, Void> recentTags = new LinkedHashMap<Tag, Void>(MAX_LRU_TAGS_NUMBER+1, 1.1f, true) { 109 107 @Override … … 124 122 public void addTag() { 125 123 changedKey = null; 126 if (Main.map.mapMode instanceof DrawAction) { 127 sel = ((DrawAction) Main.map.mapMode).getInProgressSelection(); 128 } else { 129 DataSet ds = Main.main.getCurrentDataSet(); 130 if (ds == null) return; 131 sel = ds.getSelected(); 132 } 133 if (sel.isEmpty()) return; 134 135 final AddTagsDialog addDialog = new AddTagsDialog(); 124 sel = Main.main.getInProgressSelection(); 125 if (sel == null || sel.isEmpty()) return; 126 127 final AddTagsDialog addDialog = new AddTagsDialog(); 136 128 137 129 addDialog.showDialog(); 138 130 139 131 addDialog.destroyActions(); 140 if (addDialog.getValue() == 1) 132 if (addDialog.getValue() == 1) 141 133 addDialog.performTagAdding(); 142 else 134 else 143 135 addDialog.undoAllTagsAdding(); 144 136 } … … 152 144 public void editTag(final int row, boolean focusOnKey) { 153 145 changedKey = null; 154 sel = Main.main.get CurrentDataSet().getSelected();155 if (sel .isEmpty()) return;146 sel = Main.main.getInProgressSelection(); 147 if (sel == null || sel.isEmpty()) return; 156 148 157 149 String key = tagData.getValueAt(row, 0).toString(); … … 159 151 160 152 @SuppressWarnings("unchecked") 161 final EditTagDialog editDialog = new EditTagDialog(key, row, 153 final EditTagDialog editDialog = new EditTagDialog(key, row, 162 154 (Map<String, Integer>) tagData.getValueAt(row, 1), focusOnKey); 163 155 editDialog.showDialog(); … … 290 282 keys.setSelectedItem(key); 291 283 292 p.add(Box.createVerticalStrut(5),GBC.eol()); 284 p.add(Box.createVerticalStrut(5),GBC.eol()); 293 285 p.add(new JLabel(tr("Key")), GBC.std()); 294 286 p.add(Box.createHorizontalStrut(10), GBC.std()); … … 307 299 values.setSelectedItem(selection); 308 300 values.getEditor().setItem(selection); 309 p.add(Box.createVerticalStrut(5),GBC.eol()); 301 p.add(Box.createVerticalStrut(5),GBC.eol()); 310 302 p.add(new JLabel(tr("Value")), GBC.std()); 311 303 p.add(Box.createHorizontalStrut(10), GBC.std()); … … 629 621 630 622 private void suggestRecentlyAddedTags(JPanel mainPanel, int tagsToShow, final FocusAdapter focus) { 631 if (!(tagsToShow > 0 && !recentTags.isEmpty())) 623 if (!(tagsToShow > 0 && !recentTags.isEmpty())) 632 624 return; 633 625 … … 649 641 public void actionPerformed(ActionEvent e) { 650 642 keys.setSelectedItem(t.getKey()); 651 // Update list of values (fix #7951) 643 // Update list of values (fix #7951) 652 644 // fix #8298 - update list of values before setting value (?) 653 645 focus.focusGained(null); … … 691 683 final String color = action.isEnabled() ? "" : "; color:gray"; 692 684 final JLabel tagLabel = new JLabel("<html>" 693 + "<style>td{border:1px solid gray; font-weight:normal"+color+"}</style>" 685 + "<style>td{border:1px solid gray; font-weight:normal"+color+"}</style>" 694 686 + "<table><tr><td>" + XmlWriter.encode(t.toString(), true) + "</td></tr></table></html>"); 695 687 if (action.isEnabled()) {
Note:
See TracChangeset
for help on using the changeset viewer.