2014-03-05 19:22:03 +01:00
|
|
|
package org.gcube.portlets.user.td.tablewidget.client.rows;
|
|
|
|
|
2014-03-06 12:46:22 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2014-03-06 15:33:52 +01:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
2014-05-16 16:21:10 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
2014-03-06 15:33:52 +01:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
|
|
|
|
import org.gcube.portlets.user.td.tablewidget.client.progress.DeleteRowsProgressDialog;
|
2014-03-18 13:04:27 +01:00
|
|
|
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
|
2014-05-16 16:21:10 +02:00
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
2014-03-05 19:22:03 +01:00
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
|
|
|
|
2014-03-06 15:33:52 +01:00
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
2014-03-05 19:22:03 +01:00
|
|
|
import com.google.web.bindery.event.shared.EventBus;
|
|
|
|
|
2014-05-07 12:04:10 +02:00
|
|
|
/**
|
|
|
|
* Delete rows in table
|
|
|
|
*
|
|
|
|
* @author "Giancarlo Panichi"
|
2014-05-16 16:21:10 +02:00
|
|
|
*
|
2014-05-07 12:04:10 +02:00
|
|
|
*/
|
2014-03-05 19:22:03 +01:00
|
|
|
public class DeleteRows {
|
|
|
|
protected TRId trId;
|
|
|
|
protected EventBus eventBus;
|
2014-03-06 12:46:22 +01:00
|
|
|
protected ArrayList<String> rows;
|
2014-03-06 15:33:52 +01:00
|
|
|
protected DeleteRowsSession deleteRowsSession;
|
2014-05-16 16:21:10 +02:00
|
|
|
protected DeleteRowsProgressDialog deleteRowsProgressDialog;
|
|
|
|
|
|
|
|
public DeleteRows(TRId trId, ArrayList<String> rows, EventBus eventBus) {
|
2014-03-05 19:22:03 +01:00
|
|
|
this.trId = trId;
|
2014-05-16 16:21:10 +02:00
|
|
|
this.rows = rows;
|
2014-03-05 19:22:03 +01:00
|
|
|
this.eventBus = eventBus;
|
2014-03-06 15:33:52 +01:00
|
|
|
}
|
2014-05-16 16:21:10 +02:00
|
|
|
|
|
|
|
public void delete() {
|
|
|
|
deleteRowsSession = new DeleteRowsSession(trId, rows);
|
2014-03-06 15:33:52 +01:00
|
|
|
onDelete();
|
|
|
|
}
|
|
|
|
|
2014-05-16 16:21:10 +02:00
|
|
|
protected void onDelete() {
|
|
|
|
TDGWTServiceAsync.INSTANCE.startDeleteRows(deleteRowsSession,
|
|
|
|
new AsyncCallback<Void>() {
|
|
|
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
if (caught instanceof TDGWTSessionExpiredException) {
|
|
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
|
|
} else {
|
2014-03-06 15:33:52 +01:00
|
|
|
Log.debug("Delete Rows Error: "
|
|
|
|
+ caught.getLocalizedMessage());
|
2014-05-16 16:21:10 +02:00
|
|
|
UtilsGXT3
|
|
|
|
.alert("Error Deleting Rows",
|
|
|
|
"Error in invocation Delete Rows operation!");
|
2014-03-06 15:33:52 +01:00
|
|
|
}
|
2014-05-16 16:21:10 +02:00
|
|
|
}
|
2014-03-06 15:33:52 +01:00
|
|
|
|
2014-05-16 16:21:10 +02:00
|
|
|
public void onSuccess(Void result) {
|
|
|
|
deleteRowsProgressDialog = new DeleteRowsProgressDialog(
|
|
|
|
deleteRowsSession, eventBus);
|
|
|
|
}
|
2014-03-06 15:33:52 +01:00
|
|
|
|
2014-05-16 16:21:10 +02:00
|
|
|
});
|
2014-03-06 15:33:52 +01:00
|
|
|
|
|
|
|
}
|
2014-05-16 16:21:10 +02:00
|
|
|
|
2014-03-05 19:22:03 +01:00
|
|
|
}
|