001/* An editor for a transition.
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
027 */
028package ptolemy.actor.gui;
029
030import java.awt.Component;
031
032import ptolemy.domains.modal.kernel.FSMTransitionParameter;
033import ptolemy.kernel.util.IllegalActionException;
034import ptolemy.kernel.util.NameDuplicationException;
035import ptolemy.kernel.util.NamedObj;
036
037///////////////////////////////////////////////////////////////////
038//// TransitionEditorPaneFactory
039
040/**
041An editor for a transition. This editor is used by FSMTransitionParameters.
042
043 @author Patricia Derler
044 @version $Id$
045 @since Ptolemy II 10.0
046 @Pt.ProposedRating Red (derler)
047 @Pt.AcceptedRating Red (derler)
048 */
049public class TransitionEditorPaneFactory extends EditorPaneFactory {
050    /** Construct a factory with the specified container and name.
051     *  @param container The container.
052     *  @param name The name of the factory.
053     *  @exception IllegalActionException If the factory is not of an
054     *   acceptable attribute for the container.
055     *  @exception NameDuplicationException If the name coincides with
056     *   an attribute already in the container.
057     */
058    public TransitionEditorPaneFactory(NamedObj container, String name)
059            throws IllegalActionException, NameDuplicationException {
060        super(container, name);
061    }
062
063    ///////////////////////////////////////////////////////////////////
064    ////                         public methods                    ////
065
066    /** Override the base class to look for an entity contained by
067     *  the container and return a configurer for that.
068     *  @return A new widget for configuring the container.
069     */
070    @Override
071    public Component createEditorPane() {
072        NamedObj object = getContainer();
073
074        if (object instanceof FSMTransitionParameter
075                && ((FSMTransitionParameter) object).getTransition() != null) {
076            return super.createEditorPane(
077                    ((FSMTransitionParameter) object).getTransition());
078        }
079
080        return super.createEditorPane(object);
081    }
082}