001/* Test for port that has no container with Entity.clone()
002
003 Copyright (c) 2004-2016 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.kernel.test;
029
030import ptolemy.kernel.Entity;
031import ptolemy.kernel.Port;
032import ptolemy.kernel.util.Attribute;
033import ptolemy.kernel.util.IllegalActionException;
034import ptolemy.kernel.util.NameDuplicationException;
035import ptolemy.kernel.util.Workspace;
036
037/**
038 *  Illustrates a problem with port naming and cloning.
039 *  <p> In this actor, we set the container of the port to null.
040
041 *  @author Christopher Brooks, based on code from Chad Berkley
042 *  @version $Id$
043 *  @since Ptolemy II 4.1
044 */
045public class PortHasNoContainer extends Entity {
046    public PortHasNoContainer(Workspace workspace, String name)
047            throws IllegalActionException, NameDuplicationException {
048        super(workspace, name);
049
050        // This port should be oke
051        directoryOrURLPort = new Port(this, "directoryOrURL");
052
053        startTrigger = new Port(this, "startTrigger");
054        new Attribute(startTrigger, "_showName");
055
056        startTrigger.setContainer(null);
057    }
058
059    /** This port, from actor/lib/io/DirectoryListing.java, is ok because
060     * it ends in "Port"
061     */
062    public Port directoryOrURLPort;
063
064    /**
065     * An optional input port that can be used to help the scheduling
066     * of the actor.
067     *
068     * <P>This port is activated by the hasTrigger parameter. Double-click on
069     * the actor to enable. Please enable it <i>ONLY</I> when the actor has
070     * no input and it is required for scheduling of the actor.
071     */
072    public Port startTrigger;
073}