Added progress bar
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-import-widget@84224 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5c1368ce60
commit
dd07f69e66
|
@ -0,0 +1,158 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.csvimportwidget.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.csvimportwidget.client.general.WizardCard;
|
||||||
|
import org.gcube.portlets.user.td.csvimportwidget.client.progress.CSVImportProgressBarUpdater;
|
||||||
|
import org.gcube.portlets.user.td.csvimportwidget.client.progress.CSVImportProgressListener;
|
||||||
|
import org.gcube.portlets.user.td.csvimportwidget.client.progress.CSVImportProgressUpdater;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.TRId;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
//import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
//import com.google.gwt.user.client.Command;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CSVOperationInProgressCard extends WizardCard implements
|
||||||
|
CSVImportProgressListener {
|
||||||
|
|
||||||
|
public static final int STATUS_POLLING_DELAY = 1000;
|
||||||
|
protected CSVOperationInProgressCard thisCard;
|
||||||
|
protected CSVImportSession importSession;
|
||||||
|
protected CSVImportProgressUpdater progressUpdater;
|
||||||
|
|
||||||
|
public CSVOperationInProgressCard(final CSVImportSession importSession) {
|
||||||
|
super("Operation In Progress", "");
|
||||||
|
|
||||||
|
this.importSession = importSession;
|
||||||
|
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;\";>Document: </span>");
|
||||||
|
description.setText(0, 1, "CSV File");
|
||||||
|
description.setHTML(1, 0,
|
||||||
|
"<span style=\"font-weight:bold;\";>Source: </span>");
|
||||||
|
description.setText(1, 1, importSession.getSource().getName());
|
||||||
|
|
||||||
|
description.setHTML(2, 0,
|
||||||
|
"<span style=\"font-weight:bold;\";>File: </span>");
|
||||||
|
description.setText(2, 1, importSession.getTabResource().getName());
|
||||||
|
|
||||||
|
|
||||||
|
FramedPanel summary = new FramedPanel();
|
||||||
|
summary.setHeadingText("Import 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 CSVImportProgressUpdater();
|
||||||
|
progressUpdater.addListener(new CSVImportProgressBarUpdater(progressBar));
|
||||||
|
|
||||||
|
progressUpdater.addListener(this);
|
||||||
|
|
||||||
|
setContent(operationInProgressPanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
//columnToImportMask
|
||||||
|
|
||||||
|
public void importCSV() {
|
||||||
|
TDGWTServiceAsync.INSTANCE.startCSVImport(importSession, new AsyncCallback<Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Void result) {
|
||||||
|
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
showErrorAndHide("Error in importCSV",
|
||||||
|
"An error occured in importCSV", "", caught);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
getWizardWindow().setEnableBackButton(false);
|
||||||
|
setBackButtonVisible(false);
|
||||||
|
setNextButtonVisible(false);
|
||||||
|
getWizardWindow().setEnableNextButton(false);
|
||||||
|
getWizardWindow().setNextButtonToFinish();
|
||||||
|
importCSV();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationInitializing() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationUpdate(float elaborated) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationComplete(final TRId trId) {
|
||||||
|
// final String tableId,final String tableResourceId) {
|
||||||
|
|
||||||
|
Command sayComplete = new Command() {
|
||||||
|
public void execute() {
|
||||||
|
try {
|
||||||
|
getWizardWindow().close(false);
|
||||||
|
Log.info("fire Complete: tabular resource " + trId.getId());
|
||||||
|
Log.info("fire Complete: tableId " + trId.getTableId());
|
||||||
|
|
||||||
|
getWizardWindow().fireCompleted(trId);
|
||||||
|
|
||||||
|
} 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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -32,6 +32,10 @@ import com.sencha.gxt.widget.core.client.form.TextField;
|
||||||
*/
|
*/
|
||||||
public class CSVTableDetailCard extends WizardCard {
|
public class CSVTableDetailCard extends WizardCard {
|
||||||
|
|
||||||
|
protected final String TABLEDETAILPANELWIDTH = "100%";
|
||||||
|
protected final String TABLEDETAILPANELHEIGHT = "100%";
|
||||||
|
protected final String FORMWIDTH = "460px";
|
||||||
|
|
||||||
protected CSVImportSession importSession;
|
protected CSVImportSession importSession;
|
||||||
protected CSVTableDetailCard thisCard;
|
protected CSVTableDetailCard thisCard;
|
||||||
|
|
||||||
|
@ -41,8 +45,7 @@ public class CSVTableDetailCard extends WizardCard {
|
||||||
protected TextField name;
|
protected TextField name;
|
||||||
protected TextArea description;
|
protected TextArea description;
|
||||||
protected TextArea rights;
|
protected TextArea rights;
|
||||||
protected TextField agencyName;
|
|
||||||
|
|
||||||
protected TextButton checkButton;
|
protected TextButton checkButton;
|
||||||
|
|
||||||
// protected ComboBox<Agencies> combo=null;
|
// protected ComboBox<Agencies> combo=null;
|
||||||
|
@ -58,17 +61,17 @@ public class CSVTableDetailCard extends WizardCard {
|
||||||
tableDetailPanel = new VerticalPanel();
|
tableDetailPanel = new VerticalPanel();
|
||||||
|
|
||||||
tableDetailPanel.setSpacing(4);
|
tableDetailPanel.setSpacing(4);
|
||||||
tableDetailPanel.setWidth("100%");
|
tableDetailPanel.setWidth(TABLEDETAILPANELWIDTH);
|
||||||
tableDetailPanel.setHeight("100%");
|
tableDetailPanel.setHeight(TABLEDETAILPANELHEIGHT);
|
||||||
|
|
||||||
FramedPanel form2 = new FramedPanel();
|
FramedPanel form = new FramedPanel();
|
||||||
form2.setHeadingText("Details");
|
form.setHeadingText("Details");
|
||||||
// form2.setWidth(350);
|
form.setWidth(FORMWIDTH);
|
||||||
|
|
||||||
FieldSet fieldSet = new FieldSet();
|
FieldSet fieldSet = new FieldSet();
|
||||||
fieldSet.setHeadingText("Information");
|
fieldSet.setHeadingText("Information");
|
||||||
fieldSet.setCollapsible(false);
|
fieldSet.setCollapsible(false);
|
||||||
form2.add(fieldSet);
|
form.add(fieldSet);
|
||||||
|
|
||||||
p = new VerticalLayoutContainer();
|
p = new VerticalLayoutContainer();
|
||||||
fieldSet.add(p);
|
fieldSet.add(p);
|
||||||
|
@ -101,8 +104,8 @@ public class CSVTableDetailCard extends WizardCard {
|
||||||
checkData();
|
checkData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
form2.addButton(checkButton);
|
form.addButton(checkButton);
|
||||||
tableDetailPanel.add(form2);
|
tableDetailPanel.add(form);
|
||||||
|
|
||||||
setContent(tableDetailPanel);
|
setContent(tableDetailPanel);
|
||||||
|
|
||||||
|
@ -115,8 +118,8 @@ public class CSVTableDetailCard extends WizardCard {
|
||||||
|| rights.getValue() == null || rights.getValue().isEmpty()
|
|| rights.getValue() == null || rights.getValue().isEmpty()
|
||||||
|
|
||||||
) {
|
) {
|
||||||
AlertMessageBox d = new AlertMessageBox(
|
AlertMessageBox d = new AlertMessageBox("Attention!",
|
||||||
"Attention!", "Fill in all fields");
|
"Fill in all fields");
|
||||||
d.addHideHandler(new HideHandler() {
|
d.addHideHandler(new HideHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -143,19 +146,17 @@ public class CSVTableDetailCard extends WizardCard {
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
detail.setName(name.getCurrentValue());
|
detail.setName(name.getCurrentValue());
|
||||||
// detail.setAgency(combo.getSelectedText());
|
|
||||||
detail.setAgency(agencyName.getCurrentValue());
|
|
||||||
detail.setDescription(description.getCurrentValue());
|
detail.setDescription(description.getCurrentValue());
|
||||||
detail.setRight(rights.getCurrentValue());
|
detail.setRight(rights.getCurrentValue());
|
||||||
|
|
||||||
importSession.setTabResource(detail);
|
importSession.setTabResource(detail);
|
||||||
/*
|
|
||||||
* SDMXOperationInProgressCard sdmxOperationInProgressCard = new
|
CSVOperationInProgressCard csvOperationInProgressCard = new CSVOperationInProgressCard(
|
||||||
* SDMXOperationInProgressCard( importSession);
|
importSession);
|
||||||
* getWizardWindow() .addCard(sdmxOperationInProgressCard);
|
getWizardWindow().addCard(csvOperationInProgressCard);
|
||||||
* Log.info("NextCard SDMXOperationInProgressCard");
|
Log.info("NextCard CSVOperationInProgressCard");
|
||||||
* getWizardWindow().nextCard();
|
getWizardWindow().nextCard();
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -173,7 +174,7 @@ public class CSVTableDetailCard extends WizardCard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||||
getWizardWindow().setEnableNextButton(false);
|
getWizardWindow().setEnableNextButton(false);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class CSVUploadFileCard extends WizardCard {
|
||||||
this.thisCard = this;
|
this.thisCard = this;
|
||||||
this.importSession = importSession;
|
this.importSession = importSession;
|
||||||
|
|
||||||
this.fileUploadPanel = new FileUploadPanel(res, thisCard);
|
this.fileUploadPanel = new FileUploadPanel(res, thisCard,importSession);
|
||||||
|
|
||||||
setContent(fileUploadPanel);
|
setContent(fileUploadPanel);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.gcube.portlets.user.td.csvimportwidget.client.progress.FileUploadProg
|
||||||
import org.gcube.portlets.user.td.csvimportwidget.client.progress.FileUploadProgressListener;
|
import org.gcube.portlets.user.td.csvimportwidget.client.progress.FileUploadProgressListener;
|
||||||
import org.gcube.portlets.user.td.csvimportwidget.client.progress.FileUploadProgressUpdater;
|
import org.gcube.portlets.user.td.csvimportwidget.client.progress.FileUploadProgressUpdater;
|
||||||
import org.gcube.portlets.user.td.csvimportwidget.client.dataresource.ResourceBundle;
|
import org.gcube.portlets.user.td.csvimportwidget.client.dataresource.ResourceBundle;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
@ -52,7 +53,7 @@ public class FileUploadPanel extends FormPanel {
|
||||||
protected TextButton cancelButton;
|
protected TextButton cancelButton;
|
||||||
|
|
||||||
|
|
||||||
public FileUploadPanel(ResourceBundle res, final WizardCard card)
|
public FileUploadPanel(ResourceBundle res, final WizardCard card,final CSVImportSession importSession)
|
||||||
{
|
{
|
||||||
this.res=res;
|
this.res=res;
|
||||||
|
|
||||||
|
@ -94,6 +95,8 @@ public class FileUploadPanel extends FormPanel {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(ChangeEvent event) {
|
public void onChange(ChangeEvent event) {
|
||||||
uploadButton.setEnabled(fileUploadField.isValid());
|
uploadButton.setEnabled(fileUploadField.isValid());
|
||||||
|
String filename=fileUploadField.getValue();
|
||||||
|
importSession.setLocalFileName(filename);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,9 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||||||
*/
|
*/
|
||||||
public class WizardWindow extends Window {
|
public class WizardWindow extends Window {
|
||||||
|
|
||||||
|
protected final String WIZARDWIDTH="640px";
|
||||||
|
protected final String WIZARDHEIGHT="480px";
|
||||||
|
|
||||||
protected ArrayList<WizardCard> cardStack = new ArrayList<WizardCard>();
|
protected ArrayList<WizardCard> cardStack = new ArrayList<WizardCard>();
|
||||||
|
|
||||||
protected TextButton backButton;
|
protected TextButton backButton;
|
||||||
|
@ -66,8 +69,11 @@ public class WizardWindow extends Window {
|
||||||
this.eventBus= new SimpleEventBus();
|
this.eventBus= new SimpleEventBus();
|
||||||
Log.info(title);
|
Log.info(title);
|
||||||
//setModal(true);
|
//setModal(true);
|
||||||
setResizable(true);
|
setResizable(false);
|
||||||
setCollapsible(true);
|
setCollapsible(true);
|
||||||
|
setWidth(WIZARDWIDTH);
|
||||||
|
setHeight(WIZARDHEIGHT);
|
||||||
|
|
||||||
|
|
||||||
listeners = new ArrayList<WizardListener>();
|
listeners = new ArrayList<WizardListener>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue