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 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.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.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; 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 WIDTH = "400px";
protected String HEIGHT = "120px"; protected String HEIGHT = "120px";
protected EventBus eventBus; protected EventBus eventBus;
protected UIOperationsId opertionId;
protected ProgressUpdater progressUpdater; protected ProgressUpdater progressUpdater;
protected TextButton ok; protected TextButton ok;
protected TRId trId; protected TRId trId;
private String reason; private String reason;
private String details; private String details;
public ProgressDialog(
public ProgressDialog(UIOperationsId operationId,
EventBus eventBus) { EventBus eventBus) {
this.eventBus = eventBus; this.eventBus = eventBus;
this.opertionId=operationId;
setWidth(WIDTH); setWidth(WIDTH);
setHeight(HEIGHT); setHeight(HEIGHT);
setBodyBorder(false); setBodyBorder(false);
@ -76,8 +82,9 @@ public class ProgressDialog extends Window implements
panel.add(v); panel.add(v);
panel.addButton(ok); panel.addButton(ok);
add(panel); add(panel);
progressUpdater = new ProgressUpdater(); OperationMonitorSession operationMonitorSession=new OperationMonitorSession(operationId);
progressUpdater = new ProgressUpdater(operationMonitorSession);
progressUpdater.addListener(new ProgressBarUpdater( progressUpdater.addListener(new ProgressBarUpdater(
progressBar)); progressBar));

View File

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