Package ptolemy.moml

Examples of ptolemy.moml.MoMLChangeRequest


            port = (TypedIOPort) this.getPort(argument.getName());

            if (port == null) {
                if (argument.isReturn()) {
                    try {
                        MoMLChangeRequest request = new MoMLChangeRequest(
                                this,
                                this,
                                "<port name=\""
                                        + argument.getName()
                                        + "\" class=\"ptolemy.actor.TypedIOPort\">\n"
                                        + "    <property name=\"output\"/>\n"
                                        + "</port>");
                        request.setUndoable(true);
                        requestChange(request);

                    } catch (Exception ex) {
                        throw new IllegalActionException(this, ex,
                                "Unable to construct port "
                                        + "port for argument \""
                                        + argument.getName() + "\"");
                    }
                } else if (argument.isInput() && argument.isOutput()) {
                    try {
                        MoMLChangeRequest request = new MoMLChangeRequest(
                                this,
                                this,
                                "<group>\n"
                                        + " <port name=\""
                                        + argument.getName()
                                        + "in"
                                        + "\" class=\"ptolemy.actor.TypedIOPort\">\n"
                                        + "    <property name=\"input\"/>\n"
                                        + " </port>\n"
                                        + " <port name=\""
                                        + argument.getName()
                                        + "out"
                                        + "\" class=\"ptolemy.actor.TypedIOPort\">\n"
                                        + "    <property name=\"output\"/>\n"
                                        + " </port>\n" + "</group>");
                        request.setUndoable(true);
                        requestChange(request);
                    } catch (Exception ex) {
                        throw new IllegalActionException(this, ex,
                                "Unable to construct " + "input or output "
                                        + "port for argument \""
                                        + argument.getName() + "\"");
                    }
                } else {
                    try {
                        MoMLChangeRequest request = new MoMLChangeRequest(
                                this,
                                this,
                                "<port name=\""
                                        + argument.getName()
                                        + "\" class=\"ptolemy.actor.TypedIOPort\">\n"
                                        + (argument.isInput() ? "    <property name=\"input\"/>\n"
                                                : "")
                                        + (argument.isOutput() ? "    <property name=\"output\"/>\n"
                                                : "") + "</port>");
                        request.setUndoable(true);
                        requestChange(request);
                    } catch (Exception ex) {
                        throw new IllegalActionException(this, ex,
                                "Unable to construct " + "port for argument \""
                                        + argument.getName() + "\"");
                    }
                }
            } else {

                // synchronized the arguments and the ports
                if (argument.isReturn()) {
                    MoMLChangeRequest request = new MoMLChangeRequest(
                            this,
                            this,
                            "<port name=\""
                                    + argument.getName()
                                    + "\" class=\"ptolemy.actor.TypedIOPort\"\n"
                                    + "    <property name=\"output\"/>\n"
                                    + "</port>");
                    request.setUndoable(true);
                    requestChange(request);
                } else {
                    MoMLChangeRequest request = new MoMLChangeRequest(
                            this,
                            this,
                            "<port name=\""
                                    + argument.getName()
                                    + "\" class=\"ptolemy.actor.TypedIOPort\"\n"
                                    + "    <property name=\"input\"/>\n"
                                    + "</port>");
                    request.setUndoable(true);
                    requestChange(request);

                }
            }
            port = (TypedIOPort) this.getPort(argument.getName());
View Full Code Here


            Iterator ports = portListCopy.iterator();

            while (ports.hasNext()) {
                Port port = (Port) ports.next();
                try {
                    MoMLChangeRequest request = new MoMLChangeRequest(this,
                            this, "<deletePort name=\"" + port.getName()
                                    + "\"/>");
                    request.setUndoable(true);
                    requestChange(request);
                } catch (Exception ex) {
                    // Ignore.
                }
            }
