Is there a way to display a progress bar while performing a long running
task?

Generally when I do this it requires 2 threads, does such a thing exist in
qooxdoo?

Here's what I have so far:

//console.clear();

// Document is the application root
var root = this.getRoot();      
var box = new qx.ui.layout.VBox();      
var container = new qx.ui.container.Composite(box);

var pb = new qx.ui.indicator.ProgressBar(0, 100);    
var lblPrimary = new qx.ui.basic.Label();
var lblSecondary = new qx.ui.basic.Label();
var totalCount = 1000;

// Create a button
var button1 = new qx.ui.form.Button("GO",
"icon/22/apps/internet-web-browser.png");
button1.setMaxWidth(100);

root.add(container, {left:0,top:0});   
container.add(lblPrimary);
container.add(pb);        
container.add(lblSecondary);
container.add(button1);

lblPrimary.setValue("Please Wait...");
lblSecondary.setValue("Completed: 0 (0%)");

box.setSpacing(10);      
container.setPadding(20);

//get real time change from the progressbar
pb.addListener("change", function(e) {        
  lblSecondary.setValue("Completed: " + pb.getValue() + " (" + e.getData() +
"%)");        
  lblSecondary.setTextColor("black");      
});


// Add an event listener
button1.addListener("execute", function(e) {

  for(i = 0; i<totalCount; i++)
  {
    setTimeout(function () { 
    
      var percentComplete = i / totalCount * 100;  
      pb.setValue(percentComplete);
      lblSecondary.setValue("Completed: " + i + " (" + percentComplete +
"%)");
    
    }, 2000); 
    
  }
  
});

//when complete make the info text green
pb.addListener("complete", function(e) {        
  lblSecondary.setTextColor("green");      
});


Everything works as advertised, but I really want my for loop to update the
progress bar and labels as it is performing the work.

Thanks,

-Eric


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to