TimelineProgressMonitor.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.common.ui;
00002 
00003 import java.util.concurrent.atomic.AtomicInteger;
00004 
00005 import org.eclipse.core.runtime.IProgressMonitor;
00006 import org.eclipse.jface.action.IStatusLineManager;
00007 import org.eclipse.swt.widgets.Shell;
00008 
00009 public class TimelineProgressMonitor {
00010 
00011     private AtomicInteger progress;
00012     private IStatusLineManager statusMgr;
00013     private IProgressMonitor monitor;
00014     
00015 
00016     public TimelineProgressMonitor(IStatusLineManager _statusMgr)
00017     {
00018         statusMgr = _statusMgr;
00019         monitor = statusMgr.getProgressMonitor();
00020         progress = new AtomicInteger();
00021     }
00022     
00023     public void beginProgress(int totalWork, String sMessage, String sTask, Shell shell)
00024     {
00025         progress.set(0);
00026         statusMgr.setMessage(sMessage);
00027         
00028         // quick fix to force UI to show the message.
00029         // we need a smarter way to do this. If the work is small, no need to refresh UI
00030         //shell.update();
00031         
00032         monitor.beginTask(sTask, totalWork);
00033     }
00034     
00035     public void announceProgress()
00036     {
00037         progress.getAndIncrement();
00038     }
00039     
00040     public void reportProgress()
00041     {
00042         int workDone = progress.getAndSet(0);
00043         if (workDone > 0)
00044             monitor.worked(workDone);
00045     }
00046     
00047     public void endProgress()
00048     {
00049         monitor.done();
00050         statusMgr.setMessage(null);
00051         // shell.update();
00052     }
00053 
00054 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1