246 lines
7.6 KiB
Java
246 lines
7.6 KiB
Java
/**
|
|
*
|
|
*/
|
|
package org.gcube.portlets.user.td.extractcodelistwidget.client;
|
|
|
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
|
import org.gcube.portlets.user.td.gwtservice.shared.extract.ExtractCodelistSession;
|
|
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
|
|
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
|
import com.google.gwt.user.client.Command;
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
import com.sencha.gxt.core.client.util.Margins;
|
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
|
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
|
|
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer;
|
|
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayoutAlign;
|
|
|
|
/**
|
|
*
|
|
* @author "Giancarlo Panichi" <a
|
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
*
|
|
*/
|
|
public class ExtractCodelistOperationInProgressCard extends WizardCard
|
|
implements MonitorDialogListener {
|
|
|
|
protected ExtractCodelistOperationInProgressCard thisCard;
|
|
protected ExtractCodelistSession extractCodelistSession;
|
|
protected TRId newTrId;
|
|
protected HtmlLayoutContainer resultField;
|
|
|
|
public ExtractCodelistOperationInProgressCard(
|
|
final ExtractCodelistSession extractCodelistSession) {
|
|
super("Operation In Progress", "");
|
|
|
|
this.extractCodelistSession = extractCodelistSession;
|
|
thisCard = this;
|
|
|
|
VBoxLayoutContainer operationInProgressPanel = new VBoxLayoutContainer();
|
|
operationInProgressPanel.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
|
|
|
|
resultField = new HtmlLayoutContainer("<div></div>");
|
|
|
|
operationInProgressPanel.add(resultField, new BoxLayoutData(
|
|
new Margins(10, 5, 10, 5)));
|
|
|
|
setContent(operationInProgressPanel);
|
|
resultField.setVisible(false);
|
|
|
|
}
|
|
|
|
public void extractCodelist() {
|
|
TDGWTServiceAsync.INSTANCE.startExtractCodelist(extractCodelistSession,
|
|
new AsyncCallback<String>() {
|
|
|
|
public void onSuccess(String taskId) {
|
|
openMonitorDialog(taskId);
|
|
|
|
}
|
|
|
|
public void onFailure(Throwable caught) {
|
|
if (caught instanceof TDGWTSessionExpiredException) {
|
|
getEventBus()
|
|
.fireEvent(
|
|
new SessionExpiredEvent(
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
} else {
|
|
showErrorAndHide("Error in extract codelist",
|
|
"An error occured in extract codelist: "
|
|
+ caught.getLocalizedMessage(),
|
|
caught);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override
|
|
public void setup() {
|
|
getWizardWindow().setEnableBackButton(false);
|
|
setBackButtonVisible(false);
|
|
setNextButtonVisible(false);
|
|
getWizardWindow().setEnableNextButton(false);
|
|
getWizardWindow().setNextButtonToFinish();
|
|
extractCodelist();
|
|
}
|
|
|
|
//
|
|
protected void openMonitorDialog(String taskId) {
|
|
MonitorDialog monitorDialog = new MonitorDialog(taskId, getEventBus());
|
|
monitorDialog.addProgressDialogListener(this);
|
|
monitorDialog.show();
|
|
}
|
|
|
|
@Override
|
|
public void operationComplete(TRId trId) {
|
|
newTrId = trId;
|
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
|
safeHtmlBuilder
|
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold; color:#009900;'>Operation Completed</div>"
|
|
+ "<div style=' margin-top:30px;text-align:center;font-size:medium;font-weight:bold; color:black;'>The Codelists is available in the list of yours tabular resources</div>");
|
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
|
resultField.setVisible(true);
|
|
Command sayComplete = new Command() {
|
|
public void execute() {
|
|
try {
|
|
getWizardWindow().close(false);
|
|
Log.info("fire Complete: " + newTrId);
|
|
|
|
getWizardWindow().fireCompleted(newTrId);
|
|
|
|
} catch (Exception e) {
|
|
Log.error("fire Complete :" + e.getLocalizedMessage());
|
|
}
|
|
}
|
|
};
|
|
|
|
getWizardWindow().setNextButtonCommand(sayComplete);
|
|
|
|
setNextButtonVisible(true);
|
|
getWizardWindow().setEnableNextButton(true);
|
|
forceLayout();
|
|
|
|
}
|
|
|
|
@Override
|
|
public void operationFailed(Throwable caught, String reason, String details) {
|
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
|
safeHtmlBuilder
|
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color:red;'>Operation Failed</div>");
|
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
|
resultField.setVisible(true);
|
|
if (caught instanceof TDGWTSessionExpiredException) {
|
|
getEventBus()
|
|
.fireEvent(
|
|
new SessionExpiredEvent(
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
} else {
|
|
showErrorAndHide("Error in Extract Codelist", reason, caught);
|
|
|
|
}
|
|
forceLayout();
|
|
}
|
|
|
|
@Override
|
|
public void operationStopped(TRId trId, String reason, String details) {
|
|
newTrId = trId;
|
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
|
safeHtmlBuilder
|
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #FF9900;'>Problems in the Operation</div>");
|
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
|
resultField.setVisible(true);
|
|
|
|
Command sayComplete = new Command() {
|
|
public void execute() {
|
|
try {
|
|
getWizardWindow().close(false);
|
|
Log.info("fire Complete: tabular resource "
|
|
+ newTrId.getId());
|
|
Log.info("fire Complete: tableId " + newTrId.getTableId());
|
|
|
|
getWizardWindow().fireCompleted(newTrId);
|
|
|
|
} catch (Exception e) {
|
|
Log.error("fire Complete :" + e.getLocalizedMessage());
|
|
}
|
|
}
|
|
};
|
|
|
|
getWizardWindow().setNextButtonCommand(sayComplete);
|
|
|
|
setNextButtonVisible(true);
|
|
getWizardWindow().setEnableNextButton(true);
|
|
forceLayout();
|
|
}
|
|
|
|
@Override
|
|
public void operationAborted() {
|
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
|
safeHtmlBuilder
|
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #AA00AA;'>Operation Aborted</div>");
|
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
|
resultField.setVisible(true);
|
|
|
|
Command sayComplete = new Command() {
|
|
public void execute() {
|
|
try {
|
|
getWizardWindow().close(false);
|
|
Log.info("fire Aborted");
|
|
|
|
getWizardWindow().fireAborted();
|
|
|
|
} catch (Exception e) {
|
|
Log.error("fire Aborted :" + e.getLocalizedMessage());
|
|
}
|
|
}
|
|
};
|
|
|
|
getWizardWindow().setNextButtonCommand(sayComplete);
|
|
|
|
setNextButtonVisible(true);
|
|
getWizardWindow().setEnableNextButton(true);
|
|
forceLayout();
|
|
|
|
}
|
|
|
|
@Override
|
|
public void operationPutInBackground() {
|
|
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
|
safeHtmlBuilder
|
|
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #00AAAA;'>Operation in Background</div>");
|
|
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
|
resultField.setVisible(true);
|
|
|
|
Command sayComplete = new Command() {
|
|
public void execute() {
|
|
try {
|
|
getWizardWindow().close(false);
|
|
Log.info("fire Operation In Background");
|
|
|
|
getWizardWindow().firePutInBackground();
|
|
|
|
} catch (Exception e) {
|
|
Log.error("fire Operation In Background :"
|
|
+ e.getLocalizedMessage());
|
|
}
|
|
}
|
|
};
|
|
|
|
getWizardWindow().setNextButtonCommand(sayComplete);
|
|
|
|
setNextButtonVisible(true);
|
|
getWizardWindow().setEnableNextButton(true);
|
|
forceLayout();
|
|
|
|
}
|
|
|
|
}
|