Changeset 20682 in osm for applications
- Timestamp:
- 2010-03-26T16:28:37+01:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/OsbLayer.java
r20679 r20682 38 38 import java.awt.event.MouseListener; 39 39 import java.awt.image.ImageObserver; 40 import java.util.ArrayList; 40 41 import java.util.Collection; 42 import java.util.List; 41 43 42 44 import javax.swing.Icon; … … 237 239 Node n = getNearestNode(e.getPoint()); 238 240 if(n != null && data.getNodes().contains(n)) { 239 dialog.setSelectedNode(n); 241 List<OsmPrimitive> selected = new ArrayList<OsmPrimitive>(); 242 selected.add(n); 243 data.setSelected(selected); 244 } else { 245 data.setSelected(new ArrayList<OsmPrimitive>()); 240 246 } 247 data.fireSelectionChanged(); 241 248 } 242 249 } -
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/OsbPlugin.java
r20463 r20682 38 38 import org.openstreetmap.josm.data.Bounds; 39 39 import org.openstreetmap.josm.data.osm.DataSet; 40 import org.openstreetmap.josm.data.osm.Node; 40 41 import org.openstreetmap.josm.gui.MapFrame; 41 42 import org.openstreetmap.josm.gui.MapView; … … 160 161 161 162 public void updateData() { 163 // store the current selected node 164 Node selectedNode = getDialog().getSelectedNode(); 165 162 166 // determine the bounds of the currently visible area 163 167 Bounds bounds = null; … … 190 194 } 191 195 } 196 197 // restore node selection 198 dialog.setSelectedNode(selectedNode); 192 199 } 193 200 -
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/OsbDialog.java
r20463 r20682 38 38 import java.awt.event.MouseListener; 39 39 import java.util.ArrayList; 40 import java.util.Collection; 40 41 import java.util.Collections; 41 42 import java.util.Comparator; … … 57 58 58 59 import org.openstreetmap.josm.Main; 60 import org.openstreetmap.josm.data.SelectionChangedListener; 59 61 import org.openstreetmap.josm.data.osm.DataSet; 60 62 import org.openstreetmap.josm.data.osm.Node; 61 63 import org.openstreetmap.josm.data.osm.OsmPrimitive; 64 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; 65 import org.openstreetmap.josm.data.osm.event.DataChangedEvent; 66 import org.openstreetmap.josm.data.osm.event.DataSetListener; 67 import org.openstreetmap.josm.data.osm.event.NodeMovedEvent; 68 import org.openstreetmap.josm.data.osm.event.PrimitivesAddedEvent; 69 import org.openstreetmap.josm.data.osm.event.PrimitivesRemovedEvent; 70 import org.openstreetmap.josm.data.osm.event.RelationMembersChangedEvent; 71 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent; 72 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent; 62 73 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 63 74 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 64 import org.openstreetmap.josm.gui.layer.DataChangeListener;65 75 import org.openstreetmap.josm.gui.layer.Layer; 66 import org.openstreetmap.josm.gui.layer.OsmDataLayer;67 76 import org.openstreetmap.josm.plugins.osb.ConfigKeys; 68 77 import org.openstreetmap.josm.plugins.osb.OsbObserver; … … 79 88 import org.openstreetmap.josm.tools.Shortcut; 80 89 81 public class OsbDialog extends ToggleDialog implements OsbObserver, ListSelectionListener, LayerChangeListener, 82 Data ChangeListener, MouseListener, OsbActionObserver {90 public class OsbDialog extends ToggleDialog implements OsbObserver, ListSelectionListener, LayerChangeListener, 91 DataSetListener, SelectionChangedListener, MouseListener, OsbActionObserver { 83 92 84 93 private static final long serialVersionUID = 1L; … … 216 225 closeIssueAction.addActionObserver(this); 217 226 setConnectionMode(offline); 227 DataSet.selListeners.add(this); 218 228 } 219 229 220 230 public synchronized void update(final DataSet dataset) { 221 // store the last selection222 OsbListItem listItem = (OsbListItem) bugList.getSelectedValue();223 Node lastNode = null;224 if(listItem != null) {225 lastNode = listItem.getNode();226 }227 228 231 // create a new list model 229 232 bugListModel = new DefaultListModel(); … … 236 239 } 237 240 bugList.setModel(bugListModel); 238 239 // restore the last selection240 if(lastNode != null) {241 bugList.setSelectedValue(new OsbListItem(lastNode), true);242 }243 241 } 244 242 … … 302 300 bugListModel.removeAllElements(); 303 301 } 304 }305 306 public void dataChanged(OsmDataLayer l) {307 update(l.data);308 302 } 309 303 … … 401 395 402 396 public Node getSelectedNode() { 403 return ((OsbListItem)bugList.getSelectedValue()).getNode(); 397 if(bugList.getSelectedValue() != null) { 398 return ((OsbListItem)bugList.getSelectedValue()).getNode(); 399 } else { 400 return null; 401 } 404 402 } 405 403 406 404 public void setSelectedNode(Node node) { 407 bugList.setSelectedValue(new OsbListItem(node), true); 405 if(node == null) { 406 bugList.clearSelection(); 407 } else { 408 bugList.setSelectedValue(new OsbListItem(node), true); 409 } 408 410 } 409 411 … … 413 415 toggleConnectionMode.setSelected(offline); 414 416 } 417 418 public void dataChanged(DataChangedEvent event) { 419 update(event.getDataset()); 420 } 421 422 public void nodeMoved(NodeMovedEvent event) {} 423 424 public void otherDatasetChange(AbstractDatasetChangedEvent event) {} 425 426 public void primtivesAdded(PrimitivesAddedEvent event) {} 427 428 public void primtivesRemoved(PrimitivesRemovedEvent event) {} 429 430 public void relationMembersChanged(RelationMembersChangedEvent event) {} 431 432 public void tagsChanged(TagsChangedEvent event) {} 433 434 public void wayNodesChanged(WayNodesChangedEvent event) {} 435 436 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 437 if(newSelection.size() == 1 && newSelection.iterator().next() instanceof Node) { 438 Node selectedNode = (Node) newSelection.iterator().next(); 439 if(osbPlugin.getLayer().getDataSet().getNodes().contains(selectedNode)) { 440 setSelectedNode(selectedNode); 441 } else { 442 bugList.clearSelection(); 443 } 444 } else { 445 bugList.clearSelection(); 446 } 447 } 415 448 }
Note:
See TracChangeset
for help on using the changeset viewer.