001/* Represents an undo or redo action.
002
003 Copyright (c) 2006-2014 The Regents of the University of California.
004 All rights reserved.
005 Permission is hereby granted, without written agreement and without
006 license or royalty fees, to use, copy, modify, and distribute this
007 software and its documentation for any purpose, provided that the above
008 copyright notice and the following two paragraphs appear in all copies
009 of this software.
010
011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
015 SUCH DAMAGE.
016
017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
022 ENHANCEMENTS, OR MODIFICATIONS.
023
024 PT_COPYRIGHT_VERSION_2
025 COPYRIGHTENDKEY
026 */
027package ptolemy.kernel.undo.test;
028
029import ptolemy.kernel.undo.UndoAction;
030import ptolemy.kernel.undo.UndoStackAttribute;
031
032///////////////////////////////////////////////////////////////////
033//// UndoActionTest
034
035/**
036 Test of UndoActin, an interface represents an undo or redo action that is
037 maintained on an undo/redo stack, such as that maintained by
038 UndoStackAttribute.
039
040 @see UndoStackAttribute
041 @author  Christopher Brooks
042 @version $Id$
043 @since Ptolemy II 5.2
044 @Pt.ProposedRating Red (cxh)
045 @Pt.AcceptedRating Red (cxh)
046 */
047public class UndoActionTest implements UndoAction {
048
049    /** Create a UndoActionTest.
050     *  @param name The name of this UndoAction.
051     */
052    public UndoActionTest(String name) {
053        _name = name;
054    }
055
056    ///////////////////////////////////////////////////////////////////
057    ////                         public methods                    ////
058
059    /** Execute the undo or redo action by printing the name on stdout.
060     *  @exception Exception If something goes wrong.
061     */
062    @Override
063    public void execute() throws Exception {
064        if (_name.equals("throwException")) {
065            throw new Exception("Name was \"throw Exception\", so we do so.");
066        }
067        System.out.println("UndoActionTest.execute(): " + _name);
068    }
069
070    /** Return a string representation of this object.
071     *  @return The name of the class and the name of this object
072     */
073    @Override
074    public String toString() {
075        return "UndoActionTest-" + _name;
076    }
077
078    private String _name;
079}