List of usage examples for javax.swing SwingWorker SwingWorker
public SwingWorker()
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 w w.j a va 2 s . 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.ChannelPanel.java
public void doDisableChannel() { if (isSaveEnabled() && !promptSave(true)) { return;/*from ww w . ja v a2 s. com*/ } final List<Channel> selectedChannels = getSelectedChannels(); if (selectedChannels.size() == 0) { parent.alertWarning(parent, "Channel no longer exists."); return; } final String workingId = parent.startWorking("Disabling channels..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { public Void doInBackground() { Set<String> channelIds = new HashSet<String>(); for (Channel channel : selectedChannels) { if (!(channel instanceof InvalidChannel)) { channel.setEnabled(false); channelIds.add(channel.getId()); } } try { parent.mirthClient.setChannelEnabled(channelIds, false); } catch (ClientException e) { parent.alertThrowable(parent, e); } return null; } public void done() { doRefreshChannels(); parent.stopWorking(workingId); } }; worker.execute(); }
From source file:com.lynk.hrm.ui.dialog.InfoEmployee.java
protected void uiEndLastLeftActionPerformed(ActionEvent evt) { if (StringUtils.isEmpty(employee.getId())) { showErrorMsg("???!"); return;//from ww w .ja va 2 s . com } if (uiVacationStartEnd.getText().equals("")) { showErrorMsg("!"); return; } int op = JOptionPane.showConfirmDialog(this, "?????! ?", APP_NAME, JOptionPane.YES_NO_OPTION); if (op == JOptionPane.YES_OPTION) { showWaitPanel("?......"); new SwingWorker<AttendanceVacation, Void>() { @Override protected AttendanceVacation doInBackground() throws Exception { return HrmBiz.getInstance().endAttendanceVacationLastLeft(uiId.getText()); } @Override protected void done() { try { get(); hideWaitPanel(); uiVacationRefreshActionPerformed(null); } catch (Exception e) { hideWaitPanel(); showErrorMsg(e); } } }.execute(); } }
From source file:com.mirth.connect.client.ui.Frame.java
public void doStart() { final Set<DashboardStatus> selectedStatuses = dashboardPanel.getSelectedChannelStatuses(); if (selectedStatuses.size() == 0) { return;//from w w w. ja v a2 s .c o m } if (!getStatusesWithDependencies(selectedStatuses, ChannelTask.START_RESUME)) { return; } final String workingId = startWorking("Starting or resuming channels..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { public Void doInBackground() { Set<String> startChannelIds = new HashSet<String>(); Set<String> resumeChannelIds = new HashSet<String>(); for (DashboardStatus dashboardStatus : selectedStatuses) { if (dashboardStatus.getState() == DeployedState.PAUSED) { resumeChannelIds.add(dashboardStatus.getChannelId()); } else { startChannelIds.add(dashboardStatus.getChannelId()); } } try { if (!startChannelIds.isEmpty()) { mirthClient.startChannels(startChannelIds); } if (!resumeChannelIds.isEmpty()) { mirthClient.resumeChannels(resumeChannelIds); } } 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 doStop() { final Set<DashboardStatus> selectedStatuses = dashboardPanel.getSelectedChannelStatuses(); if (selectedStatuses.size() == 0) { return;//from ww w .j a v a2 s. c om } if (!getStatusesWithDependencies(selectedStatuses, ChannelTask.STOP)) { return; } final String workingId = startWorking("Stopping channel..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { public Void doInBackground() { Set<String> channelIds = new HashSet<String>(); for (DashboardStatus dashboardStatus : selectedStatuses) { channelIds.add(dashboardStatus.getChannelId()); } try { if (!channelIds.isEmpty()) { mirthClient.stopChannels(channelIds); } } 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 doHalt() { final Set<DashboardStatus> selectedStatuses = dashboardPanel.getSelectedChannelStatuses(); int size = selectedStatuses.size(); if (size == 0 || !alertOption(this, "Are you sure you want to halt " + (size == 1 ? "this channel" : "these channels") + "?")) { return;/*from w w w . j a v a2 s . c o m*/ } final String workingId = startWorking("Halting channels..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { public Void doInBackground() { Set<String> channelIds = new HashSet<String>(); for (DashboardStatus dashboardStatus : selectedStatuses) { channelIds.add(dashboardStatus.getChannelId()); } try { if (!channelIds.isEmpty()) { mirthClient.haltChannels(channelIds); } } 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 doPause() { final Set<DashboardStatus> selectedChannelStatuses = dashboardPanel.getSelectedChannelStatuses(); if (selectedChannelStatuses.size() == 0) { return;/*from w w w . ja v a 2s.co m*/ } if (!getStatusesWithDependencies(selectedChannelStatuses, ChannelTask.PAUSE)) { return; } final String workingId = startWorking("Pausing channels..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { public Void doInBackground() { Set<String> channelIds = new HashSet<String>(); for (DashboardStatus dashboardStatus : selectedChannelStatuses) { channelIds.add(dashboardStatus.getChannelId()); } try { if (!channelIds.isEmpty()) { mirthClient.pauseChannels(channelIds); } } 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 doStartConnector() { final List<DashboardStatus> selectedStatuses = dashboardPanel.getSelectedStatuses(); if (selectedStatuses.size() == 0) { return;//from w w w.j a va 2s . c om } final String workingId = startWorking("Starting connectors..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { public Void doInBackground() { Map<String, List<Integer>> connectorInfo = new HashMap<String, List<Integer>>(); for (DashboardStatus dashboardStatus : selectedStatuses) { String channelId = dashboardStatus.getChannelId(); Integer metaDataId = dashboardStatus.getMetaDataId(); if (metaDataId != null) { if (!connectorInfo.containsKey(channelId)) { connectorInfo.put(channelId, new ArrayList<Integer>()); } connectorInfo.get(channelId).add(metaDataId); } } try { if (!connectorInfo.isEmpty()) { mirthClient.startConnectors(connectorInfo); } } 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 doStopConnector() { final List<DashboardStatus> selectedStatuses = dashboardPanel.getSelectedStatuses(); if (selectedStatuses.size() == 0) { return;// w w w .java 2 s . co m } boolean warnQueueDisabled = false; for (Iterator<DashboardStatus> it = selectedStatuses.iterator(); it.hasNext();) { DashboardStatus dashboardStatus = it.next(); if (dashboardStatus.getMetaDataId() != 0 && !dashboardStatus.isQueueEnabled()) { warnQueueDisabled = true; it.remove(); } } final String workingId = startWorking("Stopping connectors..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { public Void doInBackground() { Map<String, List<Integer>> connectorInfo = new HashMap<String, List<Integer>>(); for (DashboardStatus dashboardStatus : selectedStatuses) { String channelId = dashboardStatus.getChannelId(); Integer metaDataId = dashboardStatus.getMetaDataId(); if (metaDataId != null) { if (!connectorInfo.containsKey(channelId)) { connectorInfo.put(channelId, new ArrayList<Integer>()); } connectorInfo.get(channelId).add(metaDataId); } } try { if (!connectorInfo.isEmpty()) { mirthClient.stopConnectors(connectorInfo); } } catch (ClientException e) { alertThrowable(PlatformUI.MIRTH_FRAME, e); } return null; } public void done() { doRefreshStatuses(true); stopWorking(workingId); } }; worker.execute(); if (warnQueueDisabled) { alertWarning(this, "<html>One or more destination connectors were not stopped because queueing was not enabled.<br>Queueing must be enabled for a destination connector to be stopped individually.</html>"); } }
From source file:com.mirth.connect.client.ui.Frame.java
public void doDeleteUser() { if (!alertOption(this, "Are you sure you want to delete this user?")) { return;/* w ww . j a v a 2s . c om*/ } final String workingId = startWorking("Deleting user..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { public Void doInBackground() { if (users.size() == 1) { alertWarning(PlatformUI.MIRTH_FRAME, "You must have at least one user account."); return null; } int userToDelete = userPanel.getUserIndex(); try { if (userToDelete != UIConstants.ERROR_CONSTANT) { mirthClient.removeUser(users.get(userToDelete).getId()); retrieveUsers(); } } catch (ClientException e) { alertThrowable(PlatformUI.MIRTH_FRAME, e); } return null; } public void done() { userPanel.updateUserTable(); userPanel.deselectRows(); stopWorking(workingId); } }; worker.execute(); }