List of usage examples for javax.swing SwingWorker execute
public final void execute()
From source file:com.mirth.connect.client.ui.SettingsPanelAdministrator.java
public void doRefresh() { if (PlatformUI.MIRTH_FRAME.alertRefresh()) { return;// w w w . j a v a2 s. c o m } dashboardRefreshIntervalField.setDocument(new MirthFieldConstraints(3, false, false, true)); messageBrowserPageSizeField.setDocument(new MirthFieldConstraints(3, false, false, true)); eventBrowserPageSizeField.setDocument(new MirthFieldConstraints(3, false, false, true)); userPreferences = Preferences.userNodeForPackage(Mirth.class); int interval = userPreferences.getInt("intervalTime", 10); dashboardRefreshIntervalField.setText(interval + ""); int messageBrowserPageSize = userPreferences.getInt("messageBrowserPageSize", 20); messageBrowserPageSizeField.setText(messageBrowserPageSize + ""); int eventBrowserPageSize = userPreferences.getInt("eventBrowserPageSize", 100); eventBrowserPageSizeField.setText(eventBrowserPageSize + ""); if (userPreferences.getBoolean("messageBrowserFormat", true)) { formatYesRadio.setSelected(true); } else { formatNoRadio.setSelected(true); } if (userPreferences.getBoolean("textSearchWarning", true)) { textSearchWarningYesRadio.setSelected(true); } else { textSearchWarningNoRadio.setSelected(true); } String importChannelCodeTemplateLibraries = userPreferences.get("importChannelCodeTemplateLibraries", null); if (importChannelCodeTemplateLibraries == null) { importChannelLibrariesAskRadio.setSelected(true); } else if (Boolean.parseBoolean(importChannelCodeTemplateLibraries)) { importChannelLibrariesYesRadio.setSelected(true); } else { importChannelLibrariesNoRadio.setSelected(true); } String exportChannelCodeTemplateLibraries = userPreferences.get("exportChannelCodeTemplateLibraries", null); if (exportChannelCodeTemplateLibraries == null) { exportChannelLibrariesAskRadio.setSelected(true); } else if (Boolean.parseBoolean(exportChannelCodeTemplateLibraries)) { exportChannelLibrariesYesRadio.setSelected(true); } else { exportChannelLibrariesNoRadio.setSelected(true); } final String workingId = getFrame().startWorking("Loading " + getTabName() + " settings..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { private String checkForNotifications = null; public Void doInBackground() { try { checkForNotifications = getFrame().mirthClient.getUserPreference(currentUser.getId(), "checkForNotifications"); } catch (ClientException e) { getFrame().alertThrowable(getFrame(), e); } return null; } @Override public void done() { if (checkForNotifications == null || BooleanUtils.toBoolean(checkForNotifications)) { checkForNotificationsYesRadio.setSelected(true); } else { checkForNotificationsNoRadio.setSelected(true); } getFrame().stopWorking(workingId); } }; worker.execute(); RSTAPreferences rstaPreferences = MirthRSyntaxTextArea.getRSTAPreferences(); updateShortcutKeyTable(rstaPreferences); updateRestoreDefaultsButton(); AutoCompleteProperties autoCompleteProperties = rstaPreferences.getAutoCompleteProperties(); autoCompleteIncludeLettersCheckBox.setSelected(autoCompleteProperties.isActivateAfterLetters()); autoCompleteCharactersField.setText(autoCompleteProperties.getActivateAfterOthers()); autoCompleteDelayField.setText(String.valueOf(autoCompleteProperties.getActivationDelay())); }
From source file:co.edu.unal.pos.gui.PosHadoopJFrame.java
public void updatePropertiesTableDataModel() { SwingWorker<Void, Void> swingWorker = new SwingWorker<Void, Void>() { @Override/*w w w . ja v a 2s .c o m*/ protected Void doInBackground() throws Exception { disableGUI(); etlJProgressBar.setStringPainted(true); etlJProgressBar.setIndeterminate(true); etlJProgressBar.setString("Loading application..."); Map<String, String> properties = PropertiesProvider.getInstance().getProperties(); String[][] propertiesTableDataModel = new String[properties.size()][2]; int i = 0; for (Map.Entry<String, String> property : properties.entrySet()) { propertiesTableDataModel[i][0] = property.getKey(); propertiesTableDataModel[i][1] = property.getValue(); i++; } setConfigurationTableDataModel(propertiesTableDataModel); etlJProgressBar.setString(""); etlJProgressBar.setIndeterminate(false); enableGUI(); return null; } }; swingWorker.execute(); }
From source file:com.mirth.connect.client.ui.AttachmentExportDialog.java
private void doExport() { final String workingId = PlatformUI.MIRTH_FRAME.startWorking("Exporting attachment..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { private String errorMessage = ""; public Void doInBackground() { boolean binary = binaryButton.isSelected(); try { if (localButton.isSelected()) { AttachmentUtil.writeToFile(fileField.getText(), getSelectedAttachment(), binary); } else { PlatformUI.MIRTH_FRAME.mirthClient.exportAttachmentServer( PlatformUI.MIRTH_FRAME.messageBrowser.getChannelId(), PlatformUI.MIRTH_FRAME.messageBrowser.getSelectedMessageId(), PlatformUI.MIRTH_FRAME.messageBrowser.getSelectedAttachmentId(), fileField.getText(), binary); }// w ww .ja va 2 s . com } catch (Exception e) { errorMessage = e.getMessage(); } return null; } public void done() { PlatformUI.MIRTH_FRAME.stopWorking(workingId); PlatformUI.MIRTH_FRAME.alertInformation(PlatformUI.MIRTH_FRAME, StringUtils.isBlank(errorMessage) ? "Successfully exported attachment to: " + fileField.getText() : "Failed to export attachment: " + errorMessage); } }; worker.execute(); }
From source file:edu.ku.brc.specify.dbsupport.cleanuptools.AgentCleanupProcessor.java
/** * // w w w . j a v a2 s. co m */ public void loadExactMatchAgents() { SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { buildAgentList(); return null; } @Override protected void done() { showAgentListDialog(); } }; worker.execute(); }
From source file:com.mirth.connect.plugins.datapruner.DataPrunerPanel.java
public void doStart() { final MutableBoolean saveChanges = new MutableBoolean(false); if (isSaveEnabled()) { if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(this, "Settings changes must be saved first, would you like to save the settings and prune now?", "Select an Option", JOptionPane.OK_CANCEL_OPTION)) { if (!validateFields()) { return; }//from ww w .j a v a 2 s .co m saveChanges.setValue(true); } else { return; } } setStartTaskVisible(false); final String workingId = parent.startWorking("Starting the data pruner..."); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() { if (saveChanges.getValue()) { try { plugin.setPropertiesToServer(getProperties()); } catch (Exception e) { getFrame().alertThrowable(getFrame(), e); return null; } } try { parent.mirthClient.getServlet(DataPrunerServletInterface.class).start(); } catch (Exception e) { parent.alertThrowable(parent, e, "An error occurred while attempting to start the data pruner."); return null; } return null; } @Override public void done() { if (saveChanges.getValue()) { setSaveEnabled(false); } parent.stopWorking(workingId); updateStatus(); } }; worker.execute(); }
From source file:edu.ku.brc.specify.dbsupport.cleanuptools.AgentCleanupProcessor.java
/** * /*from w w w. j a v a 2 s. com*/ */ public void doBuildLuceneIndex() { SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { int cnt = cleanupIndexer.buildIndex(); prgDlg.setOverall(0, cnt); return null; } @Override protected void done() { currIndex = 0; nextAgent(); } }; worker.execute(); }
From source file:edu.ku.brc.af.core.SpecialMsgNotifier.java
public void checkForMessages() { if (blockMsg.get()) { return;/*from w w w. j ava 2 s. c o m*/ } SwingWorker<Integer, Integer> msgCheckWorker = new SwingWorker<Integer, Integer>() { protected String msg = null; /* (non-Javadoc) * @see javax.swing.SwingWorker#doInBackground() */ @Override protected Integer doInBackground() throws Exception { if (!blockMsg.get()) { try { Thread.sleep(15000); // 15 seconds String url = UIRegistry.getResourceString("CGI_BASE_URL") + "/getmsg2.php"; String installID = UsageTracker.getInstallId(); msg = send(url, installID); msg = StringUtils.deleteWhitespace(msg); } catch (Exception ex) { // die silently } } return null; } @Override protected void done() { super.done(); if (msg != null) { //System.out.println("["+msg+"]"); if (StringUtils.isNotEmpty(msg) && !StringUtils.contains(msg, "NOMSG")) { String header = msg.length() > 6 ? msg.substring(0, 7).toUpperCase() : ""; if (header.startsWith("<HTML>")) { UIRegistry.showLocalizedError("NO_INTERNET"); } else { UIRegistry.showError(JOptionPane.WARNING_MESSAGE, msg); } } } } }; msgCheckWorker.execute(); }
From source file:com.aw.swing.mvp.binding.component.BndSJTable.java
/** * Refresh the content of the JComponents *///from ww w . ja v a 2 s . com public void refresh(final Object param) { if (refreshAbortable) { ProcessMsgBlocker.instance().showMessage("Procesando ..."); // final ProcessMsgBlocker msgBlocker = ProcessMsgBlocker.instance(); // final SearchMsgBlocker msgBlocker = SearchMsgBlocker.instance(); SwingWorker swingWorker = new SwingWorker() { protected Object doInBackground() throws Exception { refreshInternal(param); return null; } protected void done() { // msgBlocker.close(); ProcessMsgBlocker.instance().removeMessage(); } }; swingWorker.execute(); if (SwingUtilities.isEventDispatchThread()) { // msgBlocker.show(); ProcessMsgBlocker.instance().showMessage("Procesando ..."); } else { try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { ProcessMsgBlocker.instance().showMessage("Procesando ..."); // msgBlocker.show(); } }); } catch (Throwable e) { throw new AWSystemException("Problems refreshing the table:" + this, e); } } } else { if (SwingUtilities.isEventDispatchThread()) { refreshInternal(param); } else { try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { refreshInternal(param); } }); } catch (Throwable e) { throw new AWSystemException("Problems refreshing the table:" + this, e); } } } }
From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java
private void addCapa(final Layer layer) { SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override/*from ww w . j ava 2 s. c om*/ protected Object doInBackground() throws Exception { layer.visible = true; if (!Main.pref.putColor("layer " + layer.name, Color.decode(LogicConstants.getNextColor()))) { log.error("Error al asignar el color"); } return null; } @Override protected void done() { super.done(); mapView.addLayer(layer, false); capas.add(layer); limpiar.setEnabled(true); HistoryMapViewer.enableSaveGpx(true); } }; sw.execute(); }
From source file:edu.ku.brc.specify.dbsupport.cleanuptools.GeoCleanupFuzzySearch.java
/** * @param earthId/*from w ww .j av a2s . com*/ * @param cl */ public void startIndexingProcessAsync(final int earthId, final ProgressFrame frame, final ChangeListener cl) { this.frame = frame; centerAndShow(frame); SwingWorker<Boolean, Boolean> worker = new SwingWorker<Boolean, Boolean>() { boolean isOK = true; @Override protected Boolean doInBackground() throws Exception { setProgressDesc("Build Geography Names cross-reference..."); // I18N stCntXRef = new StateCountryContXRef(readConn); isOK = stCntXRef.build(); if (isOK) { setProgressDesc("Creating searchable index..."); // I18N isOK = buildLuceneIndex(earthId); } return isOK; } @Override protected void done() { super.done(); // NOTE: need to check here that everything built OK cl.stateChanged(new ChangeEvent((Boolean) isOK)); } }; worker.execute(); }