Package ptolemy.moml

Examples of ptolemy.moml.MoMLChangeRequest


                name = ((Relation) hostObject).getName();
            }

            String moml = "<unlink port=\"" + name + "\" relation=\""
                    + hostRelation.getName() + "\"/>";
            MoMLChangeRequest request = new MoMLChangeRequest(this,
                    hostRelation.getContainer(), moml);
            request.execute();
        }

        Collection<?> entities = GTTools.getChildren(pattern, false, false,
                true, false);
        for (Object entityObject : entities) {
View Full Code Here


            }

            // Remove the composite entity here because when the objects are
            // added back, their names will not conflict with the name of this
            // composite entity.
            MoMLChangeRequest request = GTTools.getDeletionChangeRequest(this,
                    object);
            request.execute();
            _removeReplacementToHostEntries(object);

            // Move the entities and relations inside to the outside.
            for (Object childObject : preservedChildren) {
                NamedObj child = (NamedObj) childObject;
                String moml = "<group name=\"auto\">\n"
                        + child.exportMoMLPlain() + "</group>";
                request = new MoMLChangeRequest(this, container, moml);
                request.execute();
                NamedObj newlyAddedObject = _getNewlyAddedObject(container,
                        child.getClass());
                _addReplacementToHostEntries(newlyAddedObject);
                _replaceMatchResultEntries(child, newlyAddedObject);
                entityMap.put(child, newlyAddedObject);
            }

            // Create new relations for the ports.
            for (Map.Entry<Port, List<Object>> entry : portLinks.entrySet()) {
                Port port = entry.getKey();
                List<Object> linkedRelations = entry.getValue();
                int width = 1;
                for (Object relationObject : linkedRelations) {
                    Relation relation = (Relation) relationObject;
                    Parameter widthParameter = (Parameter) relation
                            .getAttribute("width");
                    if (widthParameter != null) {
                        try {
                            int thisWidth = ((IntToken) widthParameter
                                    .getToken()).intValue();
                            if (thisWidth > width) {
                                width = thisWidth;
                            }
                        } catch (IllegalActionException e) {
                            throw new TransformationException("Cannot get "
                                    + "width of relation " + relation.getName()
                                    + ".", e);
                        }
                    }
                }

                String moml = "<group name=\"auto\">"
                        + "<relation name=\"relation\" "
                        + "  class=\"ptolemy.actor.TypedIORelation\">"
                        + "</relation>" + "</group>";
                request = new MoMLChangeRequest(this, container, moml);
                request.execute();
                Relation newRelation = (Relation) _getNewlyAddedObject(
                        container, Relation.class);

                entityMap.put(port, newRelation);
            }

            // Fix the connections between the moved entities and relations.
            for (Map.Entry<NamedObj, NamedObj> entry : entityMap.entrySet()) {
                NamedObj originalObject = entry.getKey();
                NamedObj newObject = entry.getValue();
                if (originalObject instanceof Relation
                        || originalObject instanceof Port
                        && newObject instanceof Relation) {
                    List<?> linkedObjectList;
                    if (originalObject instanceof Relation) {
                        linkedObjectList = ((Relation) originalObject)
                                .linkedObjectsList();
                    } else {
                        linkedObjectList = portLinks.get(originalObject);
                    }
                    Relation relation2 = (Relation) newObject;
                    for (Object linkedObject : linkedObjectList) {
                        if (linkedObject instanceof Relation) {
                            Relation relation1 = (Relation) entityMap
                                    .get(linkedObject);
                            if (relation1 == null) {
                                relation1 = (Relation) linkedObject;
                            }
                            String moml = _getLinkMoML(relation1, relation2);
                            request = new MoMLChangeRequest(this, container,
                                    moml);
                            request.execute();
                        } else if (linkedObject instanceof Port) {
                            Port originalPort = (Port) linkedObject;
                            Entity linkedEntity = (Entity) entityMap
                                    .get(originalPort.getContainer());
                            if (linkedEntity != null) {
                                Port port1 = linkedEntity.getPort(originalPort
                                        .getName());
                                String moml = _getLinkMoML(port1, relation2);
                                request = new MoMLChangeRequest(this,
                                        container, moml);
                                request.execute();
                            }
                        }
                    }
                }
            }

            return entityMap.values();
        } else {
            MoMLChangeRequest request = GTTools.getDeletionChangeRequest(this,
                    object);
            request.execute();
            return null;
        }
    }
