Changeset 28620 in osm for applications/editors/josm/plugins/turnlanes/src/org/openstreetmap
- Timestamp:
- 2012-08-24T01:52:59+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/gui/TurnLanesDialog.java
r27927 r28620 18 18 import javax.swing.JToggleButton; 19 19 20 import org.openstreetmap.josm.Main;21 20 import org.openstreetmap.josm.actions.JosmAction; 22 21 import org.openstreetmap.josm.data.SelectionChangedListener; … … 40 39 import org.openstreetmap.josm.plugins.turnlanes.model.ModelContainer; 41 40 42 public class TurnLanesDialog extends ToggleDialog {41 public class TurnLanesDialog extends ToggleDialog implements EditLayerChangeListener, SelectionChangedListener { 43 42 private class EditAction extends JosmAction { 44 43 private static final long serialVersionUID = 4114119073563457706L; … … 152 151 super(tr("Turn Lanes"), "turnlanes.png", tr("Edit turn lanes"), null, 200); 153 152 154 MapView.addEditLayerChangeListener(new EditLayerChangeListener() { 155 @Override 156 public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) { 157 if (oldLayer != null) { 158 oldLayer.data.removeDataSetListener(dataSetListener); 159 } 160 161 if (newLayer != null) { 162 newLayer.data.addDataSetListener(dataSetListener); 163 } 164 } 165 }); 166 167 DataSet.addSelectionListener(new SelectionChangedListener() { 168 @Override 169 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 170 if (selected.equals(new HashSet<OsmPrimitive>(newSelection))) { 171 return; 172 } 173 selected.clear(); 174 selected.addAll(newSelection); 175 176 refresh(); 177 } 178 }); 153 MapView.addEditLayerChangeListener(this); 154 DataSet.addSelectionListener(this); 179 155 180 156 final JPanel buttonPanel = new JPanel(new GridLayout(1, 2, 4, 4)); … … 216 192 } 217 193 } 194 195 @Override 196 public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) { 197 if (oldLayer != null) { 198 oldLayer.data.removeDataSetListener(dataSetListener); 199 } 200 201 if (newLayer != null) { 202 newLayer.data.addDataSetListener(dataSetListener); 203 } 204 } 205 206 @Override 207 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 208 if (selected.equals(new HashSet<OsmPrimitive>(newSelection))) { 209 return; 210 } 211 selected.clear(); 212 selected.addAll(newSelection); 213 214 refresh(); 215 } 216 217 @Override 218 public void destroy() { 219 super.destroy(); 220 MapView.removeEditLayerChangeListener(this); 221 DataSet.removeSelectionListener(this); 222 } 218 223 }
Note:
See TracChangeset
for help on using the changeset viewer.