List of usage examples for javax.swing SwingWorker execute
public final void execute()
From source file:es.emergya.ui.plugins.AdminPanel.java
public void setFilter(final Integer i, final String[] items) { SwingWorker<JComboBox, Object> sw = new SwingWorker<JComboBox, Object>() { @Override//from w w w .j a v a2 s . c o m protected JComboBox doInBackground() throws Exception { JComboBox cb = setComboBoxEditor(i - 1, items); return cb; } @Override protected void done() { if (filters.getCellEditor() != null) filters.getCellEditor().cancelCellEditing(); filters.repaint(); } }; sw.execute(); }
From source file:com.mirth.connect.client.ui.SettingsPanelResources.java
@Override public boolean doSave() { resetInvalidProperties();/*from w ww .ja v a2s . com*/ final String errors = checkProperties().trim(); if (StringUtils.isNotEmpty(errors)) { getFrame().alertError(getFrame(), "Error validating resource settings:\n\n" + errors); return false; } if (!getFrame().alertOption(getFrame(), "<html>Libraries associated with any changed resources will be reloaded.<br/>Any channels / connectors using those libraries will be affected.<br/>Also, a maximum of 1000 files may be loaded into a directory<br/>resource, with additional files being skipped.<br/>Are you sure you wish to continue?</html>")) { return false; } updateResource(resourceTable.getSelectedRow()); final String workingId = getFrame().startWorking("Saving resources..."); final List<ResourceProperties> resources = new ArrayList<ResourceProperties>(); for (int row = 0; row < resourceTable.getRowCount(); row++) { resources.add((ResourceProperties) resourceTable.getModel().getValueAt(row, PROPERTIES_COLUMN)); } SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { @Override public Void doInBackground() throws ClientException { getFrame().mirthClient.setResources(resources); return null; } @Override public void done() { try { get(); setSaveEnabled(false); } catch (Throwable t) { if (t instanceof ExecutionException) { t = t.getCause(); } getFrame().alertThrowable(getFrame(), t, "Error saving resources: " + t.toString()); } finally { getFrame().stopWorking(workingId); } } }; worker.execute(); return true; }
From source file:com.mirth.connect.client.ui.SettingsPanelResources.java
@Override public void doRefresh() { if (PlatformUI.MIRTH_FRAME.alertRefresh()) { return;//from w w w . j av a2 s . c o m } final String workingId = getFrame().startWorking("Loading resources..."); final int selectedRow = resourceTable.getSelectedRow(); SwingWorker<List<ResourceProperties>, Void> worker = new SwingWorker<List<ResourceProperties>, Void>() { @Override public List<ResourceProperties> doInBackground() throws ClientException { return getFrame().mirthClient.getResources(); } @Override public void done() { try { updateResourcesTable(get(), selectedRow, true); } catch (Throwable t) { if (t instanceof ExecutionException) { t = t.getCause(); } getFrame().alertThrowable(getFrame(), t, "Error loading resources: " + t.toString()); } finally { getFrame().stopWorking(workingId); } } }; worker.execute(); }
From source file:org.astrojournal.gui.AJMainGUI.java
/** * Create the astro journals.//from www . j av a2 s . c o m */ public void createJournals() { if (mainPanel.getComponent(0) instanceof WelcomePanel) { // Replace the welcome panel with the output panel remove(mainPanel); mainPanel.remove(welcomePanel); mainPanel.add(outputPanel, BorderLayout.CENTER); add(mainPanel); } // define a SwingWorker to run in background // In this way the output is printed gradually as it is // generated. SwingWorker<String, Void> worker = new SwingWorker<String, Void>() { @Override public String doInBackground() { setStatusPanelText(resourceBundle.getString("AJ.lblFileGenerationinProgressLong.text")); cleanJTextPane(); btnCreateJournal.setEnabled(false); btnOpenJournal.setEnabled(false); menu.setEnabled(AJGUIActions.CREATE_JOURNAL.name(), false); menu.setEnabled(AJGUIActions.OPEN_JOURNAL.name(), false); menu.setEnabled(AJGUIActions.EDIT_PREFERENCES.name(), false); if (!ajMainControls.createJournal()) { setStatusPanelText(resourceBundle.getString("AJ.errPDFLatexShort.text")); } else { btnOpenJournal.setEnabled(true); menu.setEnabled(AJGUIActions.OPEN_JOURNAL.name(), true); } btnCreateJournal.setEnabled(true); menu.setEnabled(AJGUIActions.CREATE_JOURNAL.name(), true); menu.setEnabled(AJGUIActions.EDIT_PREFERENCES.name(), true); return ""; } }; // execute the background thread worker.execute(); }
From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java
public synchronized void setError(final String e) { if (limpiarError != null && limpiarError.isAlive()) { limpiarError.interrupt();//from ww w . ja v a2 s. co m } SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { return null; } @Override protected void done() { mensaje.setText(e); mensaje.repaint(); cargando.setIcon(LogicConstants.getIcon("48x48_transparente")); } }; sw.execute(); limpiarError = new Thread() { @Override public void run() { try { Thread.sleep(1000 * LogicConstants.getInt("TIMEOUT_ERROR_WEBSERVICE", 15)); SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { mensaje.setText(""); return null; } }; sw.execute(); } catch (InterruptedException e) { } } }; limpiarError.start(); }
From source file:fr.free.hd.servers.gui.FaceView.java
private void updateLabel() { ApplicationWindow aw = Application.instance().getActiveWindow(); final ProgressMonitor pm = aw.getStatusBar().getProgressMonitor(); pm.taskStarted("Rendering picture", -1); SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { //protected Object construct() in SpringRC's SwingWorker! protected Object doInBackground() { // now my long task and the progress indication if (position != null) { Phonem phonem = new Phonem("Demo", kind, position, MouthVowelEnum.MOUTH_VOWEL_A); FaceGeneratorHelper.initialWidthSize = 400; FaceGeneratorHelper.ClearCache(); Image image = FaceGeneratorHelper.Create(phonem, face, pm); lblFace.setIcon(new ImageIcon(image)); }// w ww .j a va 2 s . c om return null; } //protected void finished() @Override protected void done() { // all of the following code will be called on the Event Dispatching Thread pm.done(); } }; //sw.start(); //sw.clear(); // reuse would be possible with SpringRC's SwingWorker! sw.execute(); }
From source file:com.mirth.connect.plugins.directoryresource.DirectoryResourcePropertiesPanel.java
@Override public void setProperties(ResourceProperties properties) { final DirectoryResourceProperties props = (DirectoryResourceProperties) properties; directoryField.setText(props.getDirectory()); includeSubdirectoriesCheckBox.setSelected(props.isDirectoryRecursion()); descriptionTextPane.setText(props.getDescription()); final String workingId = PlatformUI.MIRTH_FRAME.startWorking("Loading libraries..."); SwingWorker<List<String>, Void> worker = new SwingWorker<List<String>, Void>() { @Override//from ww w. j a v a 2 s. com public List<String> doInBackground() throws ClientException { return (List<String>) PlatformUI.MIRTH_FRAME.mirthClient .getServlet(DirectoryResourceServletInterface.class).getLibraries(props.getId()); } @Override public void done() { try { List<String> libraries = get(); if (libraries == null) { libraries = new ArrayList<String>(); } Object[][] data = new Object[libraries.size()][1]; int i = 0; for (String library : libraries) { data[i++][0] = library; } ((RefreshTableModel) libraryTable.getModel()).refreshDataVector(data); } catch (Throwable t) { if (t instanceof ExecutionException) { t = t.getCause(); } PlatformUI.MIRTH_FRAME.alertThrowable(PlatformUI.MIRTH_FRAME, t, "Error loading libraries: " + t.toString()); } finally { PlatformUI.MIRTH_FRAME.stopWorking(workingId); } } }; worker.execute(); }
From source file:es.emergya.ui.plugins.LayerSelectionDialog.java
private void initOptions(final JPanel list) { SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override/*ww w . j a va 2s . c om*/ protected Object doInBackground() throws Exception { publish(new Object[0]); for (CapaInformacion ci : CapaConsultas.getAllOrderedByOrden()) { if (ci.getOpcional() && ci.getHabilitada()) { layers.add(new LayerElement(ci.getNombre(), ci.getUrl(), wasVisible(ci))); } } return null; } @Override protected void process(List<Object> chunks) { actualizando.setIcon(es.emergya.cliente.constants.LogicConstants.getIcon("anim_actualizando")); } @Override protected void done() { super.done(); actualizando.setIcon(null); list.setLayout(new BoxLayout(list, BoxLayout.Y_AXIS)); for (LayerElement le : layers) { JCheckBox cb = new JCheckBox(le.name, le.active); cb.setBackground(Color.WHITE); cb.addActionListener(LayerSelectionDialog.this); list.add(cb); list.revalidate(); } // self.pack(); } }; sw.execute(); }
From source file:org.eumetsat.metop.visat.SounderInfoView.java
private void updateAngularRelationFields(final Ifov selectedIfov, final EpsFile epsFile) { final SwingWorker<AngularRelation, Object> worker = new SwingWorker<AngularRelation, Object>() { @Override/*w ww . j a v a 2 s.c om*/ protected AngularRelation doInBackground() throws Exception { return readAngularRelation(epsFile, selectedIfov); } @Override protected void done() { try { final AngularRelation angularRelation = get(); vzaTextField.setText(Double.toString(angularRelation.vza)); vaaTextField.setText(Double.toString(angularRelation.vaa)); szaTextField.setText(Double.toString(angularRelation.sza)); saaTextField.setText(Double.toString(angularRelation.saa)); } catch (InterruptedException e) { clearAngularRelationFields(IO_ERROR); } catch (ExecutionException e) { clearAngularRelationFields(IO_ERROR); } } }; worker.execute(); }
From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java
private synchronized void cleanLayers() { SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override//from w w w.jav a 2 s .c o m protected Object doInBackground() throws Exception { return null; } @Override protected void done() { for (Layer layer : capas) { mapView.removeLayer(layer); } capas.clear(); mapView.repaint(); LogicConstants.resetColor(); } }; sw.execute(); }