/*
 * @(#)SendToBackAction.java
 *
 * Copyright (c) 2003-2008 by the original authors of JHotDraw and all its
 * contributors. All rights reserved.
 *
 * You may not use, copy or modify this file, except in compliance with the 
 * license agreement you entered into with the copyright holders. For details
 * see accompanying license terms.
 */
package org.jhotdraw.draw.action;

import java.util.*;
import javax.swing.undo.*;
import org.jhotdraw.draw.*;
import org.jhotdraw.util.ResourceBundleUtil;

/**
 * SendToBackAction.
 *
 * @author  Werner Randelshofer
 * @version $Id: SendToBackAction.java 717 2010-11-21 12:30:57Z rawcoder $
 */
public class SendToBackAction extends AbstractSelectedAction {

    public final static String ID = "edit.sendToBack";

    /** Creates a new instance. */
    public SendToBackAction(DrawingEditor editor) {
        super(editor);
        ResourceBundleUtil labels =
                ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels");
        labels.configureAction(this, ID);
        updateEnabledState();
    }

    @Override
    public void actionPerformed(java.awt.event.ActionEvent e) {
        final DrawingView view = getView();
        final LinkedList
figures = new LinkedList
(view.getSelectedFigures()); sendToBack(view, figures); fireUndoableEditHappened(new AbstractUndoableEdit() { @Override public String getPresentationName() { ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); return labels.getTextProperty(ID); } @Override public void redo() throws CannotRedoException { super.redo(); SendToBackAction.sendToBack(view, figures); } @Override public void undo() throws CannotUndoException { super.undo(); BringToFrontAction.bringToFront(view, figures); } }); } public static void sendToBack(DrawingView view, Collection figures) { Iterator i = figures.iterator(); Drawing drawing = view.getDrawing(); while (i.hasNext()) { Figure figure = (Figure) i.next(); drawing.sendToBack(figure); } } }

Ads help maintain this website.