Package ptolemy.moml

Examples of ptolemy.moml.MoMLChangeRequest


                        + transition.getName(container)
                        + "\"><property name=\"refinementName\" value=\""
                        + currentRefinements + "\"/></relation></group>";
            }

            MoMLChangeRequest change = new MoMLChangeRequest(this, container,
                    moml) {
                protected void _execute() throws Exception {
                    super._execute();

                    // Mirror the ports of the container in the refinement.
View Full Code Here


        // modified.
        NamedObj context = _attributeToEdit.getContainer();
        String request = "<property name=\"" + _attributeToEdit.getName()
                + "\" value=\""
                + StringUtilities.escapeForXML(_factory.getText()) + "\"/>";
        context.requestChange(new MoMLChangeRequest(this, context, request));
        setModified(false);
        return true;
    }
View Full Code Here

            String moml = "<group><relation name=\""
                    + transition.getName(container)
                    + "\"><property name=\"refinementName\" value=\""
                    + newRefinements.toString() + "\"/></relation>" + removal
                    + "</group>";
            MoMLChangeRequest change = new MoMLChangeRequest(this, container,
                    moml);
            container.requestChange(change);
        }
View Full Code Here

            // An XMLIcon is not a custom icon, so don't remove it.
            if (!(icon instanceof XMLIcon)) {
                String moml = "<deleteProperty name=\"" + icon.getName()
                        + "\"/>";
                MoMLChangeRequest request = new MoMLChangeRequest(this, object,
                        moml);
                object.requestChange(request);
            }
        }
    }
View Full Code Here

                // Object is already a class. Do nothing.
                return;
            }

            String moml = "<class name=\"" + object.getName() + "\"/>";
            MoMLChangeRequest request = new MoMLChangeRequest(this, container,
                    moml);
            container.requestChange(request);
        }
View Full Code Here

                // other link. This will only happen when we've deleted
                // the state at one end of the model.
                // Note that the source is NOT the graph model, so this
                // will trigger the ChangeRequest listener to
                // redraw the graph again.
                MoMLChangeRequest request = new MoMLChangeRequest(container,
                        container, "<deleteRelation name=\""
                                + relation.getName(container) + "\"/>\n");

                // Need to merge the undo for this request in with one that
                // triggered it
                request.setMergeWithPreviousUndo(true);
                request.setUndoable(true);
                container.requestChange(request);
                return false;
            }
        }
View Full Code Here

            // Make the request in the context of the container.
            final NamedObj container = getPtolemyModel();
            moml.append(_deleteRelation(container, linkRelation));

            MoMLChangeRequest request = new MoMLChangeRequest(
                    FSMGraphModel.this, container, moml.toString()) {
                protected void _execute() throws Exception {
                    super._execute();
                    link.setHead(null);
                    link.setTail(null);
                    link.setRelation(null);
                }
            };

            // Handle what happens if the mutation fails.
            request.addChangeListener(new ChangeListener() {
                public void changeFailed(ChangeRequest change,
                        Exception exception) {
                    // Ignore... nothing we can do about it anyway.
                }

                public void changeExecuted(ChangeRequest change) {
                    _linkSet.remove(edge);
                }
            });
            request.setUndoable(true);
            container.requestChange(request);
        }
View Full Code Here

            moml.append("</group>\n");
            failmoml.append("</group>\n");

            final String relationNameToAdd = relationName;
            MoMLChangeRequest request = new MoMLChangeRequest(
                    FSMGraphModel.this, container, moml.toString()) {
                protected void _execute() throws Exception {
                    super._execute();
                    link.setHead(newArcHead);

                    if (relationNameToAdd != null) {
                        ComponentRelation relation = ((CompositeEntity) getPtolemyModel())
                                .getRelation(relationNameToAdd);
                        link.setRelation(relation);
                    }
                }
            };

            // Handle what happens if the mutation fails.
            request.addChangeListener(new ChangeListener() {
                public void changeFailed(ChangeRequest change,
                        Exception exception) {
                    // If we fail here, then we remove the link entirely.
                    _linkSet.remove(link);
                    link.setHead(null);
                    link.setTail(null);
                    link.setRelation(null);

                    // and queue a new change request to clean up the model
                    // Note: JDK1.2.2 requires that this variable not be
                    // called request or we get a compile error.
                    MoMLChangeRequest requestChange = new MoMLChangeRequest(
                            FSMGraphModel.this, container, failmoml.toString());

                    // Fail moml execution not undoable
                    container.requestChange(requestChange);
                }
View Full Code Here

            moml.append("</group>\n");
            failmoml.append("</group>\n");

            final String relationNameToAdd = relationName;

            MoMLChangeRequest request = new MoMLChangeRequest(
                    FSMGraphModel.this, container, moml.toString()) {
                protected void _execute() throws Exception {
                    super._execute();
                    link.setTail(newArcTail);

                    if (relationNameToAdd != null) {
                        link.setRelation(((CompositeEntity) getPtolemyModel())
                                .getRelation(relationNameToAdd));
                    }
                }
            };

            // Handle what happens if the mutation fails.
            request.addChangeListener(new ChangeListener() {
                public void changeFailed(ChangeRequest change,
                        Exception exception) {
                    // If we fail here, then we remove the link entirely.
                    _linkSet.remove(link);
                    link.setHead(null);
                    link.setTail(null);
                    link.setRelation(null);

                    // and queue a new change request to clean up the model
                    // Note: JDK1.2.2 requires that this variable not be
                    // called request or we get a compile error.
                    MoMLChangeRequest requestChange = new MoMLChangeRequest(
                            FSMGraphModel.this, container, failmoml.toString());

                    // fail moml execution not undaoble
                    container.requestChange(requestChange);
                }
View Full Code Here

                }
            }

            moml.append("</port>");

            MoMLChangeRequest request = new MoMLChangeRequest(this, toplevel,
                    moml.toString()) {
                protected void _execute() throws Exception {
                    super._execute();

                    // Set the location of the icon.
                    // Note that this really needs to be done after
                    // the change request has succeeded, which is why
                    // it is done here.  When the graph controller
                    // gets around to handling this, it will draw
                    // the icon at this location.
                    // NOTE: The cast is safe because it is checked
                    // above, and presumably a reasonable GUI would
                    // provide no mechanism for creating a port on
                    // something that is not an entity.
                    NamedObj newObject = ((Entity) toplevel).getPort(portName);
                    Location location = (Location) newObject
                            .getAttribute(locationName);
                    location.setLocation(point);
                }
            };

            request.setUndoable(true);
            toplevel.requestChange(request);

            try {
                request.waitForCompletion();
            } catch (Exception ex) {
                ex.printStackTrace();
                throw new GraphException(ex);
            }
        }
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.