Changeset 8507 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r8492 r8507 18 18 import java.awt.event.MouseAdapter; 19 19 import java.awt.event.MouseEvent; 20 import java.beans.PropertyChangeEvent; 21 import java.beans.PropertyChangeListener; 20 22 import java.io.BufferedReader; 21 23 import java.io.File; … … 49 51 import javax.swing.DefaultListSelectionModel; 50 52 import javax.swing.Icon; 53 import javax.swing.ImageIcon; 51 54 import javax.swing.JButton; 52 55 import javax.swing.JCheckBox; … … 134 137 this.lstAvailableSources = new JList<>(availableSourcesModel); 135 138 this.lstAvailableSources.setSelectionModel(selectionModel); 136 this.lstAvailableSources.setCellRenderer(new SourceEntryListCellRenderer()); 139 final SourceEntryListCellRenderer listCellRenderer = new SourceEntryListCellRenderer(); 140 this.lstAvailableSources.setCellRenderer(listCellRenderer); 137 141 this.availableSourcesUrl = availableSourcesUrl; 138 142 this.sourceProviders = sourceProviders; … … 164 168 } 165 169 170 activeSourcesModel.addTableModelListener(new TableModelListener() { 171 @Override 172 public void tableChanged(TableModelEvent e) { 173 listCellRenderer.updateSources(activeSourcesModel.getSources()); 174 lstAvailableSources.repaint(); 175 } 176 }); 177 tblActiveSources.addPropertyChangeListener(new PropertyChangeListener() { 178 @Override 179 public void propertyChange(PropertyChangeEvent evt) { 180 listCellRenderer.updateSources(activeSourcesModel.getSources()); 181 lstAvailableSources.repaint(); 182 } 183 }); 166 184 activeSourcesModel.addTableModelListener(new TableModelListener() { 167 185 // Force swing to show horizontal scrollbars for the JTable … … 1215 1233 1216 1234 static class SourceEntryListCellRenderer extends JLabel implements ListCellRenderer<ExtendedSourceEntry> { 1235 1236 private final ImageIcon GREEN_CHECK = ImageProvider.getIfAvailable("misc", "green_check"); 1237 private final ImageIcon GRAY_CHECK = ImageProvider.getIfAvailable("misc", "gray_check"); 1238 private final Map<String, SourceEntry> entryByUrl = new HashMap<>(); 1239 1217 1240 @Override 1218 1241 public Component getListCellRendererComponent(JList<? extends ExtendedSourceEntry> list, ExtendedSourceEntry value, … … 1232 1255 setOpaque(true); 1233 1256 setToolTipText(value.getTooltip()); 1257 final SourceEntry sourceEntry = entryByUrl.get(value.url); 1258 setIcon(sourceEntry == null ? null : sourceEntry.active ? GREEN_CHECK : GRAY_CHECK); 1234 1259 return this; 1260 } 1261 1262 public void updateSources(List<SourceEntry> sources) { 1263 synchronized (entryByUrl) { 1264 entryByUrl.clear(); 1265 for (SourceEntry i : sources) { 1266 entryByUrl.put(i.url, i); 1267 } 1268 } 1235 1269 } 1236 1270 }
Note:
See TracChangeset
for help on using the changeset viewer.