- Timestamp:
- 2009-07-15T18:28:23+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/relation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r1790 r1794 13 13 import java.awt.event.ComponentAdapter; 14 14 import java.awt.event.ComponentEvent; 15 import java.awt.event.FocusAdapter; 16 import java.awt.event.FocusEvent; 15 17 import java.awt.event.KeyEvent; 16 18 import java.io.IOException; … … 30 32 import javax.swing.JSplitPane; 31 33 import javax.swing.JTable; 34 import javax.swing.JTextField; 32 35 import javax.swing.KeyStroke; 33 36 import javax.swing.ListSelectionModel; 37 import javax.swing.event.DocumentEvent; 38 import javax.swing.event.DocumentListener; 34 39 import javax.swing.event.ListSelectionEvent; 35 40 import javax.swing.event.ListSelectionListener; … … 88 93 private SelectionTableModel selectionTableModel; 89 94 95 private JTextField tfRole; 96 90 97 /** 91 98 * Creates a new relation editor for the given relation. The relation … … 506 513 JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); 507 514 buttonPanel.add(new SideButton(new DownlaodAction())); 515 buttonPanel.add(new JLabel(tr("Role:"))); 516 tfRole = new JTextField(10); 517 tfRole.addFocusListener( 518 new FocusAdapter() { 519 @Override 520 public void focusGained(FocusEvent e) { 521 tfRole.selectAll(); 522 } 523 } 524 ); 525 buttonPanel.add(tfRole); 526 SetRoleAction setRoleAction = new SetRoleAction(); 527 memberTableModel.getSelectionModel().addListSelectionListener(setRoleAction); 528 buttonPanel.add(new SideButton(setRoleAction)); 529 tfRole.getDocument().addDocumentListener(setRoleAction); 508 530 return buttonPanel; 509 531 } … … 862 884 public void actionPerformed(ActionEvent e) { 863 885 downloadRelationMembers(); 886 } 887 } 888 889 class SetRoleAction extends AbstractAction implements ListSelectionListener, DocumentListener{ 890 public SetRoleAction() { 891 putValue(SHORT_DESCRIPTION, tr("Sets a role for the selected members")); 892 // FIXME: find better icon 893 putValue(SMALL_ICON, ImageProvider.get("ok")); 894 putValue(NAME, tr("Apply Role")); 895 refreshEnabled(); 896 } 897 898 protected void refreshEnabled() { 899 setEnabled(memberTable.getSelectedRowCount() > 0 && !tfRole.getText().equals("")); 900 } 901 902 public void actionPerformed(ActionEvent e) { 903 memberTableModel.updateRole(memberTable.getSelectedRows(), tfRole.getText()); 904 } 905 906 public void valueChanged(ListSelectionEvent e) { 907 refreshEnabled(); 908 } 909 910 public void changedUpdate(DocumentEvent e) { 911 refreshEnabled(); 912 } 913 914 public void insertUpdate(DocumentEvent e) { 915 refreshEnabled(); 916 } 917 918 public void removeUpdate(DocumentEvent e) { 919 refreshEnabled(); 864 920 } 865 921 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r1793 r1794 326 326 return count; 327 327 } 328 329 /** 330 * updates the role of the members given by the indices in <code>idx</code> 331 * 332 * @param idx the array of indices 333 * @param role the new role 334 */ 335 public void updateRole(int [] idx, String role) { 336 if (idx == null || idx.length == 0) return; 337 for (int row: idx) { 338 members.get(row).role = role; 339 } 340 fireTableDataChanged(); 341 for (int row: idx) { 342 getSelectionModel().addSelectionInterval(row, row); 343 } 344 } 328 345 }
Note:
See TracChangeset
for help on using the changeset viewer.