- Timestamp:
- 2019-07-06T22:47:06+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r15213 r15214 88 88 import org.openstreetmap.josm.gui.util.FileFilterAllFiles; 89 89 import org.openstreetmap.josm.gui.util.GuiHelper; 90 import org.openstreetmap.josm.gui.util.ReorderableTableModel;91 90 import org.openstreetmap.josm.gui.util.TableHelper; 92 91 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; … … 628 627 * Table model of active sources. 629 628 */ 630 protected class ActiveSourcesModel extends AbstractTableModel implements ReorderableTableModel<SourceEntry>{629 protected class ActiveSourcesModel extends AbstractTableModel { 631 630 private transient List<SourceEntry> data; 632 631 private final DefaultListSelectionModel selectionModel; … … 768 767 } 769 768 770 @Override 771 public DefaultListSelectionModel getSelectionModel() { 772 return selectionModel; 773 } 774 775 @Override 776 public SourceEntry getValue(int index) { 777 return data.get(index); 778 } 779 780 @Override 781 public SourceEntry setValue(int index, SourceEntry value) { 782 return data.set(index, value); 769 public boolean canMove(int i) { 770 int[] sel = tblActiveSources.getSelectedRows(); 771 if (sel.length == 0) 772 return false; 773 if (i < 0) 774 return sel[0] >= -i; 775 else if (i > 0) 776 return sel[sel.length-1] <= getRowCount()-1 - i; 777 else 778 return true; 779 } 780 781 public void move(int i) { 782 if (!canMove(i)) return; 783 int[] sel = tblActiveSources.getSelectedRows(); 784 for (int row: sel) { 785 SourceEntry t1 = data.get(row); 786 SourceEntry t2 = data.get(row + i); 787 data.set(row, t2); 788 data.set(row + i, t1); 789 } 790 selectionModel.setValueIsAdjusting(true); 791 selectionModel.clearSelection(); 792 for (int row: sel) { 793 selectionModel.addSelectionInterval(row + i, row + i); 794 } 795 selectionModel.setValueIsAdjusting(false); 783 796 } 784 797 }
Note:
See TracChangeset
for help on using the changeset viewer.