javax.swing.SwingWorker.StateValue Java Examples
The following examples show how to use
javax.swing.SwingWorker.StateValue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EvaluationGui.java From OpenID-Attacker with GNU General Public License v2.0 | 6 votes |
private void performAttackButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_performAttackButtonActionPerformed String attackName = (String)attackComboBox.getSelectedItem(); currentActionProgressBar.setIndeterminate(true); performAttackButton.setEnabled(false); currentActionLabel.setText("Performing " + attackName + " Attack..."); enableAllButtons(false); showProgressBar(true); AttackWorker attackWorker = new AttackWorker(attackName, serviceProvider, EvaluationResultStore.getEvaluationResultStore().getLatestEvaluationResult()); attackWorker.addPropertyChangeListener((PropertyChangeEvent evt1) -> { if (evt1.getPropertyName().equals("state")) { if ((StateValue) evt1.getNewValue() == DONE) { currentActionProgressBar.setIndeterminate(false); performAttackButton.setEnabled(true); currentActionLabel.setText(""); enableAllButtons(true); setTrainined(true); showProgressBar(false); } } }); attackWorker.execute(); }
Example #2
Source File: ProgressCancelAction.java From blog with Apache License 2.0 | 6 votes |
@Override public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if ("state".equals(propertyName)) { StateValue state = (StateValue) evt.getNewValue(); switch (state) { case PENDING: case STARTED: progressStarted(); break; default: break; } if (StateValue.DONE.equals(state)) { progressDone(); } } }
Example #3
Source File: SwingWorkerPropertyChangeAdapter.java From blog with Apache License 2.0 | 6 votes |
@Override public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if ("state".equals(propertyName)) { StateValue state = (StateValue) evt.getNewValue(); switch (state) { case PENDING: case STARTED: started(); break; case DONE: SwingWorker<?, ?> future = (SwingWorker<?, ?>) evt.getSource(); boolean cancelled = future.isCancelled(); done(cancelled); } } }
Example #4
Source File: EvaluationGui.java From OpenID-Attacker with GNU General Public License v2.0 | 5 votes |
private void trainButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_trainButtonActionPerformed serviceProvider = new ServiceProvider(serviceProviderTextField.getText()); EvaluationResult evaluationResult = new EvaluationResult(new Date(), serviceProviderTextField.getText()); EvaluationResultStore evaluationResultStore = EvaluationResultStore.getEvaluationResultStore(); evaluationResultStore.addEvaluationResult(evaluationResult); enableAllButtons(false); showProgressBar(true); TrainingWorker trainingWorker = new TrainingWorker(serviceProvider, currentActionProgressBar, evaluationResult); trainingWorker.addPropertyChangeListener((PropertyChangeEvent evt1) -> { if (evt1.getPropertyName().equals("state")) { if ((StateValue) evt1.getNewValue() == DONE) { boolean cancelled = currentWorker.isCancelled(); System.out.println("cancelled: " + cancelled); if (cancelled) { try { ((TrainingWorker)currentWorker).awaitActualCompletion(); } catch (InterruptedException ex) { Logger.getLogger(EvaluationGui.class.getName()).log(Level.SEVERE, null, ex); } } enableAllButtons(true); setTrainined(!cancelled); showProgressBar(false); } } System.out.println(evt1.getPropertyName() + " from " + evt1.getOldValue() + " to " + evt1.getNewValue()); }); trainingWorker.execute(); currentWorker = trainingWorker; }
Example #5
Source File: SwingWorkerBasedComponentVisibility.java From blog with Apache License 2.0 | 5 votes |
public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if ("state".equals(propertyName)) { StateValue stateValue = (StateValue) evt.getNewValue(); switch (stateValue) { case STARTED: case PENDING: setComponentsVisible(true); break; case DONE: setComponentsVisible(false); break; } } }
Example #6
Source File: LoadFromMemoryFrame.java From jpexs-decompiler with GNU General Public License v3.0 | 4 votes |
private void selectProcess() { if (processing) { return; } selProcesses = list.getSelectedValuesList(); if (!selProcesses.isEmpty()) { processing = true; tableRes.setEnabled(false); resTableModel.getDataVector().removeAllElements(); resTableModel.fireTableDataChanged(); foundIs = null; progress.setIndeterminate(true); progress.setString(translate("searching")); progress.setStringPainted(true); progress.setVisible(true); final SelectProcessWorker wrk = new SelectProcessWorker(selProcesses); wrk.addPropertyChangeListener((PropertyChangeEvent evt) -> { switch (evt.getPropertyName()) { case "progress": progress.setIndeterminate(false); progress.setStringPainted(false); progress.setValue((Integer) evt.getNewValue()); break; case "state": if (((StateValue) evt.getNewValue()) == StateValue.DONE) { try { foundIs = wrk.get(); } catch (InterruptedException | ExecutionException ex) { Logger.getLogger(LoadFromMemoryFrame.class.getName()).log(Level.SEVERE, null, ex); } if (foundIs == null) { addResultRow(null); } tableRes.setEnabled(foundIs != null); progress.setVisible(false); processing = false; } } }); wrk.execute(); } }