2014-09-09 19:17:22 +02:00
|
|
|
package org.gcube.portlets.user.td.monitorwidget.client.background;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2014-09-10 18:34:48 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
2015-02-13 14:39:34 +01:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.monitor.BackgroundOperationMonitor;
|
2014-09-11 18:36:09 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.task.State;
|
2014-09-09 19:17:22 +02:00
|
|
|
import org.gcube.portlets.user.td.monitorwidget.client.resources.ResourceBundle;
|
2014-09-10 18:34:48 +02:00
|
|
|
import org.gcube.portlets.user.td.monitorwidget.client.utils.UtilsGXT3;
|
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
2014-09-09 19:17:22 +02:00
|
|
|
|
2014-09-10 18:34:48 +02:00
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
2014-09-09 19:17:22 +02:00
|
|
|
import com.google.gwt.cell.client.AbstractCell;
|
2015-02-13 14:39:34 +01:00
|
|
|
import com.google.gwt.core.client.GWT;
|
|
|
|
import com.google.gwt.editor.client.Editor.Path;
|
2014-09-10 18:34:48 +02:00
|
|
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
|
|
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
2014-09-09 19:17:22 +02:00
|
|
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
|
|
|
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
|
|
|
|
import com.google.web.bindery.event.shared.EventBus;
|
|
|
|
import com.sencha.gxt.cell.core.client.ProgressBarCell;
|
|
|
|
import com.sencha.gxt.core.client.ValueProvider;
|
2014-09-10 18:34:48 +02:00
|
|
|
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
|
2014-09-09 19:17:22 +02:00
|
|
|
import com.sencha.gxt.core.client.util.Margins;
|
2015-02-13 14:39:34 +01:00
|
|
|
import com.sencha.gxt.data.shared.ListStore;
|
2014-09-09 19:17:22 +02:00
|
|
|
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
2015-02-13 14:39:34 +01:00
|
|
|
import com.sencha.gxt.data.shared.PropertyAccess;
|
2014-09-09 19:17:22 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.MarginData;
|
|
|
|
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.grid.ColumnConfig;
|
|
|
|
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
|
2015-02-13 14:39:34 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.grid.Grid;
|
2014-09-10 18:34:48 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.menu.Item;
|
2014-09-09 19:17:22 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.menu.Menu;
|
|
|
|
import com.sencha.gxt.widget.core.client.menu.MenuItem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author "Giancarlo Panichi" <a
|
|
|
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
|
|
*
|
|
|
|
*/
|
2014-09-10 18:34:48 +02:00
|
|
|
public class MonitorBackgroundPanel extends FramedPanel implements
|
|
|
|
MonitorBackgroundUpdaterListener {
|
2015-02-13 15:54:32 +01:00
|
|
|
private static final int STATUS_POLLING_DELAY = 5000;
|
|
|
|
private static final String WIDTH = "640px";
|
|
|
|
private static final String HEIGHT = "520px";
|
|
|
|
private static final int CC1WIDTH = 90;
|
2015-04-24 18:33:44 +02:00
|
|
|
private static final int CC2WIDTH = 66;
|
|
|
|
private static final int CC3WIDTH = 104;
|
|
|
|
private static final int PROGRESS_WIDTH = 100;
|
2015-02-13 15:54:32 +01:00
|
|
|
private MonitorBackgroundDialog parent;
|
|
|
|
|
|
|
|
private ArrayList<MonitorBackgroundEventUIListener> monitorBackgroundEventUIListeners = new ArrayList<MonitorBackgroundEventUIListener>();
|
|
|
|
|
|
|
|
private Menu contextMenu;
|
|
|
|
private MenuItem infoItem;
|
|
|
|
private MenuItem abortItem;
|
|
|
|
private MenuItem hideItem;
|
|
|
|
|
2015-04-24 18:33:44 +02:00
|
|
|
// private TRId trId;
|
2015-02-13 15:54:32 +01:00
|
|
|
private VerticalLayoutContainer con;
|
2015-04-24 18:33:44 +02:00
|
|
|
// private ValidationsTasksMetadata validationsTasksMetadata;
|
2015-02-13 15:54:32 +01:00
|
|
|
|
|
|
|
private ListStore<BackgroundOperationMonitor> store;
|
|
|
|
private Grid<BackgroundOperationMonitor> grid;
|
|
|
|
private ArrayList<BackgroundOperationMonitor> backgroundOperationMonitorList;
|
2015-04-24 18:33:44 +02:00
|
|
|
private ArrayList<BackgroundOperationMonitor> backgroundOperationMonitorListCache;
|
2015-02-13 15:54:32 +01:00
|
|
|
|
|
|
|
private EventBus eventBus;
|
|
|
|
private MonitorBackgroundUpdater monitorBackgroundUpdater;
|
2014-09-10 18:34:48 +02:00
|
|
|
|
2015-02-13 14:39:34 +01:00
|
|
|
public interface BackgroundOperationMonitorProperties extends
|
|
|
|
PropertyAccess<BackgroundOperationMonitor> {
|
|
|
|
|
|
|
|
@Path("taskId")
|
|
|
|
ModelKeyProvider<BackgroundOperationMonitor> taskId();
|
|
|
|
|
|
|
|
ValueProvider<BackgroundOperationMonitor, String> tabularResourceName();
|
|
|
|
|
|
|
|
ValueProvider<BackgroundOperationMonitor, State> state();
|
|
|
|
|
|
|
|
ValueProvider<BackgroundOperationMonitor, Float> progress();
|
2014-09-09 19:17:22 +02:00
|
|
|
}
|
2014-09-10 18:34:48 +02:00
|
|
|
|
2014-09-09 19:17:22 +02:00
|
|
|
public MonitorBackgroundPanel(EventBus eventBus) {
|
|
|
|
super();
|
2015-04-24 18:33:44 +02:00
|
|
|
backgroundOperationMonitorListCache = null;
|
2014-09-09 19:17:22 +02:00
|
|
|
this.eventBus = eventBus;
|
|
|
|
forceLayoutOnResize = true;
|
|
|
|
init();
|
|
|
|
create();
|
|
|
|
}
|
2014-09-10 18:34:48 +02:00
|
|
|
|
|
|
|
public MonitorBackgroundPanel(MonitorBackgroundDialog parent,
|
|
|
|
EventBus eventBus) {
|
|
|
|
super();
|
2015-04-24 18:33:44 +02:00
|
|
|
backgroundOperationMonitorListCache = null;
|
2014-09-10 18:34:48 +02:00
|
|
|
this.eventBus = eventBus;
|
|
|
|
this.parent = parent;
|
|
|
|
forceLayoutOnResize = true;
|
|
|
|
init();
|
|
|
|
create();
|
|
|
|
}
|
|
|
|
|
2014-09-09 19:17:22 +02:00
|
|
|
protected void init() {
|
|
|
|
setWidth(WIDTH);
|
|
|
|
setHeight(HEIGHT);
|
|
|
|
setHeaderVisible(false);
|
|
|
|
setBodyBorder(false);
|
|
|
|
setResize(true);
|
|
|
|
|
|
|
|
}
|
2014-09-10 18:34:48 +02:00
|
|
|
|
2014-09-09 19:17:22 +02:00
|
|
|
protected void create() {
|
|
|
|
con = new VerticalLayoutContainer();
|
2014-09-11 18:36:09 +02:00
|
|
|
con.setScrollMode(ScrollMode.AUTO);
|
2015-02-13 14:39:34 +01:00
|
|
|
BackgroundOperationMonitorProperties props = GWT
|
|
|
|
.create(BackgroundOperationMonitorProperties.class);
|
|
|
|
store = new ListStore<BackgroundOperationMonitor>(props.taskId());
|
2014-09-09 19:17:22 +02:00
|
|
|
|
|
|
|
addChildrensToStore();
|
|
|
|
|
2015-02-13 14:39:34 +01:00
|
|
|
ColumnConfig<BackgroundOperationMonitor, String> cc1 = new ColumnConfig<BackgroundOperationMonitor, String>(
|
|
|
|
props.tabularResourceName());
|
|
|
|
cc1.setHeader("Tabular Resource");
|
2015-02-13 15:54:32 +01:00
|
|
|
cc1.setWidth(CC1WIDTH);
|
2014-09-09 19:17:22 +02:00
|
|
|
cc1.setCell(new AbstractCell<String>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
|
|
|
sb.appendHtmlConstant("<span title='"
|
2015-02-13 14:39:34 +01:00
|
|
|
+ SafeHtmlUtils.htmlEscape(value) + "'>"
|
|
|
|
+ SafeHtmlUtils.htmlEscape(value) + "</span>");
|
2014-09-09 19:17:22 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-13 14:39:34 +01:00
|
|
|
ColumnConfig<BackgroundOperationMonitor, State> cc2 = new ColumnConfig<BackgroundOperationMonitor, State>(
|
|
|
|
props.state());
|
2014-09-09 19:17:22 +02:00
|
|
|
cc2.setHeader("Status");
|
2015-02-13 15:54:32 +01:00
|
|
|
cc2.setWidth(CC2WIDTH);
|
2015-04-24 18:33:44 +02:00
|
|
|
|
2015-02-13 14:39:34 +01:00
|
|
|
ColumnConfig<BackgroundOperationMonitor, Double> cc3 = new ColumnConfig<BackgroundOperationMonitor, Double>(
|
|
|
|
new ValueProvider<BackgroundOperationMonitor, Double>() {
|
2014-09-09 19:17:22 +02:00
|
|
|
|
|
|
|
@Override
|
2015-02-13 14:39:34 +01:00
|
|
|
public Double getValue(BackgroundOperationMonitor object) {
|
2014-09-09 19:17:22 +02:00
|
|
|
Double d = null;
|
2015-02-13 14:39:34 +01:00
|
|
|
Float f = object.getProgress();
|
|
|
|
d = new Double(f);
|
2014-09-09 19:17:22 +02:00
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-02-13 14:39:34 +01:00
|
|
|
public void setValue(BackgroundOperationMonitor object,
|
|
|
|
Double value) {
|
|
|
|
object.setProgress(value.floatValue());
|
2014-09-09 19:17:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getPath() {
|
|
|
|
return "progress";
|
|
|
|
}
|
2014-09-10 18:34:48 +02:00
|
|
|
}, CC3WIDTH, "Progress");
|
|
|
|
cc3.setHeader("Progress");
|
2014-09-09 19:17:22 +02:00
|
|
|
|
|
|
|
ProgressBarCell progress = new ProgressBarCell() {
|
|
|
|
@Override
|
|
|
|
public boolean handlesSelection() {
|
2015-04-27 10:41:51 +02:00
|
|
|
return false;
|
2014-09-09 19:17:22 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
progress.setProgressText("{0}% Complete");
|
2015-02-13 15:54:32 +01:00
|
|
|
progress.setWidth(PROGRESS_WIDTH);
|
2014-09-09 19:17:22 +02:00
|
|
|
|
2014-09-10 18:34:48 +02:00
|
|
|
cc3.setCell(progress);
|
2014-09-09 19:17:22 +02:00
|
|
|
|
2015-02-13 14:39:34 +01:00
|
|
|
List<ColumnConfig<BackgroundOperationMonitor, ?>> l = new ArrayList<ColumnConfig<BackgroundOperationMonitor, ?>>();
|
2014-09-09 19:17:22 +02:00
|
|
|
l.add(cc1);
|
|
|
|
l.add(cc2);
|
|
|
|
l.add(cc3);
|
2015-02-13 14:39:34 +01:00
|
|
|
ColumnModel<BackgroundOperationMonitor> cm = new ColumnModel<BackgroundOperationMonitor>(
|
|
|
|
l);
|
|
|
|
|
|
|
|
grid = new Grid<BackgroundOperationMonitor>(store, cm);
|
|
|
|
grid.getView().setStripeRows(true);
|
|
|
|
grid.getView().setColumnLines(true);
|
|
|
|
grid.getView().setAutoFill(true);
|
|
|
|
grid.setBorders(false);
|
|
|
|
grid.setLoadMask(true);
|
|
|
|
grid.setColumnReordering(false);
|
|
|
|
grid.setColumnResize(true);
|
2015-04-24 18:33:44 +02:00
|
|
|
grid.getView().setAutoExpandColumn(cc1);
|
2014-09-09 19:17:22 +02:00
|
|
|
|
2014-09-10 18:34:48 +02:00
|
|
|
createContextMenu();
|
2014-09-09 19:17:22 +02:00
|
|
|
|
2015-02-13 14:39:34 +01:00
|
|
|
con.add(grid, new VerticalLayoutData(1, -1, new Margins(0)));
|
2014-09-09 19:17:22 +02:00
|
|
|
|
|
|
|
add(con, new MarginData(0));
|
|
|
|
|
2014-09-11 18:36:09 +02:00
|
|
|
addMonitor();
|
2014-09-10 18:34:48 +02:00
|
|
|
|
2014-09-09 19:17:22 +02:00
|
|
|
forceLayout();
|
|
|
|
|
|
|
|
}
|
2014-09-10 18:34:48 +02:00
|
|
|
|
2014-09-09 19:17:22 +02:00
|
|
|
protected void addMonitor() {
|
|
|
|
monitorBackgroundUpdater = new MonitorBackgroundUpdater();
|
|
|
|
monitorBackgroundUpdater.addListener(this);
|
2014-09-10 18:34:48 +02:00
|
|
|
|
2014-09-09 19:17:22 +02:00
|
|
|
addMonitorBackgroundEventUIListener(monitorBackgroundUpdater);
|
2014-09-11 18:36:09 +02:00
|
|
|
monitorBackgroundUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
|
|
|
monitorBackgroundUpdater.run();
|
2014-09-10 18:34:48 +02:00
|
|
|
}
|
2014-09-09 19:17:22 +02:00
|
|
|
|
|
|
|
public void addMonitorBackgroundEventUIListener(
|
|
|
|
MonitorBackgroundEventUIListener listener) {
|
|
|
|
monitorBackgroundEventUIListeners.add(listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void removeMonitorBackgroundEventUIListener(
|
|
|
|
MonitorBackgroundEventUIListener listener) {
|
|
|
|
monitorBackgroundEventUIListeners.remove(listener);
|
|
|
|
}
|
2014-09-10 18:34:48 +02:00
|
|
|
|
2014-09-09 19:17:22 +02:00
|
|
|
public void update() {
|
|
|
|
forceLayout();
|
|
|
|
}
|
|
|
|
|
2014-09-11 18:36:09 +02:00
|
|
|
public void close() {
|
2014-09-10 18:34:48 +02:00
|
|
|
if (parent != null) {
|
|
|
|
parent.close();
|
|
|
|
}
|
2015-04-27 11:28:36 +02:00
|
|
|
|
2014-09-10 18:34:48 +02:00
|
|
|
|
2014-09-09 19:17:22 +02:00
|
|
|
}
|
2015-04-27 11:28:36 +02:00
|
|
|
|
|
|
|
public void cancelMonitorBackgroundUpdater(){
|
|
|
|
if(monitorBackgroundUpdater!=null){
|
|
|
|
monitorBackgroundUpdater.cancel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-09 19:17:22 +02:00
|
|
|
|
|
|
|
private void addChildrensToStore() {
|
2015-04-24 18:33:44 +02:00
|
|
|
if (backgroundOperationMonitorList != null) {
|
2015-02-13 14:39:34 +01:00
|
|
|
store.addAll(backgroundOperationMonitorList);
|
2015-04-24 18:33:44 +02:00
|
|
|
}
|
2014-09-09 19:17:22 +02:00
|
|
|
}
|
|
|
|
|
2014-09-10 18:34:48 +02:00
|
|
|
protected void createContextMenu() {
|
|
|
|
contextMenu = new Menu();
|
|
|
|
|
|
|
|
infoItem = new MenuItem();
|
|
|
|
infoItem.setText("Info");
|
2014-09-11 18:36:09 +02:00
|
|
|
infoItem.setIcon(ResourceBundle.INSTANCE.information());
|
2014-09-10 18:34:48 +02:00
|
|
|
infoItem.addSelectionHandler(new SelectionHandler<Item>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelection(SelectionEvent<Item> event) {
|
2015-02-13 14:39:34 +01:00
|
|
|
BackgroundOperationMonitor selected = grid.getSelectionModel()
|
2014-09-10 18:34:48 +02:00
|
|
|
.getSelectedItem();
|
|
|
|
Log.debug(selected.toString());
|
|
|
|
requestMoreInfo(selected);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
abortItem = new MenuItem();
|
|
|
|
abortItem.setText("Abort");
|
2014-09-11 18:36:09 +02:00
|
|
|
abortItem.setIcon(ResourceBundle.INSTANCE.basketDelete());
|
2014-09-10 18:34:48 +02:00
|
|
|
abortItem.addSelectionHandler(new SelectionHandler<Item>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelection(SelectionEvent<Item> event) {
|
2015-02-13 14:39:34 +01:00
|
|
|
BackgroundOperationMonitor selected = grid.getSelectionModel()
|
2014-09-10 18:34:48 +02:00
|
|
|
.getSelectedItem();
|
|
|
|
Log.debug(selected.toString());
|
|
|
|
requestBacgroundAbort(selected);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2014-09-19 18:34:01 +02:00
|
|
|
hideItem = new MenuItem();
|
|
|
|
hideItem.setText("Hide");
|
|
|
|
hideItem.setIcon(ResourceBundle.INSTANCE.basketRemove());
|
|
|
|
hideItem.addSelectionHandler(new SelectionHandler<Item>() {
|
2014-09-11 18:36:09 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelection(SelectionEvent<Item> event) {
|
2015-02-13 14:39:34 +01:00
|
|
|
BackgroundOperationMonitor selected = grid.getSelectionModel()
|
2014-09-11 18:36:09 +02:00
|
|
|
.getSelectedItem();
|
|
|
|
Log.debug(selected.toString());
|
|
|
|
requestBacgroundHidden(selected);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2014-09-10 18:34:48 +02:00
|
|
|
contextMenu.add(infoItem);
|
|
|
|
contextMenu.add(abortItem);
|
2014-09-19 18:34:01 +02:00
|
|
|
contextMenu.add(hideItem);
|
2014-09-11 18:36:09 +02:00
|
|
|
|
2015-02-13 14:39:34 +01:00
|
|
|
grid.setContextMenu(contextMenu);
|
2014-09-10 18:34:48 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-02-13 14:39:34 +01:00
|
|
|
protected void requestMoreInfo(BackgroundOperationMonitor selected) {
|
|
|
|
Log.debug("Found Task Id: " + selected.getTaskId());
|
|
|
|
MonitorBackgroundInfoDialog monitorBackgroundInfoDialog = new MonitorBackgroundInfoDialog(
|
|
|
|
selected, eventBus);
|
|
|
|
monitorBackgroundInfoDialog.show();
|
|
|
|
return;
|
2014-09-10 18:34:48 +02:00
|
|
|
|
2014-09-09 19:17:22 +02:00
|
|
|
}
|
2014-09-10 18:34:48 +02:00
|
|
|
|
2015-02-13 14:39:34 +01:00
|
|
|
protected void requestBacgroundAbort(BackgroundOperationMonitor selected) {
|
|
|
|
Log.debug("Found Task Id: " + selected.getTaskId());
|
|
|
|
if (selected.getState() == State.IN_PROGRESS
|
|
|
|
|| selected.getState() == State.INITIALIZING
|
|
|
|
|| selected.getState() == State.VALIDATING_RULES) {
|
|
|
|
fireRequestAborted(selected.getTaskId());
|
2014-09-11 18:36:09 +02:00
|
|
|
}
|
2015-02-13 14:39:34 +01:00
|
|
|
|
2014-09-11 18:36:09 +02:00
|
|
|
}
|
2014-09-10 18:34:48 +02:00
|
|
|
|
2015-02-13 14:39:34 +01:00
|
|
|
protected void requestBacgroundHidden(BackgroundOperationMonitor selected) {
|
|
|
|
Log.debug("Found Task Id: " + selected.getTaskId());
|
|
|
|
fireRequestHidden(selected.getTaskId());
|
|
|
|
return;
|
2014-09-10 18:34:48 +02:00
|
|
|
}
|
|
|
|
|
2014-09-09 19:17:22 +02:00
|
|
|
@Override
|
|
|
|
public void operationMonitorListUpdated(
|
2015-04-24 18:33:44 +02:00
|
|
|
ArrayList<BackgroundOperationMonitor> backgroundOperationMonitorList) {
|
|
|
|
this.backgroundOperationMonitorList = backgroundOperationMonitorList;
|
|
|
|
|
|
|
|
if (!isCacheValid(backgroundOperationMonitorList)) {
|
|
|
|
store.clear();
|
|
|
|
store.commitChanges();
|
|
|
|
addChildrensToStore();
|
|
|
|
store.commitChanges();
|
|
|
|
forceLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
protected boolean isCacheValid(
|
|
|
|
ArrayList<BackgroundOperationMonitor> backgroundOperationMonitorList) {
|
|
|
|
if (backgroundOperationMonitorList == null
|
|
|
|
|| backgroundOperationMonitorList.size() <= 0) {
|
|
|
|
backgroundOperationMonitorListCache = null;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (backgroundOperationMonitorListCache == null) {
|
|
|
|
backgroundOperationMonitorListCache = backgroundOperationMonitorList;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (backgroundOperationMonitorListCache.size() == backgroundOperationMonitorList
|
|
|
|
.size()) {
|
|
|
|
for (int i = 0; i < backgroundOperationMonitorList.size(); i++) {
|
|
|
|
BackgroundOperationMonitor backgroundOperationMonitor = backgroundOperationMonitorList
|
|
|
|
.get(i);
|
|
|
|
BackgroundOperationMonitor backgroundOperationMonitorCache = backgroundOperationMonitorListCache
|
|
|
|
.get(i);
|
|
|
|
if (backgroundOperationMonitor.getTaskId().compareTo(
|
|
|
|
backgroundOperationMonitorCache.getTaskId()) == 0
|
|
|
|
&& backgroundOperationMonitor.getState().compareTo(
|
|
|
|
backgroundOperationMonitorCache.getState()) == 0
|
|
|
|
&& backgroundOperationMonitor.getProgress() == backgroundOperationMonitorCache
|
|
|
|
.getProgress()) {
|
|
|
|
|
|
|
|
} else {
|
2015-04-27 10:41:51 +02:00
|
|
|
backgroundOperationMonitorListCache = backgroundOperationMonitorList;
|
2015-04-24 18:33:44 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
2015-04-27 10:41:51 +02:00
|
|
|
backgroundOperationMonitorListCache = backgroundOperationMonitorList;
|
2015-04-24 18:33:44 +02:00
|
|
|
return false;
|
|
|
|
}
|
2014-09-09 19:17:22 +02:00
|
|
|
|
2015-04-24 18:33:44 +02:00
|
|
|
return true;
|
2014-09-10 18:34:48 +02:00
|
|
|
}
|
2014-09-09 19:17:22 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void retrieveOperationMonitorListFailed(Throwable caught) {
|
2014-09-10 18:34:48 +02:00
|
|
|
if (caught instanceof TDGWTSessionExpiredException) {
|
|
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
|
|
} else {
|
|
|
|
UtilsGXT3.alert("Error", "Error retrieving tasks in bacground: "
|
|
|
|
+ caught.getLocalizedMessage());
|
2014-09-09 19:17:22 +02:00
|
|
|
|
2014-09-10 18:34:48 +02:00
|
|
|
}
|
2014-09-09 19:17:22 +02:00
|
|
|
|
2014-09-10 18:34:48 +02:00
|
|
|
}
|
2014-09-09 19:17:22 +02:00
|
|
|
|
2014-09-11 18:36:09 +02:00
|
|
|
// UI event Fire
|
|
|
|
protected void fireRequestAborted(String taskId) {
|
|
|
|
for (MonitorBackgroundEventUIListener listener : monitorBackgroundEventUIListeners) {
|
|
|
|
listener.requestAborted(taskId);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void fireRequestHidden(String taskId) {
|
|
|
|
for (MonitorBackgroundEventUIListener listener : monitorBackgroundEventUIListeners) {
|
|
|
|
listener.requestHidden(taskId);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void fireRequestResume(String taskId) {
|
|
|
|
for (MonitorBackgroundEventUIListener listener : monitorBackgroundEventUIListeners) {
|
|
|
|
listener.requestResume(taskId);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-09 19:17:22 +02:00
|
|
|
}
|