Changeset 2473 in josm for trunk/src/org/openstreetmap/josm
- Timestamp:
- 2009-11-18T20:14:00+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r2445 r2473 1 // License: GPL. See LICENSE file for details.2 1 3 2 package org.openstreetmap.josm.gui.dialogs; 4 3 5 import static org.openstreetmap.josm.tools.I18n.marktr;6 4 import static org.openstreetmap.josm.tools.I18n.tr; 7 5 import static org.openstreetmap.josm.tools.I18n.trn; … … 365 363 selectionChanged(sel); // update table 366 364 Main.parent.repaint(); // repaint all - drawing could have been changed 365 366 btnAdd.requestFocusInWindow(); 367 367 } 368 368 … … 558 558 559 559 JPanel buttonPanel = new JPanel(new GridLayout(1,3)); 560 ActionListener buttonAction = new ActionListener(){ 561 public void actionPerformed(ActionEvent e) { 562 int row = membershipTable.getSelectedRow(); 563 if (e.getActionCommand().equals("Add")) { 564 add(); 565 } else if(row >= 0) 566 { 567 if (e.getActionCommand().equals("Edit")) { 568 membershipEdit(row); 569 } 570 } 571 else 572 { 573 int sel = propertyTable.getSelectedRow(); 574 // Although we might edit/delete the wrong tag here, chances are still better 575 // than just displaying an error message (which always "fails"). 576 if (e.getActionCommand().equals("Edit")) { 577 propertyEdit(sel >= 0 ? sel : 0); 578 } 579 } 580 } 581 }; 582 583 Shortcut s = Shortcut.registerShortcut("properties:add", tr("Add Properties"), KeyEvent.VK_B, 560 561 AddAction addAction = new AddAction(); 562 Shortcut.registerShortcut("properties:add", tr("Add Properties"), KeyEvent.VK_B, 584 563 Shortcut.GROUP_MNEMONIC); 585 this.btnAdd = new SideButton( marktr("Add"),"add","Properties",586 tr("Add a new key/value pair to all objects"), s, buttonAction);564 this.btnAdd = new SideButton(addAction); 565 btnAdd.setFocusable(true); 587 566 buttonPanel.add(this.btnAdd); 588 589 s = Shortcut.registerShortcut("properties:edit", tr("Edit Properties"), KeyEvent.VK_I, 590 Shortcut.GROUP_MNEMONIC); 591 this.btnEdit = new SideButton(marktr("Edit"),"edit","Properties", 592 tr("Edit the value of the selected key for all objects"), s, buttonAction); 567 btnAdd.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "onEnter"); 568 btnAdd.getActionMap().put("onEnter", addAction); 569 570 EditAction editAction = new EditAction(); 571 membershipTable.getSelectionModel().addListSelectionListener(editAction); 572 this.btnEdit = new SideButton(editAction); 593 573 buttonPanel.add(this.btnEdit); 594 574 … … 895 875 } 896 876 877 878 class AddAction extends AbstractAction { 879 public AddAction() { 880 putValue(NAME, tr("Add")); 881 putValue(SHORT_DESCRIPTION, tr("Add a new key/value pair to all objects")); 882 putValue(SMALL_ICON, ImageProvider.get("dialogs", "add")); 883 } 884 885 public void actionPerformed(ActionEvent e) { 886 add(); 887 } 888 } 889 890 class EditAction extends AbstractAction implements ListSelectionListener { 891 public EditAction() { 892 putValue(NAME, tr("Edit")); 893 putValue(SHORT_DESCRIPTION, tr("Edit the value of the selected key for all objects")); 894 putValue(SMALL_ICON, ImageProvider.get("dialogs", "edit")); 895 updateEnabledState(); 896 } 897 898 public void actionPerformed(ActionEvent e) { 899 if (!isEnabled()) 900 return; 901 int row = membershipTable.getSelectedRow(); 902 if (e.getActionCommand().equals("Edit")) { 903 propertyEdit(row >= 0 ? row : 0); 904 } 905 } 906 907 protected void updateEnabledState() { 908 setEnabled(membershipTable.getSelectedRowCount() == 1); 909 } 910 911 public void valueChanged(ListSelectionEvent e) { 912 updateEnabledState(); 913 } 914 } 897 915 }
Note:
See TracChangeset
for help on using the changeset viewer.