Example usage for javax.swing SwingWorker execute

List of usage examples for javax.swing SwingWorker execute

Introduction

In this page you can find the example usage for javax.swing SwingWorker execute.

Prototype

public final void execute() 

Source Link

Document

Schedules this SwingWorker for execution on a worker thread.

Usage

From source file:com.mirth.connect.client.ui.Frame.java

public void doEditGlobalScripts() {
    if (globalScriptsPanel == null) {
        globalScriptsPanel = new GlobalScriptsPanel();
    }/*from ww  w.j  a  v a2 s .c  o m*/

    final String workingId = startWorking("Loading global scripts...");

    SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

        public Void doInBackground() {
            globalScriptsPanel.edit();
            return null;
        }

        public void done() {
            editGlobalScripts();
            stopWorking(workingId);
        }
    };

    worker.execute();
}

From source file:com.mirth.connect.client.ui.Frame.java

public void viewImage() {
    final String workingId = startWorking("Opening attachment...");

    SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

        public Void doInBackground() {
            messageBrowser.viewAttachment();
            stopWorking(workingId);//from   ww  w .  j a v a  2  s .  c  om
            return null;
        }

        public void done() {
            stopWorking(workingId);
        }
    };
    worker.execute();
}

From source file:com.mirth.connect.client.ui.Frame.java

public boolean doSaveGlobalScripts() {
    String validationMessage = globalScriptsPanel.validateAllScripts();
    if (validationMessage != null) {
        alertCustomError(this, validationMessage, CustomErrorDialog.ERROR_VALIDATING_GLOBAL_SCRIPTS);
        return false;
    }//from  w ww .  j  a  v a 2s  .c  o m

    final String workingId = startWorking("Saving global scripts...");

    SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

        public Void doInBackground() {
            globalScriptsPanel.save();
            return null;
        }

        public void done() {
            setSaveEnabled(false);
            stopWorking(workingId);
        }
    };

    worker.execute();

    return true;
}

From source file:com.mirth.connect.client.ui.Frame.java

public void doSaveAlerts() {
    if (changesHaveBeenMade()) {
        try {//from   w  w  w  .j  a v a 2  s  .c o  m
            ServerSettings serverSettings = mirthClient.getServerSettings();
            if (StringUtils.isBlank(serverSettings.getSmtpHost())
                    || StringUtils.isBlank(serverSettings.getSmtpPort())) {
                alertWarning(PlatformUI.MIRTH_FRAME,
                        "The SMTP server on the settings page is not specified or is incomplete.  An SMTP server is required to send email alerts.");
            }
        } catch (ClientException e) {
            alertThrowable(PlatformUI.MIRTH_FRAME, e, false);
        }

        final String workingId = startWorking("Saving alerts...");

        SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

            public Void doInBackground() {
                if (alertEditPanel.saveAlert()) {
                    setSaveEnabled(false);
                }

                return null;
            }

            public void done() {
                stopWorking(workingId);
            }
        };

        worker.execute();
    }
}

From source file:com.mirth.connect.client.ui.Frame.java

public void doShowSettings() {
    if (settingsPane == null) {
        settingsPane = new SettingsPane();
    }/*from  w  w w . j  ava 2  s. c om*/

    if (!confirmLeave()) {
        return;
    }

    final String workingId = startWorking("Loading settings...");

    SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

        public Void doInBackground() {
            settingsPane.setSelectedSettingsPanel(0);
            return null;
        }

        public void done() {
            setBold(viewPane, 3);
            setPanelName("Settings");
            setCurrentContentPage(settingsPane);
            stopWorking(workingId);
        }
    };

    worker.execute();
}

From source file:com.mirth.connect.client.ui.Frame.java

