Changeset 9497 in josm for trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
- Timestamp:
- 2016-01-17T04:02:53+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
r9376 r9497 7 7 import java.awt.Dimension; 8 8 import java.awt.GraphicsEnvironment; 9 import java.awt.KeyboardFocusManager;10 9 import java.awt.event.ActionEvent; 11 import java.awt.event.KeyEvent;12 10 import java.util.ArrayList; 13 11 import java.util.Arrays; … … 17 15 import javax.swing.AbstractAction; 18 16 import javax.swing.DropMode; 19 import javax.swing.JComponent;20 17 import javax.swing.JPopupMenu; 21 18 import javax.swing.JTable; 22 19 import javax.swing.JViewport; 23 import javax.swing.KeyStroke;24 20 import javax.swing.ListSelectionModel; 25 21 import javax.swing.SwingUtilities; … … 61 57 setLayer(layer); 62 58 model.addMemberModelListener(this); 63 init(); 64 } 65 66 /** 67 * initialize the table 68 */ 69 protected void init() { 59 70 60 MemberRoleCellEditor ce = (MemberRoleCellEditor) getColumnModel().getColumn(0).getCellEditor(); 71 61 setRowHeight(ce.getEditor().getPreferredSize().height); … … 74 64 putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); 75 65 76 // make ENTER behave like TAB 77 // 78 getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put( 79 KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), "selectNextColumnCell"); 80 66 installCustomNavigation(0); 81 67 initHighlighting(); 82 83 // install custom navigation actions84 //85 getActionMap().put("selectNextColumnCell", new SelectNextColumnCellAction());86 getActionMap().put("selectPreviousColumnCell", new SelectPreviousColumnCellAction());87 68 88 69 if (!GraphicsEnvironment.isHeadless()) { … … 164 145 } 165 146 166 /**167 * Action to be run when the user navigates to the next cell in the table, for instance by168 * pressing TAB or ENTER. The action alters the standard navigation path from cell to cell: <ul>169 * <li>it jumps over cells in the first column</li> <li>it automatically add a new empty row170 * when the user leaves the last cell in the table</li></ul>171 */172 class SelectNextColumnCellAction extends AbstractAction {173 @Override174 public void actionPerformed(ActionEvent e) {175 run();176 }177 178 public void run() {179 int col = getSelectedColumn();180 int row = getSelectedRow();181 if (getCellEditor() != null) {182 getCellEditor().stopCellEditing();183 }184 185 if (col == 0 && row < getRowCount() - 1) {186 row++;187 } else if (row < getRowCount() - 1) {188 col = 0;189 row++;190 } else {191 // go to next component, no more rows in this table192 KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();193 manager.focusNextComponent();194 return;195 }196 changeSelection(row, col, false, false);197 }198 }199 200 /**201 * Action to be run when the user navigates to the previous cell in the table, for instance by202 * pressing Shift-TAB203 */204 private class SelectPreviousColumnCellAction extends AbstractAction {205 206 @Override207 public void actionPerformed(ActionEvent e) {208 int col = getSelectedColumn();209 int row = getSelectedRow();210 if (getCellEditor() != null) {211 getCellEditor().stopCellEditing();212 }213 214 if (col <= 0 && row <= 0) {215 // change nothing216 } else if (row > 0) {217 col = 0;218 row--;219 }220 changeSelection(row, col, false, false);221 }222 }223 224 147 @Override 225 148 public void unlinkAsListener() {
Note:
See TracChangeset
for help on using the changeset viewer.
