Ignore:
Timestamp:
2012-02-25T17:03:41+01:00 (13 years ago)
Author:
joshdoe
Message:

utilsplugin2: replace geometry methods indicate success (for conflation plugin)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/dumbutils/ReplaceGeometryAction.java

    r27852 r27937  
    6363         
    6464    }
    65     public void replace(OsmPrimitive firstObject, OsmPrimitive secondObject) {
     65    public boolean replace(OsmPrimitive firstObject, OsmPrimitive secondObject) {
    6666        if (firstObject instanceof Way && secondObject instanceof Way) {
    67             replaceWayWithWay(Arrays.asList((Way) firstObject, (Way) secondObject));
     67            return replaceWayWithWay(Arrays.asList((Way) firstObject, (Way) secondObject));
    6868        } else if (firstObject instanceof Node && secondObject instanceof Node) {
    6969            throw new IllegalArgumentException(tr("To replace a node with a node, use the node merge tool."));
    7070        } else if (firstObject instanceof Node) {
    71             replaceNode((Node) firstObject, secondObject);
     71            return replaceNode((Node) firstObject, secondObject);
    7272        } else if (secondObject instanceof Node) {
    73             replaceNode((Node) secondObject, firstObject);
     73            return replaceNode((Node) secondObject, firstObject);
    7474        } else {
    7575            throw new IllegalArgumentException(tr("This tool can only replace a node with a way, a node with a multipolygon, or a way with a way."));
     
    8383     * @param target
    8484     */
    85     public void replaceNode(Node node, OsmPrimitive target) {
     85    public boolean replaceNode(Node node, OsmPrimitive target) {
    8686        if (!OsmPrimitive.getFilteredList(node.getReferrers(), Way.class).isEmpty()) {
    8787            JOptionPane.showMessageDialog(Main.parent, tr("Node belongs to way(s), cannot replace."),
    8888                    TITLE, JOptionPane.INFORMATION_MESSAGE);
    89             return;
     89            return false;
    9090        }
    9191
     
    9393            JOptionPane.showMessageDialog(Main.parent, tr("Relation is not a multipolygon, cannot be used as a replacement."),
    9494                    TITLE, JOptionPane.INFORMATION_MESSAGE);
    95             return;
     95            return false;
    9696        }
    9797
     
    125125        if (tagResolutionCommands == null) {
    126126            // user canceled tag merge dialog
    127             return;
     127            return false;
    128128        }
    129129        commands.addAll(tagResolutionCommands);
     
    161161                tr("Replace geometry for node {0}", node.getDisplayName(DefaultNameFormatter.getInstance())),
    162162                commands));
    163     }
    164    
    165     public void replaceWayWithWay(List<Way> selection) {
     163        return true;
     164    }
     165   
     166    public boolean replaceWayWithWay(List<Way> selection) {
    166167        // determine which way will be replaced and which will provide the geometry
    167168        boolean overrideNewCheck = false;
     
    190191                    tr("Please select one way that exists in the database and one new way with correct geometry."),
    191192                    TITLE, JOptionPane.WARNING_MESSAGE);
    192             return;
     193            return false;
    193194        }
    194195
     
    198199                    tr("The ways must be entirely within the downloaded area."),
    199200                    TITLE, JOptionPane.WARNING_MESSAGE);
    200             return;
     201            return false;
    201202        }
    202203       
     
    205206                    tr("The way to be replaced cannot have any nodes with properties or relation memberships unless they belong to both ways."),
    206207                    TITLE, JOptionPane.WARNING_MESSAGE);
    207             return;
     208            return false;
    208209        }
    209210
     
    214215        if (tagResolutionCommands == null) {
    215216            // user canceled tag merge dialog
    216             return;
     217            return false;
    217218        }
    218219        commands.addAll(tagResolutionCommands);
     
    273274                tr("Replace geometry for way {0}", way.getDisplayName(DefaultNameFormatter.getInstance())),
    274275                commands));
     276        return true;
    275277    }
    276278
Note: See TracChangeset for help on using the changeset viewer.