- Timestamp:
- 2019-07-06T22:45:08+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r15211 r15213 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; 90 91 import org.openstreetmap.josm.gui.util.TableHelper; 91 92 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; … … 627 628 * Table model of active sources. 628 629 */ 629 protected class ActiveSourcesModel extends AbstractTableModel {630 protected class ActiveSourcesModel extends AbstractTableModel implements ReorderableTableModel<SourceEntry> { 630 631 private transient List<SourceEntry> data; 631 632 private final DefaultListSelectionModel selectionModel; … … 767 768 } 768 769 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); 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); 796 783 } 797 784 } … … 1388 1375 } 1389 1376 final ImageSizes size = ImageSizes.TABLE; 1390 setIcon(value.icon == null ? ImageProvider.getEmpty(size) : value.icon.getImageIcon (size.getImageDimension()));1377 setIcon(value.icon == null ? ImageProvider.getEmpty(size) : value.icon.getImageIconBounded(size.getImageDimension())); 1391 1378 return this; 1392 1379 }
Note:
See TracChangeset
for help on using the changeset viewer.