public void reprocessMessage(final String channelId, final MessageFilter filter, final boolean replace,
        final Collection<Integer> reprocessMetaDataIds) {
    final String workingId = startWorking("Reprocessing messages...");

    SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
        public Void doInBackground() {
            try {
                mirthClient.reprocessMessages(channelId, filter, replace, reprocessMetaDataIds);
            } catch (ClientException e) {
                alertThrowable(PlatformUI.MIRTH_FRAME, e);
            }//from  w  w  w.j  ava  2  s.com
            return null;
        }

        public void done() {
            messageBrowser.updateFilterButtonFont(Font.BOLD);
            stopWorking(workingId);
        }
    };

    worker.execute();
}

From source file:com.mirth.connect.client.ui.Frame.java

public void deployChannel(final Set<String> selectedChannelIds) {
    if (CollectionUtils.isNotEmpty(selectedChannelIds)) {
        String plural = (selectedChannelIds.size() > 1) ? "s" : "";
        final String workingId = startWorking("Deploying channel" + plural + "...");

        dashboardPanel.deselectRows(false);
        doShowDashboard();/*from  w w  w .  j  av a  2  s  .c  o m*/

        SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

            public Void doInBackground() {
                try {
                    mirthClient.deployChannels(selectedChannelIds);
                } catch (ClientException e) {
                    alertThrowable(PlatformUI.MIRTH_FRAME, e);
                }
                return null;
            }

            public void done() {
                stopWorking(workingId);
                doRefreshStatuses(true);
            }
        };

        worker.execute();
    }
}

From source file:com.mirth.connect.client.ui.Frame.java

public void registerUser(final User user) {
    final String workingId = startWorking("Registering user...");

    SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

        public Void doInBackground() {
            try {
                ConnectServiceUtil.registerUser(PlatformUI.SERVER_ID, PlatformUI.SERVER_VERSION, user,
                        PlatformUI.HTTPS_PROTOCOLS, PlatformUI.HTTPS_CIPHER_SUITES);
            } catch (ClientException e) {
                // ignore errors connecting to update/stats server
            }/*from   w  ww .  j a v a2s  . c  om*/

            return null;
        }

        public void done() {
            stopWorking(workingId);
        }
    };

    worker.execute();
}

From source file:com.mirth.connect.client.ui.Frame.java

public void clearStats(List<DashboardStatus> statusesToClear, final boolean deleteReceived,
        final boolean deleteFiltered, final boolean deleteSent, final boolean deleteErrored) {
    final String workingId = startWorking("Clearing statistics...");
    Map<String, List<Integer>> channelConnectorMap = new HashMap<String, List<Integer>>();

    for (DashboardStatus status : statusesToClear) {
        String channelId = status.getChannelId();
        Integer metaDataId = status.getMetaDataId();

        List<Integer> metaDataIds = channelConnectorMap.get(channelId);

        if (metaDataIds == null) {
            metaDataIds = new ArrayList<Integer>();
            channelConnectorMap.put(channelId, metaDataIds);
        }//  w  w w  .  ja  v a2  s. com

        metaDataIds.add(metaDataId);
    }

    final Map<String, List<Integer>> channelConnectorMapFinal = channelConnectorMap;

    SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

        public Void doInBackground() {
            try {
                mirthClient.clearStatistics(channelConnectorMapFinal, deleteReceived, deleteFiltered,
                        deleteSent, deleteErrored);
            } catch (ClientException e) {
                alertThrowable(PlatformUI.MIRTH_FRAME, e);
            }
            return null;
        }

        public void done() {
            doRefreshStatuses(true);
            stopWorking(workingId);
        }
    };

    worker.execute();
}

From source file:com.mirth.connect.client.ui.Frame.java

public void processMessage(final String channelId, final RawMessage rawMessage) {
    final String workingId = startWorking("Processing message...");

    SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

        public Void doInBackground() {
            try {
                mirthClient.processMessage(channelId, rawMessage);
            } catch (ClientException e) {
                alertThrowable(PlatformUI.MIRTH_FRAME, e);
            }//from   www .  ja v  a  2 s .  c  om
            return null;
        }

        public void done() {
            if (currentContentPage == messageBrowser) {
                messageBrowser.updateFilterButtonFont(Font.BOLD);
            }

            stopWorking(workingId);
        }
    };

    worker.execute();
}