- Timestamp:
- 2009-12-19T14:06:51+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/event/DatasetEventManager.java
r2652 r2658 2 2 package org.openstreetmap.josm.data.osm.event; 3 3 4 import java.util.ArrayList;5 import java.util.List;6 4 import java.util.Queue; 5 import java.util.concurrent.CopyOnWriteArrayList; 7 6 import java.util.concurrent.LinkedBlockingQueue; 8 7 … … 32 31 33 32 private final Queue<AbstractDatasetChangedEvent> eventsInEDT = new LinkedBlockingQueue<AbstractDatasetChangedEvent>(); 34 private final List<DataSetListener> inEDTListeners = newArrayList<DataSetListener>();35 private final List<DataSetListener> normalListeners = newArrayList<DataSetListener>();33 private final CopyOnWriteArrayList<DataSetListener> inEDTListeners = new CopyOnWriteArrayList<DataSetListener>(); 34 private final CopyOnWriteArrayList<DataSetListener> normalListeners = new CopyOnWriteArrayList<DataSetListener>(); 36 35 private final DataSetListener myListener = new DataSetListenerAdapter(this); 37 36 … … 48 47 public void addDatasetListener(DataSetListener listener, boolean fireInEDT) { 49 48 if (fireInEDT) { 50 inEDTListeners.add (listener);49 inEDTListeners.addIfAbsent(listener); 51 50 } else { 52 normalListeners.add (listener);51 normalListeners.addIfAbsent(listener); 53 52 } 54 53 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r2626 r2658 18 18 import java.util.Collections; 19 19 import java.util.LinkedList; 20 import java.util.List;21 20 import java.util.NoSuchElementException; 22 21 … … 46 45 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 47 46 import org.openstreetmap.josm.gui.SideButton; 48 import org.openstreetmap.josm.gui.layer.Layer;49 47 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 50 48 import org.openstreetmap.josm.tools.Shortcut; … … 57 55 * @author imi 58 56 */ 59 public class SelectionListDialog extends ToggleDialog implements SelectionChangedListener, MapView. LayerChangeListener {57 public class SelectionListDialog extends ToggleDialog implements SelectionChangedListener, MapView.EditLayerChangeListener { 60 58 61 59 private static final int SELECTION_HISTORY_SIZE = 10; … … 162 160 } 163 161 164 DataSet.selListeners.add(this); 165 MapView.addLayerChangeListener(this); 162 MapView.addEditLayerChangeListener(this); 166 163 } 167 164 168 165 @Override 169 166 public void tearDown() { 170 MapView.removeLayerChangeListener(this); 167 MapView.removeEditLayerChangeListener(this); 168 } 169 170 @Override 171 public void showNotify() { 172 DataSet.selListeners.add(this); 173 updateSelection(); 174 } 175 176 @Override 177 public void hideNotify() { 171 178 DataSet.selListeners.remove(this); 172 179 } … … 370 377 } 371 378 372 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 373 if (newLayer instanceof OsmDataLayer) { 374 OsmDataLayer dataLayer = (OsmDataLayer)newLayer; 375 selectionChanged(dataLayer.data.getSelected()); 379 private void updateSelection() { 380 if (Main.main.getCurrentDataSet() == null) { 381 selectionChanged(Collections.<OsmPrimitive>emptyList()); 376 382 } else { 377 List<OsmPrimitive> selection = Collections.emptyList(); 378 selectionChanged(selection); 379 } 380 } 381 382 public void layerAdded(Layer newLayer) { 383 // do nothing 384 } 385 386 public void layerRemoved(Layer oldLayer) { 387 // do nothing 383 selectionChanged(Main.main.getCurrentDataSet().getSelected()); 384 } 385 } 386 387 public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) { 388 updateSelection(); 388 389 } 389 390 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/ListOfUsedTags.java
r2657 r2658 47 47 else 48 48 return values; 49 } 50 51 public void rebuildNecessary() { 52 dirty = true; 49 53 } 50 54 -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r2657 r2658 71 71 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 72 72 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 73 import org.openstreetmap.josm.gui.layer.Layer;74 73 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 75 74 import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference; … … 97 96 * @author imi 98 97 */ 99 public class PropertiesDialog extends ToggleDialog implements SelectionChangedListener, MapView. LayerChangeListener {98 public class PropertiesDialog extends ToggleDialog implements SelectionChangedListener, MapView.EditLayerChangeListener { 100 99 /** 101 100 * Watches for double clicks and from editing or new property, depending on the … … 145 144 public void showNotify() { 146 145 DatasetEventManager.getInstance().addDatasetListener(listOfUsedTags, false); 146 listOfUsedTags.rebuildNecessary(); 147 DataSet.selListeners.add(this); 148 updateSelection(); 147 149 } 148 150 … … 150 152 public void hideNotify() { 151 153 DatasetEventManager.getInstance().removeDatasetListener(listOfUsedTags); 154 DataSet.selListeners.remove(this); 152 155 } 153 156 … … 568 571 add(buttonPanel, BorderLayout.SOUTH); 569 572 570 DataSet.selListeners.add(this); 571 MapView.addLayerChangeListener(this); 573 MapView.addEditLayerChangeListener(this); 572 574 } 573 575 574 576 @Override 575 577 public void tearDown() { 576 MapView.remove LayerChangeListener(this);578 MapView.removeEditLayerChangeListener(this); 577 579 } 578 580 … … 776 778 } 777 779 780 private void updateSelection() { 781 if (Main.main.getCurrentDataSet() == null) { 782 selectionChanged(Collections.<OsmPrimitive>emptyList()); 783 } else { 784 selectionChanged(Main.main.getCurrentDataSet().getSelected()); 785 } 786 } 787 778 788 /* ---------------------------------------------------------------------------------- */ 779 /* LayerChangeListener */789 /* EditLayerChangeListener */ 780 790 /* ---------------------------------------------------------------------------------- */ 781 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 782 if (newLayer instanceof OsmDataLayer) { 783 OsmDataLayer dataLayer = (OsmDataLayer)newLayer; 784 selectionChanged(dataLayer.data.getSelected()); 785 } else { 786 List<OsmPrimitive> selection = Collections.emptyList(); 787 selectionChanged(selection); 788 } 789 } 790 791 public void layerAdded(Layer newLayer) { 792 // do nothing 793 } 794 795 public void layerRemoved(Layer oldLayer) { 796 // do nothing 791 public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) { 792 updateSelection(); 797 793 } 798 794
Note:
See TracChangeset
for help on using the changeset viewer.