-
Notifications
You must be signed in to change notification settings - Fork 1.6k
HowTo use Progress
Progress management usually come with LongTask. The LongTask API offers asynchronous tasks execution, as well as progress and cancellation.
When implementing a Importer, Statistics and some others a ProgressTicket
is given through the setProgressTicket(ProgressTicket progressTicket)
method of LongTask
interface.
See Progress Javadoc
ProgressTicket progressTicket = ...;
Progress.setDisplayName(progressTicket, "Task running...");
Progress.start(progressTicket);
...
Progress.finish(progressTicket);
Note we use a static class Progress
, which wraps operations on a ticket. It is preferable to use it instead than directly call the progress ticket. Indeed, the Progress
static class supports null
tickets. In that case, failing to get a progress ticket will never throw any NullPointerException
.
It shows two variants. Either you always increment the progress by one (Variant A), or specify the unit pointer.
Progress.setDisplayName(progressTicket, "Task running...");
int units = 100;
Progress.start(progressTicket, units);
for (int i = 0; i < units; i ) {
Progress.progress(progressTicket);
}
Progress.finish(progressTicket);
Progress.setDisplayName(progressTicket, "Task running...");
int units = 100;
Progress.start(progressTicket, units);
for (int i = 0; i < units; i ) {
Progress.progress(progressTicket, i);
}
Progress.finish(progressTicket);
Here is how to manually get a ProgressTicket
, when not working with a LongTask
:
ProgressTicketProvider progressProvider = Lookup.getDefault().lookup(ProgressTicketProvider.class);
ProgressTicket ticket = null;
if (progressProvider != null) {
ticket = progressProvider.createTicket("Task name", null);
}
Instead of null
, you can provide a Cancellable
implementation.
- Developer Handbook
- Build
- Code Style
- Localization
- Datasets
- Import CSV Data
- Import Dynamic Data
- Scripting Plugin
- Quick Start
- Démarrage rapide (FR)
- Layout
- Spatialisations (FR)
- Statistics
- Import
- Spigot importer with Wizard
- Export
- Generator
- Filter
- Extend Data Laboratory
- Preview renderer
- Add a module panel
- Add a submenu
- Build a plugin without Gephi source code
- Update a plugin
- Code Sharing Strategy
- Graph Streaming