99 lines
2.9 KiB
Java
99 lines
2.9 KiB
Java
package org.gcube.portlets.user.td.monitorwidget.client;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.UIOperationsId;
|
|
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor;
|
|
import org.gcube.portlets.user.td.gwtservice.shared.task.JobS;
|
|
import org.gcube.portlets.user.td.gwtservice.shared.task.State;
|
|
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskS;
|
|
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsJobS;
|
|
import org.gcube.portlets.user.td.gwtservice.shared.task.WorkerState;
|
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
|
import com.google.gwt.core.client.EntryPoint;
|
|
import com.google.gwt.user.client.Random;
|
|
import com.google.gwt.user.client.Timer;
|
|
import com.google.web.bindery.event.shared.SimpleEventBus;
|
|
|
|
/**
|
|
*
|
|
* @author "Giancarlo Panichi" email: <a
|
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
*
|
|
*/
|
|
public class MonitorWidgetEntry implements EntryPoint {
|
|
|
|
private MonitorDialog monitorWidget;
|
|
|
|
|
|
public void onModuleLoad() {
|
|
Log.debug("Test MonitorWidget");
|
|
SimpleEventBus eventBus = new SimpleEventBus();
|
|
monitorWidget = new MonitorDialog("1", eventBus);
|
|
monitorWidget.show();
|
|
|
|
Timer elapsedTimer = new Timer () {
|
|
public void run() {
|
|
showElapsed();
|
|
}
|
|
};
|
|
|
|
Log.debug("Start Time:"+System.currentTimeMillis());
|
|
|
|
// Schedule the timer for every 1/2 second (500 milliseconds)
|
|
elapsedTimer.scheduleRepeating(3000);
|
|
|
|
}
|
|
|
|
private void showElapsed(){
|
|
OperationMonitor operationMonitor = new OperationMonitor("1",
|
|
UIOperationsId.EditRow);
|
|
operationMonitor.setTask(createTaskForTest());
|
|
monitorWidget.updateOperationMonitor(operationMonitor);
|
|
}
|
|
|
|
|
|
private TaskS createTaskForTest() {
|
|
|
|
ArrayList<ValidationsJobS> validationsJobs = new ArrayList<ValidationsJobS>();
|
|
ValidationsJobS validationJobS = new ValidationsJobS("1",
|
|
WorkerState.IN_PROGRESS, genProgress(), "Row Validate", null,
|
|
"Validation in progress");
|
|
validationsJobs.add(validationJobS);
|
|
|
|
ArrayList<JobS> jobs = new ArrayList<JobS>();
|
|
JobS job1 = new JobS("1", genProgress(), "Edit Row Job for Human",
|
|
"Edit Row Job", WorkerState.IN_PROGRESS, null, validationsJobs);
|
|
jobs.add(job1);
|
|
|
|
JobS job2 = new JobS("2", genProgress(), "Add Row Job for Human",
|
|
"Add Row Job", WorkerState.IN_PROGRESS, null, validationsJobs);
|
|
jobs.add(job2);
|
|
|
|
JobS job3 = new JobS("3", genProgress(), "Delete Job for Human",
|
|
"Delete Row Job", WorkerState.IN_PROGRESS, null, validationsJobs);
|
|
jobs.add(job3);
|
|
|
|
TaskS task = new TaskS("1", genProgress(), State.IN_PROGRESS, null, "default",
|
|
new Date(), null, jobs);
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
private float genProgress(){
|
|
float fperc;
|
|
int perc=Random.nextInt(100);
|
|
if(perc==0){
|
|
fperc=0f;
|
|
} else {
|
|
fperc= new Float(perc)/100;
|
|
}
|
|
Log.debug("ProgressSet: "+fperc);
|
|
return fperc;
|
|
}
|
|
|
|
}
|