buttonFinish.addActionListener(buttonFinishActionListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
final ProgressMonitorDialog lvProgressMonitorDialog = new ProgressMonitorDialog(AbsSimpleDialog.this);
final ProgressMonitor lvProgressMonitor = new ProgressMonitor();
lvProgressMonitor.addDialog(lvProgressMonitorDialog);
// Get and initialize the finish-action.
AbsAction<S, VoidSelection> lvFinishAction = getActionConfiguration().getPerformFinishAction();
lvFinishAction.setInSelection(getMask().getSelection());
final ActionWorker<VoidSelection> lvWorker = new ActionWorker<VoidSelection>(lvFinishAction, lvProgressMonitor);
//Listen for thread to finish, to be able to remove listener:
lvWorker.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent pvEvt) {
if (ActionWorker.StateValue.DONE.equals(pvEvt.getNewValue())) {
//Removing Listener(Dialog) from Monitor, if Action finished:
lvProgressMonitor.removeDialog(lvProgressMonitorDialog);
lvWorker.removePropertyChangeListener(this);
if (lvProgressMonitor.isCanceled()) {
handlePerformFinishActionException(lvProgressMonitor.getCancelThrowable());
}
closeDialog();
}
}