- Timestamp:
- 2009-12-19T10:47:49+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r2558 r2655 30 30 import java.util.Map; 31 31 import java.util.Set; 32 import java.util.logging.Logger;33 32 34 33 import javax.swing.JComponent; … … 62 61 */ 63 62 public class DrawAction extends MapMode implements MapViewPaintable, SelectionChangedListener, AWTEventListener { 64 static private final Logger logger = Logger.getLogger(DrawAction.class.getName());63 //static private final Logger logger = Logger.getLogger(DrawAction.class.getName()); 65 64 66 65 final private Cursor cursorCrosshair; … … 70 69 private Cursors currCursor = Cursors.crosshair; 71 70 72 private staticNode lastUsedNode = null;71 private Node lastUsedNode = null; 73 72 private double PHI=Math.toRadians(90); 74 73 … … 119 118 if(currCursor.equals(c) || (!drawTargetCursor && currCursor.equals(Cursors.crosshair))) 120 119 return; 121 try { 122 // We invoke this to prevent strange things from happening 123 EventQueue.invokeLater(new Runnable() { 124 public void run() { 125 // Don't change cursor when mode has changed already 126 if(!(Main.map.mapMode instanceof DrawAction)) 127 return; 128 switch(c) { 129 case way: 130 Main.map.mapView.setCursor(cursorJoinWay); 131 break; 132 case node: 133 Main.map.mapView.setCursor(cursorJoinNode); 134 break; 135 default: 136 Main.map.mapView.setCursor(cursorCrosshair); 137 break; 138 } 139 } 140 }); 141 currCursor = c; 142 } catch(Exception e) {} 120 // We invoke this to prevent strange things from happening 121 EventQueue.invokeLater(new Runnable() { 122 public void run() { 123 // Don't change cursor when mode has changed already 124 if(!(Main.map.mapMode instanceof DrawAction)) 125 return; 126 switch(c) { 127 case way: 128 Main.map.mapView.setCursor(cursorJoinWay); 129 break; 130 case node: 131 Main.map.mapView.setCursor(cursorJoinNode); 132 break; 133 default: 134 Main.map.mapView.setCursor(cursorCrosshair); 135 break; 136 } 137 } 138 }); 139 currCursor = c; 143 140 } 144 141 … … 975 972 */ 976 973 if (getCurrentDataSet() != null && getCurrentDataSet().getSelectedWays().size() > 0 && !wayIsFinished && !alt) { 977 Way w = (Way)getCurrentDataSet().getSelectedWays().iterator().next();974 Way w = getCurrentDataSet().getSelectedWays().iterator().next(); 978 975 for (Node m : w.getNodes()) { 979 976 if (m.equals(mouseOnExistingNode) || mouseOnExistingWays.contains(w)) { -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r2645 r2655 26 26 import java.util.Map.Entry; 27 27 import java.util.concurrent.CopyOnWriteArrayList; 28 import java.util.logging.Logger;29 28 import java.util.regex.Matcher; 30 29 import java.util.regex.Pattern; … … 44 43 */ 45 44 public class Preferences { 46 static private final Logger logger = Logger.getLogger(Preferences.class.getName());45 //static private final Logger logger = Logger.getLogger(Preferences.class.getName()); 47 46 48 47 /** … … 131 130 132 131 public void addPreferenceChangeListener(PreferenceChangedListener listener) { 133 if (listener != null && ! listeners.contains(listener)) {134 listeners.add (listener);132 if (listener != null) { 133 listeners.addIfAbsent(listener); 135 134 } 136 135 } 137 136 138 137 public void removePreferenceChangeListener(PreferenceChangedListener listener) { 139 if (listener != null && listeners.contains(listener)) { 140 listeners.remove(listener); 141 } 138 listeners.remove(listener); 142 139 } 143 140 -
trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java
r2512 r2655 42 42 43 43 public void addConflictListener(IConflictListener listener) { 44 if (listener != null && ! listeners.contains(listener)) {45 listeners.add (listener);44 if (listener != null) { 45 listeners.addIfAbsent(listener); 46 46 } 47 47 } 48 48 49 49 public void removeConflictListener(IConflictListener listener) { 50 if (listener != null) { 51 listeners.remove(listener); 52 } 50 listeners.remove(listener); 53 51 } 54 52 -
trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java
r2618 r2655 8 8 import java.util.Map; 9 9 import java.util.concurrent.CopyOnWriteArrayList; 10 import java.util.logging.Logger;11 10 12 11 import org.openstreetmap.josm.Main; … … 15 14 16 15 public class ChangesetCache implements PreferenceChangedListener{ 17 static private final Logger logger = Logger.getLogger(ChangesetCache.class.getName());16 //static private final Logger logger = Logger.getLogger(ChangesetCache.class.getName()); 18 17 static private final ChangesetCache instance = new ChangesetCache(); 19 18 … … 32 31 33 32 public void addChangesetCacheListener(ChangesetCacheListener listener) { 34 synchronized(listeners) { 35 if (listener != null && ! listeners.contains(listener)) { 36 listeners.add(listener); 37 } 33 if (listener != null) { 34 listeners.addIfAbsent(listener); 38 35 } 39 36 } 40 37 41 38 public void removeChangesetCacheListener(ChangesetCacheListener listener) { 42 synchronized(listeners) { 43 if (listener != null && listeners.contains(listener)) { 44 listeners.remove(listener); 45 } 46 } 39 listeners.remove(listener); 47 40 } 48 41 -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2623 r2655 21 21 import org.openstreetmap.josm.data.SelectionChangedListener; 22 22 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; 23 import org.openstreetmap.josm.data.osm.event.ChangesetIdChangedEvent; 23 24 import org.openstreetmap.josm.data.osm.event.DataChangedEvent; 24 25 import org.openstreetmap.josm.data.osm.event.DataSetListener; … … 863 864 } 864 865 866 void fireChangesetIdChanged(OsmPrimitive primitive, int oldChangesetId, int newChangesetId) { 867 fireEvent(new ChangesetIdChangedEvent(this, Collections.singletonList(primitive), oldChangesetId, newChangesetId)); 868 } 869 865 870 public void clenupDeletedPrimitives() { 866 871 if (cleanupDeleted(nodes.iterator()) -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r2651 r2655 649 649 */ 650 650 public void setChangesetId(int changesetId) throws IllegalStateException, IllegalArgumentException { 651 if (this.changesetId == changesetId) 652 return; 651 653 if (changesetId < 0) 652 654 throw new IllegalArgumentException(tr("Parameter ''{0}'' >= 0 expected, got {1}", "changesetId", changesetId)); 653 655 if (isNew() && changesetId > 0) 654 656 throw new IllegalStateException(tr("Can''t assign a changesetId > 0 to a new primitive. Value of changesetId is {0}", changesetId)); 657 int old = this.changesetId; 655 658 this.changesetId = changesetId; 659 if (dataSet != null) { 660 dataSet.fireChangesetIdChanged(this, old, changesetId); 661 } 656 662 } 657 663 … … 1003 1009 flags = other.flags; 1004 1010 user= other.user; 1005 changesetId = other.changesetId;1011 setChangesetId(other.changesetId); 1006 1012 clearCached(); 1007 1013 } … … 1031 1037 flags = other.flags; 1032 1038 user= other.user; 1033 changesetId = other.changesetId;1039 setChangesetId(other.changesetId); 1034 1040 } 1035 1041 … … 1178 1184 timestamp = data.getTimestamp(); 1179 1185 user = data.getUser(); 1180 changesetId = data.getChangesetId();1186 setChangesetId(data.getChangesetId()); 1181 1187 setDeleted(data.isDeleted()); 1182 1188 setModified(data.isModified()); -
trunk/src/org/openstreetmap/josm/data/osm/event/AbstractDatasetChangedEvent.java
r2645 r2655 11 11 12 12 public enum DatasetEventType {DATA_CHANGED, NODE_MOVED, PRIMITIVES_ADDED, PRIMITIVES_REMOVED, 13 RELATION_MEMBERS_CHANGED, TAGS_CHANGED, WAY_NODES_CHANGED }13 RELATION_MEMBERS_CHANGED, TAGS_CHANGED, WAY_NODES_CHANGED, CHANGESET_ID_CHANGED} 14 14 15 15 protected final DataSet dataSet; -
trunk/src/org/openstreetmap/josm/data/osm/event/DataSetListener.java
r2622 r2655 73 73 74 74 /** 75 * Minor dataset change, currently only changeset id changed is supported, but can 76 * be extended in future. 77 * @param event 78 */ 79 void otherDatasetChange(AbstractDatasetChangedEvent event); 80 81 /** 75 82 * Called after big changes in dataset. Usually other events are stopped using Dataset.beginUpdate() and 76 83 * after operation is completed (Dataset.endUpdate()), {@link #dataChanged()} is called. 77 84 */ 78 85 void dataChanged(DataChangedEvent event); 79 80 86 } -
trunk/src/org/openstreetmap/josm/data/osm/event/DataSetListenerAdapter.java
r2645 r2655 48 48 } 49 49 50 public void otherDatasetChange(AbstractDatasetChangedEvent event) { 51 listener.processDatasetEvent(event); 52 } 53 50 54 } -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryDataSet.java
r2512 r2655 7 7 import java.util.HashMap; 8 8 import java.util.concurrent.CopyOnWriteArrayList; 9 import java.util.logging.Logger;10 9 11 10 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 19 18 */ 20 19 public class HistoryDataSet { 21 private final static Logger logger = Logger.getLogger(HistoryDataSet.class.getName());20 //private final static Logger logger = Logger.getLogger(HistoryDataSet.class.getName()); 22 21 23 22 /** the unique instance */ … … 46 45 47 46 public void addHistoryDataSetListener(HistoryDataSetListener listener) { 48 synchronized(listeners) { 49 if (!listeners.contains(listener)) { 50 listeners.add(listener); 51 } 47 if (listener != null) { 48 listeners.addIfAbsent(listener); 52 49 } 53 50 } 54 51 55 52 public void removeHistoryDataSetListener(HistoryDataSetListener listener) { 56 synchronized(listeners) { 57 if (listeners.contains(listener)) { 58 listeners.remove(listener); 59 } 60 } 53 listeners.remove(listener); 61 54 } 62 55 -
trunk/src/org/openstreetmap/josm/gui/MapFrame.java
r2629 r2655 9 9 import java.awt.event.MouseWheelListener; 10 10 import java.util.ArrayList; 11 import java.util.Collection;12 11 import java.util.List; 13 12 import java.util.concurrent.CopyOnWriteArrayList; … … 334 333 * the mapMode listeners 335 334 */ 336 private static final Co llection<MapModeChangeListener> mapModeChangeListeners = new CopyOnWriteArrayList<MapModeChangeListener>();337 335 private static final CopyOnWriteArrayList<MapModeChangeListener> mapModeChangeListeners = new CopyOnWriteArrayList<MapModeChangeListener>(); 336 /** 338 337 * Adds a mapMode change listener 339 338 * … … 341 340 */ 342 341 public static void addMapModeChangeListener(MapModeChangeListener listener) { 343 if (listener != null && ! mapModeChangeListeners.contains(listener)) {344 mapModeChangeListeners.add (listener);342 if (listener != null) { 343 mapModeChangeListeners.addIfAbsent(listener); 345 344 } 346 345 } … … 351 350 */ 352 351 public static void removeMapModeChangeListener(MapModeChangeListener listener) { 353 if (listener != null && mapModeChangeListeners.contains(listener)) { 354 mapModeChangeListeners.remove(listener); 355 } 352 mapModeChangeListeners.remove(listener); 356 353 } 357 354 -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r2654 r2655 83 83 * the layer listeners 84 84 */ 85 private static final Co llection<MapView.LayerChangeListener> layerChangeListeners = new CopyOnWriteArrayList<MapView.LayerChangeListener>();86 private static final Co llection<EditLayerChangeListener> editLayerChangeListeners = new CopyOnWriteArrayList<EditLayerChangeListener>();85 private static final CopyOnWriteArrayList<MapView.LayerChangeListener> layerChangeListeners = new CopyOnWriteArrayList<MapView.LayerChangeListener>(); 86 private static final CopyOnWriteArrayList<EditLayerChangeListener> editLayerChangeListeners = new CopyOnWriteArrayList<EditLayerChangeListener>(); 87 87 88 88 /** … … 92 92 */ 93 93 public static void removeLayerChangeListener(MapView.LayerChangeListener listener) { 94 if (listener != null && layerChangeListeners.contains(listener)) { 95 layerChangeListeners.remove(listener); 96 } 94 layerChangeListeners.remove(listener); 97 95 } 98 96 99 97 public static void removeEditLayerChangeListener(EditLayerChangeListener listener) { 100 if (listener != null && editLayerChangeListeners.contains(listener)) { 101 editLayerChangeListeners.remove(listener); 102 } 98 editLayerChangeListeners.remove(listener); 103 99 } 104 100 … … 111 107 */ 112 108 public static void addLayerChangeListener(MapView.LayerChangeListener listener) { 113 if (listener != null && ! layerChangeListeners.contains(listener)) {114 layerChangeListeners.add (listener);109 if (listener != null) { 110 layerChangeListeners.addIfAbsent(listener); 115 111 } 116 112 } 117 113 118 114 public static void addEditLayerChangeListener(EditLayerChangeListener listener) { 119 if (listener != null && ! layerChangeListeners.contains(listener)) {120 editLayerChangeListeners.add (listener);115 if (listener != null) { 116 editLayerChangeListeners.addIfAbsent(listener); 121 117 } 122 118 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellEditor.java
r2512 r2655 45 45 46 46 public void addNavigationListeners(NavigationListener listener) { 47 if (listener != null && ! (listeners.contains(listener))) {48 listeners.add (listener);47 if (listener != null) { 48 listeners.addIfAbsent(listener); 49 49 } 50 50 } 51 51 52 52 public void removeavigationListeners(NavigationListener listener) { 53 if (listener != null && listeners.contains(listener)) { 54 listeners.remove(listener); 55 } 53 listeners.remove(listener); 56 54 } 57 55 … … 116 114 } 117 115 switch(decision.getDecisionType()) { 118 119 120 121 122 123 124 125 126 127 128 116 case UNDECIDED: 117 editor.setSelectedIndex(0); 118 break; 119 case KEEP_ONE: 120 editor.setSelectedItem(decision.getChosenValue()); 121 break; 122 case KEEP_NONE: 123 editor.setSelectedItem(MultiValueDecisionType.KEEP_NONE); 124 break; 125 case KEEP_ALL: 126 editor.setSelectedItem(MultiValueDecisionType.KEEP_ALL); 129 127 } 130 128 } … … 167 165 } else if (MultiValueDecisionType.class.isInstance(value)) { 168 166 switch(MultiValueDecisionType.class.cast(value)) { 169 170 171 172 173 174 175 176 177 178 167 case KEEP_NONE: 168 setText(tr("none")); 169 setFont(UIManager.getFont("ComboBox.font").deriveFont(Font.ITALIC + Font.BOLD)); 170 break; 171 case KEEP_ALL: 172 setText(tr("all")); 173 setFont(UIManager.getFont("ComboBox.font").deriveFont(Font.ITALIC + Font.BOLD)); 174 break; 175 default: 176 // don't display other values 179 177 } 180 178 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java
r2621 r2655 14 14 import java.util.List; 15 15 import java.util.Set; 16 import java.util.logging.Logger;17 16 18 17 import javax.swing.AbstractAction; … … 35 34 import org.openstreetmap.josm.data.osm.DataSet; 36 35 import org.openstreetmap.josm.data.osm.OsmPrimitive; 36 import org.openstreetmap.josm.data.osm.event.DatasetEventManager; 37 37 import org.openstreetmap.josm.gui.MapFrame; 38 38 import org.openstreetmap.josm.gui.MapView; … … 61 61 */ 62 62 public class ChangesetDialog extends ToggleDialog{ 63 static private final Logger logger = Logger.getLogger(ChangesetDialog.class.getName());63 //static private final Logger logger = Logger.getLogger(ChangesetDialog.class.getName()); 64 64 65 65 private ChangesetInSelectionListModel inSelectionModel; … … 98 98 99 99 ChangesetCache.getInstance().addChangesetCacheListener(inActiveDataLayerModel); 100 MapView.addLayerChangeListener(inActiveDataLayerModel);101 100 102 101 DblClickHandler dblClickHandler = new DblClickHandler(); … … 114 113 MapView.removeLayerChangeListener(inSelectionModel); 115 114 DataSet.selListeners.remove(inSelectionModel); 116 MapView.removeLayerChangeListener(inActiveDataLayerModel); 115 } 116 117 @Override 118 public void showNotify() { 119 DatasetEventManager.getInstance().addDatasetListener(inActiveDataLayerModel, true); 120 } 121 122 @Override 123 public void hideNotify() { 124 DatasetEventManager.getInstance().removeDatasetListener(inActiveDataLayerModel); 117 125 } 118 126 -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r2621 r2655 47 47 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 48 48 import org.openstreetmap.josm.gui.SideButton; 49 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;50 49 import org.openstreetmap.josm.gui.layer.Layer; 51 50 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 285 284 286 285 public void addListDataListener(ListDataListener l) { 287 if (l != null && ! listeners.contains(l)) {288 listeners.add (l);286 if (l != null) { 287 listeners.addIfAbsent(l); 289 288 } 290 289 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r2626 r2655 642 642 */ 643 643 public void addLayerListModelListener(LayerListModelListener listener) { 644 synchronized(listeners) { 645 if (listener != null && !listeners.contains(listener)) { 646 listeners.add(listener); 647 } 644 if (listener != null) { 645 listeners.addIfAbsent(listener); 648 646 } 649 647 } … … 655 653 */ 656 654 public void removeLayerListModelListener(LayerListModelListener listener) { 657 synchronized(listeners) { 658 if (listener != null && listeners.contains(listener)) { 659 listeners.remove(listener); 660 } 661 } 655 listeners.remove(listener); 662 656 } 663 657 -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r2632 r2655 36 36 import org.openstreetmap.josm.data.osm.Relation; 37 37 import org.openstreetmap.josm.data.osm.RelationMember; 38 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; 38 39 import org.openstreetmap.josm.data.osm.event.DataChangedEvent; 39 40 import org.openstreetmap.josm.data.osm.event.DataSetListener; … … 738 739 } 739 740 } 741 742 public void otherDatasetChange(AbstractDatasetChangedEvent event) {/* ignore */} 740 743 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetListModel.java
r2616 r2655 9 9 import java.util.List; 10 10 import java.util.Set; 11 import java.util.logging.Logger;12 11 13 12 import javax.swing.DefaultListModel; … … 20 19 import org.openstreetmap.josm.data.osm.DataSet; 21 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 import org.openstreetmap.josm.data.osm.Storage; 22 22 23 23 public class ChangesetListModel extends DefaultListModel implements ChangesetCacheListener{ 24 static private final Logger logger = Logger.getLogger(ChangesetListModel.class.getName());24 //static private final Logger logger = Logger.getLogger(ChangesetListModel.class.getName()); 25 25 26 26 private final List<Changeset> data = new ArrayList<Changeset>(); 27 private final Storage<Changeset> shownChangesets = new Storage<Changeset>(); 27 28 private DefaultListSelectionModel selectionModel; 28 29 … … 63 64 } 64 65 66 protected void addChangeset(Changeset changeset) { 67 if (shownChangesets.add(changeset)) { 68 setChangesets(shownChangesets); 69 updateModel(); 70 } 71 } 72 73 protected void removeChangeset(Changeset changeset) { 74 if (shownChangesets.remove(changeset)) { 75 setChangesets(shownChangesets); 76 updateModel(); 77 } 78 } 79 65 80 protected void setChangesets(Collection<Changeset> changesets) { 81 shownChangesets.clear(); 82 if (changesets != null) { 83 shownChangesets.addAll(changesets); 84 } 85 updateModel(); 86 } 87 88 private void updateModel() { 66 89 Set<Changeset> sel = getSelectedChangesets(); 67 90 data.clear(); 68 if (changesets == null) { 69 fireContentsChanged(this, 0, getSize()); 70 return; 71 } 72 data.addAll(changesets); 91 data.addAll(shownChangesets); 73 92 ChangesetCache cache = ChangesetCache.getInstance(); 74 93 for (Changeset cs: data) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetsInActiveDataLayerListModel.java
r2652 r2655 4 4 import javax.swing.DefaultListSelectionModel; 5 5 6 import org.openstreetmap.josm.Main; 7 import org.openstreetmap.josm.gui.MapView; 8 import org.openstreetmap.josm.gui.layer.DataChangeListener; 9 import org.openstreetmap.josm.gui.layer.Layer; 10 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 6 import org.openstreetmap.josm.data.osm.Changeset; 7 import org.openstreetmap.josm.data.osm.OsmPrimitive; 8 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; 9 import org.openstreetmap.josm.data.osm.event.ChangesetIdChangedEvent; 10 import org.openstreetmap.josm.data.osm.event.DataChangedEvent; 11 import org.openstreetmap.josm.data.osm.event.DataSetListener; 12 import org.openstreetmap.josm.data.osm.event.NodeMovedEvent; 13 import org.openstreetmap.josm.data.osm.event.PrimitivesAddedEvent; 14 import org.openstreetmap.josm.data.osm.event.PrimitivesRemovedEvent; 15 import org.openstreetmap.josm.data.osm.event.RelationMembersChangedEvent; 16 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent; 17 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent; 11 18 12 public class ChangesetsInActiveDataLayerListModel extends ChangesetListModel implements MapView.LayerChangeListener, DataChangeListener{19 public class ChangesetsInActiveDataLayerListModel extends ChangesetListModel implements DataSetListener { 13 20 14 21 public ChangesetsInActiveDataLayerListModel(DefaultListSelectionModel selectionModel) { … … 16 23 } 17 24 18 /* ---------------------------------------------------------------------------- */ 19 /* Interface LayerChangeListener */ 20 /* ---------------------------------------------------------------------------- */ 21 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 22 if (oldLayer != null && oldLayer instanceof OsmDataLayer) { 23 OsmDataLayer l = (OsmDataLayer)oldLayer; 24 l.listenerDataChanged.remove(this); 25 } 26 if (newLayer == null) { 27 setChangesets(null); 28 } else if (newLayer instanceof OsmDataLayer){ 29 OsmDataLayer l = (OsmDataLayer)newLayer; 30 l.listenerDataChanged.add(this); 31 initFromDataSet(l.data); 32 } else { 33 setChangesets(null); 25 public void dataChanged(DataChangedEvent event) { 26 initFromPrimitives(event.getPrimitives()); 27 } 28 29 public void nodeMoved(NodeMovedEvent event) {/* ignored */} 30 31 public void primtivesAdded(PrimitivesAddedEvent event) { 32 for (OsmPrimitive primitive:event.getPrimitives()) { 33 addChangeset(new Changeset(primitive.getChangesetId())); 34 34 } 35 35 } 36 public void layerAdded(Layer newLayer) {}37 public void layerRemoved(Layer oldLayer) {}38 36 39 /* ---------------------------------------------------------------------------- */ 40 /* Interface DataChangeListener */ 41 /* ---------------------------------------------------------------------------- */ 42 public void dataChanged(OsmDataLayer l) { 43 if (l == null) return; 44 if (l != Main.main.getEditLayer()) return; 45 initFromDataSet(l.data); 37 public void primtivesRemoved(PrimitivesRemovedEvent event) { 38 for (OsmPrimitive primitive:event.getPrimitives()) { 39 removeChangeset(new Changeset(primitive.getChangesetId())); 40 } 46 41 } 42 43 public void relationMembersChanged(RelationMembersChangedEvent event) {/* ignored */} 44 45 public void tagsChanged(TagsChangedEvent event) {/* ignored */} 46 47 public void otherDatasetChange(AbstractDatasetChangedEvent event) { 48 if (event instanceof ChangesetIdChangedEvent) { 49 ChangesetIdChangedEvent e = (ChangesetIdChangedEvent) event; 50 removeChangeset(new Changeset(e.getOldChangesetId())); 51 addChangeset(new Changeset(e.getNewChangesetId())); 52 } 53 } 54 55 public void wayNodesChanged(WayNodesChangedEvent event) {/* ignored */} 56 47 57 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r2622 r2655 33 33 import org.openstreetmap.josm.data.osm.RelationMember; 34 34 import org.openstreetmap.josm.data.osm.Way; 35 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; 35 36 import org.openstreetmap.josm.data.osm.event.DataChangedEvent; 36 37 import org.openstreetmap.josm.data.osm.event.DataSetListener; … … 131 132 132 133 public void wayNodesChanged(WayNodesChangedEvent event) {/* ignore */} 134 135 public void otherDatasetChange(AbstractDatasetChangedEvent event) {/* ignore */} 133 136 /* --------------------------------------------------------------------------- */ 134 137 135 138 public void addMemberModelListener(IMemberModelListener listener) { 136 synchronized (listeners) { 137 if (listener != null && !listeners.contains(listener)) { 138 listeners.add(listener); 139 } 139 if (listener != null) { 140 listeners.addIfAbsent(listener); 140 141 } 141 142 } 142 143 143 144 public void removeMemberModelListener(IMemberModelListener listener) { 144 synchronized (listeners) { 145 if (listener != null && listeners.contains(listener)) { 146 listeners.remove(listener); 147 } 148 } 145 listeners.remove(listener); 149 146 } 150 147 151 148 protected void fireMakeMemberVisible(int index) { 152 synchronized (listeners) { 153 for (IMemberModelListener listener : listeners) { 154 listener.makeMemberVisible(index); 155 } 149 for (IMemberModelListener listener : listeners) { 150 listener.makeMemberVisible(index); 156 151 } 157 152 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationTreeModel.java
r2578 r2655 4 4 import java.util.List; 5 5 import java.util.concurrent.CopyOnWriteArrayList; 6 import java.util.logging.Logger;7 6 8 7 import javax.swing.event.TreeModelEvent; … … 24 23 */ 25 24 public class RelationTreeModel implements TreeModel { 26 private static final Logger logger = Logger.getLogger(RelationTreeModel.class.getName());25 //private static final Logger logger = Logger.getLogger(RelationTreeModel.class.getName()); 27 26 28 27 /** the root relation */ … … 215 214 216 215 public void addTreeModelListener(TreeModelListener l) { 217 synchronized (listeners) { 218 if (l != null && !listeners.contains(l)) { 219 listeners.add(l); 220 } 216 if (l != null) { 217 listeners.addIfAbsent(l); 221 218 } 222 219 } 223 220 224 221 public void removeTreeModelListener(TreeModelListener l) { 225 synchronized (listeners) { 226 if (l != null && listeners.contains(l)) { 227 listeners.remove(l); 228 } 229 } 222 listeners.remove(l); 230 223 } 231 224 -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r2626 r2655 20 20 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 21 21 import org.openstreetmap.josm.data.osm.Way; 22 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; 22 23 import org.openstreetmap.josm.data.osm.event.DataChangedEvent; 23 24 import org.openstreetmap.josm.data.osm.event.DataSetListener; … … 830 831 } 831 832 833 public void otherDatasetChange(AbstractDatasetChangedEvent event) { 834 // Irrelevant 835 } 836 832 837 /* ---------------------------------------------------------------------- */ 833 838 /* DataChangeListener */ -
trunk/src/org/openstreetmap/josm/gui/io/FilenameCellEditor.java
r2512 r2655 72 72 73 73 public void addCellEditorListener(CellEditorListener l) { 74 if ( !listeners.contains(l)) {75 listeners.add (l);74 if (l != null) { 75 listeners.addIfAbsent(l); 76 76 } 77 77 } … … 102 102 103 103 public void removeCellEditorListener(CellEditorListener l) { 104 if (listeners.contains(l)) { 105 listeners.remove(l); 106 } 104 listeners.remove(l); 107 105 } 108 106 -
trunk/src/org/openstreetmap/josm/gui/io/SaveFlagCellEditor.java
r2512 r2655 37 37 38 38 public void addCellEditorListener(CellEditorListener l) { 39 if ( !listeners.contains(l)) {40 listeners.add (l);39 if (l != null) { 40 listeners.addIfAbsent(l); 41 41 } 42 42 } … … 67 67 68 68 public void removeCellEditorListener(CellEditorListener l) { 69 if (listeners.contains(l)) { 70 listeners.remove(l); 71 } 69 listeners.remove(l); 72 70 } 73 71 … … 90 88 SaveLayerInfo info = (SaveLayerInfo)value; 91 89 switch(column) { 92 93 90 case 4: setInitialValue(info.isDoUploadToServer()); break; 91 case 5: setInitialValue(info.isDoSaveToFile()); break; 94 92 } 95 93 return this; -
trunk/src/org/openstreetmap/josm/gui/preferences/StyleSourceEditor.java
r2626 r2655 859 859 860 860 public void addCellEditorListener(CellEditorListener l) { 861 if ( !listeners.contains(l)) {862 listeners.add (l);861 if (l != null) { 862 listeners.addIfAbsent(l); 863 863 } 864 864 } … … 891 891 892 892 public void removeCellEditorListener(CellEditorListener l) { 893 if (listeners.contains(l)) { 894 listeners.remove(l); 895 } 893 listeners.remove(l); 896 894 } 897 895 -
trunk/src/org/openstreetmap/josm/io/NmeaReader.java
r2626 r2655 272 272 e[GPGGA.LONGITUDE.position] 273 273 ); 274 if(latLon==null) throw(null); // malformed 274 if(latLon==null) 275 throw new NullPointerException(); // malformed 275 276 276 277 if((latLon.lat()==0.0) && (latLon.lon()==0.0)) {
Note:
See TracChangeset
for help on using the changeset viewer.