Updated OperationMonitor
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-monitor-widget@99242 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d52159d988
commit
af300a561d
|
@ -3,6 +3,7 @@ package org.gcube.portlets.user.td.monitorwidget.client;
|
|||
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -14,7 +15,7 @@ import com.sencha.gxt.widget.core.client.ProgressBar;
|
|||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ProgressBarUpdater implements ProgressListener {
|
||||
public class MonitorBarUpdater implements MonitorListener {
|
||||
|
||||
protected ProgressBar progressBar;
|
||||
|
||||
|
@ -22,7 +23,7 @@ public class ProgressBarUpdater implements ProgressListener {
|
|||
* Creates a new {@link ProgressBar} updater.
|
||||
* @param progressBar the {@link ProgressBar} to update.
|
||||
*/
|
||||
public ProgressBarUpdater(ProgressBar progressBar) {
|
||||
public MonitorBarUpdater(ProgressBar progressBar) {
|
||||
this.progressBar = progressBar;
|
||||
this.progressBar.updateProgress(0, "Please Wait...");
|
||||
}
|
||||
|
@ -91,4 +92,11 @@ public class ProgressBarUpdater implements ProgressListener {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void operationMonitorChanged(OperationMonitor operationMonitor) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package org.gcube.portlets.user.td.monitorwidget.client;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
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.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
|
@ -28,13 +29,13 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
|||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ProgressDialog extends Window implements ProgressListener {
|
||||
public class MonitorDialog extends Window implements MonitorListener {
|
||||
|
||||
public static final int STATUS_POLLING_DELAY = 1000;
|
||||
private static final String WIDTH = "400px";
|
||||
private static final String HEIGHT = "120px";
|
||||
private EventBus eventBus;
|
||||
private ProgressUpdater progressUpdater;
|
||||
private MonitorUpdater progressUpdater;
|
||||
private TextButton ok;
|
||||
private TRId trId;
|
||||
private String reason;
|
||||
|
@ -43,10 +44,10 @@ public class ProgressDialog extends Window implements ProgressListener {
|
|||
protected boolean backgroundBtnEnabled=true;
|
||||
protected ToolButton backgroundBtn;
|
||||
|
||||
protected ArrayList<ProgressDialogListener> listeners = new ArrayList<ProgressDialogListener>();
|
||||
protected ArrayList<MonitorDialogListener> listeners = new ArrayList<MonitorDialogListener>();
|
||||
|
||||
|
||||
public ProgressDialog(String taskId, EventBus eventBus) {
|
||||
public MonitorDialog(String taskId, EventBus eventBus) {
|
||||
this.eventBus = eventBus;
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
|
@ -83,8 +84,8 @@ public class ProgressDialog extends Window implements ProgressListener {
|
|||
|
||||
OperationMonitorSession operationMonitorSession = new OperationMonitorSession(
|
||||
taskId);
|
||||
progressUpdater = new ProgressUpdater(operationMonitorSession);
|
||||
progressUpdater.addListener(new ProgressBarUpdater(progressBar));
|
||||
progressUpdater = new MonitorUpdater(operationMonitorSession);
|
||||
progressUpdater.addListener(new MonitorBarUpdater(progressBar));
|
||||
|
||||
progressUpdater.addListener(this);
|
||||
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
||||
|
@ -93,11 +94,11 @@ public class ProgressDialog extends Window implements ProgressListener {
|
|||
|
||||
}
|
||||
|
||||
public void addProgressDialogListener(ProgressDialogListener listener) {
|
||||
public void addProgressDialogListener(MonitorDialogListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeProgressDialogListener(ProgressDialogListener listener) {
|
||||
public void removeProgressDialogListener(MonitorDialogListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
|
@ -166,17 +167,17 @@ public class ProgressDialog extends Window implements ProgressListener {
|
|||
}
|
||||
|
||||
protected void fireOperationComplete(TRId trId) {
|
||||
for (ProgressDialogListener listener : listeners)
|
||||
for (MonitorDialogListener listener : listeners)
|
||||
listener.operationComplete(trId);
|
||||
}
|
||||
|
||||
protected void fireOperationFailed(Throwable caught, String reason) {
|
||||
for (ProgressDialogListener listener : listeners)
|
||||
for (MonitorDialogListener listener : listeners)
|
||||
listener.operationFailed(caught, reason);
|
||||
}
|
||||
|
||||
protected void fireOperationStopped(TRId trId, String reason, String details) {
|
||||
for (ProgressDialogListener listener : listeners)
|
||||
for (MonitorDialogListener listener : listeners)
|
||||
listener.operationStopped(trId, reason, details);
|
||||
}
|
||||
|
||||
|
@ -215,4 +216,10 @@ public class ProgressDialog extends Window implements ProgressListener {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationMonitorChanged(OperationMonitor operationMonitor) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,13 @@ package org.gcube.portlets.user.td.monitorwidget.client;
|
|||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
public interface ProgressDialogListener {
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface MonitorDialogListener {
|
||||
|
||||
|
||||
/**
|
||||
|
@ -30,5 +36,17 @@ public interface ProgressDialogListener {
|
|||
public void operationStopped(TRId trId, String reason, String details);
|
||||
|
||||
|
||||
/**
|
||||
* Called when the operation is aborted
|
||||
*
|
||||
*/
|
||||
public void operationAborted();
|
||||
|
||||
|
||||
/**
|
||||
* Called when the operation is put in the background
|
||||
*
|
||||
*/
|
||||
public void operationPutInBackground();
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.td.monitorwidget.client;
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.monitor.OperationMonitor;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
|
||||
|
@ -12,7 +13,7 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
|||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface ProgressListener {
|
||||
public interface MonitorListener {
|
||||
|
||||
/**
|
||||
* Called when the operation is starting.
|
||||
|
@ -57,4 +58,12 @@ public interface ProgressListener {
|
|||
*/
|
||||
public void operationGeneratingView();
|
||||
|
||||
|
||||
/**
|
||||
* Called when the operation montor is changed
|
||||
*
|
||||
* @param operationMonitor
|
||||
*/
|
||||
public void operationMonitorChanged(OperationMonitor operationMonitor);
|
||||
|
||||
}
|
|
@ -18,12 +18,12 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
|||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ProgressUpdater extends Timer {
|
||||
public class MonitorUpdater extends Timer implements MonitorUpdaterListener {
|
||||
|
||||
protected ArrayList<ProgressListener> listeners = new ArrayList<ProgressListener>();
|
||||
protected ArrayList<MonitorListener> listeners = new ArrayList<MonitorListener>();
|
||||
protected OperationMonitorSession operationMonitorSession;
|
||||
|
||||
public ProgressUpdater(OperationMonitorSession operationMonitorSession){
|
||||
public MonitorUpdater(OperationMonitorSession operationMonitorSession){
|
||||
this.operationMonitorSession=operationMonitorSession;
|
||||
}
|
||||
|
||||
|
@ -138,61 +138,77 @@ public class ProgressUpdater extends Timer {
|
|||
}
|
||||
|
||||
protected void fireOperationInitializing() {
|
||||
for (ProgressListener listener : listeners)
|
||||
for (MonitorListener listener : listeners)
|
||||
listener.operationInitializing();
|
||||
}
|
||||
|
||||
protected void fireOperationGeneratingView() {
|
||||
for (ProgressListener listener : listeners)
|
||||
for (MonitorListener listener : listeners)
|
||||
listener.operationGeneratingView();
|
||||
}
|
||||
|
||||
protected void fireOperationUpdate(float elaborated) {
|
||||
for (ProgressListener listener : listeners)
|
||||
for (MonitorListener listener : listeners)
|
||||
listener.operationUpdate(elaborated);
|
||||
}
|
||||
|
||||
protected void fireOperationValidate(float elaborated) {
|
||||
for (ProgressListener listener : listeners)
|
||||
for (MonitorListener listener : listeners)
|
||||
listener.operationValidate(elaborated);
|
||||
}
|
||||
|
||||
protected void fireOperationComplete(TRId trId) {
|
||||
for (ProgressListener listener : listeners)
|
||||
for (MonitorListener listener : listeners)
|
||||
listener.operationComplete(trId);
|
||||
}
|
||||
|
||||
protected void fireOperationFailed(Throwable caught, String failure,
|
||||
String failureDetails) {
|
||||
for (ProgressListener listener : listeners)
|
||||
for (MonitorListener listener : listeners)
|
||||
listener.operationFailed(caught, failure, failureDetails);
|
||||
}
|
||||
|
||||
protected void fireOperationStopped(TRId trId, String reason, String details) {
|
||||
for (ProgressListener listener : listeners)
|
||||
for (MonitorListener listener : listeners)
|
||||
listener.operationStopped(trId,reason, details);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new {@link ProgressListener} to this
|
||||
* Add a new {@link MonitorListener} to this
|
||||
* {@link AddColumnProgressUpdater}.
|
||||
*
|
||||
* @param listener
|
||||
* the listener to add.
|
||||
*/
|
||||
public void addListener(ProgressListener listener) {
|
||||
public void addListener(MonitorListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified {@link ProgressListener} from this
|
||||
* Removes the specified {@link MonitorListener} from this
|
||||
* {@link AddColumnProgressUpdater}.
|
||||
*
|
||||
* @param listener
|
||||
* the listener to remove.
|
||||
*/
|
||||
public void removeListener(ProgressListener listener) {
|
||||
public void removeListener(MonitorListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void operationAborted() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void operationPutInBackground() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package org.gcube.portlets.user.td.monitorwidget.client;
|
||||
|
||||
public interface MonitorUpdaterListener {
|
||||
/**
|
||||
* Called when the operation is aborted
|
||||
*
|
||||
*/
|
||||
public void operationAborted();
|
||||
|
||||
|
||||
/**
|
||||
* Called when the operation is put in the background
|
||||
*
|
||||
*/
|
||||
public void operationPutInBackground();
|
||||
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package org.gcube.portlets.user.td.monitorwidget.client;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class MonitorWidget {
|
||||
public MonitorWidget(){
|
||||
|
||||
}
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
package org.gcube.portlets.user.td.monitorwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.web.bindery.event.shared.SimpleEventBus;
|
||||
|
||||
|
@ -15,9 +12,8 @@ import com.google.web.bindery.event.shared.SimpleEventBus;
|
|||
public class MonitorWidgetEntry implements EntryPoint {
|
||||
|
||||
public void onModuleLoad() {
|
||||
TRId trId=new TRId();
|
||||
SimpleEventBus eventBus=new SimpleEventBus();
|
||||
MonitorWidget monitorWidget= new MonitorWidget();
|
||||
|
||||
MonitorDialog monitorWidget= new MonitorDialog("taskId",eventBus);
|
||||
monitorWidget.show();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue