All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.spardat.xma.boot.comp.BRBusyIndicator Maven / Gradle / Ivy

There is a newer version: 1.16.0
Show newest version
/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

package at.spardat.xma.boot.comp;

import javax.swing.ProgressMonitor;

import at.spardat.xma.boot.exc.BRTCodes;


/**
 * Shell with a progress bar, shown while downloading the resources of an application.
 * @author s3595
 */
public class BRBusyIndicator {
    Object result;

    /**
     * construts the BRBusyIndicator
     */
    public BRBusyIndicator() {
    }

    /**
     * shows a message box as long as the thread loader is alive.
     *
     * @param loader thread to start
     * @return null
     */
    public Object open ( Thread loader ) {
        /*
         * start the thread and wait until it has finished.
         * assume a duration of 60 seconds.
         */
        loader.start();
        ProgressMonitor progressMonitor = new ProgressMonitor(null,BRTCodes.getText("BusyText"),null,0,100);

        int progress = 0;
        long sleep   = 600;
        while(loader.isAlive() ) {
            try { loader.join(sleep);
            } catch (InterruptedException e) { }
            progressMonitor.setProgress((int)(progress/sleep)%99);
            progress+=sleep;
        }
        progressMonitor.close();

        return result;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy