Package ptolemy.actor.gui

Examples of ptolemy.actor.gui.Configuration


    /* (non-Javadoc)
     * @see ptolemy.actor.gui.MoMLApplication#_createEmptyConfiguration()
     */
    protected Configuration _createEmptyConfiguration() throws Exception {
        Configuration configuration = _createDefaultConfiguration();

        try {
            UIManager.setLookAndFeel(System.getProperty("swing.defaultlaf"));
        } catch (Exception e) {
            // Ignore exceptions, which only result in the wrong look and feel.
        }

        // FIXME: This code is Dog slow for some reason.
        URL inurl = specToURL("thales/configs/singleWindow/singleWindowWelcomeWindow.xml");
        _parser.reset();
        _parser.setContext(configuration);
        _parser.parse(inurl, inurl);

        Effigy doc = (Effigy) configuration.getEntity("directory.doc");
        URL idurl = specToURL("ptolemy/configs/full/intro.htm");
        doc.identifier.setExpression(idurl.toExternalForm());

        if (_mainFrame != null) {
            _mainFrame.setConfiguration(configuration);
View Full Code Here


        public void actionPerformed(ActionEvent e) {
            NamedObj toOpen = getModel().getContainer();

            if (toOpen != null) {
                Configuration configuration = SingleWindowApplication._mainFrame
                        .getConfiguration();

                try {
                    configuration.openModel(toOpen);
                } catch (IllegalActionException e1) {
                    e1.printStackTrace();
                } catch (NameDuplicationException e1) {
                    e1.printStackTrace();
                }
View Full Code Here

     @return A tableau for the effigy, or null if one cannot be created.
     *  @exception Exception If the factory should be able to create a
     *   Tableau for the effigy, but something goes wrong.
     */
    public Tableau createTableau(Effigy effigy) throws Exception {
        Configuration configuration = (Configuration) effigy.toplevel();
        ModalModel model = (ModalModel) ((PtolemyEffigy) effigy).getModel();
        FSMActor controller = ((FSMDirector) model.getDirector())
                .getController();
        return configuration.openModel(controller);
    }
View Full Code Here

            Query query = new Query();
            String defaultName = container.uniqueName(state.getName());
            query.addLine("Name", "Name", defaultName);

            // See whether the configuration offers state refinements.
            Configuration configuration = ((FSMGraphController) getController())
                    .getConfiguration();
            Entity refinements = configuration.getEntity("_stateRefinements");

            // Default choices.
            String[] choiceClasses = { "ptolemy.domains.fsm.modal.Refinement",
                    "ptolemy.domains.fsm.modal.ModalController" };
            String[] choiceNames = { "Default Refinement",
View Full Code Here

                        // Regrettably, we cannot continue with the firing until
                        // the open is complete, so we use the very dangerous
                        // invokeAndWait() method.
                        Runnable doOpen = new Runnable() {
                            public void run() {
                                Configuration configuration = (Configuration) myEffigy
                                        .toplevel();

                                if (_debugging) {
                                    _debug("** Using the configuration to open a tableau.");
                                }

                                try {
                                    // NOTE: Executing this in the event thread averts
                                    // a race condition... Previous close(), which was
                                    // deferred to the UI thread, will have completed.
                                    _exception = null;
                                    _tableau = configuration.openModel(_model,
                                            myEffigy);

                                    // Set this tableau to be a master so that when it
                                    // gets closed, all its subwindows get closed.
                                    _tableau.setMaster(true);
View Full Code Here

         @param object The object to configure.
         *  @param parent The parent window, or null if there is none.
         */
        public void createEditor(NamedObj object, Frame parent) {
            try {
                Configuration configuration = ((TableauFrame) parent)
                        .getConfiguration();

                // NamedObj container = (NamedObj)object.getContainer();
                TypedCompositeActor model = (TypedCompositeActor) GiottoCodeGenerator.this
                        .getContainer();

                // Preinitialize and resolve types.
                CompositeActor toplevel = (CompositeActor) model.toplevel();
                Manager manager = toplevel.getManager();

                if (manager == null) {
                    manager = new Manager(toplevel.workspace(), "manager");
                    toplevel.setManager(manager);
                }

                manager.preinitializeAndResolveTypes();

                TextEffigy codeEffigy = TextEffigy.newTextEffigy(configuration
                        .getDirectory(), generateGiottoCode(model));
                codeEffigy.setModified(true);
                configuration.createPrimaryTableau(codeEffigy);

                // end the model execution.
                manager.stop();
                manager.wrapup();
            } catch (Exception ex) {
View Full Code Here

        public Tableau createTableau(Effigy effigy) throws Exception {
            if (_model == null) {
                throw new IllegalActionException(VisualModelReference.this,
                        "No model referenced.");
            }
            Configuration configuration = (Configuration) effigy.toplevel();
            return configuration.openInstance(_model, effigy);
        }
View Full Code Here

        JButton moreInfoButton = new JButton("More Info");
        moreInfoButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                try {
                    Configuration configuration = getConfiguration();

                    // FIXME: Customize to the particular code generator.
                    // Use Thread.currentThread() so that this code will
                    // work under WebStart.
                    URL infoURL = Thread.currentThread()
                            .getContextClassLoader().getResource(
                                    "ptolemy/codegen/README.html");

                    configuration.openModel(null, infoURL, infoURL
                            .toExternalForm());
                } catch (Exception ex) {
                    throw new InternalErrorException(codeGenerator, ex,
                            "Failed to open doc/codegen.htm: ");
                }
            }
        });
        caveatsPanel.add(moreInfoButton);

        JPanel left = new JPanel();
        left.setLayout(new BoxLayout(left, BoxLayout.Y_AXIS));
        caveatsPanel.setMaximumSize(new Dimension(500, 100));
        left.add(caveatsPanel);

        // Panel for push buttons.
        JPanel buttonPanel = new JPanel();
        buttonPanel.setLayout(new GridLayout(1, 4));

        JButton goButton = new JButton("Generate");
        goButton.setToolTipText("Generate code");
        buttonPanel.add(goButton);

        JButton stopButton = new JButton("Cancel");
        stopButton.setToolTipText("Terminate executing processes");
        buttonPanel.add(stopButton);

        JButton clearButton = new JButton("Clear");
        clearButton.setToolTipText("Clear Log");
        buttonPanel.add(clearButton);

        buttonPanel.setMaximumSize(new Dimension(500, 50));
        left.add(buttonPanel);

        Configurer configurer = new Configurer(codeGenerator);
        JPanel controlPanel = new JPanel();
        controlPanel.add(configurer);

        JScrollPane scrollPane = new JScrollPane(controlPanel);

        left.add(scrollPane, BorderLayout.CENTER);

        // Create a JTextAreaExec without Start and Cancel buttons.
        final JTextAreaExec exec = new JTextAreaExec("Code Generator Commands",
                false);

        // If we execute any commands, print the output in the text area.
        codeGenerator.setExecuteCommands(exec);

        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                left, exec);
        splitPane.setOneTouchExpandable(true);

        // Adjust the divider so that the control panel does not
        // have a horizontal scrollbar.
        Dimension preferred = left.getPreferredSize();
        splitPane.setDividerLocation(preferred.width + 20);

        getContentPane().add(splitPane, BorderLayout.CENTER);

        stopButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                exec.cancel();
            }
        });

        clearButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                exec.clear();
            }
        });

        goButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                try {
                    exec.updateStatusBar("// Starting " + codeGenerator
                            + " code generation.");

                    StringBuffer code = new StringBuffer();
                    codeGenerator.generateCode(code);
                    String codeFileNameWritten = codeGenerator
                            .getCodeFileName();

                    if (codeFileNameWritten != null) {
                        Configuration configuration = getConfiguration();

                        URL codeURL = new File(codeFileNameWritten).toURI()
                                .toURL();
                        // Use Thread.currentThread() so that this code will
                        // work under WebStart.
                        configuration.openModel(null, codeURL, codeURL
                                .toExternalForm());

                    }
                    // Don't write the file to the window
                    //exec.updateStatusBar(code.toString());
View Full Code Here

            Query query = new Query();
            String defaultName = container.uniqueName(transition.getName());
            query.addLine("Name", "Name", defaultName);

            // See whether the configuration offers transition refinements.
            Configuration configuration = ((FSMGraphController) getController())
                    .getConfiguration();
            Entity refinements = configuration
                    .getEntity("_transitionRefinements");

            // Default choices.
            String[] choiceClasses = { "ptolemy.domains.fsm.modal.TransitionRefinement" };
            String[] choiceNames = { "Default Refinement" };
View Full Code Here

                    URL url = file.toURI().toURL();

                    // NOTE: Used to use for the first argument the following,
                    // but it seems to not work for relative file references:
                    // new URL("file", null, _directory.getAbsolutePath()
                    Configuration configuration = getConfiguration();
                    Tableau newAutomatonTableau = configuration.openModel(url,
                            url, url.toExternalForm());

                    // compose the two interface automata and show result
                    InterfaceAutomaton model1 = (InterfaceAutomaton) getFrame()
                            .getModel();
                    InterfaceAutomatonGraphFrame graphFrame2 = (InterfaceAutomatonGraphFrame) newAutomatonTableau
                            .getFrame();
                    InterfaceAutomaton model2 = (InterfaceAutomaton) graphFrame2
                            .getModel();

                    InterfaceAutomaton composition = model1.compose(model2);
                    configuration.openModel(composition);
                } catch (Exception ex) {
                    getFrame().report("Error reading input", ex);
                }
            }
        }
View Full Code Here

TOP

Related Classes of ptolemy.actor.gui.Configuration

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.