Search in sources :

Example 1 with DesignEditorUI

use of edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI in project cogtool by cogtool.

the class DesignEditorController method createDuplicateFrameAction.

protected IListenerAction createDuplicateFrameAction() {
    return new IListenerAction() {

        public Class<?> getParameterClass() {
            return DesignEditorUI.DuplicateParameters.class;
        }

        public boolean performAction(Object prms) {
            // From DesignEditorUI
            DesignEditorUI.DuplicateParameters parameters = (DesignEditorUI.DuplicateParameters) prms;
            Frame[] framesToDuplicate = parameters.selection.getSelectedFrames();
            if ((framesToDuplicate != null) && (framesToDuplicate.length > 0)) {
                FrameSubsetDuplicator duplicator = new FrameSubsetDuplicator(framesToDuplicate);
                Frame[] duplicatedFrames = new Frame[framesToDuplicate.length];
                for (int i = 0; i < framesToDuplicate.length; i++) {
                    Frame duplicatedFrame = duplicator.getOrDuplicate(framesToDuplicate[i]);
                    duplicatedFrames[i] = duplicatedFrame;
                    duplicatedFrame.moveFrameOrigin(parameters.dx, parameters.dy);
                }
                design.addFrames(duplicatedFrames);
                undoMgr.addEdit(createDuplicateFramesEdit(duplicatedFrames));
                return true;
            }
            interaction.protestNoSelection();
            return false;
        }
    };
}
Also used : DesignEditorUI(edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI) Frame(edu.cmu.cs.hcii.cogtool.model.Frame) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint)

Aggregations

DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)1 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)1 DesignEditorUI (edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI)1 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)1