Changeset 32638 in osm for applications/editors/josm/plugins/NanoLog/src/nanolog/NanoLogPanel.java
- Timestamp:
- 2016-07-11T23:01:43+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/NanoLog/src/nanolog/NanoLogPanel.java
r32447 r32638 11 11 import javax.swing.JList; 12 12 13 import nanolog.NanoLogLayer.NanoLogLayerListener;14 15 13 import org.openstreetmap.josm.Main; 16 14 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; … … 20 18 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 21 19 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 20 21 import nanolog.NanoLogLayer.NanoLogLayerListener; 22 22 23 23 /** … … 40 40 public void updateMarkers() { 41 41 List<NanoLogEntry> entries = new ArrayList<>(); 42 for (NanoLogLayer l : Main.getLayerManager().getLayersOfType(NanoLogLayer.class)) {42 for (NanoLogLayer l : Main.getLayerManager().getLayersOfType(NanoLogLayer.class)) { 43 43 entries.addAll(l.getEntries()); 44 44 } … … 53 53 public void layerAdded(LayerAddEvent e) { 54 54 Layer newLayer = e.getAddedLayer(); 55 if (newLayer instanceof NanoLogLayer )55 if (newLayer instanceof NanoLogLayer) 56 56 ((NanoLogLayer) newLayer).addListener(this); 57 57 updateMarkers(); … … 64 64 65 65 @Override 66 public void markersUpdated( NanoLogLayer layer) {66 public void markersUpdated(NanoLogLayer layer) { 67 67 updateMarkers(); 68 68 } 69 69 70 70 @Override 71 public void markerActivated( NanoLogLayer layer, NanoLogEntry entry) {71 public void markerActivated(NanoLogLayer layer, NanoLogEntry entry) { 72 72 int idx = entry == null ? -1 : listModel.find(entry); 73 if (idx >= 0) {73 if (idx >= 0) { 74 74 logPanel.setSelectedIndex(idx); 75 75 Rectangle rect = logPanel.getCellBounds(Math.max(0, idx-2), Math.min(idx+4, listModel.getSize())); … … 83 83 84 84 @Override 85 public int getSize() {85 public int getSize() { 86 86 return entries.size(); 87 87 } 88 88 89 89 @Override 90 public String getElementAt(int index) {90 public String getElementAt(int index) { 91 91 return TIME_FORMAT.format(entries.get(index).getTime()) + " " + entries.get(index).getMessage(); 92 92 } 93 93 94 public void setEntries( List<NanoLogEntry> entries) {94 public void setEntries(List<NanoLogEntry> entries) { 95 95 this.entries = entries; 96 96 fireContentsChanged(this, 0, entries.size()); 97 97 } 98 98 99 public int find( NanoLogEntry entry) {99 public int find(NanoLogEntry entry) { 100 100 return entries.indexOf(entry); 101 101 }
Note:
See TracChangeset
for help on using the changeset viewer.
