FileDocCategorySizeDatePackage
Lesson8.javaAPI DocExample2758Thu Feb 17 20:00:56 GMT 2000com.togethersoft.modules.tutorial

Lesson8

public class Lesson8 extends Object implements com.togethersoft.openapi.ide.IdeScript
This script shows how to use Together's progress indicator. You can use the java.text.MessageFormat's format in the ProgressIndicator.start method to produce a nice output.
author
TogetherSoft LLC

Fields Summary
Constructors Summary
Methods Summary
private java.lang.StringgetDescription(int stage)

        switch (stage) {
            case 0:
                return "You can stop this demo by pressing Cancel button";
            case 1:
                return "Indicator supports java.text.MessageFormat's syntax";
            case 2:
                return "Use it to create nice-looking output messages";
            case 3:
                return "You can create cancelabe/non-cancelable indicators";
            case 4:
                return "You can create delayed indicators (see API docs)";
            case 5:
                return "Together's progress indicator is very flexible!";
            case 6:
                return "See ide.progress package description in API docs";
        }
        return "";
    
public voidrun(com.togethersoft.openapi.ide.IdeContext context)

        IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Lesson8 script: started");
        IdeProgressIndicator progressIndicator = IdeProgressIndicatorAccess.getProgressIndicator();
        IdeProgress progress = progressIndicator.start("myID", true, 70,
            "Step {0, number, integer} of {1, number, integer}. {3, number, percent} completed. ({2})");
        for (int i = 0; i < 70; i++) {
            if (progress.isCancelRequested()) {
                break;
            }
            try { Thread.sleep(600); }
            catch(Exception e) { }
            progress.setCount(i);
            if (i % 10 == 0) {
                progress.setStep(getDescription(i / 10));
            }
        }
        progress.stop();
        IdeMessageManagerAccess.printMessage(IdeMessageType.INFORMATION, "Lesson8 script: finished");