import java.util.UUID;
import org.apache.log4j.Logger;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
final int pollInterval,
final IPostMoniteredOperationEnabled postOp,
IFeedbackGenerator feedbackGenerator,
- IProgressMonitor monitor) throws InterruptedException {
+ SubMonitor monitor) throws InterruptedException {
return pollMonitor(label, uuid, pollInterval, postOp, Arrays.asList(feedbackGenerator), monitor);
}
/**
final int pollInterval,
final IPostMoniteredOperationEnabled postOp,
List<IFeedbackGenerator> feedbackGenerators,
- IProgressMonitor monitor) throws InterruptedException {
+ SubMonitor monitor) throws InterruptedException {
IProgressMonitorService progressMonitorService = CdmApplicationState.getCurrentAppConfig().getProgressMonitorService();
IRemotingProgressMonitor remotingMonitor = progressMonitorService.getRemotingMonitor(uuid);
try {
final int START_DELAY=10;
// wait about 10 seconds for the remoting monitor to be initialised
// (i.e. for the begin task method to be called ON THE REMOTING MONITOR)
+ if ( remotingMonitor.isDone()){
+ return remotingMonitor;
+ }
for(int i=0;i<START_DELAY;i++) {
Thread.sleep(10);
logger.info("Waiting for monitered work to start ..");
}
// start the client monitor
- monitor.beginTask(label, remotingMonitor.getTotalWork());
+ // monitor.subTask(remotingMonitor.getTaskName());
+ monitor.beginTask(remotingMonitor.getTaskName(), remotingMonitor.getTotalWork());
logger.info("Work to be done: " + remotingMonitor.getTotalWork());
int editorTotalWorkDone = 0;
int serverTotalWorkDone = 0;
}
serverTotalWorkDone = (int) remotingMonitor.getWorkDone();
logger.info("Work done from start: " + serverTotalWorkDone);
- String percentage = new DecimalFormat("#.##").format(remotingMonitor.getPercentage());
+ String percentage = "100";
+ if (remotingMonitor.getTotalWork() != 0){
+ percentage = new DecimalFormat("#.##").format(remotingMonitor.getPercentage());
+ }
+
// set dialog text
monitor.setTaskName(label + " " + percentage + "% done ");
monitor.subTask(remotingMonitor.getSubTask());
- int worked = serverTotalWorkDone - editorTotalWorkDone;
+// monitor.setWorkRemaining((int) (remotingMonitor.getTotalWork()-remotingMonitor.getWorkDone()));
+ // monitor.subTask(remotingMonitor.getSubTask(), remotingMonitor.getWorkDone());
+ int worked = 0;
+ if (serverTotalWorkDone > editorTotalWorkDone){
+ worked = serverTotalWorkDone - editorTotalWorkDone;
+ }
if(worked > 0) {
logger.info("Work done since last check: " + worked);
monitor.worked(worked);
}
+
+
editorTotalWorkDone = serverTotalWorkDone;
}
if(remotingMonitor.getResult() instanceof Exception) {