Changeset 4604 in josm for trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
- Timestamp:
- 2011-11-21T22:16:25+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r4536 r4604 32 32 import java.util.LinkedList; 33 33 import java.util.List; 34 import java.util.Map; 34 35 import java.util.Map.Entry; 35 import java.util.Map;36 36 import java.util.Set; 37 37 import java.util.TreeMap; … … 67 67 import org.openstreetmap.josm.Main; 68 68 import org.openstreetmap.josm.actions.JosmAction; 69 import org.openstreetmap.josm.actions.search.SearchAction.SearchMode; 70 import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting; 69 71 import org.openstreetmap.josm.command.ChangeCommand; 70 72 import org.openstreetmap.josm.command.ChangePropertyCommand; … … 72 74 import org.openstreetmap.josm.command.SequenceCommand; 73 75 import org.openstreetmap.josm.data.SelectionChangedListener; 76 import org.openstreetmap.josm.data.osm.DataSet; 74 77 import org.openstreetmap.josm.data.osm.IRelation; 75 78 import org.openstreetmap.josm.data.osm.Node; … … 105 108 import org.openstreetmap.josm.tools.Shortcut; 106 109 import org.openstreetmap.josm.tools.Utils; 107 import org.openstreetmap.josm.actions.search.SearchAction.SearchMode;108 import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting;109 110 110 111 /** … … 170 171 // button in the upper right corner of this dialog 171 172 public static JPanel pluginHook = new JPanel(); 172 173 173 174 private JPopupMenu propertyMenu; 174 175 private JPopupMenu membershipMenu; … … 338 339 ed.setButtonIcons(new String[]{"purge", "cancel"}); 339 340 ed.setContent(tr("You changed the key from ''{0}'' to ''{1}''.\n" 340 + "The new key is already used, overwrite values?", key, newkey));341 + "The new key is already used, overwrite values?", key, newkey)); 341 342 ed.setCancelButton(2); 342 343 ed.toggleEnable("overwriteEditKey"); 343 344 ed.showDialog(); 344 345 345 if (ed.getValue() != 1) {346 if (ed.getValue() != 1) 346 347 return; 347 }348 348 break; 349 349 } … … 389 389 390 390 /** 391 * For a given key k, return a list of keys which are used as keys for 391 * For a given key k, return a list of keys which are used as keys for 392 392 * auto-completing values to increase the search space. 393 393 * @param key the key k … … 395 395 */ 396 396 static List<String> getAutocompletionKeys(String key) { 397 if ("name".equals(key) || "addr:street".equals(key)) {397 if ("name".equals(key) || "addr:street".equals(key)) 398 398 return Arrays.asList("addr:street", "name"); 399 } else {399 else 400 400 return Arrays.asList(key); 401 }402 401 } 403 402 … … 424 423 */ 425 424 void add() { 426 Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); 425 DataSet ds = Main.main.getCurrentDataSet(); 426 if (ds == null) return; 427 Collection<OsmPrimitive> sel = ds.getSelected(); 427 428 if (sel.isEmpty()) return; 428 429 … … 435 436 List<AutoCompletionListItem> keyList = autocomplete.getKeys(); 436 437 437 AutoCompletionListItem itemToSelect = null; 438 AutoCompletionListItem itemToSelect = null; 438 439 // remove the object's tag keys from the list 439 440 Iterator<AutoCompletionListItem> iter = keyList.iterator(); … … 445 446 for (int i = 0; i < propertyData.getRowCount(); ++i) { 446 447 if (item.getValue().equals(propertyData.getValueAt(i, 0))) { 447 if (itemToSelect == item) 448 if (itemToSelect == item) { 448 449 itemToSelect = null; 450 } 449 451 iter.remove(); 450 452 break; … … 468 470 keys.setSelectedItem(itemToSelect); 469 471 /* don't add single chars, as they are no properly selected */ 470 if(lastAddValue != null && lastAddValue.length() > 1) 472 if(lastAddValue != null && lastAddValue.length() > 1) { 471 473 values.setSelectedItem(lastAddValue); 474 } 472 475 } 473 476 … … 506 509 // get the combo box' editor component 507 510 JTextComponent editor = (JTextComponent)values.getEditor() 508 .getEditorComponent();511 .getEditorComponent(); 509 512 // Refresh the values model when focus is gained 510 513 FocusAdapter focus = new FocusAdapter() { … … 632 635 propertyMenu.addSeparator(); 633 636 propertyMenu.add(helpAction); 634 637 635 638 propertyData.setColumnIdentifiers(new String[]{tr("Key"),tr("Value")}); 636 639 propertyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); … … 813 816 getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( 814 817 KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),"delete" 815 );818 ); 816 819 getActionMap().put("delete", deleteAction); 817 820 818 821 JScrollPane scrollPane = (JScrollPane) createLayout(bothTables, true, Arrays.asList(new SideButton[] { 819 this.btnAdd, this.btnEdit, this.btnDel822 this.btnAdd, this.btnEdit, this.btnDel 820 823 })); 821 824 … … 962 965 return comp; 963 966 }} 964 );967 ); 965 968 966 969 for (Relation r: sortedRelations) { … … 1027 1030 super(tr("Delete"), "dialogs/delete", tr("Delete the selected key in all objects"), 1028 1031 Shortcut.registerShortcut("properties:delete", tr("Delete Properties"), KeyEvent.VK_D, 1029 Shortcut.GROUP_MNEMONIC), false);1032 Shortcut.GROUP_MNEMONIC), false); 1030 1033 updateEnabledState(); 1031 1034 } … … 1098 1101 (propertyTable != null && propertyTable.getSelectedRowCount() == 1) 1099 1102 ^ (membershipTable != null && membershipTable.getSelectedRowCount() == 1) 1100 );1103 ); 1101 1104 } 1102 1105 … … 1111 1114 super(tr("Add"), "dialogs/add", tr("Add a new key/value pair to all objects"), 1112 1115 Shortcut.registerShortcut("properties:add", tr("Add Property"), KeyEvent.VK_A, 1113 Shortcut.GROUP_MNEMONIC), false);1116 Shortcut.GROUP_MNEMONIC), false); 1114 1117 } 1115 1118 … … 1124 1127 super(tr("Edit"), "dialogs/edit", tr("Edit the value of the selected key for all objects"), 1125 1128 Shortcut.registerShortcut("properties:edit", tr("Edit Properties"), KeyEvent.VK_S, 1126 Shortcut.GROUP_MNEMONIC), false);1129 Shortcut.GROUP_MNEMONIC), false); 1127 1130 updateEnabledState(); 1128 1131 } … … 1146 1149 (propertyTable != null && propertyTable.getSelectedRowCount() == 1) 1147 1150 ^ (membershipTable != null && membershipTable.getSelectedRowCount() == 1) 1148 );1151 ); 1149 1152 } 1150 1153 … … 1174 1177 ((Map<String,Integer>)propertyData.getValueAt(row, 1)) 1175 1178 .entrySet().iterator().next().getKey(), "UTF-8" 1176 );1179 ); 1177 1180 1178 1181 uris.add(new URI(String.format("%s%sTag:%s=%s", base, lang, key, val))); … … 1186 1189 String type = URLEncoder.encode( 1187 1190 ((Relation)membershipData.getValueAt(row, 0)).get("type"), "UTF-8" 1188 );1191 ); 1189 1192 1190 1193 if (type != null && !type.equals("")) { … … 1220 1223 .replace("=", "%3D") /* do not URLencode whole string! */ 1221 1224 .replaceFirst("/wiki/", "/w/index.php?redirect=no&title=") 1222 ).toURL().openConnection();1225 ).toURL().openConnection(); 1223 1226 conn.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect",15)*1000); 1224 1227 … … 1257 1260 return propertyMenu.add(a); 1258 1261 } 1259 1262 1260 1263 public void addPropertyPopupMenuListener(PopupMenuListener l) { 1261 1264 propertyMenu.addPopupMenuListener(l); … … 1265 1268 propertyMenu.addPopupMenuListener(l); 1266 1269 } 1267 1270 1268 1271 @SuppressWarnings("unchecked") 1269 1272 public Tag getSelectedProperty() { … … 1272 1275 TreeMap<String, Integer> map = (TreeMap<String, Integer>) propertyData.getValueAt(row, 1); 1273 1276 return new Tag( 1274 propertyData.getValueAt(row, 0).toString(), 1277 propertyData.getValueAt(row, 0).toString(), 1275 1278 map.size() > 1 ? "" : map.keySet().iterator().next()); 1276 1279 } 1277 1280 1278 1281 public void addMembershipPopupMenuSeparator() { 1279 1282 membershipMenu.addSeparator(); 1280 1283 } 1281 1284 1282 1285 public JMenuItem addMembershipPopupMenuAction(Action a) { 1283 1286 return membershipMenu.add(a); 1284 1287 } 1285 1288 1286 1289 public void addMembershipPopupMenuListener(PopupMenuListener l) { 1287 1290 membershipMenu.addPopupMenuListener(l); … … 1291 1294 membershipMenu.addPopupMenuListener(l); 1292 1295 } 1293 1296 1294 1297 public IRelation getSelectedMembershipRelation() { 1295 1298 int row = membershipTable.getSelectedRow(); … … 1301 1304 public void setRelation(Relation relation); 1302 1305 } 1303 1306 1304 1307 static abstract class AbstractRelationAction extends AbstractAction implements RelationRelated { 1305 1308 protected Relation relation; … … 1311 1314 } 1312 1315 } 1313 1316 1314 1317 static class SelectRelationAction extends AbstractRelationAction { 1315 1318 boolean selectionmode; … … 1382 1385 buildSetOfIncompleteMembers(relation), 1383 1386 Main.map.mapView.getEditLayer() 1384 ));1387 )); 1385 1388 } 1386 1389 } … … 1392 1395 @Override 1393 1396 public void actionPerformed(ActionEvent ae) { 1394 if (propertyTable.getSelectedRowCount() != 1) {1397 if (propertyTable.getSelectedRowCount() != 1) 1395 1398 return; 1396 }1397 1399 String key = propertyData.getValueAt(propertyTable.getSelectedRow(), 0).toString(); 1398 1400 Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); 1399 if (sel.isEmpty()) {1401 if (sel.isEmpty()) 1400 1402 return; 1401 }1402 1403 Set<String> values = new TreeSet<String>(); 1403 1404 for (OsmPrimitive p : sel) { … … 1470 1471 1471 1472 public void actionPerformed(ActionEvent e) { 1472 if (propertyTable.getSelectedRowCount() != 1) {1473 if (propertyTable.getSelectedRowCount() != 1) 1473 1474 return; 1474 }1475 1475 String key = propertyData.getValueAt(propertyTable.getSelectedRow(), 0).toString(); 1476 1476 Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); 1477 if (sel.isEmpty()) {1477 if (sel.isEmpty()) 1478 1478 return; 1479 }1480 1479 String sep = ""; 1481 1480 String s = "";
Note:
See TracChangeset
for help on using the changeset viewer.