Changeset 4604 in josm
- Timestamp:
- 2011-11-21T22:16:25+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r3783 r4604 95 95 } 96 96 97 ImageLabel lonText = new ImageLabel("lon", tr("The geographic longitude at the mouse pointer."), 11);98 ImageLabel nameText = new ImageLabel("name", tr("The name of the object at the mouse pointer."), 20);99 JTextField helpText = new JTextField();100 ImageLabel latText = new ImageLabel("lat", tr("The geographic latitude at the mouse pointer."), 11);101 ImageLabel angleText = new ImageLabel("angle", tr("The angle between the previous and the current way segment."), 6);102 ImageLabel headingText = new ImageLabel("heading", tr("The (compass) heading of the line segment being drawn."), 6);103 ImageLabel distText = new ImageLabel("dist", tr("The length of the new way segment being drawn."), 10);97 final ImageLabel lonText = new ImageLabel("lon", tr("The geographic longitude at the mouse pointer."), 11); 98 final ImageLabel nameText = new ImageLabel("name", tr("The name of the object at the mouse pointer."), 20); 99 final JTextField helpText = new JTextField(); 100 final ImageLabel latText = new ImageLabel("lat", tr("The geographic latitude at the mouse pointer."), 11); 101 final ImageLabel angleText = new ImageLabel("angle", tr("The angle between the previous and the current way segment."), 6); 102 final ImageLabel headingText = new ImageLabel("heading", tr("The (compass) heading of the line segment being drawn."), 6); 103 final ImageLabel distText = new ImageLabel("dist", tr("The length of the new way segment being drawn."), 10); 104 104 105 105 /** … … 108 108 */ 109 109 public Thread thread; 110 111 private final List<StatusTextHistory> statusText = new ArrayList<StatusTextHistory>(); 112 113 private static class StatusTextHistory { 114 final Object id; 115 final String text; 116 117 public StatusTextHistory(Object id, String text) { 118 this.id = id; 119 this.text = text; 120 } 121 122 @Override 123 public boolean equals(Object obj) { 124 return obj instanceof StatusTextHistory && ((StatusTextHistory)obj).id == id; 125 } 126 127 @Override 128 public int hashCode() { 129 return System.identityHashCode(id); 130 } 131 } 110 132 111 133 /** … … 218 240 final JLabel lbl = new JLabel( 219 241 "<html>"+tr("Middle click again to cycle through.<br>"+ 220 "Hold CTRL to select directly from this list with the mouse.<hr>")+"</html>",221 null,222 JLabel.HORIZONTAL223 );242 "Hold CTRL to select directly from this list with the mouse.<hr>")+"</html>", 243 null, 244 JLabel.HORIZONTAL 245 ); 224 246 lbl.setHorizontalAlignment(JLabel.LEFT); 225 247 c.add(lbl, GBC.eol().insets(2, 0, 2, 0)); … … 472 494 ImageProvider.get(OsmPrimitiveType.from(osm)), 473 495 JLabel.HORIZONTAL 474 ) {496 ) { 475 497 // This is necessary so the label updates its colors when the 476 498 // selection is changed from the outside … … 656 678 657 679 public void setHelpText(String t) { 658 helpText.setText(t); 659 helpText.setToolTipText(t); 680 setHelpText(null, t); 681 } 682 public void setHelpText(Object id, String text) { 683 684 StatusTextHistory entry = new StatusTextHistory(id, text); 685 686 statusText.remove(entry); 687 statusText.add(entry); 688 689 helpText.setText(text); 690 helpText.setToolTipText(text); 691 } 692 public void resetHelpText(Object id) { 693 if (statusText.isEmpty()) 694 return; 695 696 StatusTextHistory entry = new StatusTextHistory(id, null); 697 if (statusText.get(statusText.size() - 1).equals(entry)) { 698 if (statusText.size() == 1) { 699 setHelpText(""); 700 } else { 701 StatusTextHistory history = statusText.get(statusText.size() - 2); 702 setHelpText(history.id, history.text); 703 } 704 } 705 statusText.remove(entry); 660 706 } 661 707 public void setAngle(double a) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r4596 r4604 460 460 461 461 @Override 462 public void executeMultikeyAction(int index ) {462 public void executeMultikeyAction(int index, boolean repeat) { 463 463 Layer l = LayerListDialog.getLayerForIndex(index); 464 464 if (l != null) { 465 465 l.toggleVisible(); 466 466 lastLayer = new WeakReference<Layer>(l); 467 } 468 } 469 470 @Override 471 public void repeateLastMultikeyAction() { 472 if (lastLayer != null) { 473 Layer l = lastLayer.get(); 467 } else if (repeat && lastLayer != null) { 468 l = lastLayer.get(); 474 469 if (LayerListDialog.isLayerValid(l)) { 475 470 l.toggleVisible(); … … 690 685 691 686 @Override 692 public void executeMultikeyAction(int index ) {687 public void executeMultikeyAction(int index, boolean repeat) { 693 688 Layer l = LayerListDialog.getLayerForIndex(index); 694 689 if (l != null) { 695 690 execute(l); 696 691 } 697 }698 699 @Override700 public void repeateLastMultikeyAction() {701 // Do nothing, repating not supported702 692 } 703 693 … … 1558 1548 List<Layer> layers = Main.map.mapView.getAllLayersAsList(); 1559 1549 1560 if (index < layers.size() )1550 if (index < layers.size() && index >= 0) 1561 1551 return layers.get(index); 1562 1552 else -
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 = ""; -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r4595 r4604 460 460 461 461 @Override 462 public void executeMultikeyAction(int index ) {462 public void executeMultikeyAction(int index, boolean repeat) { 463 463 Layer l = LayerListDialog.getLayerForIndex(index); 464 if (l != null && l instanceof MarkerLayer) { 465 execute((MarkerLayer) l); 466 } 467 } 468 469 @Override 470 public void repeateLastMultikeyAction() { 471 if (lastLayer != null) { 472 MarkerLayer l = lastLayer.get(); 464 if (l != null) { 465 if (l instanceof MarkerLayer) { 466 execute((MarkerLayer) l); 467 } 468 } else if (repeat && lastLayer != null) { 469 l = lastLayer.get(); 473 470 if (LayerListDialog.isLayerValid(l)) { 474 execute(l); 475 } 476 } 477 } 471 execute((MarkerLayer) l); 472 } 473 } 474 } 475 478 476 479 477 private void execute(MarkerLayer l) { … … 516 514 517 515 @Override 518 public void executeMultikeyAction(int index ) {516 public void executeMultikeyAction(int index, boolean repeat) { 519 517 Layer l = LayerListDialog.getLayerForIndex(index); 520 if (l != null && l instanceof MarkerLayer) { 521 execute((MarkerLayer) l); 522 } 523 } 524 525 @Override 526 public void repeateLastMultikeyAction() { 527 if (lastLayer != null) { 528 MarkerLayer l = lastLayer.get(); 518 if (l != null) { 519 if (l instanceof MarkerLayer) { 520 execute((MarkerLayer) l); 521 } 522 } else if (repeat && lastLayer != null) { 523 l = lastLayer.get(); 529 524 if (LayerListDialog.isLayerValid(l)) { 530 execute( l);525 execute((MarkerLayer) l); 531 526 } 532 527 } -
trunk/src/org/openstreetmap/josm/tools/MultikeyActionsHandler.java
r4595 r4604 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.tools; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.awt.KeyEventDispatcher; … … 21 23 public class MultikeyActionsHandler { 22 24 23 private static final long DIALOG_DELAY = 2000; 25 private static final long DIALOG_DELAY = 1000; 26 private static final String STATUS_BAR_ID = new String("multikeyShortcut"); 24 27 25 28 private class MyKeyEventDispatcher implements KeyEventDispatcher { … … 31 34 32 35 if (lastAction != null && e.getID() == KeyEvent.KEY_PRESSED) { 33 if (e.getKeyCode() == lastAction.shortcut.getKeyCode()) { 34 lastAction.action.repeateLastMultikeyAction(); 35 } else { 36 int index = getIndex(e.getKeyChar()); 37 if (index >= 0) { 38 lastAction.action.executeMultikeyAction(index); 39 } 36 int index = getIndex(e.getKeyCode()); 37 if (index >= 0) { 38 lastAction.action.executeMultikeyAction(index, e.getKeyCode() == lastAction.shortcut.getKeyCode()); 40 39 } 41 40 lastAction = null; 41 Main.map.statusLine.resetHelpText(STATUS_BAR_ID); 42 42 return true; 43 43 } … … 45 45 } 46 46 47 private int getIndex(char lastKey) { 48 if (lastKey >= KeyEvent.VK_0 && lastKey <= KeyEvent.VK_9) 49 return lastKey - KeyEvent.VK_0; 47 private int getIndex(int lastKey) { 48 if (lastKey >= KeyEvent.VK_1 && lastKey <= KeyEvent.VK_9) 49 return lastKey - KeyEvent.VK_1; 50 else if (lastKey == KeyEvent.VK_0) 51 return 9; 50 52 else if (lastKey >= KeyEvent.VK_A && lastKey <= KeyEvent.VK_Z) 51 53 return lastKey - KeyEvent.VK_A + 10; … … 70 72 lastAction = this; 71 73 timer.schedule(new MyTimerTask(lastTimestamp, lastAction), DIALOG_DELAY); 74 Main.map.statusLine.setHelpText(STATUS_BAR_ID, tr("{0}... [please type its number]", (String) action.getValue(SHORT_DESCRIPTION))); 72 75 } 73 76 … … 132 135 layers.add(lbTitle); 133 136 137 char repeatKey = (char) action.shortcut.getKeyCode(); 138 boolean repeatKeyUsed = false; 139 134 140 135 141 for (final MultikeyInfo info: action.action.getMultikeyCombinations()) { 142 143 if (info.getShortcut() == repeatKey) { 144 repeatKeyUsed = true; 145 } 146 136 147 JMenuItem item = new JMenuItem(formatMenuText(action.shortcut, String.valueOf(info.getShortcut()), info.getDescription())); 137 148 item.setMnemonic(info.getShortcut()); … … 139 150 @Override 140 151 public void actionPerformed(ActionEvent e) { 141 action.action.executeMultikeyAction(info.getIndex()); 152 Main.map.statusLine.resetHelpText(STATUS_BAR_ID); 153 action.action.executeMultikeyAction(info.getIndex(), false); 142 154 } 143 155 }); … … 145 157 } 146 158 147 MultikeyInfo lastLayer = action.action.getLastMultikeyAction(); 148 if (lastLayer != null) { 149 JMenuItem repeateItem = new JMenuItem(formatMenuText(action.shortcut, 150 KeyEvent.getKeyText(action.shortcut.getKeyCode()), 151 "Repeat " + lastLayer.getDescription())); 152 repeateItem.addActionListener(new ActionListener() { 153 @Override 154 public void actionPerformed(ActionEvent e) { 155 action.action.repeateLastMultikeyAction(); 156 } 157 }); 158 layers.add(repeateItem); 159 if (!repeatKeyUsed) { 160 MultikeyInfo lastLayer = action.action.getLastMultikeyAction(); 161 if (lastLayer != null) { 162 JMenuItem repeateItem = new JMenuItem(formatMenuText(action.shortcut, 163 KeyEvent.getKeyText(action.shortcut.getKeyCode()), 164 "Repeat " + lastLayer.getDescription())); 165 repeateItem.setMnemonic(action.shortcut.getKeyCode()); 166 repeateItem.addActionListener(new ActionListener() { 167 @Override 168 public void actionPerformed(ActionEvent e) { 169 Main.map.statusLine.resetHelpText(STATUS_BAR_ID); 170 action.action.executeMultikeyAction(-1, true); 171 } 172 }); 173 layers.add(repeateItem); 174 } 159 175 } 160 176 -
trunk/src/org/openstreetmap/josm/tools/MultikeyShortcutAction.java
r4595 r4604 22 22 23 23 public char getShortcut() { 24 if (index < 10) 25 return (char)('0' + index); 24 if (index < 9) 25 return (char)('1' + index); 26 else if (index == 9) 27 return '0'; 26 28 else 27 29 return (char)('A' + index - 10); … … 33 35 } 34 36 35 void executeMultikeyAction(int index); 36 void repeateLastMultikeyAction(); 37 void executeMultikeyAction(int index, boolean repeatLastAction); 37 38 List<MultikeyInfo> getMultikeyCombinations(); 38 39 MultikeyInfo getLastMultikeyAction();
Note:
See TracChangeset
for help on using the changeset viewer.