001/* A frame for evaluating expressions interactively.
002
003 Copyright (c) 2003-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;
028
029import java.awt.BorderLayout;
030import java.net.URL;
031
032import javax.swing.BoxLayout;
033import javax.swing.JPanel;
034
035import ptolemy.gui.ShellTextArea;
036import ptolemy.kernel.util.IllegalActionException;
037import ptolemy.kernel.util.NameDuplicationException;
038
039///////////////////////////////////////////////////////////////////
040//// ExpressionShellFrame
041
042/**
043 A frame that provides an interactive shell for evaluating expressions.
044
045 @author Edward A. Lee
046 @version $Id$
047 @since Ptolemy II 3.0
048 @Pt.ProposedRating Red (cxh)
049 @Pt.AcceptedRating Red (cxh)
050 @see ExpressionShellTableau
051 @see ShellTextArea
052 @see ExpressionShellEffigy
053 */
054@SuppressWarnings("serial")
055public class ExpressionShellFrame extends TableauFrame {
056    /** Construct a frame to display the ExpressionShell window.
057     *  After constructing this, it is necessary
058     *  to call setVisible(true) to make the frame appear.
059     *  This is typically accomplished by calling show() on
060     *  enclosing tableau.
061     *  @param tableau The tableau responsible for this frame.
062     *  @exception IllegalActionException If the model rejects the
063     *   configuration attribute.
064     *  @exception NameDuplicationException If a name collision occurs.
065     */
066    public ExpressionShellFrame(ExpressionShellTableau tableau)
067            throws IllegalActionException, NameDuplicationException {
068        super(tableau);
069
070        JPanel component = new JPanel();
071        component.setLayout(new BoxLayout(component, BoxLayout.Y_AXIS));
072
073        tableau.shell = new ShellTextArea();
074        tableau.shell.setInterpreter(tableau);
075        component.add(tableau.shell);
076        getContentPane().add(component, BorderLayout.CENTER);
077    }
078
079    ///////////////////////////////////////////////////////////////////
080    ////                         protected methods                 ////
081    @Override
082    protected void _help() {
083        try {
084            URL doc = getClass().getClassLoader()
085                    .getResource("doc/expressions.htm");
086            getConfiguration().openModel(null, doc, doc.toExternalForm());
087        } catch (Exception ex) {
088            System.out.println("ExpressionShellTableau._help(): " + ex);
089            _about();
090        }
091    }
092}