Package ptolemy.kernel

Examples of ptolemy.kernel.ComponentRelation


        if (relationName != null) {
            Relation tmpRelation = context.getRelation(relationName);
            _checkForNull(tmpRelation, "No relation named \"" + relationName
                    + "\" in " + context.getFullName());

            ComponentRelation relation = (ComponentRelation) tmpRelation;

            // Ensure that derived objects aren't changed.
            if (_isLinkInClass(context, port, relation)) {
                throw new IllegalActionException(port,
                        "Cannot unlink a port from a relation when both"
                                + " are part of the class definition.");
            }

            // Handle the undoable aspect.
            // Generate a link in the undo only if one or the other relation is
            // not derived. If they are both derived, then the link belongs to
            // the class definition and should not be recreated in undo.
            if (_undoEnabled
                    && (port.getDerivedLevel() == Integer.MAX_VALUE || relation
                            .getDerivedLevel() == Integer.MAX_VALUE)) {
                // Get the relation at the given index
                List linkedRelations = port.linkedRelationList();
                int index = linkedRelations.indexOf(tmpRelation);

                if (index != -1) {
                    // Linked on the outside...
                    _undoContext.appendUndoMoML("<link port=\"" + portName
                            + "\" insertAt=\"" + index + "\" relation=\""
                            + relationName + "\" />\n");
                } else {
                    List insideLinkedRelations = port.insideRelationList();
                    index = insideLinkedRelations.indexOf(tmpRelation);

                    // Linked on the inside.
                    _undoContext.appendUndoMoML("<link port=\"" + portName
                            + "\" insertInsideAt=\"" + index + "\" relation=\""
                            + relationName + "\" />\n");
                }
            }

            // Propagate. Get the derived list for the relation,
            // then use its container as the context in which to
            // find the port.
            Iterator derivedObjects = relation.getDerivedList().iterator();

            while (derivedObjects.hasNext()) {
                ComponentRelation derivedRelation = (ComponentRelation) derivedObjects
                        .next();
                CompositeEntity derivedContext = (CompositeEntity) derivedRelation
                        .getContainer();
                ComponentPort derivedPort = _getPort(portName, derivedContext);
                derivedPort.unlink(derivedRelation);
            }
View Full Code Here


     @return The relation.
     *  @exception XmlException If the relation is not found.
     */
    private ComponentRelation _searchForRelation(String name)
            throws XmlException {
        ComponentRelation result = null;

        // If the name is absolute, strip the prefix.
        String topLevelName = "(no top level)";

        if (_toplevel != null) {
View Full Code Here

                    }

                    link.setHead(newLinkHead);

                    if (relationNameToAdd != null) {
                        ComponentRelation relation = container
                                .getRelation(relationNameToAdd);

                        if (relation == null) {
                            throw new InternalErrorException(
                                    "Tried to find relation with name "
View Full Code Here

                    }

                    link.setTail(newLinkTail);

                    if (relationNameToAdd != null) {
                        ComponentRelation relation = container
                                .getRelation(relationNameToAdd);

                        if (relation == null) {
                            throw new InternalErrorException(
                                    "Tried to find relation with name "
View Full Code Here

         *  of the vertex.
         *  @param node The node.
         *  @return A valid MoML string.
         */
        public String getDeleteNodeMoML(Object node) {
            ComponentRelation deleteObj = (ComponentRelation) ((Vertex) node)
                    .getContainer();
            String moml = "<deleteRelation name=\"" + deleteObj.getName()
                    + "\"/>\n";
            return moml;
        }
View Full Code Here

         @param eventSource The source of the event that will be dispatched,
         *   e.g. the view that made this call.
         *  @param node The node.
         */
        public void removeNode(final Object eventSource, Object node) {
            ComponentRelation relation = (ComponentRelation) ((Vertex) node)
                    .getContainer();
            NamedObj container = relation.getContainer();

            // Delete the relation.
            String moml = "<deleteRelation name=\"" + relation.getName()
                    + "\"/>\n";

            // Note: The source is NOT the graph mode.
            MoMLChangeRequest request = new MoMLChangeRequest(this, container,
                    moml);
View Full Code Here

                AddSubtract add = new AddSubtract(_top, "add");
                SampleDelay sampleDelay = new SampleDelay(_top, "sampleDelay");
                sampleDelay.initialOutputs.setExpression("{4, 5}");
                _top.connect(_const.output, add.plus);

                ComponentRelation relation = _top.connect(add.output,
                        sampleDelay.input);
                _rec.input.link(relation);

                // Any pre-existing input port whose connections
                // are modified needs to have this method called.
View Full Code Here

            int index = -1;

            while (relations.hasNext()) {
                index++;

                ComponentRelation relation = (ComponentRelation) relations
                        .next();

                if (relation == null) {
                    // Gap in the links.  The next link has to use an
                    // explicit index.
View Full Code Here

                int index = -1;

                while (relations.hasNext()) {
                    index++;

                    ComponentRelation relation = (ComponentRelation) relations
                            .next();

                    if (relation == null) {
                        // Gap in the links.  The next link has to use an
                        // explicit index.
View Full Code Here

                        }
                    }
                }

                // Remove the relation as well.
                ComponentRelation relation = model.getRelation(getName()
                        + "Relation");

                if (relation != null) {
                    relation.setContainer(null);
                }
            }

            super.setContainer(container);
        } finally {
View Full Code Here

TOP

Related Classes of ptolemy.kernel.ComponentRelation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.