Ignore:
Timestamp:
2014-09-14T17:11:14+02:00 (10 years ago)
Author:
Don-vip
Message:

see #10511 - add unit test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r7052 r7534  
    4848
    4949/**
    50  * Join Areas (i.e. closed ways and multipolygons)
     50 * Join Areas (i.e. closed ways and multipolygons).
     51 * @since 2575
    5152 */
    5253public class JoinAreasAction extends JosmAction {
     
    5758
    5859    /**
    59      * This helper class describes join ares action result.
     60     * This helper class describes join areas action result.
    6061     * @author viesturs
    61      *
    6262     */
    6363    public static class JoinAreasResult {
     
    394394
    395395    /**
    396      * Gets called whenever the shortcut is pressed or the menu entry is selected
    397      * Checks whether the selected objects are suitable to join and joins them if so
     396     * Gets called whenever the shortcut is pressed or the menu entry is selected.
     397     * Checks whether the selected objects are suitable to join and joins them if so.
    398398     */
    399399    @Override
    400400    public void actionPerformed(ActionEvent e) {
    401         LinkedList<Way> ways = new LinkedList<>(Main.main.getCurrentDataSet().getSelectedWays());
     401        join(Main.main.getCurrentDataSet().getSelectedWays());
     402    }
     403
     404    /**
     405     * Joins the given ways.
     406     * @param ways Ways to join
     407     * @since 7534
     408     */
     409    public void join(Collection<Way> ways) {
    402410        addedRelations.clear();
    403411
     
    471479                }
    472480                DataSet ds = Main.main.getCurrentDataSet();
    473                 ds.setSelected(allWays);
    474                 Main.map.mapView.repaint();
     481                if (ds != null) {
     482                    ds.setSelected(allWays);
     483                    Main.map.mapView.repaint();
     484                }
    475485            } else {
    476486                new Notification(
     
    479489                        .show();
    480490            }
    481         }
    482         catch (UserCancelException exception) {
     491        } catch (UserCancelException exception) {
    483492            //revert changes
    484493            //FIXME: this is dirty hack
     
    915924    /**
    916925     * This is a method splits way into smaller parts, using the prepared nodes list as split points.
    917      * Uses  SplitWayAction.splitWay for the heavy lifting.
     926     * Uses {@link SplitWayAction#splitWay} for the heavy lifting.
    918927     * @return list of split ways (or original ways if no splitting is done).
    919928     */
     
    924933
    925934        if (chunks.size() > 1) {
    926             SplitWayResult split = SplitWayAction.splitWay(Main.main.getEditLayer(), way, chunks, Collections.<OsmPrimitive>emptyList());
     935            SplitWayResult split = SplitWayAction.splitWay(getEditLayer(), way, chunks, Collections.<OsmPrimitive>emptyList());
    927936
    928937            //execute the command, we need the results
     
    12541263     * @return list of polygons, or null if too complex relation encountered.
    12551264     */
    1256     private List<Multipolygon> collectMultipolygons(List<Way> selectedWays) {
     1265    private List<Multipolygon> collectMultipolygons(Collection<Way> selectedWays) {
    12571266
    12581267        List<Multipolygon> result = new ArrayList<>();
     
    13801389
    13811390    /**
    1382      * Removes a given OsmPrimitive from all relations
     1391     * Removes a given OsmPrimitive from all relations.
    13831392     * @param osm Element to remove from all relations
    13841393     * @return List of relations with roles the primitives was part of
Note: See TracChangeset for help on using the changeset viewer.