Package ptolemy.gui

Examples of ptolemy.gui.JTextAreaExec$_StreamReaderThread


        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.
        JNICodeGenerator.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 generatio for "
                            + getModel().getContainer());

                    JNIUtilities.generateJNI((CompositeEntity) (getModel()
                            .getContainer()));
                    //                     StringBuffer code = new StringBuffer();
                    //                     codeGenerator.generateCode(code);
                    //                     String codeFileNameWritten = codeGenerator
                    //                             .getCodeFileName();

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

                    //                         URL codeURL = new File(codeFileNameWritten).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());

                    exec.updateStatusBar("// Code generation " + "complete.");
                } catch (Exception ex) {
                    MessageHandler.error("Code generation failed.", ex);
                }
            }
        });
View Full Code Here


            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);

            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);

            // ActionListeners for the buttons
            parametersButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    try {
                        options.sanityCheckAndUpdateParameters(null);
                    } catch (Exception ex) {
                        exec.appendJTextArea(ex.toString());
                    }

                    exec.appendJTextArea(options.toString());
                }
            });

            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 {
                        // The code generator to run.  The value of this
                        // parameter should name a subdirectory of
                        // ptolemy/copernicus such as "java" or "shallow".
                        String codeGenerator = options
                                .getParameter("codeGenerator");

                        String targetPath = options.getParameter("targetPath");

                        String ptIIUserDirectory = options
                                .getParameter("ptIIUserDirectory");

                        // Check that we will be able to write
                        File directory = new File(ptIIUserDirectory, targetPath);

                        if (!directory.isDirectory()) {
                            throw new IllegalActionException(model,
                                    "Not a directory: " + ptIIUserDirectory
                                            + "/" + targetPath
                                            + "\n.Try hitting the "
                                            + "Parameters button to "
                                            + "create the directory.");
                        }

                        if (!directory.canWrite()) {
                            throw new IllegalActionException(model,
                                    "Can't write: " + ptIIUserDirectory + "/"
                                            + targetPath);
                        }

                        exec.updateStatusBar("Starting " + codeGenerator
                                + " code generation.");

                        // Run the code generator in a separate process
                        try {
                            List commands = _generateCodeGeneratorCommands(
                                    model, options, codeGenerator);
                            exec.setCommands(commands);
                            exec.start();
                        } catch (Exception ex) {
                            throw new IllegalActionException(model, ex, null);
                        }

                        // FIXME: Above is asynchronous: Do in listener?
                        exec.updateStatusBar("Code generation " + "complete.");
                    } catch (Exception ex) {
                        MessageHandler.error("Code generation failed.", ex);
                    }
                }
            });
View Full Code Here

        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());

                    exec.updateStatusBar("// Code generation " + "complete.");
                } catch (Exception ex) {
                    MessageHandler.error("Code generation failed.", ex);
                }
            }
        });
View Full Code Here

        JScrollPane scrollPane = new JScrollPane(controlPanel);

        left.add(scrollPane, BorderLayout.CENTER);

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

        docBuilder.setConfiguration(configuration);

        // If we execute any commands, print the output in the text area.
        docBuilder.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 Doc Building"
                            + (_applicationName != null ? " for "
                                    + _applicationName : ""));

                    docBuilder.buildDocs();

                    exec.updateStatusBar(" ");
                } catch (Exception ex) {
                    MessageHandler.error("Doc Building failed.", ex);
                }
            }
        });
View Full Code Here

TOP

Related Classes of ptolemy.gui.JTextAreaExec$_StreamReaderThread

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.