From 5200b6d0177918ab7f83a00cae71b41496b7c57a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torstein=20I=2E=20B=C3=B8?= Date: Sun, 7 Jun 2015 22:08:10 +0200 Subject: [PATCH] Bugfix: fixed crash when non-ways where selected --- .../kartverket/actions/ReplaceWayAction.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/org/openstreetmap/josm/plugins/kartverket/actions/ReplaceWayAction.java b/src/org/openstreetmap/josm/plugins/kartverket/actions/ReplaceWayAction.java index b9a798c..1eef1e4 100644 --- a/src/org/openstreetmap/josm/plugins/kartverket/actions/ReplaceWayAction.java +++ b/src/org/openstreetmap/josm/plugins/kartverket/actions/ReplaceWayAction.java @@ -45,7 +45,7 @@ public void actionPerformed(ActionEvent e) { // There must be two ways selected: one with id > 0 and one new. List selection = new ArrayList<>(getCurrentDataSet().getSelected()); - if (selection.size() != 2 && selection.get(0) instanceof Way && selection.get(1) instanceof Way) { + if (selection.size() != 2 || !(selection.get(0) instanceof Way && selection.get(1) instanceof Way)) { new Notification( tr("This tool replaces coastline of one way with another, and so requires exactly two coatline ways to be selected.") ).setIcon(JOptionPane.WARNING_MESSAGE).show(); @@ -115,7 +115,16 @@ protected void updateEnabledState() { @Override protected void updateEnabledState( Collection selection ) { - setEnabled(selection != null && selection.size() >= 2 ); + boolean allWays = true; + for (OsmPrimitive w : selection) { + if( !(w instanceof Way)){ + allWays = false; + break; + } + + } + + setEnabled(selection != null && selection.size() == 2 && allWays); } }