Changeset 4072 in josm for trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
- Timestamp:
- 2011-05-04T07:09:56+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r4041 r4072 84 84 85 85 final protected boolean isMapPaint; 86 86 87 87 protected JTable tblActiveSources; 88 88 protected ActiveSourcesModel activeSourcesModel; … … 113 113 // some kind of hack to prevent the table from scrolling slightly to the 114 114 // right when clicking on the text 115 @Override 115 116 public void scrollRectToVisible(Rectangle aRect) { 116 117 super.scrollRectToVisible(new Rectangle(0, aRect.y, aRect.width, aRect.height)); … … 142 143 }); 143 144 activeSourcesModel.setActiveSources(getInitialSourcesList()); 144 145 145 146 final EditActiveSourceAction editActiveSourceAction = new EditActiveSourceAction(); 146 147 tblActiveSources.getSelectionModel().addListSelectionListener(editActiveSourceAction); … … 368 369 */ 369 370 protected enum I18nString { AVAILABLE_SOURCES, ACTIVE_SOURCES, NEW_SOURCE_ENTRY_TOOLTIP, NEW_SOURCE_ENTRY, 370 371 372 371 REMOVE_SOURCE_TOOLTIP, EDIT_SOURCE_TOOLTIP, ACTIVATE_TOOLTIP, RELOAD_ALL_AVAILABLE, 372 LOADING_SOURCES_FROM, FAILED_TO_LOAD_SOURCES_FROM, FAILED_TO_LOAD_SOURCES_FROM_HELP_TOPIC, 373 ILLEGAL_FORMAT_OF_ENTRY } 373 374 374 375 /** … … 378 379 private static void adjustColumnWidth(JTable tbl, int col) { 379 380 int maxwidth = 0; 380 381 for (int row=0; row<tbl.getRowCount(); row++) { 381 382 TableCellRenderer tcr = tbl.getCellRenderer(row, col); 382 383 384 385 386 383 Object val = tbl.getValueAt(row, col); 384 Component comp = tcr.getTableCellRendererComponent(tbl, val, false, false, row, col); 385 maxwidth = Math.max(comp.getPreferredSize().width, maxwidth); 386 } 387 tbl.getColumnModel().getColumn(col).setPreferredWidth(maxwidth); 387 388 } 388 389 … … 587 588 if (sel.length == 0) 588 589 return false; 589 if (i < 0) { // Up590 if (i < 0) 590 591 return sel[0] >= -i; 591 } else if (i > 0) { // Down592 return sel[sel.length-1] <= getRowCount()-1 - i;593 }else594 return true;592 else if (i > 0) 593 return sel[sel.length-1] <= getRowCount()-1 - i; 594 else 595 return true; 595 596 } 596 597 … … 735 736 } 736 737 738 @Override 737 739 public String getTitle() { 738 740 return tfTitle.getText(); … … 1211 1213 } 1212 1214 } 1213 1215 1214 1216 class SourceEntryTableCellRenderer extends DefaultTableCellRenderer { 1215 1217 @Override 1216 1218 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { 1219 if (value == null) 1220 return this; 1217 1221 SourceEntry se = (SourceEntry) value; 1218 1222 JLabel label = (JLabel)super.getTableCellRendererComponent(table, … … 1490 1494 public Collection<? extends SourceEntry> readNewFormat() { 1491 1495 List<SourceEntry> entries = readNewFormatImpl(); 1492 if (entries == null) {1496 if (entries == null) 1493 1497 return getDefault(); 1494 }1495 1498 return entries; 1496 1499 } … … 1500 1503 Collection<Collection<String>> mappaintSrc = Main.pref.getArray(pref, null); 1501 1504 if (mappaintSrc == null || mappaintSrc.isEmpty()) { 1502 if (Main.pref.getBoolean(pref + "._empty_", false)) {1505 if (Main.pref.getBoolean(pref + "._empty_", false)) 1503 1506 return Collections.<SourceEntry>emptyList(); 1504 }1505 1507 return null; 1506 1508 }
Note:
See TracChangeset
for help on using the changeset viewer.