Changeset 2742 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2010-01-06T19:00:49+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r2741 r2742 50 50 import javax.swing.table.DefaultTableCellRenderer; 51 51 import javax.swing.table.DefaultTableModel; 52 import javax.swing.table.TableModel; 52 53 import javax.swing.text.JTextComponent; 53 54 … … 296 297 } 297 298 298 Main.main.getCurrentDataSet().fireSelectionChanged();299 selectionChanged(sel); // update whole table300 Main.parent.repaint(); // repaint all - drawing could have been changed301 302 299 if(!key.equals(newkey)) { 303 300 for(int i=0; i < propertyTable.getRowCount(); i++) … … 372 369 return; 373 370 Main.main.undoRedo.add(new ChangePropertyCommand(sel, key, value)); 374 Main.main.getCurrentDataSet().fireSelectionChanged();375 selectionChanged(sel); // update table376 Main.parent.repaint(); // repaint all - drawing could have been changed377 378 371 btnAdd.requestFocusInWindow(); 379 372 } … … 696 689 } 697 690 691 private int findRow(TableModel model, Object value) { 692 for (int i=0; i<model.getRowCount(); i++) { 693 if (model.getValueAt(i, 0).equals(value)) 694 return i; 695 } 696 return -1; 697 } 698 698 699 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 699 700 if (!isVisible()) … … 703 704 if (propertyTable.getCellEditor() != null) { 704 705 propertyTable.getCellEditor().cancelCellEditing(); 706 } 707 708 String selectedTag = null; 709 Relation selectedRelation = null; 710 if (propertyTable.getSelectedRowCount() == 1) { 711 selectedTag = (String)propertyData.getValueAt(propertyTable.getSelectedRow(), 0); 712 } 713 if (membershipTable.getSelectedRowCount() == 1) { 714 selectedRelation = (Relation)membershipData.getValueAt(membershipTable.getSelectedRow(), 0); 705 715 } 706 716 … … 788 798 propertyTable.getTableHeader().setVisible(hasSelection); 789 799 selectSth.setVisible(!hasSelection); 790 if(hasTags) { 800 801 int selectedIndex; 802 if (selectedTag != null && (selectedIndex = findRow(propertyData, selectedTag)) != -1) { 803 propertyTable.changeSelection(selectedIndex, 0, false, false); 804 } else if (selectedRelation != null && (selectedIndex = findRow(membershipData, selectedRelation)) != -1) { 805 membershipTable.changeSelection(selectedIndex, 0, false, false); 806 } else if(hasTags) { 791 807 propertyTable.changeSelection(0, 0, false, false); 792 808 } else if(hasMemberships) { … … 825 841 protected void deleteProperty(int row){ 826 842 String key = propertyData.getValueAt(row, 0).toString(); 843 844 String nextKey = null; 845 int rowCount = propertyData.getRowCount(); 846 if (rowCount > 1) { 847 nextKey = (String)propertyData.getValueAt((row + 1 < rowCount ? row + 1 : row - 1), 0); 848 } 849 827 850 Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected(); 828 851 Main.main.undoRedo.add(new ChangePropertyCommand(sel, key, null)); 829 Main.main.getCurrentDataSet().fireSelectionChanged(); 830 selectionChanged(sel); // update table831 832 int rowCount = propertyTable.getRowCount();833 propertyTable.changeSelection((row < rowCount ? row : (rowCount-1)), 0, false, false);852 853 membershipTable.clearSelection(); 854 if (nextKey != null) { 855 propertyTable.changeSelection(findRow(propertyData, nextKey), 0, false, false); 856 } 834 857 } 835 858 836 859 protected void deleteFromRelation(int row) { 837 860 Relation cur = (Relation)membershipData.getValueAt(row, 0); 861 862 Relation nextRelation = null; 863 int rowCount = membershipTable.getRowCount(); 864 if (rowCount > 1) { 865 nextRelation = (Relation)membershipData.getValueAt((row + 1 < rowCount ? row + 1 : row - 1), 0); 866 } 838 867 839 868 ExtendedDialog ed = new ExtendedDialog(Main.parent, … … 853 882 } 854 883 Main.main.undoRedo.add(new ChangeCommand(cur, rel)); 855 Main.main.getCurrentDataSet().fireSelectionChanged(); 856 selectionChanged(sel); // update whole table 884 885 propertyTable.clearSelection(); 886 if (nextRelation != null) { 887 membershipTable.changeSelection(findRow(membershipData, nextRelation), 0, false, false); 888 } 857 889 } 858 890
Note:
See TracChangeset
for help on using the changeset viewer.