View Full Code Here

        while (arguments.hasNext()) {
            Argument argument = (Argument) arguments.next();
            port = (TypedIOPort) this.getPort(argument.getName());

            if (port == null) {
                MoMLChangeRequest request = null;

                try {
                    if (argument.isReturn()) {

                        request = new MoMLChangeRequest(
                                this,
                                this,
                                "<port name=\""
                                        + argument.getName()
                                        + "\" class=\"ptolemy.actor.TypedIOPort\">\n"
                                        + "    <property name=\"output\"/>\n"
                                        + "</port>");
                    } else if (argument.isInput() && argument.isOutput()) {
                        request = new MoMLChangeRequest(
                                this,
                                this,
                                "<port name=\""
                                        + argument.getName()
                                        + "in"
                                        + "\" class=\"ptolemy.actor.TypedIOPort\">\n"
                                        + "    <property name=\"input\"/>\n"
                                        + "</port>\n"
                                        + "<port name=\""
                                        + argument.getName()
                                        + "out"
                                        + "\" class=\"ptolemy.actor.TypedIOPort\">\n"
                                        + "    <property name=\"output\"/>\n"
                                        + "</port>");
                    } else {
                        request = new MoMLChangeRequest(
                                this,
                                this,
                                "<port name=\""
                                        + argument.getName()
                                        + "\" class=\"ptolemy.actor.TypedIOPort\">\n"
                                        + (argument.isInput() ? "    <property name=\"input\"/>\n"
                                                : "")
                                        + (argument.isOutput() ? "    <property name=\"output\"/>\n"
                                                : "") + "</port>");

                    }
                    request.setUndoable(true);
                    requestChange(request);
                } catch (Throwable throwable) {
                    throw new IllegalActionException(this, throwable,
                            "MoMLChangeRequest for \"" + argument.getName()
                                    + "\" failed. Request was:\n" + request);
                }
            } else {
                // We have a preexisting port, synchronized the
                // arguments and the ports.

                if (argument.isReturn()) {
                    if (port.isInput()) {
                        MoMLChangeRequest request = new MoMLChangeRequest(
                                this,
                                this,
                                "<port name=\""
                                        + argument.getName()
                                        + "\" class=\"ptolemy.actor.TypedIOPort\">\n"
                                        + "    <deleteProperty name=\"input\"/>\n"
                                        + (port.isOutput() ? ""
                                                : "    <property name=\"output\"/>\n")
                                        + "</port>");
                        request.setUndoable(true);
                        requestChange(request);
                    }
                    if (!port.isOutput()) {
                        MoMLChangeRequest request = new MoMLChangeRequest(
                                this,
                                this,
                                "<port name=\""
                                        + argument.getName()
                                        + "\" class=\"ptolemy.actor.TypedIOPort\">\n"
                                        + "    <property name=\"output\"/>\n"
                                        + "</port>");
                        request.setUndoable(true);
                        requestChange(request);
                    }
                } else /*if (port.isInput() != argument.isInput()
                                                              || port.isOutput() != argument.isOutput())*/{
                    MoMLChangeRequest request = new MoMLChangeRequest(
                            this,
                            this,
                            "<port name=\""
                                    + argument.getName()
                                    + "\" class=\"ptolemy.actor.TypedIOPort\">\n"
                                    + (port.isInput() ? (argument.isInput() ? ""
                                            : "<deleteProperty name=\"input\"/>\n")
                                            : (argument.isInput() ? "<property name=\"input\"/>\n"
                                                    : ""))
                                    + (port.isOutput() ? (argument.isOutput() ? ""
                                            : "<deleteProperty name=\"output\"/>\n")
                                            : (argument.isOutput() ? "<property name=\"output\"/>\n"
                                                    : "")) + "</port>");
                    request.setUndoable(true);
                    requestChange(request);
                }
            }
        }

        // Remove any ports that do not have arguments.
        Iterator ports = portList().iterator();

        while (ports.hasNext()) {
            port = (TypedIOPort) ports.next();
            Argument argument = (Argument) _argumentsList.get(port.getName());
            if (argument == null) {
                MoMLChangeRequest request = new MoMLChangeRequest(this, this,
                        "<deletePort name=\"" + port.getName() + "\"/>");
                request.setUndoable(true);
                requestChange(request);

            }
        }
    }
View Full Code Here

            }
        }

        // Recreate the relations and links.
        try {
            MoMLChangeRequest request = new MoMLChangeRequest(actor
                    .getContainer(), actor.getContainer(), "<group>\n"
                    + relationsMoML.toString() + "</group>");
            request.setUndoable(true);
            actor.getContainer().requestChange(request);

            request = new MoMLChangeRequest(actor, actor.getContainer(),
                    linksMoML);
            request.setUndoable(true);
            actor.getContainer().requestChange(request);
        } catch (Throwable throwable) {
            // Ignore
            throwable.printStackTrace();
        }
View Full Code Here

                        // immediate parent if there is none.
                        NamedObj container = argument.getContainer();
                        String moml = "<deleteProperty name=\""
                                + argument.getName() + "\"/>\n";

                        ChangeRequest request = new MoMLChangeRequest(this,
                                container, moml);
                        container.addChangeListener(this);
                        container.requestChange(request);
                    }
                }
View Full Code Here

            String moml = "<property name=\"" + argument.getName()
                    + "\" value=\"" + argument.getExpression() + "\""
                    + " class=\"" + "jni.Argument" + "\"/>";
            _target.addChangeListener(this);
            _target.requestChange(new MoMLChangeRequest(this, _target, moml));
        }

        return dialog;
    }
View Full Code Here

     */
    public void fire() throws IllegalActionException {
        super.fire();
        if (input.getWidth() > 0 && input.hasToken(0)) {
            String moml = ((StringToken) input.get(0)).stringValue();
            MoMLChangeRequest request = new MoMLChangeRequest(this, _entity,
                    moml);
            request.addChangeListener(this);
            _entity.requestChange(request);
        }
    }
View Full Code Here

    public boolean postfire() throws IllegalActionException {
        if (!_stopRequested && (_moml != null)) {
            //remove the old model inside first, if there is one.
            if (((BooleanToken) refresh.getToken()).booleanValue()) {
                String delete = _requestToRemoveAll(this);
                MoMLChangeRequest removeRequest = new MoMLChangeRequest(this, // originator
                        this, // context
                        delete, // MoML code
                        null);
                requestChange(removeRequest);
            }

            //update the inside model change.
            MoMLChangeRequest request2 = new MoMLChangeRequest(this, // originator
                    this, // context
                    _moml, // MoML code
                    null);
            requestChange(request2);
View Full Code Here

     *  actor is not opaque.
     */
    public void wrapup() throws IllegalActionException {
        // clean the inside content.
        String delete = _requestToRemoveAll(this);
        MoMLChangeRequest removeRequest = new MoMLChangeRequest(this, // originator
                this, // context
                delete, // MoML code
                null);
        requestChange(removeRequest);
        super.wrapup();
View Full Code Here

            // Use a MoML change request to ensure propagation.
            // Note that when that change request is executed,
            // this port will be the associated port, but no
            // change request will be issued because its container
            // is already null.
            MoMLChangeRequest request = new MoMLChangeRequest(this,
                    _associatedPort.getContainer(), "<deletePort name=\""
                            + _associatedPort.getName() + "\"/>");
            _associatedPort.getContainer().requestChange(request);
        }
    }
View Full Code Here

TOP

Related Classes of ptolemy.moml.MoMLChangeRequest

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.