Banana.Application.ProgressBar

Documentation •
In this article

Banana.Application.ProgressBar is the interface to the program progress bar and can be accessed through Banana.application.progressBar. The progressBar object is used to give the user an indication of the progress of an operation and the possibility to interrupt the running process. The progress bar is showed in bottom left corner of the application windows.



// Example use of a progress bar
var progressBar = Banana.application.progressBar;
progressBar.start(10);
for (var i = 0; i < 10; i++) {
   ...
   if (!progressBar.step(1)) {
      return; // Operation canceled by the user
   }
}
progressBar.finish();

Properties

showDetails

If true details are showed in the progess bar. If false only the text set by the first progressBar.start() call is showed.



progressBar.showDetails = false; // Example without details: "VAT Report"
progressBar.showDetails = true; // Example with details: "Vat Report; Sales; Row: 120"

Since Banana Accounting 9.0.3.

Methods

finish()

Notifies that the operation has been completed and closes the progress bar.

Returns false if the user canceled the operation, otherwise true.



progressBar.finish();

 pause()

Notifies that the operation has been paused, the cursor icon is set to the arrow cursor or poiting hand cursor. This is usually called before showing a dialog.



Banana.application.progressBar.pause();
var result = dialog.exec();
Banana.application.progressBar.resume();

resume()

Notifies that the operation has been resumed, the cursor icon is set back to an hourglass or watch cursor. This is usually called after a dialog has been closed.



Banana.application.progressBar.pause();
var result = dialog.exec();
Banana.application.progressBar.resume();

start(maxSteps)

Starts the progress indicator and defines the number of steps this operation needs before being complete.

You can call this method several times to split the progress in main and sub steps. Every call of the method start() should be paired with a call of the method finish().

Returns false if the user canceled the operation, otherwise true.



// Example use of a progress bar
var progressBar = Banana.application.progressBar;
progressBar.start(10);
for (var i = 0; i < 10; i++) {
   ...
   if (!progressBar.step(1)) {
      return; // Operation canceled by the user
   }
}
progressBar.finish();

start(text, maxSteps)

Starts the progress indicator and defines the text to be showed in the progress bar as well as the number of steps this operation needs before being complete.

You can call this method several times to split the progress in main and sub steps. Every call of the method start() should be paired with a call of the method finish().

Returns false if the user canceled the operation, otherwise true.



// Example use of a progress bar
var progressBar = Banana.application.progressBar;
progressBar.start("Checking rows", 10);
for (var i = 0; i < 10; i++) {
   ...
   if (!progressBar.step("Row: " + i.toString())) {
      return; // Operation canceled by the user
   }
}
progressBar.finish();

Since Banana Accounting 9.0.3.

setText(text)

Sets the text to show in the progress bar. 



progressBar.setText("Checking vat rates");

Since Banana Accounting 9.0.3.

step([stepCount])

Advances the progress indicator of stepCount steps. If stepCount is not defined, it advances of one step.

Returns false if the user canceled the operation, otherwise true.



progressBar.step(1);

step(text, [stepCount])

Advances the progress indicator of stepCount steps and sets the text of the progress bar. If stepCount is not defined it advances of one step.

Returns false if the user canceled the operation, otherwise true.



progressBar.step("Row: " i.toString());

Since Banana Accounting 9.0.3.

Example multiple steps inside a block



// Two blocks of progress bar inside a progressBar
var progressBar = Banana.application.progressBar;

progressBar.start("Vat Report", 2);

// Block 1
progressBar.start("Sales", 10)
for (i = 0; i < 10; i++) {
   progressBar.step("Row: " + i.toString());
}
progressBar.finish();

// Block 2
progressBar.start("Purchases", 10)
for (i = 0; i < 10; i++) {
   progressBar.step("Row: " + i.toString());
}
progressBar.finish();

progressBar.finish();

 

 

Tell us how we can help you better
If the information on this page is not what you're looking for, is not clear enough, or is not up-to-date, let us know.

Share this article: Twitter | Facebook | LinkedIn | Email