Package org.mevenide.idea.repository

Source Code of org.mevenide.idea.repository.ProgressIndicatorDownloadMeter

package org.mevenide.idea.repository;

import com.intellij.openapi.progress.ProgressIndicator;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.maven.util.DownloadMeter;
import org.mevenide.idea.util.IDEUtils;

/**
* @author Arik
*/
public class ProgressIndicatorDownloadMeter implements DownloadMeter {
    private AtomicBoolean started = new AtomicBoolean(false);

    public void finish(final int pTotal) {
        final ProgressIndicator indicator = IDEUtils.getProgressIndicator();
        if (indicator != null)
            indicator.setFraction(1);
    }

    public void update(final int pComplete, final int pTotal) {
        final ProgressIndicator indicator = IDEUtils.getProgressIndicator();
        if (indicator != null) {
            if (started.compareAndSet(false, true))
                indicator.setIndeterminate(false);

            final double fraction = (double) pComplete / (double) pTotal;
            indicator.setFraction(fraction);
        }
    }

}
TOP

Related Classes of org.mevenide.idea.repository.ProgressIndicatorDownloadMeter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.