Ticket #19056: 19056.patch

File 19056.patch, 2.3 KB (added by taylor.smock, 6 years ago)
  • src/org/openstreetmap/josm/command/DeleteCommand.java

     
    478478            cmds.add(new DeleteCommand(primitivesToDelete.iterator().next().getDataSet(), primitivesToDelete));
    479479        }
    480480
    481         return new SequenceCommand(tr("Delete"), cmds);
     481        return SequenceCommand.createSimplifiedSequenceCommand(tr("Delete"), cmds);
    482482    }
    483483
    484484    /**
  • src/org/openstreetmap/josm/command/SequenceCommand.java

     
    7474        this(name, Arrays.asList(sequenz));
    7575    }
    7676
     77    /**
     78     * Convenient constructor, if the commands are known at compile time.
     79     * @param name The description text to be used for the sequence command, if one is created.
     80     * @param sequenz The sequence that should be executed.
     81     * @return Either a SequenceCommand, or the only command in the potential sequence
     82     * @since xxx
     83     */
     84    public static Command createSimplifiedSequenceCommand(String name, Command... sequenz) {
     85        if (sequenz.length == 1) {
     86            return sequenz[0];
     87        }
     88        return new SequenceCommand(name, sequenz);
     89    }
     90
     91    /**
     92     * Convenient constructor, if the commands are known at compile time.
     93     * @param name The description text to be used for the sequence command, if one is created.
     94     * @param sequenz The sequence that should be executed.
     95     * @return Either a SequenceCommand, or the only command in the potential sequence
     96     * @since xxx
     97     */
     98    public static Command createSimplifiedSequenceCommand(String name, Collection<Command> sequenz) {
     99        if (sequenz.size() == 1) {
     100            return sequenz.iterator().next();
     101        }
     102        return new SequenceCommand(name, sequenz);
     103    }
     104
    77105    @Override public boolean executeCommand() {
    78106        for (int i = 0; i < sequence.length; i++) {
    79107            boolean result = sequence[i].executeCommand();