Package ptolemy.moml

Examples of ptolemy.moml.MoMLParser$UnlinkRequest


            // Ignore blank argument.
        } else {
            if (_expectingClass) {
                _expectingClass = false;

                MoMLParser parser = new MoMLParser();
                String string = "<entity name=\"toplevel\" class=\"" + arg
                        + "\"/>";
                CompositeActor model = (CompositeActor) parser.parse(string);

                // Temporary hack because cloning doesn't properly clone
                // type constraints.
                CompositeActor modelClass = (CompositeActor) parser
                        .searchForClass(arg, model.getSource());

                if (modelClass != null) {
                    model = modelClass;
                }
View Full Code Here


    ///////////////////////////////////////////////////////////////////
    ////                     public methods                        ////

    public Object clone() throws CloneNotSupportedException {
        ModelView actor = (ModelView) super.clone();
        actor._parser = new MoMLParser();
        return actor;
    }
View Full Code Here

                throw new IllegalActionException(this, ex, "Failed to parse '"
                        + modelPathOrURL + "'");
            }
        }

        MoMLParser parser = new MoMLParser();

        // Get the old filters, save them, add our own
        // filters, use them, remove our filters,
        // and then readd the old filters in the finally clause.
        List oldFilters = MoMLParser.getMoMLFilters();
        MoMLParser.setMoMLFilters(null);

        // Parse the model and get the name of the model.
        try {
            // Handle Backward Compatibility.
            MoMLParser.addMoMLFilters(BackwardCompatibility.allFilters());

            // Filter out any graphical classes
            RemoveGraphicalClasses filter = new RemoveGraphicalClasses();

            // FIXME: Not sure why this is necessary, but it helps
            // when generating an applet for moml/demo/spectrum.xml
            filter.put("ptolemy.kernel.util.Location", null);
            MoMLParser.addMoMLFilter(filter);

            NamedObj toplevel = null;

            try {
                toplevel = parser.parse(null, modelURL);

                // FIXME: 1st arg of parse() could be $PTII as a URL.
                modelPathOrURL = modelURL.toExternalForm();
            } catch (FileNotFoundException ex) {
                try {
                    // Might be under Web Start, try it this way.
                    URL anotherURL = ClassUtilities
                            .jarURLEntryResource(modelPathOrURL);

                    if (anotherURL != null) {
                        toplevel = parser.parse(null, anotherURL);
                        modelPathOrURL = anotherURL.toExternalForm();
                    } else {
                        throw new Exception("1. Failed to find '"
                                + modelURL.toExternalForm() + "'\n"
                                + "2. Failed to find '" + modelPathOrURL + "'");
View Full Code Here

                // default XML description.
                URL source = getClass()
                        .getClassLoader()
                        .getResource(
                                "ptolemy/vergil/kernel/attributes/iconEditorLibrary.xml");
                MoMLParser parser = new MoMLParser(workspace);

                try {
                    result = (CompositeEntity) parser.parse(null, source);
                } catch (Exception e) {
                    throw new InternalErrorException(
                            "Unable to open default icon editor library: " + e);
                }
            }
View Full Code Here

        String moml = getModel().exportMoML();
        boolean modified = isModified();
        setModified(false);
        close();

        MoMLParser parser = new MoMLParser();
        try {
            Tableau tableau = getFrameController().getConfiguration().openModel(
                    parser.parse(moml));
            Frame frame = tableau.getFrame();
            if (modified && (frame instanceof TableauFrame)) {
                ((TableauFrame) tableau.getFrame()).setModified(true);
            }
        } catch (Exception e) {
View Full Code Here

     *   to use the default.
     *  @exception Exception If the parser cannot parse the file.
     */
    public TreeEditorPanel(String filename, TreeCellRenderer cellRenderer)
            throws Exception {
        _parser = new MoMLParser();

        // FIXME: This should use the Configuration.
        _toplevel = _parser.parseFile(filename);

        if (_toplevel instanceof CompositeEntity) {
View Full Code Here

                        + modelPathOrURL + "'");
            }
        }

        // Create a parser.
        _parser = new MoMLParser();

        // Handle Backward Compatibility.
        MoMLParser.addMoMLFilters(BackwardCompatibility.allFilters());

        // Filter out any graphical classes and the GeneratorAttribute
View Full Code Here

            // Ignore blank argument.
        } else {
            if (_expectingClass) {
                _expectingClass = false;

                MoMLParser parser = new MoMLParser();
                String string = "<entity name=\"toplevel\" class=\"" + arg
                        + "\"/>";
                CompositeActor model = (CompositeActor) parser.parse(string);

                // Temporary hack because cloning doesn't properly clone
                // type constraints.
                CompositeActor modelClass = (CompositeActor) parser
                        .searchForClass(arg, model.getSource());

                if (modelClass != null) {
                    model = modelClass;
                }
View Full Code Here

            boolean filterGraphicalClasses) throws Exception {
        // ptolemy.vergil.MoMLViewerApplet() calls this with
        // filterGraphicalClasses set to false.
        _modelURL = _readModelURLParameter();

        MoMLParser parser = new MoMLParser();

        // FIXME: if we call _createModel twice, then we will add
        // this filter twice.  We reset the filter list here,
        // though we will lose any other filters.
        MoMLParser.setMoMLFilters(null);

        MoMLParser.setMoMLFilters(BackwardCompatibility.allFilters());

        RemoveGraphicalClasses removeNonAppletClasses = new RemoveGraphicalClasses();
        // If filterGraphicalClasses is true, then we filter out
        // graphical classes so that we do not require diva.jar.  If
        // it is false, then we clear the filter.  In both cases we
        // add some classes that are always filtered.
        if (!filterGraphicalClasses) {
            RemoveGraphicalClasses.clear();
        }

        // Exclude the code generator
        removeNonAppletClasses.put(
                "ptolemy.codegen.kernel.StaticSchedulingCodeGenerator", null);
        removeNonAppletClasses
                .put("ptolemy.vergil.kernel.attributes.DocumentationAttribute",
                        null);
        MoMLParser.addMoMLFilter(removeNonAppletClasses);

        URL docBase = getDocumentBase();
        URL xmlFile = new URL(docBase, _modelURL);
        _manager = null;

        NamedObj toplevel = parser.parse(docBase, xmlFile);
        _workspace = toplevel.workspace();

        if ((_fragment != null) && !_fragment.trim().equals("")) {
            // A fragment was specified, so we should look inside.
            ComponentEntity inside = null;
View Full Code Here

        // The Ptolemy II model returned by the Java parser.
        NamedObj toplevel;

        try {
            MoMLParser parser = new MoMLParser();
            toplevel = parser.parseFile(args[0]);
        } catch (Exception ex) {
            throw new RuntimeException(ex.getMessage()
                    + "Exception raised from the MoML parser\n");
        }
View Full Code Here

TOP

Related Classes of ptolemy.moml.MoMLParser$UnlinkRequest

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.