Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.netbeans.api.progress/1 1.5.22
PREV NEXT | FRAMES NO FRAMES

# NetBeans Progress API

See:
Description

Progress API
org.netbeans.api.progress | This API allows to visualize tracking for progress of long lasting tasks.
org.netbeans.api.progress.aggregate | Advanced progress manipulation, allowing to construct a single progress indication bar from multiple, possibly independent sources.

The module will be autoload. There will be no pluggable extensions. Progress

### What is New (see all changes)?

- Nov 25 '05 Allow to change display name of running progress task

  Added new method `setDisplayName(String)` to `ProgressHandle` and `AggregateProgressHandle`, allows to change the main identifying name of the progress task.

- Oct 19 '05 Adding `createProgressComponent(AggregateProgressHandle)` method to `AggregateProgressFactory`

  For aggregated progress handles the equivalent of ProgressHandleFactory.createProgressComponent() was missing. Added in this version.

- Sep 26 '05 Adding `setInitialDelay(int)` method to `ProgressHandle` and `AggregateProgressHandle`

  The newly added methods allow to customize the amount of time that shall pass between the start of handle's progress and it's appearance in the status bar. If the progress task finishes fast enough it won't appear in the UI at all. The default value is around 0.5s.

  For handles that are used in dialogs and elsewhere, this property has no effect and the handle's component is shown immediately.

- May 4 '05 Initial version released

  first initial release of the progress api.

### Use Cases

##### Basic usage

There are 3 types of progress indication:

- 1. indefinite when it's not known how much time will be needed to complete
- 2. definite with time estimate for completion (UI shows time that remains)
- 3. definite without time estimate where the UI shows percentage completed.

The default location of the progress indication is the status bar which aggregates all tasks running in the IDE that show progress. However it's possible to exclude the task from the default location and show the progress in one's custom dialog component. In such a case the same task should not appear in the status line component as well.

It's possible to request cancelling the task from status line progress aggregator if the task allows cancelling.

Progress tasks that get started as a result of explicit user action takes precedence in the status line docked component over tasks that are triggered by the system. (say filesystem refresh for example)

The most common usecase of the API looks like this:

    ProgressHandle handle = ProgressHandleFactory.creatHandle("My custom task");
    ...
    // we have 100 workunits
    // at this point the task appears in status bar.
    handle.start(100);
    ...
    handle.progress(10);
    ...
    handle.progress("half way through", 50);
    ...
    handle.progress(99);
    // at this point the task is finished and removed from status bar
    // it's not realy necessary to count all the way to the limit, finish can be called earlier.
    // however it has to be called at the end of the processing.
    handle.finish();

##### Advanced Usage

In case your usage of the API

- spans across multiple independent modules,
- requires adjusting of number of workunits or
- triggers additional action based on the current progress

then you should consider using the aggregating version of APIs which is similar to the simple APIs but has distinctive differences and additions that allow for more complex scenarios.

It allows to compose the progress bar from 1+ independent sources, all sharing proportional piece of the progress bar. Additionally you can monitor the task's overall progress from one central place and possibly add more contributing sources of the progress during processing.

            // let's have a factory for client code that performs some part of the job to be done..
            Lookup.Result res = Lookup.getDefault().lookup(new LookupTemplate(MyWorkerFactory.class));
            Iterator it = res.allInstances().iterator();
            ProgressContributor[] contribs = new ProgressContributor[res.allInstances().size()];
            int i = 0;
            while (it.hasNext()) {
                MyWorkerFactory prov = (MyWorkerFactory)it.next();
                contribs[i] = AggregateProgressFactory.createProgressContributor("Module X contribution");
                MyWorker worker = prov.createWorker(contribs[i]);
                //... snip ... do something with the worker..
                i = i + 1;
            }
            AggregateProgressHandle handle = AggregateProgressFactory.createHandle("My Task", contribs, null, null);
            // non-cancellable and with out output link.

            // calling start() at the time when the actual long running task starts processing
            handle.start("here we go");
            // ...snip...
            // now the individual MyWorker instances log their progress.
            // possibly in other threads too..
            // ... snip...
            //
            if (myConditionThatSpawnsAnotherContributor()) {
                ProgressContributor cont = AggregateProgressFactory.createProgressContributor("Additional exceptional contribution");
                handle.addContributor(cont);
                // ... snip ...
            }

            // the task is finished when all the ProgressContributors finish..

### Exported Interfaces

This table lists all of the module exported APIs with defined stability classifications. It is generated based on answers to questions about the architecture of the module. Read them all...

##### Group of java interfaces

Interface Name | In/Out | Stability | Specified in What Document?
Progress | Exported | Official | ../org-netbeans-api-progress/index.html

### Implementation Details

##### What do other modules need to do to declare a dependency on this one?

OpenIDE-Module-Module-Dependencies org.netbeans.api.progress/1 > 1.0

Read more about the implementation in the answers to architecture questions.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| org.netbeans.api.progress/1 1.5.22
PREV NEXT | FRAMES NO FRAMES

Built on December 7 2006. | Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.