001/* A tableau for editing the layout of a customizable run panel.
002
003 Copyright (c) 2007-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.actor.gui.run;
028
029import ptolemy.actor.CompositeActor;
030import ptolemy.actor.gui.PtolemyEffigy;
031import ptolemy.actor.gui.Tableau;
032import ptolemy.kernel.util.IllegalActionException;
033import ptolemy.kernel.util.NameDuplicationException;
034import ptolemy.kernel.util.NamedObj;
035
036//////////////////////////////////////////////////////////////////////////
037//// LayoutTableau
038
039/**
040   A run control pane for the model.
041
042 @author Edward A. Lee
043 @version $Id$
044 @since Ptolemy II 8.0
045 @Pt.ProposedRating Yellow (eal)
046 @Pt.AcceptedRating Red (neuendor)
047 */
048public class LayoutTableau extends Tableau {
049    /** Create a new run control panel for the model with the given
050     *  effigy.  The tableau is itself an entity contained by the effigy
051     *  and having the specified name.  The frame is not made visible
052     *  automatically.  You must call show() to make it visible.
053     *  @param container The containing effigy.
054     *  @param name The name of this tableau within the specified effigy.
055     *  @param pane The pane whose layout is being edited.
056     *  @exception IllegalActionException If the tableau is not acceptable
057     *   to the specified container.
058     *  @exception NameDuplicationException If the container already contains
059     *   an entity with the specified name.
060     */
061    public LayoutTableau(PtolemyEffigy container, String name,
062            CustomizableRunPane pane)
063            throws IllegalActionException, NameDuplicationException {
064        super(container, name);
065        NamedObj model = container.getModel();
066
067        if (!(model instanceof CompositeActor)) {
068            throw new IllegalActionException(this,
069                    "Cannot run a model that is not a CompositeActor."
070                            + " It is: " + model);
071        }
072        try {
073            RunLayoutFrame frame = new RunLayoutFrame((CompositeActor) model,
074                    this, pane);
075            setFrame(frame);
076        } catch (IllegalActionException ex) {
077            // Remove this tableau from its container.
078            setContainer(null);
079            throw ex;
080        }
081    }
082}