View Full Code Here

                String moml = "<group name=\"auto\"><property name=\""
                        + rootName + "\" class=\"" + _lastAttributeClassName
                        + "\"><property name=\"_location\" "
                        + "class=\"ptolemy.kernel.util.Location\" value=\"" + x
                        + ", " + y + "\"></property></property></group>";
                MoMLChangeRequest request = new MoMLChangeRequest(this,
                        context, moml);
                context.requestChange(request);
            }
        }
View Full Code Here

                String moml = "<group name=\"auto\"><entity name=\"" + rootName
                        + "\" class=\"" + _lastEntityClassName + "\"" + source
                        + "><property name=\"_location\" "
                        + "class=\"ptolemy.kernel.util.Location\" value=\"" + x
                        + ", " + y + "\"></property></entity></group>";
                MoMLChangeRequest request = new MoMLChangeRequest(this,
                        context, moml);
                context.requestChange(request);
            }
        }
View Full Code Here

        }

        if (foundOne) {
            moml.append("</group>");

            MoMLChangeRequest request = new MoMLChangeRequest(this, // originator
                    parent, // context
                    moml.toString(), // MoML code
                    null); // base

            request.setUndoable(true);

            // NOTE: There is no need to listen for completion
            // or errors in this change request, since, in theory,
            // it will just work.  Will someone report the error
            // if one occurs?  I hope so...
View Full Code Here

                        + "\" class=\"ptolemy.kernel.util.Location\""
                        + " value=\"[" + x + ", " + y + "]\"/>\n"
                        + "</entity>\n";
            }

            ChangeRequest request = new MoMLChangeRequest(this, toplevel, moml);
            toplevel.requestChange(request);

            try {
                request.waitForCompletion();
            } catch (Exception ex) {
                throw new GraphException(ex);
            }
        }
View Full Code Here

            moml.append("<group name=\"auto\">");
            moml.append(found.exportMoML("style"));
            moml.append("</group></property></group>");
        }

        MoMLChangeRequest change = new MoMLChangeRequest(this, _object, moml
                .toString());
        _object.requestChange(change);
    }
View Full Code Here

                // Set the new exitAngle and gamma parameter values based
                // on the current arc.
                String moml = "<group><property name=\"exitAngle\" value=\""
                        + angle + "\"/>" + "<property name=\"gamma\" value=\""
                        + gamma + "\"/></group>";
                MoMLChangeRequest request = new MoMLChangeRequest(this,
                        transition, moml);
                transition.requestChange(request);
            }

            // rerender the edge.  This is necessary for several reasons.
View Full Code Here

                    if (port != null) {
                        if (port instanceof PortMatcher) {
                            port.setInput(isInput);
                            port.setOutput(isOutput);
                        } else {
                            MoMLChangeRequest request =
                                new MoMLChangeRequest(entity, (NamedObj) entity,
                                        "<deletePort name=\"" + port.getName()
                                        + "\"/>");
                            request.setUndoable(true);
                            request.setMergeWithPreviousUndo(true);
                            request.execute();
                            port = new PortMatcher(criterion,
                                    (ComponentEntity) entity, portID, isInput,
                                    isOutput);
                            port.setPersistent(false);
                        }
View Full Code Here

        CompositeActor container = new CompositeActor();
        String moml = "<group><entity name=\"NewActor\" class=\""
                + actorClassName + "\"/></group>";

        try {
            new MoMLChangeRequest(entity, container, moml).execute();
            new LoadActorIconChangeRequest(entity, container).execute();
        } catch (Throwable t) {
            _removeEditorIcons(entity);
            _setIconDescription(entity, entity.getDefaultIconDescription());
        }
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.