Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-monitor-widget@99230 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-08-07 15:45:30 +00:00 committed by Giancarlo Panichi
parent 41aa2cb4f9
commit d52159d988
1 changed files with 66 additions and 34 deletions

View File

@ -1,9 +1,7 @@
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;
@ -17,6 +15,7 @@ import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.ProgressBar;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.button.ToolButton;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
@ -29,27 +28,26 @@ 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 {
protected ArrayList<ProgressDialogListener> listeners = new ArrayList<ProgressDialogListener>();
public class ProgressDialog extends Window implements ProgressListener {
public static final int STATUS_POLLING_DELAY = 1000;
protected String WIDTH = "400px";
protected String HEIGHT = "120px";
protected EventBus eventBus;
protected UIOperationsId opertionId;
protected ProgressUpdater progressUpdater;
protected TextButton ok;
protected TRId trId;
private static final String WIDTH = "400px";
private static final String HEIGHT = "120px";
private EventBus eventBus;
private ProgressUpdater progressUpdater;
private TextButton ok;
private TRId trId;
private String reason;
private String details;
public ProgressDialog(UIOperationsId operationId,
EventBus eventBus) {
protected boolean backgroundBtnEnabled=true;
protected ToolButton backgroundBtn;
protected ArrayList<ProgressDialogListener> listeners = new ArrayList<ProgressDialogListener>();
public ProgressDialog(String taskId, EventBus eventBus) {
this.eventBus = eventBus;
this.opertionId=operationId;
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
@ -82,11 +80,11 @@ public class ProgressDialog extends Window implements
panel.add(v);
panel.addButton(ok);
add(panel);
OperationMonitorSession operationMonitorSession=new OperationMonitorSession(operationId);
OperationMonitorSession operationMonitorSession = new OperationMonitorSession(
taskId);
progressUpdater = new ProgressUpdater(operationMonitorSession);
progressUpdater.addListener(new ProgressBarUpdater(
progressBar));
progressUpdater.addListener(new ProgressBarUpdater(progressBar));
progressUpdater.addListener(this);
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
@ -94,15 +92,15 @@ public class ProgressDialog extends Window implements
ok.setVisible(false);
}
public void addProgressDialogListener(ProgressDialogListener listener) {
listeners.add(listener);
}
public void removeProgressDialogListener(ProgressDialogListener listener) {
listeners.remove(listener);
}
@Override
public void operationInitializing() {
// TODO Auto-generated method stub
@ -130,9 +128,9 @@ public class ProgressDialog extends Window implements
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
fireOperationFailed(caught,reason);
fireOperationFailed(caught, reason);
hide();
}
}
@ -149,10 +147,10 @@ public class ProgressDialog extends Window implements
Log.debug("Operation Stopped: [" + trId.toString() + ", " + reason
+ ", " + details + "]");
this.trId = trId;
this.reason=reason;
this.details=details;
this.reason = reason;
this.details = details;
ok.setVisible(true);
}
@Override
@ -166,7 +164,7 @@ public class ProgressDialog extends Window implements
// TODO Auto-generated method stub
}
protected void fireOperationComplete(TRId trId) {
for (ProgressDialogListener listener : listeners)
listener.operationComplete(trId);
@ -176,11 +174,45 @@ public class ProgressDialog extends Window implements
for (ProgressDialogListener listener : listeners)
listener.operationFailed(caught, reason);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (ProgressDialogListener listener : listeners)
listener.operationStopped(trId,reason, details);
listener.operationStopped(trId, reason, details);
}
/**
* {@inheritDoc}
*/
@Override
protected void initTools() {
if (backgroundBtnEnabled) {
backgroundBtn = new ToolButton(ToolButton.CLOSE);
backgroundBtn.setToolTip("Put in the background");
backgroundBtn.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
hide();
}
});
header.addTool(backgroundBtn);
}
super.initTools();
closeBtn.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
close();
}
});
}
protected void close() {
hide();
}
}