Package cz.fidentis.analyst.gui.elements
Class RemoteServiceWorker<T>
java.lang.Object
javax.swing.SwingWorker<T,Void>
cz.fidentis.analyst.gui.elements.RemoteServiceWorker<T>
- Type Parameters:
T
- The result type returned by this SwingWorker'sdoInBackground()
andSwingWorker.get()
methods. Also, input parameter type of theprocessResults(Object)
method.
- All Implemented Interfaces:
Runnable
,Future<T>
,RunnableFuture<T>
Worker for cancelable "atomic" remote services that can't be divided into multiple steps and then visualized by progress bar.
This worker enables to show simple "cancel" dialogue of the long-term atomic call.
Usage:
var worker = new RemoteServiceWorker(gui_component) { protected type_t doInBackground() throws RemoteServiceException { return service_call(); } protected void processResults(type_t results) throws Exception { if (process_results(results)) { } else { throw new Exception(); } } } worker.execute(); // call the remote service worker.showCancelDialogue();
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.SwingWorker
SwingWorker.StateValue
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract T
The implementation of the service call.protected void
done()
protected abstract void
processResults
(T results) void
Run afterworker.execute();
to whot the cancel dialogue.protected void
protected void
Methods inherited from class javax.swing.SwingWorker
addPropertyChangeListener, cancel, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, process, publish, removePropertyChangeListener, run, setProgress
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Constructor Details
-
RemoteServiceWorker
Constructor.- Parameters:
parent
- Parent GUI component for the shown cancel dialogue windowinstallationUrl
- Url with service installation instructions
-
-
Method Details
-
showCancelDialogue
public void showCancelDialogue()Run afterworker.execute();
to whot the cancel dialogue. -
processResults
- Parameters:
results
- Values returned by the service, i.e., thedoInBackground()
method- Throws:
Exception
- on failure of processing values
-
doInBackground
The implementation of the service call. The service has to fail with exception.- Specified by:
doInBackground
in classSwingWorker<T,
Void> - Returns:
- Values returned by the service
- Throws:
RemoteServiceException
- on failer
-
done
protected void done()- Overrides:
done
in classSwingWorker<T,
Void>
-
showErrorMessage
protected void showErrorMessage() -
showInstallationMessage
protected void showInstallationMessage()
-