/*
 * @(#)DuplicateCommand.java 5.1
 *
 */

package CH.ifa.draw.standard;

import java.util.Vector;

import de.renew.draw.storables.ontology.Figure;
import de.renew.draw.ui.ontology.DrawingView;
import de.renew.draw.ui.ontology.FigureSelection;

/**
 * Duplicate the selection and select the duplicates.
 * @deprecated This class is not to be used externally and will later be hidden.
 */
@Deprecated(since = "5.0", forRemoval = true)
@SuppressWarnings("removal")
public class DuplicateCommand extends FigureTransferCommand {

    /**
     * Constructs a duplicate command.
     * @param name the command name
     */
    public DuplicateCommand(String name) {
        super(name);
    }

    @Override
    public boolean executeUndoable() {
        DrawingView view = getEditor().view();

        FigureSelection selection = view.getFigureSelection();

        view.clearSelection();

        Vector<Figure> figures = selection.getData();
        insertFigures(figures, 10, 10);
        view.checkDamage();
        return true;
    }

    @Override
    public boolean isExecutable() {
        if (!super.isExecutable()) {
            return false;
        }
        return getEditor().view().selectionCount() > 0;
    }
}