Package org.openquark.util.ui

Examples of org.openquark.util.ui.SwingWorker


        config.setMonitor(monitor);
       
        final String carName = CarBuilder.makeCarNameFromSourceWorkspaceDeclName(workspaceManager.getInitialWorkspaceDeclarationName());
       
        // Set up a SwingWorker to run the export process in a separate thread.
        SwingWorker worker = new SwingWorker() {
            public Object construct() {
                try {
                    CarBuilder.buildCar(config, outputDirectory, carName, options);
                   
                    // Display a status message.
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            String statusMessage = GemCutterMessages.getString("SM_CarExported", carName);
                            statusMessageManager.displayMessage(GemCutter.this, statusMessage, StatusMessageDisplayer.MessageType.TRANSIENT, true);
                        }
                    });
                   
                } catch (final IOException e) {
                    // Inform the user.
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            showActionFailureDialog(getResourceString("ExportWorkspaceToCarFailedDialogTitle"), getResourceString("ExportWorkspaceToCarFailedDialogMessage"), e);
                        }
                    });
                }
                return null;
            }
        };
       
        // Start the CarBuilder worker and then launch the progress monitor (which is modal and would block the UI until
        // either the progress reaches 100% or the monitor is canceled)
        worker.start();
        monitor.showDialog();
        // there is no interesting value to get from the worker, but a call to get() effectively does a join
        // on the worker thread
        worker.get();
    }
View Full Code Here


    private void buildOneCarPerWorkspaceDeclaration(final File outputDirectory, final CarBuilder.BuilderOptions options) {
        // Set up the progress monitor for the potentially length export process
        final ExportCarProgressMonitor monitor = new ExportCarProgressMonitor();
       
        // Set up a SwingWorker to run the export process in a separate thread.
        SwingWorker worker = new SwingWorker() {
            public Object construct() {
                try {
                    CarBuilder.buildOneCarPerWorkspaceDeclaration(workspaceManager, monitor, outputDirectory, options);
                   
                    // Display a status message.
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            String statusMessage = GemCutterMessages.getString("SM_CarExported", outputDirectory.getAbsolutePath());
                            statusMessageManager.displayMessage(GemCutter.this, statusMessage, StatusMessageDisplayer.MessageType.TRANSIENT, true);
                        }
                    });
                   
                } catch (final IOException e) {
                    // Inform the user.
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            showActionFailureDialog(getResourceString("ExportWorkspaceToCarFailedDialogTitle"), getResourceString("ExportWorkspaceToCarFailedDialogMessage"), e);
                        }
                    });
                }
                return null;
            }
        };
       
        // Start the CarBuilder worker and then launch the progress monitor (which is modal and would block the UI until
        // either the progress reaches 100% or the monitor is canceled)
        worker.start();
        monitor.showDialog();
        // there is no interesting value to get from the worker, but a call to get() effectively does a join
        // on the worker thread
        worker.get();
    }
View Full Code Here

TOP

Related Classes of org.openquark.util.ui.SwingWorker

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.