Updated CSVExport

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-export-widget@86446 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-12-02 16:45:23 +00:00
parent e4d4535e7b
commit ce78be6541
2 changed files with 163 additions and 31 deletions

View File

@ -0,0 +1,155 @@
/**
*
*/
package org.gcube.portlets.user.td.csvexportwidget.client;
import org.gcube.portlets.user.td.csvexportwidget.client.progress.CSVExportProgressBarUpdater;
import org.gcube.portlets.user.td.csvexportwidget.client.progress.CSVExportProgressListener;
import org.gcube.portlets.user.td.csvexportwidget.client.progress.CSVExportProgressUpdater;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.FlexTable;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.ProgressBar;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
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 CSVOperationInProgressCard extends WizardCard implements
CSVExportProgressListener {
public static final int STATUS_POLLING_DELAY = 1000;
protected CSVOperationInProgressCard thisCard;
protected CSVExportSession exportSession;
protected CSVExportProgressUpdater progressUpdater;
public CSVOperationInProgressCard(final CSVExportSession exportSession) {
super("Operation In Progress", "");
this.exportSession = exportSession;
thisCard = this;
VBoxLayoutContainer operationInProgressPanel = new VBoxLayoutContainer();
operationInProgressPanel.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
final FlexTable description = new FlexTable();
//FlexCellFormatter cellFormatter = description.getFlexCellFormatter();
description.setCellSpacing(10);
description.setCellPadding(4);
description.setBorderWidth(0);
// display:block;vertical-align:text-top;
description.setHTML(0, 0,
"<span style=\"font-weight:bold;\";>Destination: </span>");
description.setText(0, 1, exportSession.getDestination().getName());
description.setHTML(1, 0,
"<span style=\"font-weight:bold;\";>File Name: </span>");
description.setText(1, 1, exportSession.getFileName());
description.setHTML(2, 0,
"<span style=\"font-weight:bold;\";>File Description: </span>");
description.setText(2, 1, exportSession.getFileDescription());
FramedPanel summary = new FramedPanel();
summary.setHeadingText("Export Summary");
summary.setWidth(400);
summary.add(description);
operationInProgressPanel.add(summary, new BoxLayoutData(new Margins(20,
5, 10, 5)));
ProgressBar progressBar = new ProgressBar();
operationInProgressPanel.add(progressBar, new BoxLayoutData(
new Margins(10, 5, 10, 5)));
progressUpdater = new CSVExportProgressUpdater();
progressUpdater.addListener(new CSVExportProgressBarUpdater(progressBar));
progressUpdater.addListener(this);
setContent(operationInProgressPanel);
}
//columnToImportMask
public void exportCSV() {
TDGWTServiceAsync.INSTANCE.startCSVExport(exportSession, new AsyncCallback<Void>() {
@Override
public void onSuccess(Void result) {
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
}
@Override
public void onFailure(Throwable caught) {
showErrorAndHide("Error in exportCSV",
"An error occured in exportCSV: "+caught.getLocalizedMessage(), caught.getStackTrace().toString(), caught);
}
});
}
@Override
public void setup() {
getWizardWindow().setEnableBackButton(false);
setBackButtonVisible(false);
setNextButtonVisible(false);
getWizardWindow().setEnableNextButton(false);
getWizardWindow().setNextButtonToFinish();
exportCSV();
}
@Override
public void operationInitializing() {
}
@Override
public void operationUpdate(float elaborated) {
}
@Override
public void operationComplete() {
// final String tableId,final String tableResourceId) {
Command sayComplete = new Command() {
public void execute() {
try {
getWizardWindow().close(false);
Log.info("fire Complete: tableId");
getWizardWindow().fireCompleted(null);
} catch (Exception e) {
Log.error("fire Complete :" + e.getLocalizedMessage());
}
}
};
getWizardWindow().setNextButtonCommand(sayComplete);
setNextButtonVisible(true);
getWizardWindow().setEnableNextButton(true);
}
@Override
public void operationFailed(Throwable caught, String reason,
String failureDetails) {
}
}

View File

@ -71,7 +71,7 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
Log.debug("Set Workspace Panel");
wpanel = new WorkspacePanel();
wpanel.setSpWidth("410px");
wpanel.setSpHeight("356px");
wpanel.setSpHeight("330px");
List<ItemType> lItemType = new ArrayList<ItemType>();
lItemType.add(ItemType.ROOT);
lItemType.add(ItemType.FOLDER);
@ -125,7 +125,7 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
if (exportSession.getItemId() != null) {
exportSession.setFileName(fileName.getCurrentValue());
exportSession.setFileDescription(fileDescription.getCurrentValue());
getFileFromWorkspace();
goNext();
} else {
d = new AlertMessageBox("AttecheckExportDatantion",
"No folder selected");
@ -184,35 +184,12 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
}
protected void getFileFromWorkspace() {
TDGWTServiceAsync tdGwtServiceAsync = TDGWTServiceAsync.INSTANCE;
/*
* tdGwtServiceAsync.setFileInWorkspace(exportSession, new
* AsyncCallback<Void>(){
*
* @Override public void onFailure(Throwable caught) {
* wpanel.endWaiting(); thisCard.showErrorAndHide("Error",
* "Error retrieving the file from the workspace: "
* +caught.getLocalizedMessage(), caught.toString(), caught);
*
* }
*
* @Override public void onSuccess(Void result) { wpanel.endWaiting();
* goForward();
*
* }
*
* });
*/
}
protected void goForward() {
/*
* CSVConfigCard csvConfigCard = new CSVConfigCard(importSession);
* getWizardWindow().addCard(csvConfigCard);
* Log.info("NextCard CSVConfigCard"); getWizardWindow().nextCard();
*/
protected void goNext() {
CSVOperationInProgressCard csvOperationInProgressCard = new CSVOperationInProgressCard(exportSession);
getWizardWindow().addCard(csvOperationInProgressCard);
Log.info("NextCard CSVOperationInProgressCard");
getWizardWindow().nextCard();
}
}