Updated OperationMonitor

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-monitor-widget@99227 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-08-06 18:11:44 +00:00 committed by Giancarlo Panichi
parent 7d8a0f7142
commit 41aa2cb4f9
2 changed files with 42 additions and 29 deletions

View File

@ -3,7 +3,9 @@ package org.gcube.portlets.user.td.monitorwidget.client;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.shared.UIOperationsId;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitorSession;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@ -35,15 +37,19 @@ public class ProgressDialog extends Window implements
protected String WIDTH = "400px";
protected String HEIGHT = "120px";
protected EventBus eventBus;
protected UIOperationsId opertionId;
protected ProgressUpdater progressUpdater;
protected TextButton ok;
protected TRId trId;
private String reason;
private String details;
public ProgressDialog(
public ProgressDialog(UIOperationsId operationId,
EventBus eventBus) {
this.eventBus = eventBus;
this.opertionId=operationId;
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
@ -76,8 +82,9 @@ public class ProgressDialog extends Window implements
panel.add(v);
panel.addButton(ok);
add(panel);
progressUpdater = new ProgressUpdater();
OperationMonitorSession operationMonitorSession=new OperationMonitorSession(operationId);
progressUpdater = new ProgressUpdater(operationMonitorSession);
progressUpdater.addListener(new ProgressBarUpdater(
progressBar));

View File

@ -3,7 +3,8 @@ package org.gcube.portlets.user.td.monitorwidget.client;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.AddColumnMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitorSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
@ -18,9 +19,14 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
*
*/
public class ProgressUpdater extends Timer {
protected ArrayList<ProgressListener> listeners = new ArrayList<ProgressListener>();
protected OperationMonitorSession operationMonitorSession;
public ProgressUpdater(OperationMonitorSession operationMonitorSession){
this.operationMonitorSession=operationMonitorSession;
}
/**
* {@inheritDoc}
*/
@ -28,7 +34,7 @@ public class ProgressUpdater extends Timer {
public void run() {
Log.debug("requesting operation progress");
TDGWTServiceAsync.INSTANCE
.getAddColumnMonitor(new AsyncCallback<AddColumnMonitor>() {
.getOperationMonitor(operationMonitorSession,new AsyncCallback<OperationMonitor>() {
public void onFailure(Throwable caught) {
@ -40,10 +46,10 @@ public class ProgressUpdater extends Timer {
"Failed getting operation updates", message);
}
public void onSuccess(AddColumnMonitor result) {
Log.info("retrieved AddColumnMonitor: "
+ result.getStatus());
switch (result.getStatus()) {
public void onSuccess(OperationMonitor result) {
Log.info("retrieved OperationMonitor: "
+ result.getTask().getState());
switch (result.getTask().getState()) {
case INITIALIZING:
Log.info("Initializing...");
fireOperationInitializing();
@ -53,10 +59,10 @@ public class ProgressUpdater extends Timer {
Log.info("Aborted");
break;
case IN_PROGRESS:
fireOperationUpdate(result.getProgress());
fireOperationUpdate(result.getTask().getProgress());
break;
case VALIDATING_RULES:
fireOperationValidate(result.getProgress());
fireOperationValidate(result.getTask().getProgress());
break;
case GENERATING_VIEW:
Log.info("Generating View...");
@ -89,34 +95,34 @@ public class ProgressUpdater extends Timer {
}
protected void errorMessage(AddColumnMonitor result) {
Log.info("AddColumn Failed");
Throwable th = null;
protected void errorMessage(OperationMonitor result) {
Log.info("Opration Failed");
Throwable th;
String failure = null;
String details = null;
if (result.getError() != null) {
th = result.getError();
failure = "Failed Client Library Add Column";
details = result.getError().getLocalizedMessage();
if (result.getTask().getErrorCause() != null) {
th = result.getTask().getErrorCause();
failure = "Failed Client Library";
details = result.getTask().getErrorCause().getLocalizedMessage();
} else {
th = new Throwable("Failed");
failure = "Failed Client Library Add Columnn";
details = "Add Column failed";
failure = "Failed Client Library";
details = "Operation failed";
}
fireOperationFailed(th, failure, details);
}
protected void stopMessage(AddColumnMonitor result) {
Log.info("Add Column Stopped");
protected void stopMessage(OperationMonitor result) {
Log.info("Operation Stopped");
String failure = null;
String details = null;
if (result.getError() != null) {
failure = "Stopped add column";
details = result.getError().getLocalizedMessage();
if (result.getTask().getErrorCause() != null) {
failure = "Stopped Operation";
details = result.getTask().getErrorCause().getLocalizedMessage();
} else {
failure = "Stopped add column";
details = "Add Column stopped";
failure = "Stopped Operation";
details = "Operation stopped";
}
fireOperationStopped(result.getTrId(),failure, details);