Changeset 27750 in osm for applications/editors/josm


Ignore:
Timestamp:
2012-02-12T07:08:03+01:00 (13 years ago)
Author:
joshdoe
Message:

utilsplugin2: make use of Replace Geometry outside class easier

File:
1 edited

Legend:

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

    r27710 r27750  
    5454        OsmPrimitive firstObject = selection.get(0);
    5555        OsmPrimitive secondObject = selection.get(1);
    56 
     56       
     57        try {
     58            replace(firstObject, secondObject);
     59        } catch (IllegalArgumentException ex) {
     60            JOptionPane.showMessageDialog(Main.parent,
     61                    ex.getMessage(), TITLE, JOptionPane.INFORMATION_MESSAGE);
     62        }
     63         
     64    }
     65    public void replace(OsmPrimitive firstObject, OsmPrimitive secondObject) {
    5766        if (firstObject instanceof Way && secondObject instanceof Way) {
    5867            replaceWayWithWay(Arrays.asList((Way) firstObject, (Way) secondObject));
    5968        } else if (firstObject instanceof Node && secondObject instanceof Node) {
    60             JOptionPane.showMessageDialog(Main.parent,
    61                     tr("To replace a node with a node, use the node merge tool."),
    62                     TITLE, JOptionPane.INFORMATION_MESSAGE);
    63             return;
     69            throw new IllegalArgumentException(tr("To replace a node with a node, use the node merge tool."));
    6470        } else if (firstObject instanceof Node) {
    6571            replaceNode((Node) firstObject, secondObject);
     
    6773            replaceNode((Node) secondObject, firstObject);
    6874        } else {
    69             JOptionPane.showMessageDialog(Main.parent,
    70                     tr("This tool can only replace a node with a way, a node with a multipolygon, or a way with a way."),
    71                     TITLE, JOptionPane.INFORMATION_MESSAGE);
    72             return;
     75            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."));
    7376        }
    7477    }
Note: See TracChangeset for help on using the changeset viewer.