tabular-data-column-widget/src/main/java/org/gcube/portlets/user/td/columnwidget/client/batch/ReplaceBatchDialog.java

109 lines
2.8 KiB
Java

package org.gcube.portlets.user.td.columnwidget.client.batch;
import org.gcube.portlets.user.td.columnwidget.client.progress.ReplaceBatchColumnProgressDialog;
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.columnwidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ReplaceBatchDialog extends Window {
protected String WIDTH = "650px";
protected String HEIGHT = "530px";
protected TRId trId;
protected String columnName=null;
protected EventBus eventBus;
public ReplaceBatchDialog(TRId trId, String columnName, EventBus eventBus) {
this.trId=trId;
this.columnName=columnName;
this.eventBus=eventBus;
initWindow();
ReplaceBatchPanel batchRepalcePanel= new ReplaceBatchPanel(this, trId,columnName,eventBus);
add(batchRepalcePanel);
}
protected void initWindow() {
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(false);
setHeadingText("Replace Batch");
setClosable(true);
setModal(true);
forceLayoutOnResize = true;
getHeader().setIcon(ResourceBundle.INSTANCE.replaceBatch());
}
/**
* {@inheritDoc}
*/
@Override
protected void initTools() {
super.initTools();
closeBtn.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
close();
}
});
}
protected void close (){
hide();
}
protected void startBatchReplace(ReplaceBatchColumnSession replaceBatchColumnSession){
TDGWTServiceAsync.INSTANCE.startReplaceBatchColumn(replaceBatchColumnSession,
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
Log.error("Start Replace Batch failed:"
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error on batch replace",
"Error on batch replace");
close();
}
public void onSuccess(Void v) {
Log.trace("Started batch replace ");
callReplaceBatchColumnProgressDialog();
}
});
}
protected void callReplaceBatchColumnProgressDialog() {
ReplaceBatchColumnProgressDialog dialog = new ReplaceBatchColumnProgressDialog(
this, eventBus);
dialog.show();
}
}