package mypkg;

import java.util.logging.Level;

import com.meldcraft.application.swing.DefaultSwingApplication;

public class MyApp2 extends DefaultSwingApplication
{
    public void doSomething(long millis, boolean doLog)
    {
        // sleep for a while
        long time = 100;
        long count = 0;
        while (true)
        {
            try {Thread.sleep(time);}catch (Exception e){}

            if ((count += time) >= millis)
            {
                break;
            }
            getApplicationContext().contextChanged("Application.Progress",
                                                      ""+((double)count/millis));
            if (doLog)
            {
                getApplicationContext().getLogger().log(Level.INFO,
                                    "progress: " + ((double)count/millis));
            }
        }
    }

    @Override
    public void applicationOpen(Object obj)
    {
        Object[][] rows = {{"Encinitas", "CA"},
                           {"Windsor", "CO"}};
        getApplicationContext().contextChanged("TableData", rows);
    }
}
