Updated OperationMonitor
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-monitor-widget@99340 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7ea82a3f6a
commit
8a8d6145bc
|
@ -13,6 +13,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.task.WorkerState;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.core.client.EntryPoint;
|
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;
|
import com.google.web.bindery.event.shared.SimpleEventBus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,42 +25,74 @@ import com.google.web.bindery.event.shared.SimpleEventBus;
|
||||||
*/
|
*/
|
||||||
public class MonitorWidgetEntry implements EntryPoint {
|
public class MonitorWidgetEntry implements EntryPoint {
|
||||||
|
|
||||||
|
private MonitorDialog monitorWidget;
|
||||||
|
|
||||||
|
|
||||||
public void onModuleLoad() {
|
public void onModuleLoad() {
|
||||||
Log.debug("Test MonitorWidget");
|
Log.debug("Test MonitorWidget");
|
||||||
SimpleEventBus eventBus = new SimpleEventBus();
|
SimpleEventBus eventBus = new SimpleEventBus();
|
||||||
MonitorDialog monitorWidget = new MonitorDialog("1", eventBus);
|
monitorWidget = new MonitorDialog("1", eventBus);
|
||||||
monitorWidget.show();
|
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",
|
OperationMonitor operationMonitor = new OperationMonitor("1",
|
||||||
UIOperationsId.EditRow);
|
UIOperationsId.EditRow);
|
||||||
operationMonitor.setTask(createTaskForTest());
|
operationMonitor.setTask(createTaskForTest());
|
||||||
monitorWidget.updateOperationMonitor(operationMonitor);
|
monitorWidget.updateOperationMonitor(operationMonitor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private TaskS createTaskForTest() {
|
private TaskS createTaskForTest() {
|
||||||
|
|
||||||
ArrayList<ValidationsJobS> validationsJobs = new ArrayList<ValidationsJobS>();
|
ArrayList<ValidationsJobS> validationsJobs = new ArrayList<ValidationsJobS>();
|
||||||
ValidationsJobS validationJobS = new ValidationsJobS("1",
|
ValidationsJobS validationJobS = new ValidationsJobS("1",
|
||||||
WorkerState.IN_PROGRESS, 0.5f, "Row Validate", null,
|
WorkerState.IN_PROGRESS, genProgress(), "Row Validate", null,
|
||||||
"Validation in progress");
|
"Validation in progress");
|
||||||
validationsJobs.add(validationJobS);
|
validationsJobs.add(validationJobS);
|
||||||
|
|
||||||
ArrayList<JobS> jobs = new ArrayList<JobS>();
|
ArrayList<JobS> jobs = new ArrayList<JobS>();
|
||||||
JobS job1 = new JobS("1", 0.8f, "Edit Row Job for Human",
|
JobS job1 = new JobS("1", genProgress(), "Edit Row Job for Human",
|
||||||
"Edit Row Job", WorkerState.IN_PROGRESS, null, validationsJobs);
|
"Edit Row Job", WorkerState.IN_PROGRESS, null, validationsJobs);
|
||||||
jobs.add(job1);
|
jobs.add(job1);
|
||||||
|
|
||||||
JobS job2 = new JobS("2", 0.3f, "Add Row Job for Human",
|
JobS job2 = new JobS("2", genProgress(), "Add Row Job for Human",
|
||||||
"Add Row Job", WorkerState.IN_PROGRESS, null, validationsJobs);
|
"Add Row Job", WorkerState.IN_PROGRESS, null, validationsJobs);
|
||||||
jobs.add(job2);
|
jobs.add(job2);
|
||||||
|
|
||||||
JobS job3 = new JobS("3", 0.72f, "Delete Job for Human",
|
JobS job3 = new JobS("3", genProgress(), "Delete Job for Human",
|
||||||
"Delete Row Job", WorkerState.IN_PROGRESS, null, validationsJobs);
|
"Delete Row Job", WorkerState.IN_PROGRESS, null, validationsJobs);
|
||||||
jobs.add(job3);
|
jobs.add(job3);
|
||||||
|
|
||||||
TaskS task = new TaskS("1", 0.3f, State.IN_PROGRESS, null, "default",
|
TaskS task = new TaskS("1", genProgress(), State.IN_PROGRESS, null, "default",
|
||||||
new Date(), null, jobs);
|
new Date(), null, jobs);
|
||||||
|
|
||||||
return task;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class MonitorDetailPanel extends FramedPanel {
|
||||||
protected static final String WIDTH = "498px";
|
protected static final String WIDTH = "498px";
|
||||||
protected static final String HEIGHT = "256px";
|
protected static final String HEIGHT = "256px";
|
||||||
protected static final String GRIDHEIGHT = "212px";
|
protected static final String GRIDHEIGHT = "212px";
|
||||||
|
|
||||||
protected MonitorDetailPanel thisPanel;
|
protected MonitorDetailPanel thisPanel;
|
||||||
|
|
||||||
protected Menu contextMenu;
|
protected Menu contextMenu;
|
||||||
|
@ -86,18 +86,11 @@ public class MonitorDetailPanel extends FramedPanel {
|
||||||
this.thisPanel = this;
|
this.thisPanel = this;
|
||||||
forceLayoutOnResize = true;
|
forceLayoutOnResize = true;
|
||||||
init();
|
init();
|
||||||
draw();
|
create();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void draw() {
|
|
||||||
if (tree != null) {
|
|
||||||
remove(tree);
|
|
||||||
}
|
|
||||||
|
|
||||||
createTreeData();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void init() {
|
protected void init() {
|
||||||
setWidth(WIDTH);
|
setWidth(WIDTH);
|
||||||
|
@ -107,25 +100,16 @@ public class MonitorDetailPanel extends FramedPanel {
|
||||||
forceLayoutOnResize = true;
|
forceLayoutOnResize = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createTreeData() {
|
|
||||||
gen = new MonitorTreeDataGenerator(operationMonitor);
|
|
||||||
create();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void create() {
|
protected void create() {
|
||||||
con = new VerticalLayoutContainer();
|
con = new VerticalLayoutContainer();
|
||||||
//con.setScrollMode(ScrollMode.AUTO);
|
//con.setScrollMode(ScrollMode.AUTO);
|
||||||
|
|
||||||
store = new TreeStore<MonitorBaseDto>(new KeyProvider());
|
store = new TreeStore<MonitorBaseDto>(new KeyProvider());
|
||||||
|
|
||||||
MonitorFolderDto root = gen.getRoot();
|
addChildrensToStore();
|
||||||
for (MonitorBaseDto base : root.getChildrens()) {
|
|
||||||
store.add(base);
|
|
||||||
if (base instanceof MonitorFolderDto) {
|
|
||||||
processFolder(store, (MonitorFolderDto) base);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnConfig<MonitorBaseDto, String> cc1 = new ColumnConfig<MonitorBaseDto, String>(
|
ColumnConfig<MonitorBaseDto, String> cc1 = new ColumnConfig<MonitorBaseDto, String>(
|
||||||
new ToStringValueProvider<MonitorBaseDto>("task"), 168, "Task");
|
new ToStringValueProvider<MonitorBaseDto>("task"), 168, "Task");
|
||||||
cc1.setHeader("Task");
|
cc1.setHeader("Task");
|
||||||
|
@ -175,17 +159,7 @@ public class MonitorDetailPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
}, 100, "Status");
|
}, 100, "Status");
|
||||||
cc2.setHeader("Status");
|
cc2.setHeader("Status");
|
||||||
/*
|
|
||||||
ProgressBarCell progress = new ProgressBarCell() {
|
|
||||||
@Override
|
|
||||||
public boolean handlesSelection() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
progress.setProgressText("{0}% Complete");
|
|
||||||
progress.setWidth(140);
|
|
||||||
cc2.setCell(progress);
|
|
||||||
*/
|
|
||||||
ColumnConfig<MonitorBaseDto, Double> cc3 = new ColumnConfig<MonitorBaseDto, Double>(
|
ColumnConfig<MonitorBaseDto, Double> cc3 = new ColumnConfig<MonitorBaseDto, Double>(
|
||||||
new ValueProvider<MonitorBaseDto, Double>() {
|
new ValueProvider<MonitorBaseDto, Double>() {
|
||||||
|
|
||||||
|
@ -231,6 +205,7 @@ public class MonitorDetailPanel extends FramedPanel {
|
||||||
};
|
};
|
||||||
progress.setProgressText("{0}% Complete");
|
progress.setProgressText("{0}% Complete");
|
||||||
progress.setWidth(110);
|
progress.setWidth(110);
|
||||||
|
|
||||||
cc3.setCell(progress);
|
cc3.setCell(progress);
|
||||||
|
|
||||||
|
|
||||||
|
@ -326,7 +301,8 @@ public class MonitorDetailPanel extends FramedPanel {
|
||||||
con.add(tree, new VerticalLayoutData(1, -1, new Margins(0)));
|
con.add(tree, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||||
|
|
||||||
add(con, new MarginData(0));
|
add(con, new MarginData(0));
|
||||||
|
|
||||||
|
tree.expandAll();
|
||||||
forceLayout();
|
forceLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -335,19 +311,31 @@ public class MonitorDetailPanel extends FramedPanel {
|
||||||
String key = (String) context.getKey();
|
String key = (String) context.getKey();
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
MonitorBaseDto d = store.findModelWithKey(key);
|
MonitorBaseDto d = store.findModelWithKey(key);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void update(OperationMonitor operationMonitor) {
|
public void update(OperationMonitor operationMonitor) {
|
||||||
this.operationMonitor = operationMonitor;
|
this.operationMonitor = operationMonitor;
|
||||||
draw();
|
store.clear();
|
||||||
|
addChildrensToStore();
|
||||||
|
store.commitChanges();
|
||||||
|
tree.expandAll();
|
||||||
|
forceLayout();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addChildrensToStore() {
|
||||||
|
gen = new MonitorTreeDataGenerator(operationMonitor);
|
||||||
|
|
||||||
|
MonitorFolderDto root = gen.getRoot();
|
||||||
|
for (MonitorBaseDto base : root.getChildrens()) {
|
||||||
|
store.add(base);
|
||||||
|
if (base instanceof MonitorFolderDto) {
|
||||||
|
processFolder(store, (MonitorFolderDto) base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void processFolder(TreeStore<MonitorBaseDto> store,
|
private void processFolder(TreeStore<MonitorBaseDto> store,
|
||||||
MonitorFolderDto folder) {
|
MonitorFolderDto folder) {
|
||||||
|
@ -359,6 +347,4 @@ public class MonitorDetailPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class MonitorTreeDataGenerator {
|
||||||
root = new MonitorFolderDto("root", "-1", "root", "root", 0,
|
root = new MonitorFolderDto("root", "-1", "root", "root", 0,
|
||||||
childrens);
|
childrens);
|
||||||
Log.debug("Generated root");
|
Log.debug("Generated root");
|
||||||
printRecorsive(root);
|
//printRecorsive(root);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
root = new MonitorFolderDto("root", "-1", "root", "root", 0,
|
root = new MonitorFolderDto("root", "-1", "root", "root", 0,
|
||||||
|
|
Loading…
Reference in New Issue