diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..dddaa98 --- /dev/null +++ b/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..c993d82 --- /dev/null +++ b/.project @@ -0,0 +1,36 @@ + + + tabular-data-codelistmapping-import-widget + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..29abf99 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..443e085 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..47a6883 --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..4f92af5 --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/CodelistMappingImportWizardTD.launch b/CodelistMappingImportWizardTD.launch new file mode 100644 index 0000000..4d83c92 --- /dev/null +++ b/CodelistMappingImportWizardTD.launch @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..9774cf8 --- /dev/null +++ b/pom.xml @@ -0,0 +1,317 @@ + + + + + maven-parent + org.gcube.tools + 1.0.0 + + + + + 4.0.0 + org.gcube.portlets.user + tabular-data-codelistmapping-import-widget + 1.0.0-SNAPSHOT + + tabular-data-codelistmapping-import-widget + tabular-data-codelistmapping-import-widget allows import from url, file and workspace of maps for codelist + + + https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-codelistmapping-import-widget + + + + + Giancarlo Panichi + g.panichi@isti.cnr.it + CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" + + architect + developer + + + + + + ${project.basedir}/distro + ${project.build.directory}/${project.build.finalName} + 2014-06-05 + templates + distro + config + + + 2.5.1 + + ${env.KEYS} + + UTF-8 + UTF-8 + + + + + localRun + + + org.slf4j + slf4j-api + compile + + + ch.qos.logback + logback-classic + 1.0.1 + runtime + + + + + + + + + com.google.gwt + gwt-servlet + + + com.google.gwt + gwt-user + + + + junit + junit + 4.8.1 + test + + + javax.validation + validation-api + 1.0.0.GA + test + + + javax.validation + validation-api + 1.0.0.GA + sources + test + + + + com.sencha.gxt + gxt + 3.0.1 + + + + + + + org.gcube.portlets.user + tabular-data-gwt-service + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + provided + + + + + org.gcube.portlets.user + tabular-data-widget-common-event + [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) + provided + + + + + + org.gcube.portlets.user + tabular-data-wizard-widget + [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) + provided + + + + + org.gcube.portlets.widgets + workspace-light-tree + [2.13.0-SNAPSHOT, 3.0.0-SNAPSHOT) + provided + + + org.gcube.common + home-library + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + provided + + + org.gcube.portlets.user + gcube-widgets + provided + + + + com.allen-sauer.gwt.log + gwt-log + 3.2.1 + provided + + + + org.slf4j + slf4j-api + + + + + + + + + + ${webappDirectory}/WEB-INF/classes + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.16 + + true + + + + + org.apache.maven.surefire + surefire-junit47 + 2.16 + + + + + + + org.codehaus.mojo + gwt-maven-plugin + ${gwtVersion} + + + + resources + + + + + CodelistMappingImportWizardTD.html + ${webappDirectory} + org.gcube.portlets.user.td.codelistmappingimportwidget.CodelistMappingImportWizardTD + + + + + + maven-resources-plugin + 2.6 + + + copy-profile + process-resources + + copy-resources + + + ${configDirectory} + + + ${templatesDirectory} + + profile.xml + + true + + + + + + copy-distro-resources + process-resources + + copy-resources + + + ${distroDirectory} + + + ${templatesDirectory} + + profile.xml + descriptor.xml + + true + + + + + + + + maven-clean-plugin + 2.5 + + + + ${distroDirectory} + + ** + + false + + + ${configDirectory} + + ** + + false + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2 + + + ${templatesDirectory}/descriptor.xml + + + + + servicearchive + package + + single + + + + + + + + + + + + + org.gcube.distribution + maven-portal-bom + LATEST + pom + import + + + + diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingFileUploadPanel.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingFileUploadPanel.java new file mode 100644 index 0000000..b9c6307 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingFileUploadPanel.java @@ -0,0 +1,199 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client; + +import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle; +import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.FileUploadProgressBarUpdater; +import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.FileUploadProgressListener; +import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.FileUploadProgressUpdater; +import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ChangeEvent; +import com.google.gwt.event.dom.client.ChangeHandler; +import com.sencha.gxt.core.client.Style.HideMode; +import com.sencha.gxt.core.client.util.Padding; +import com.sencha.gxt.widget.core.client.ProgressBar; +import com.sencha.gxt.widget.core.client.box.AlertMessageBox; +import com.sencha.gxt.widget.core.client.button.TextButton; +import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; +import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; +import com.sencha.gxt.widget.core.client.event.SelectEvent; +import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; +import com.sencha.gxt.widget.core.client.event.ShowEvent; +import com.sencha.gxt.widget.core.client.event.ShowEvent.ShowHandler; +import com.sencha.gxt.widget.core.client.form.FieldLabel; +import com.sencha.gxt.widget.core.client.form.FileUploadField; +import com.sencha.gxt.widget.core.client.form.FormPanel; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class CodelistMappingFileUploadPanel extends FormPanel { + + protected static final String UPLOAD_SERVLET = "LocalUploadServlet"; + + public static final int STATUS_POLLING_DELAY = 1000; + + protected ResourceBundle res; + protected FileUploadField fileUploadField; + protected TextButton uploadButton; + + protected FileUploadProgressUpdater progressUpdater; + + protected ProgressBar uploadProgressBar; + + protected TextButton cancelButton; + + public CodelistMappingFileUploadPanel(ResourceBundle res, final CodelistMappingUploadFileCard card, + final CSVImportSession importSession) { + this.res = res; + + setId("LocalUploadPanel"); + setLabelAlign(LabelAlign.TOP); + getElement().setPadding(new Padding(5)); + + addShowHandler(new ShowHandler() { + + + public void onShow(ShowEvent event) { + doLayout(); + + } + }); + + setAction(GWT.getModuleBaseURL() + UPLOAD_SERVLET); + setWidth("100%"); + + setEncoding(Encoding.MULTIPART); + setMethod(Method.POST); + + VerticalLayoutContainer content = new VerticalLayoutContainer(); + content.setWidth("100%"); + add(content); + + fileUploadField = new FileUploadField(); + fileUploadField.setName("uploadFormElement"); + fileUploadField.setWidth("100%"); + + content.add(new FieldLabel(fileUploadField, + "Select the csv file to import"), + new VerticalLayoutData(-2, -1)); + + uploadButton = new TextButton("Upload"); + content.add(uploadButton, new VerticalLayoutData(-1, -1)); + + fileUploadField.addChangeHandler(new ChangeHandler() { + + public void onChange(ChangeEvent event) { + uploadButton.setEnabled(fileUploadField.isValid()); + String path = fileUploadField.getValue(); + int punto = path.lastIndexOf("."); + if(punto<0){ + punto=path.length(); + } + int slash = path.lastIndexOf("/"); + int backslash = path.lastIndexOf("\\"); + String filename=""; + if (slash > backslash) { + if (slash != -1) { + filename = path.substring(slash + 1, punto); + } + } else { + if (backslash != -1) { + filename = path.substring(backslash + 1, punto); + } + + + } + importSession.setLocalFileName(filename); + } + }); + + uploadProgressBar = new ProgressBar(); + uploadProgressBar.setHideMode(HideMode.VISIBILITY); + uploadProgressBar.getElement().setPadding(new Padding(3, 0, 5, 0)); + content.add(uploadProgressBar, new VerticalLayoutData(-2, -1)); + uploadProgressBar.hide(); + + cancelButton = new TextButton("Cancel"); + cancelButton.hide(); + content.add(cancelButton, new VerticalLayoutData(-1, -1)); + + uploadButton.addSelectHandler(new SelectHandler() { + + public void onSelect(SelectEvent event) { + Log.info("request upload"); + + if (fileUploadField.getValue() == null + || fileUploadField.getValue().equals("")) { + Log.info("fileUploadField is null or empty"); + AlertMessageBox alertMessageBox = new AlertMessageBox( + "CSV file missing", "Please specify a CSV file."); + alertMessageBox.show(); + return; + } else { + Log.info("startUpload call"); + startUpload(); + } + + } + }); + + progressUpdater = new FileUploadProgressUpdater(); + progressUpdater.addListener(new FileUploadProgressBarUpdater( + uploadProgressBar)); + + progressUpdater.addListener(new FileUploadProgressListener() { + + public void operationUpdate(float elaborated) { + // + } + + public void operationInitializing() { + + + } + + public void operationFailed(Throwable caught, String reason, + String failureDetails) { + card.showErrorAndHide("Error uploading the csv file", reason, + failureDetails, caught); + } + + public void operationComplete() { + card.setEnableNextButton(true); + cancelButton.disable(); + + } + }); + + } + + protected void startUpload() { + disableUpload(); + + StringBuilder actionUrl = new StringBuilder(); + actionUrl.append(GWT.getModuleBaseURL()); + actionUrl.append(UPLOAD_SERVLET); + setAction(actionUrl.toString()); + Log.info("Start Upload action Url " + actionUrl.toString()); + submit(); + + progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY); + } + + protected void disableUpload() { + fileUploadField.disable(); + uploadButton.disable(); + + uploadProgressBar.show(); + cancelButton.show(); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingImportWizardTD.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingImportWizardTD.java new file mode 100644 index 0000000..a0e0f5f --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingImportWizardTD.java @@ -0,0 +1,35 @@ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client; + +import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow; +import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; +import com.google.web.bindery.event.shared.EventBus; + +/** + * + */ +public class CodelistMappingImportWizardTD extends WizardWindow { + + protected CSVImportSession importSession; + //private CSVImportWizardTD wizard; + + /** + * The id of the {@link CSVTarget} to use. + * @param targetId + */ + + public CodelistMappingImportWizardTD(String title, EventBus eventBus) { + super(title,eventBus); + + importSession= new CSVImportSession(); + //this.wizard=this; + + SourceSelectionCard sourceSelection= new SourceSelectionCard(importSession); + addCard(sourceSelection); + sourceSelection.setup(); + + } + + + + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingImportWizardTDEntry.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingImportWizardTDEntry.java new file mode 100644 index 0000000..f66c34a --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingImportWizardTDEntry.java @@ -0,0 +1,15 @@ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.core.client.EntryPoint; +import com.google.web.bindery.event.shared.SimpleEventBus; + +public class CodelistMappingImportWizardTDEntry implements EntryPoint { + + + public void onModuleLoad() { + SimpleEventBus eventBus=new SimpleEventBus(); + CodelistMappingImportWizardTD importWizard= new CodelistMappingImportWizardTD("CSVImport",eventBus); + Log.info(importWizard.getId()); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingOperationInProgressCard.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingOperationInProgressCard.java new file mode 100644 index 0000000..3bbe8f9 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingOperationInProgressCard.java @@ -0,0 +1,221 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client; + +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 org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.CodelistMappingImportProgressBarUpdater; +import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.CodelistMappingImportProgressListener; +import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.CodelistMappingImportProgressUpdater; +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; + +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.box.AlertMessageBox; +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.sencha.gxt.widget.core.client.event.HideEvent; +import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; + +//import com.allen_sauer.gwt.log.client.Log; +//import com.google.gwt.user.client.Command; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class CodelistMappingOperationInProgressCard extends WizardCard implements + CodelistMappingImportProgressListener { + + public static final int STATUS_POLLING_DELAY = 1000; + protected CodelistMappingOperationInProgressCard thisCard; + protected CSVImportSession importSession; + protected CodelistMappingImportProgressUpdater progressUpdater; + + public CodelistMappingOperationInProgressCard(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, + "Document: "); + description.setText(0, 1, "CSV File"); + description.setHTML(1, 0, + "Source: "); + description.setText(1, 1, importSession.getSource().getName()); + + description.setHTML(2, 0, + "File: "); + 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 CodelistMappingImportProgressUpdater(); + progressUpdater + .addListener(new CodelistMappingImportProgressBarUpdater(progressBar)); + + progressUpdater.addListener(this); + + setContent(operationInProgressPanel); + + } + + // columnToImportMask + + public void importCSV() { + TDGWTServiceAsync.INSTANCE.startCSVImport(importSession, + new AsyncCallback() { + + public void onSuccess(Void result) { + progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY); + } + + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + showErrorAndHide( + "Error in importCSV", + "An error occured in importCSV: " + + caught.getLocalizedMessage(), + caught.getStackTrace().toString(), caught); + } + } + }); + } + + @Override + public void setup() { + getWizardWindow().setEnableBackButton(false); + setBackButtonVisible(false); + setNextButtonVisible(false); + getWizardWindow().setEnableNextButton(false); + getWizardWindow().setNextButtonToFinish(); + importCSV(); + } + + public void operationInitializing() { + + } + + public void operationUpdate(float elaborated) { + + } + + 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); + } + + public void operationFailed(Throwable caught, String reason, + String failureDetails) { + if (caught instanceof TDGWTSessionExpiredException) { + getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + AlertMessageBox d = new AlertMessageBox("Error in CSV Import", + reason); + d.addHideHandler(new HideHandler() { + public void onHide(HideEvent event) { + } + }); + d.show(); + } + } + + @Override + public void operationStopped(final TRId trId, String reason, String details) { + // 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 operationGeneratingView() { + // TODO Auto-generated method stub + + } + + @Override + public void operationValidate(float elaborated) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingTableDetailCard.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingTableDetailCard.java new file mode 100644 index 0000000..c59b591 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingTableDetailCard.java @@ -0,0 +1,171 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client; + +import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; +import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; +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.ui.VerticalPanel; +import com.sencha.gxt.widget.core.client.FramedPanel; +import com.sencha.gxt.widget.core.client.box.AlertMessageBox; +import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; +import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; +import com.sencha.gxt.widget.core.client.event.HideEvent; +import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; +import com.sencha.gxt.widget.core.client.form.FieldLabel; +import com.sencha.gxt.widget.core.client.form.FieldSet; +import com.sencha.gxt.widget.core.client.form.TextArea; +import com.sencha.gxt.widget.core.client.form.TextField; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class CodelistMappingTableDetailCard extends WizardCard { + + protected final String TABLEDETAILPANELWIDTH = "100%"; + protected final String TABLEDETAILPANELHEIGHT = "100%"; + protected final String FORMWIDTH = "538px"; + + protected CSVImportSession importSession; + protected CodelistMappingTableDetailCard thisCard; + + protected VerticalLayoutContainer p; + protected VerticalPanel tableDetailPanel; + + protected TextField name; + protected TextArea description; + protected TextArea rights; + + protected TabResource detail = new TabResource(); + + public CodelistMappingTableDetailCard(final CSVImportSession importSession) { + super("Codelist Mapping Detail", ""); + + this.importSession = importSession; + thisCard = this; + + tableDetailPanel = new VerticalPanel(); + + tableDetailPanel.setSpacing(4); + tableDetailPanel.setWidth(TABLEDETAILPANELWIDTH); + tableDetailPanel.setHeight(TABLEDETAILPANELHEIGHT); + + FramedPanel form = new FramedPanel(); + form.setHeadingText("Details"); + form.setWidth(FORMWIDTH); + + FieldSet fieldSet = new FieldSet(); + fieldSet.setHeadingText("Information"); + fieldSet.setCollapsible(false); + form.add(fieldSet); + + p = new VerticalLayoutContainer(); + fieldSet.add(p); + + name = new TextField(); + name.setAllowBlank(false); + name.setEmptyText("Enter a name..."); + name.setValue(importSession.getLocalFileName()); + name.setAllowBlank(false); + p.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1)); + + description = new TextArea(); + description.setAllowBlank(false); + description.setEmptyText("Enter a description..."); + description.setValue("File CSV"); + description.setAllowBlank(false); + p.add(new FieldLabel(description, "Description"), + new VerticalLayoutData(1, -1)); + + + tableDetailPanel.add(form); + + setContent(tableDetailPanel); + + } + + + @Override + public void setup() { + Command sayNextCard = new Command() { + + + public void execute() { + checkData(); + } + + }; + + getWizardWindow().setNextButtonCommand(sayNextCard); + + Command sayPreviousCard = new Command() { + public void execute() { + try { + getWizardWindow().previousCard(); + getWizardWindow().removeCard(thisCard); + Log.info("Remove CodelistMappingTableDetailCard"); + } catch (Exception e) { + Log.error("sayPreviousCard :" + e.getLocalizedMessage()); + } + } + }; + + getWizardWindow().setPreviousButtonCommand(sayPreviousCard); + getWizardWindow().setEnableNextButton(true); + + } + + protected void checkData() { + getWizardWindow().setEnableNextButton(false); + getWizardWindow().setEnableBackButton(false); + AlertMessageBox d; + HideHandler hideHandler = new HideHandler() { + + public void onHide(HideEvent event) { + getWizardWindow().setEnableNextButton(true); + getWizardWindow().setEnableBackButton(false); + + } + }; + + if (name.getValue() == null || name.getValue().isEmpty() + || !name.isValid() || description.getValue() == null + || description.getValue().isEmpty() || !description.isValid() + ) { + d = new AlertMessageBox("Attention!", "Fill in all fields"); + d.addHideHandler(hideHandler); + d.show(); + } else { + name.setReadOnly(true); + description.setReadOnly(true); + rights.setReadOnly(true); + goNext(); + } + } + + protected void goNext() { + try { + detail.setName(name.getCurrentValue()); + detail.setDescription(description.getCurrentValue()); + detail.setRight(rights.getCurrentValue()); + + importSession.setTabResource(detail); + + CodelistMappingOperationInProgressCard csvOperationInProgressCard = new CodelistMappingOperationInProgressCard( + importSession); + getWizardWindow().addCard(csvOperationInProgressCard); + Log.info("NextCard CodelistMappingOperationInProgressCard"); + getWizardWindow().nextCard(); + } catch (Exception e) { + Log.error("sayNextCard :" + e.getLocalizedMessage()); + } + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingUploadFileCard.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingUploadFileCard.java new file mode 100644 index 0000000..81b81f5 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingUploadFileCard.java @@ -0,0 +1,65 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client; + +import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; +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; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class CodelistMappingUploadFileCard extends WizardCard { + protected CSVImportSession importSession; + protected CodelistMappingFileUploadPanel fileUploadPanel; + protected CodelistMappingUploadFileCard thisCard; + + public CodelistMappingUploadFileCard(final CSVImportSession importSession) { + super("Codelist Mapping Import File Upload", ""); + this.thisCard = this; + this.importSession = importSession; + + this.fileUploadPanel = new CodelistMappingFileUploadPanel(res, thisCard,importSession); + + setContent(fileUploadPanel); + + } + + @Override + public void setup() { + Command sayNextCard = new Command() { + + public void execute() { + CodelistMappingTableDetailCard detailsCard = new CodelistMappingTableDetailCard(importSession); + getWizardWindow().addCard(detailsCard); + Log.info("NextCard CodelistMappingTableDetailCard"); + getWizardWindow().nextCard(); + } + + }; + + getWizardWindow().setNextButtonCommand(sayNextCard); + + Command sayPreviousCard = new Command() { + public void execute() { + try { + getWizardWindow().previousCard(); + getWizardWindow().removeCard(thisCard); + Log.info("Remove CSVUploadFileCard"); + } catch (Exception e) { + Log.error("sayPreviousCard :" + e.getLocalizedMessage()); + } + } + }; + + getWizardWindow().setPreviousButtonCommand(sayPreviousCard); + getWizardWindow().setEnableNextButton(false); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingWorkSpaceSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingWorkSpaceSelectionCard.java new file mode 100644 index 0000000..d033d39 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/CodelistMappingWorkSpaceSelectionCard.java @@ -0,0 +1,164 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client; + +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.wizardwidget.client.WizardCard; +import org.gcube.portlets.user.td.codelistmappingimportwidget.client.workspace.WorkspacePanel; +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; +import org.gcube.portlets.widgets.lighttree.client.Item; +import org.gcube.portlets.widgets.lighttree.client.ItemType; +import org.gcube.portlets.widgets.lighttree.client.event.ItemSelectionEvent; +import org.gcube.portlets.widgets.lighttree.client.event.ItemSelectionHandler; + +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.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class CodelistMappingWorkSpaceSelectionCard extends WizardCard { + + protected CSVImportSession importSession; + protected CodelistMappingWorkSpaceSelectionCard thisCard; + + protected Item item; + protected VerticalLayoutContainer p; + protected WorkspacePanel wpanel; + + public CodelistMappingWorkSpaceSelectionCard( + final CSVImportSession importSession) { + super("CSV Import From Workspace", ""); + + this.importSession = importSession; + thisCard = this; + + p = new VerticalLayoutContainer(); + + Log.debug("Set Workspace Panel"); + wpanel = new WorkspacePanel(); + wpanel.setSpWidth("536px"); + wpanel.setSpHeight("384px"); + // wpanel.setShowableTypes(ItemType.EXTERNAL_FILE); + wpanel.setSelectableTypes(ItemType.EXTERNAL_FILE); + wpanel.getSelectableTypes().remove(ItemType.ROOT); + wpanel.getSelectableTypes().remove(ItemType.FOLDER); + wpanel.setAllowedMimeTypes("text/csv", "application/zip", + "application/x-zip", "application/x-zip-compressed", + "application/octet", "application/octet-stream"); + wpanel.addSelectionHandler(new ItemSelectionHandler() { + + public void onSelection(ItemSelectionEvent event) { + item = event.getSelectedItem(); + Log.debug("Selected Item:" + item); + if (item.getType() == ItemType.EXTERNAL_FILE) { + String filename = item.getName(); + if (filename != null && !filename.isEmpty()) { + Log.debug("Item name: " + filename); + Log.debug("Item path: " + item.getPath()); + + importSession.setItemId(item.getId()); + getWizardWindow().setEnableNextButton(true); + + } else { + Log.debug("Item name null or empty"); + getWizardWindow().setEnableNextButton(false); + } + + } else { + Log.debug("Item type:" + item.getType()); + getWizardWindow().setEnableNextButton(false); + } + } + }); + p.add(wpanel); + wpanel.loadTree(); + setContent(p); + + } + + @Override + public void setup() { + Log.debug("CSVWorkSpaceSelectionCard Call Setup "); + Command sayNextCard = new Command() { + + public void execute() { + Log.debug("CSVWorkSpaceSelectionCard Call sayNextCard wpanel:" + + wpanel); + wpanel.disable(); + wpanel.startWaiting(); + getWizardWindow().setEnableNextButton(false); + getWizardWindow().setEnableBackButton(false); + getFileFromWorkspace(); + } + + }; + + getWizardWindow().setNextButtonCommand(sayNextCard); + + Command sayPreviousCard = new Command() { + public void execute() { + try { + getWizardWindow().previousCard(); + getWizardWindow().removeCard(thisCard); + Log.debug("Remove CSVWorkSpaceSelectionCard"); + } catch (Exception e) { + Log.error("sayPreviousCard :" + e.getLocalizedMessage()); + } + } + }; + + getWizardWindow().setPreviousButtonCommand(sayPreviousCard); + getWizardWindow().setEnableNextButton(false); + + } + + protected void getFileFromWorkspace() { + TDGWTServiceAsync tdGwtServiceAsync = TDGWTServiceAsync.INSTANCE; + tdGwtServiceAsync.getFileFromWorkspace(importSession, + new AsyncCallback() { + + public void onFailure(Throwable caught) { + wpanel.endWaiting(); + if (caught instanceof TDGWTSessionExpiredException) { + getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + thisCard.showErrorAndHide("Error", + "Error retrieving the file from the workspace: " + + caught.getLocalizedMessage(), + caught.toString(), caught); + } + } + + public void onSuccess(Void result) { + wpanel.endWaiting(); + goForward(); + + } + + }); + + } + + protected void goForward() { + CodelistMappingTableDetailCard detailsCard = new CodelistMappingTableDetailCard( + importSession); + getWizardWindow().addCard(detailsCard); + Log.info("NextCard CodelistMappingTableDetailCard"); + getWizardWindow().nextCard(); + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/SourceSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/SourceSelectionCard.java new file mode 100644 index 0000000..36418e5 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/SourceSelectionCard.java @@ -0,0 +1,141 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client; + +import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; + +import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; +import org.gcube.portlets.user.td.gwtservice.shared.source.FileSource; +import org.gcube.portlets.user.td.gwtservice.shared.source.WorkspaceSource; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.logical.shared.ValueChangeHandler; +import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.ui.HasValue; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.sencha.gxt.core.client.util.ToggleGroup; +import com.sencha.gxt.widget.core.client.form.Radio; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class SourceSelectionCard extends WizardCard { + + protected final CSVImportSession importSession; + + final FileSource fileSource = FileSource.INSTANCE; + final WorkspaceSource workspaceSource = WorkspaceSource.INSTANCE; + + public SourceSelectionCard(final CSVImportSession importSession) { + super("Codelist Mapping source selection", ""); + + this.importSession = importSession; + // Default + importSession.setSource(fileSource); + + VerticalPanel sourceSelectionPanel = new VerticalPanel(); + sourceSelectionPanel.setStylePrimaryName(res.wizardCSS() + .getImportSelectionSources()); + + Radio radioFileSource = new Radio(); + radioFileSource.setBoxLabel("

" + + fileSource.getName() + "
" + + fileSource.getDescription() + "

"); + radioFileSource.setName(fileSource.getName()); + radioFileSource.setStylePrimaryName(res.wizardCSS() + .getImportSelectionSource()); + radioFileSource.setValue(true); + + Radio radioWorkspaceSource = new Radio(); + radioWorkspaceSource.setBoxLabel("

" + + workspaceSource.getName() + "
" + + workspaceSource.getDescription() + "

"); + radioWorkspaceSource.setName(workspaceSource.getName()); + radioWorkspaceSource.setStylePrimaryName(res.wizardCSS() + .getImportSelectionSource()); + // radioWorkspaceSource.disable(); + + sourceSelectionPanel.add(radioFileSource); + sourceSelectionPanel.add(radioWorkspaceSource); + + // we can set name on radios or use toggle group + ToggleGroup toggle = new ToggleGroup(); + toggle.add(radioWorkspaceSource); + toggle.add(radioFileSource); + + toggle.addValueChangeHandler(new ValueChangeHandler>() { + + + public void onValueChange(ValueChangeEvent> event) { + try { + ToggleGroup group = (ToggleGroup) event.getSource(); + Radio radio = (Radio) group.getValue(); + Log.info("Source Selected:" + radio.getName()); + if (radio.getName().compareTo(workspaceSource.getName()) == 0) { + importSession.setSource(workspaceSource); + } else { + if (radio.getName().compareTo(fileSource.getName()) == 0) { + importSession.setSource(fileSource); + } else { + + } + + } + + } catch (Exception e) { + Log.error("ToggleGroup: onValueChange " + + e.getLocalizedMessage()); + } + + } + }); + + setContent(sourceSelectionPanel); + + } + + @Override + public void setup() { + Log.debug("Setup Card"); + Command sayNextCard = new Command() { + public void execute() { + try { + String sourceId = importSession.getSource().getId(); + if (sourceId == null || sourceId.isEmpty()) { + Log.error("CSV Import Source Id: " + sourceId); + } else { + if (sourceId.compareTo("File") == 0) { + Log.info("NextCard CSVUploadFileCard"); + CodelistMappingUploadFileCard csvUploadFileCard = new CodelistMappingUploadFileCard( + importSession); + getWizardWindow().addCard(csvUploadFileCard); + getWizardWindow().nextCard(); + } else { + if (sourceId.compareTo("Workspace") == 0) { + Log.info("NextCard CSVWorkspaceSelectionCard"); + CodelistMappingWorkSpaceSelectionCard csvWorkspaceSelectionCard = new CodelistMappingWorkSpaceSelectionCard( + importSession); + getWizardWindow().addCard( + csvWorkspaceSelectionCard); + getWizardWindow().nextCard(); + } else { + Log.debug("No source selected and no card loaded"); + } + } + } + } catch (Exception e) { + Log.error("sayNextCard :" + e.getLocalizedMessage()); + } + } + }; + + getWizardWindow().setNextButtonCommand(sayNextCard); + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/CodelistMappingImportCSS.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/CodelistMappingImportCSS.java new file mode 100644 index 0000000..04da495 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/CodelistMappingImportCSS.java @@ -0,0 +1,41 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client.dataresource; + +import com.google.gwt.resources.client.CssResource; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public interface CodelistMappingImportCSS extends CssResource { + + @ClassName("wizard-title") + public String getWizardTitle(); + + @ClassName("wizard-footer") + public String getWizardFooter(); + + @ClassName("source-selection-hover") + public String getSourceSelectionHover(); + + @ClassName("column-excluded") + public String getColumnExcluded(); + + @ClassName("importSelection-sources") + public String getImportSelectionSources(); + + @ClassName("importSelection-source") + public String getImportSelectionSource(); + + @ClassName("sdmxRegistryUrlStyle") + public String getSDMXRegistryUrlStyle(); + + @ClassName("sdmxRegistryUrlInputStyle") + public String getSDMXRegistryUrlInputStyle(); + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/ResourceBundle.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/ResourceBundle.java new file mode 100644 index 0000000..8515d15 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/ResourceBundle.java @@ -0,0 +1,40 @@ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client.dataresource; + + + +import com.google.gwt.core.client.GWT; +import com.google.gwt.resources.client.ClientBundle; +import com.google.gwt.resources.client.ImageResource; + + +public interface ResourceBundle extends ClientBundle { + + public static final ResourceBundle INSTANCE=GWT.create(ResourceBundle.class); + + @Source("resources/CSVImportWizardTD.css") + CodelistMappingImportCSS importCss(); + + @Source("resources/arrow-refresh.png") + ImageResource refresh(); + + @Source("resources/arrow-refresh_16.png") + ImageResource refresh_16(); + + @Source("resources/arrow-refresh_32.png") + ImageResource refresh32(); + + @Source("resources/accept.png") + ImageResource csvCheckSuccess(); + + @Source("resources/error.png") + ImageResource csvCheckFailure(); + + @Source("resources/loading.gif") + ImageResource loading(); + + @Source("resources/information.png") + ImageResource information(); + + +} + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/CodelistMappingImportProgressBarUpdater.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/CodelistMappingImportProgressBarUpdater.java new file mode 100644 index 0000000..736b46d --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/CodelistMappingImportProgressBarUpdater.java @@ -0,0 +1,99 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress; + + + + +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; + +import com.allen_sauer.gwt.log.client.Log; +import com.sencha.gxt.widget.core.client.ProgressBar; + +/** + * Updates a {@link ProgressBar} progress and text based on {@link CodelistMappingImportProgressListener} events. + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class CodelistMappingImportProgressBarUpdater implements CodelistMappingImportProgressListener { + + protected ProgressBar progressBar; + + /** + * Creates a new {@link ProgressBar} updater. + * @param progressBar the {@link ProgressBar} to update. + */ + public CodelistMappingImportProgressBarUpdater(ProgressBar progressBar) { + this.progressBar = progressBar; + } + + + /** + * {@inheritDoc} + */ + @Override + public void operationComplete(TRId trId) { + Log.info("Import completed"); + progressBar.updateProgress(1, "Import completed."); + + } + + /** + * {@inheritDoc} + */ + @Override + public void operationFailed(Throwable caught, String reason, String failureDetails) { + Log.info("Import failed"); + progressBar.updateText("Import failed"); + } + + @Override + public void operationInitializing() { + Log.info("Inport Inizializing"); + progressBar.updateProgress(0, "Initializing..."); + } + + @Override + public void operationUpdate(float elaborated) { + Log.info("Elaborated: "+elaborated); + if (elaborated == 0) progressBar.updateProgress(0, "Initializing..."); + if (elaborated>0 && elaborated<1) { + Log.trace("progress "+elaborated); + int elab=new Float(elaborated*100).intValue(); + progressBar.updateProgress(elaborated,elab+"% Importing..."); + } + if (elaborated == 1) progressBar.updateProgress(1, "Completing..."); + + } + + @Override + public void operationValidate(float elaborated) { + Log.info("Validation Elaborated: "+elaborated); + if (elaborated == 0) progressBar.updateProgress(0, "Start Validation..."); + if (elaborated>0 && elaborated<1) { + Log.trace("Validation progress "+elaborated); + int elab=new Float(elaborated*100).intValue(); + progressBar.updateProgress(elaborated,elab+"% Validation Progress..."); + } + if (elaborated == 1) progressBar.updateProgress(1, "Validation..."); + } + + @Override + public void operationStopped(TRId trId,String reason, String details) { + Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]"); + progressBar.updateText("Validations failed"); + + } + + + @Override + public void operationGeneratingView() { + Log.info("Generating View..."); + progressBar.updateText("Generating View..."); + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/CodelistMappingImportProgressListener.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/CodelistMappingImportProgressListener.java new file mode 100644 index 0000000..a118699 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/CodelistMappingImportProgressListener.java @@ -0,0 +1,63 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress; + +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; + + + +/** + * Defines a listener for operation progress. + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public interface CodelistMappingImportProgressListener { + + /** + * Called when the operation is starting. + */ + public void operationInitializing(); + + /** + * Called when there is a progress for the operation. + * @param elaborated the elaborated part. + */ + public void operationUpdate(float elaborated); + + /** + * Called when there is a validate for the operation. + * @param elaborated the elaborated part. + */ + public void operationValidate(float elaborated); + + + /** + * Called when the operation is complete. + */ + public void operationComplete(TRId trId); + + /** + * Called when the operation is failed. + * @param caught the failure exception. + * @param reason the failure reason. + */ + public void operationFailed(Throwable caught, String reason, String failureDetails); + + /** + * Called when the operation is stopped + * + * @param trId + * @param reason + * @param details + */ + public void operationStopped(TRId trId, String reason, String details); + + /** + * Called when the operation is generating the view + */ + public void operationGeneratingView(); + +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/CodelistMappingImportProgressUpdater.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/CodelistMappingImportProgressUpdater.java new file mode 100644 index 0000000..87744c9 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/CodelistMappingImportProgressUpdater.java @@ -0,0 +1,193 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress; + +import java.util.ArrayList; + +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportMonitor; +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.user.client.Timer; +import com.google.gwt.user.client.rpc.AsyncCallback; + +/** + * This {@link Timer} retrieves {@link OperationProgress} from the specified + * {@link OperationProgressSource} with the scheduled interval. The retrieved + * information are spread to the subscribed {@link CodelistMappingImportProgressListener}. + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class CodelistMappingImportProgressUpdater extends Timer { + + protected ArrayList listeners = new ArrayList(); + + /** + * {@inheritDoc} + */ + @Override + public void run() { + Log.debug("requesting operation progress"); + TDGWTServiceAsync.INSTANCE + .getCSVImportMonitor(new AsyncCallback() { + + + public void onFailure(Throwable caught) { + cancel(); + Log.error("Error retrieving the operation state", + caught); + String message = getStack(caught); + fireOperationFailed(caught, + "Failed getting operation updates", message); + } + + public void onSuccess(CSVImportMonitor result) { + Log.info("retrieved CSVImportMonitor: " + + result.getStatus()); + switch (result.getStatus()) { + case INITIALIZING: + Log.info("CSV Import Initializing..."); + fireOperationInitializing(); + break; + case ABORTED: + cancel(); + Log.info("CSV Import Operation Aborted"); + break; + case IN_PROGRESS: + fireOperationUpdate(result.getProgress()); + break; + case VALIDATING_RULES: + fireOperationValidate(result.getProgress()); + break; + case GENERATING_VIEW: + Log.info("Generating View..."); + fireOperationGeneratingView(); + break; + case STOPPED: + cancel(); + stopMessage(result); + break; + case FAILED: + cancel(); + errorMessage(result); + break; + case SUCCEDED: + cancel(); + Log.info("Import fisnish TableId :" + + result.getTrId()); + fireOperationComplete(result.getTrId()); + break; + default: + Log.info("Unknow State"); + break; + } + + } + + }); + + } + + protected void errorMessage(CSVImportMonitor result) { + Log.info("CSV Import Failed"); + Throwable th = null; + String failure = null; + String details = null; + if (result.getError() != null) { + th = result.getError(); + failure = "Failed Client Library Import"; + details = result.getError().getLocalizedMessage(); + } else { + th = new Throwable("Failed"); + failure = "Failed Client Library Import"; + details = "Error in import"; + } + fireOperationFailed(th, failure, details); + + } + + protected void stopMessage(CSVImportMonitor result) { + Log.info("CSV Import Stopped"); + String failure = null; + String details = null; + if (result.getError() != null) { + failure = "Stopped"; + details = result.getError().getLocalizedMessage(); + } else { + failure = "Stopped"; + details = "Stopped import CSV"; + } + + fireOperationStopped(result.getTrId(),failure, details); + } + + protected String getStack(Throwable e) { + String message = e.getLocalizedMessage() + " ->
"; + Throwable c = e.getCause(); + if (c != null) + message += getStack(c); + return message; + } + + protected void fireOperationInitializing() { + for (CodelistMappingImportProgressListener listener : listeners) + listener.operationInitializing(); + } + + protected void fireOperationGeneratingView() { + for (CodelistMappingImportProgressListener listener : listeners) + listener.operationGeneratingView(); + } + + protected void fireOperationUpdate(float elaborated) { + for (CodelistMappingImportProgressListener listener : listeners) + listener.operationUpdate(elaborated); + } + + protected void fireOperationValidate(float elaborated) { + for (CodelistMappingImportProgressListener listener : listeners) + listener.operationValidate(elaborated); + } + + protected void fireOperationComplete(TRId trId) { + for (CodelistMappingImportProgressListener listener : listeners) + listener.operationComplete(trId); + } + + protected void fireOperationFailed(Throwable caught, String failure, + String failureDetails) { + for (CodelistMappingImportProgressListener listener : listeners) + listener.operationFailed(caught, failure, failureDetails); + } + + protected void fireOperationStopped(TRId trId, String reason, String details) { + for (CodelistMappingImportProgressListener listener : listeners) + listener.operationStopped(trId,reason, details); + } + + /** + * Add a new {@link CodelistMappingImportProgressListener} to this + * {@link CodelistMappingImportProgressUpdater}. + * + * @param listener + * the listener to add. + */ + public void addListener(CodelistMappingImportProgressListener listener) { + listeners.add(listener); + } + + /** + * Removes the specified {@link CodelistMappingImportProgressListener} from this + * {@link CodelistMappingImportProgressUpdater}. + * + * @param listener + * the listener to remove. + */ + public void removeListener(CodelistMappingImportProgressListener listener) { + listeners.remove(listener); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/FileUploadProgressBarUpdater.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/FileUploadProgressBarUpdater.java new file mode 100644 index 0000000..196d3bb --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/FileUploadProgressBarUpdater.java @@ -0,0 +1,64 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress; + + +import com.allen_sauer.gwt.log.client.Log; +import com.sencha.gxt.widget.core.client.ProgressBar; + +/** + * Updates a {@link ProgressBar} progress and text based on {@link CodelistMappingImportProgressListener} events. + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class FileUploadProgressBarUpdater implements FileUploadProgressListener { + + protected ProgressBar progressBar; + + /** + * Creates a new {@link ProgressBar} updater. + * @param progressBar the {@link ProgressBar} to update. + */ + public FileUploadProgressBarUpdater(ProgressBar progressBar) { + this.progressBar = progressBar; + } + + + /** + * {@inheritDoc} + */ + public void operationComplete() { + Log.info("File upload complete"); + progressBar.updateProgress(1, "File upload completed."); + + } + + /** + * {@inheritDoc} + */ + public void operationFailed(Throwable caught, String reason, String failureDetails) { + Log.info("File upload failed"); + progressBar.updateText("File upload failed."); + } + + public void operationInitializing() { + Log.info("File upload inizializing"); + progressBar.updateProgress(0, "Initializing..."); + } + + public void operationUpdate(float elaborated) { + Log.info("File upload elaborated: "+elaborated); + if (elaborated == 0) progressBar.updateProgress(0, "Initializing..."); + if (elaborated>0 && elaborated<1) { + Log.trace("progress "+elaborated); + int elab=new Float(elaborated*100).intValue(); + progressBar.updateProgress(elaborated,elab+"% Uploading..."); + } + if (elaborated == 1) progressBar.updateProgress(1, "Completed."); + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/FileUploadProgressCardUpdater.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/FileUploadProgressCardUpdater.java new file mode 100644 index 0000000..dc78562 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/FileUploadProgressCardUpdater.java @@ -0,0 +1,45 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress; + + +import com.allen_sauer.gwt.log.client.Log; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class FileUploadProgressCardUpdater implements FileUploadProgressListener { + + + /** + * + */ + public FileUploadProgressCardUpdater() { + } + + + public void operationComplete() { + Log.info("File upload completed"); + + } + + /** + * {@inheritDoc} + */ + public void operationFailed(Throwable caught, String reason, String failureDetails) { + Log.info("File upload failed"); + } + + public void operationInitializing() { + Log.info("File upload inizializing"); + } + + public void operationUpdate(float elaborated) { + Log.info("File uploading: "+elaborated); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/FileUploadProgressListener.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/FileUploadProgressListener.java new file mode 100644 index 0000000..51adc17 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/FileUploadProgressListener.java @@ -0,0 +1,41 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress; + + + + +/** + * Defines a listener for operation progress. + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public interface FileUploadProgressListener { + + /** + * Called when the operation is starting. + */ + public void operationInitializing(); + + /** + * Called when there is a progress for the operation. + * @param elaborated the elaborated part. + */ + public void operationUpdate(float elaborated); + + + /** + * Called when the operation is complete. + */ + public void operationComplete(); + + /** + * Called when the operation is failed. + * @param caught the failure exception. + * @param reason the failure reason. + */ + public void operationFailed(Throwable caught, String reason, String failureDetails); +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/FileUploadProgressUpdater.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/FileUploadProgressUpdater.java new file mode 100644 index 0000000..ead8112 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/progress/FileUploadProgressUpdater.java @@ -0,0 +1,127 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress; + +import java.util.ArrayList; + +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.file.FileUploadMonitor; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.user.client.Timer; +import com.google.gwt.user.client.rpc.AsyncCallback; + +/** + * This {@link Timer} retrieves {@link OperationProgress} from the specified {@link OperationProgressSource} with the scheduled interval. + * The retrieved information are spread to the subscribed {@link CodelistMappingImportProgressListener}. + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class FileUploadProgressUpdater extends Timer { + + protected ArrayList listeners = new ArrayList(); + + + /** + * {@inheritDoc} + */ + @Override + public void run() { + Log.debug("requesting operation progress"); + TDGWTServiceAsync.INSTANCE.getFileUploadMonitor(new AsyncCallback() { + + + public void onFailure(Throwable caught) { + cancel(); + Log.error("Error retrieving the operation state", caught); + String message = getStack(caught); + fireOperationFailed(caught, "Failed getting operation updates", message); + } + + public void onSuccess(FileUploadMonitor result) { + Log.info("retrieved FileUploadMonitor: "+result.getState()); + switch (result.getState()) { + case STARTED: + Log.debug("File Upload Started"); + break; + case INPROGRESS: + Log.debug("Progress: "+result.getElaboratedLenght()+" of "+result.getTotalLenght()); + fireOperationUpdate(result.getPercentDone()); + break; + case FAILED: + Log.debug("File Upload Failed"); + cancel(); + fireOperationFailed(new Throwable("Failed Client Library Import") ,result.getFailureReason(), result.getFailureDetails()); + break; + case COMPLETED: + cancel(); + Log.debug("File Upload Completed"); + fireOperationComplete(); + break; + default: + break; + } + + } + + + + + + }); + + + + } + + + + protected String getStack(Throwable e) + { + String message = e.getLocalizedMessage()+" ->
"; + Throwable c = e.getCause(); + if (c!=null) message += getStack(c); + return message; + } + + protected void fireOperationInitializing() + { + for (FileUploadProgressListener listener:listeners) listener.operationInitializing(); + } + + protected void fireOperationUpdate(float elaborated) + { + for (FileUploadProgressListener listener:listeners) listener.operationUpdate(elaborated); + } + + protected void fireOperationComplete() + { + for (FileUploadProgressListener listener:listeners) listener.operationComplete(); + } + + protected void fireOperationFailed(Throwable caught, String failure, String failureDetails) + { + for (FileUploadProgressListener listener:listeners) listener.operationFailed(caught, failure, failureDetails); + } + + /** + * Add a new {@link CodelistMappingImportProgressListener} to this {@link FileUploadProgressUpdater}. + * @param listener the listener to add. + */ + public void addListener(FileUploadProgressListener listener) + { + listeners.add(listener); + } + + /** + * Removes the specified {@link CodelistMappingImportProgressListener} from this {@link FileUploadProgressUpdater}. + * @param listener the listener to remove. + */ + public void removeListener(FileUploadProgressListener listener) + { + listeners.remove(listener); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/util/ErrorMessageBox.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/util/ErrorMessageBox.java new file mode 100644 index 0000000..6ac73d8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/util/ErrorMessageBox.java @@ -0,0 +1,67 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client.util; + +import com.google.gwt.core.client.Callback; +import com.google.gwt.user.client.ui.Label; +import com.sencha.gxt.widget.core.client.Dialog; +import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton; +import com.sencha.gxt.widget.core.client.box.MessageBox; +import com.sencha.gxt.widget.core.client.event.HideEvent; +import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class ErrorMessageBox { + + + private static final String DETAILS = "Details"; + + + public static void showError(String title, String failureReason, final String failureDetails) + { + showError(title, failureReason, failureDetails, new NOPCallBack()); + } + + public static void showError(String title, String failureReason, final String failureDetails, final Callback callback) + { + final MessageBox box = new MessageBox(title); + box.setMessage(failureReason); + box.addHideHandler(new HideHandler() { + + public void onHide(HideEvent event) { + Dialog dialog = (Dialog) event.getSource(); + + if (dialog.getHideButton().getText().equals(DETAILS)){ + //box.close(); + showErrorDetails("Error details", failureDetails); + } else callback.onSuccess(dialog); + } + }); + + box.show(); + } + + public static void showErrorDetails(String title, String failureDetails) + { + final Dialog simple = new Dialog(); + simple.setHeadingText(title); + simple.setPredefinedButtons(PredefinedButton.OK); + simple.setBodyStyleName("pad-text"); + + + simple.add(new Label("
"+failureDetails+"
")); + + + simple.setHideOnButtonClick(true); + simple.setWidth(400); + simple.setHeight(400); + simple.show(); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/util/Format.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/util/Format.java new file mode 100644 index 0000000..afc6037 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/util/Format.java @@ -0,0 +1,37 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client.util; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class Format { + + /** + * Converts a file size into a {@link String} representation adding the misure unit. + * @param size the file size. + * @return the textual representation. + */ + public static String fileSize(long size) { + StringBuilder text = new StringBuilder(); + if (size < 1024) { + text.append(size); + text.append(" bytes"); + } else if (size < 1048576) { + text.append(Math.round(((size * 10) / 1024)) / 10); + text.append(" KB"); + } else if (size < 1073741824) { + text.append(Math.round(((size * 10) / 1048576)) / 10); + text.append(" MB"); + } else { + text.append(Math.round(((size * 10) / 1073741824)) / 10); + text.append(" GB"); + } + return text.toString(); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/util/NOPCallBack.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/util/NOPCallBack.java new file mode 100644 index 0000000..14ebb86 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/util/NOPCallBack.java @@ -0,0 +1,22 @@ +/** + * + */ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client.util; + +import com.google.gwt.core.client.Callback; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + * @param + * @param + */ +public class NOPCallBack implements Callback { + + public void onFailure(F reason) {} + + public void onSuccess(T result) {} + +} diff --git a/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/workspace/WorkspacePanel.java b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/workspace/WorkspacePanel.java new file mode 100644 index 0000000..b5dd4e5 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/workspace/WorkspacePanel.java @@ -0,0 +1,47 @@ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client.workspace; + +import org.gcube.portlets.widgets.lighttree.client.WorkspaceLightTreePanel; + +import com.allen_sauer.gwt.log.client.Log; +import com.sencha.gxt.widget.core.client.box.AutoProgressMessageBox; +import com.sencha.gxt.widget.core.client.event.DisableEvent; +import com.sencha.gxt.widget.core.client.event.EnableEvent; + +public class WorkspacePanel extends WorkspaceLightTreePanel { + + AutoProgressMessageBox box; + + public void setSpWidth(String w) { + sp.setWidth(w); + + } + + public void setSpHeight(String h) { + sp.setHeight(h); + } + + public void disable() { + Log.debug("WorkspacePanel Disable"); + fireEvent(new DisableEvent()); + } + + public void enable() { + Log.debug("WorkspacePanel Enable"); + fireEvent(new EnableEvent()); + } + + public void startWaiting() { + box= new AutoProgressMessageBox("Loading", + "Retriving data from workspace, please wait..."); + box.setProgressText("Loading..."); + box.setModal(false); + box.auto(); + box.show(); + + } + + public void endWaiting() { + box.hide(); + } + +} diff --git a/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/CodelistMappingImportWizardTD.gwt.xml b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/CodelistMappingImportWizardTD.gwt.xml new file mode 100644 index 0000000..e541222 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/CodelistMappingImportWizardTD.gwt.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/Messages.properties b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/Messages.properties new file mode 100644 index 0000000..c222555 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/Messages.properties @@ -0,0 +1,2 @@ +sendButton = Send +nameField = Enter your name \ No newline at end of file diff --git a/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/Messages_fr.properties b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/Messages_fr.properties new file mode 100644 index 0000000..b4a7627 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/Messages_fr.properties @@ -0,0 +1,2 @@ +sendButton = Envoyer +nameField = Entrez votre nom \ No newline at end of file diff --git a/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/CodelistMappingImportWizardTD.css b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/CodelistMappingImportWizardTD.css new file mode 100644 index 0000000..553fd48 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/CodelistMappingImportWizardTD.css @@ -0,0 +1,54 @@ +@CHARSET "UTF-8"; + + +.wizard-title { + padding: 5px; + font-weight: bold; + font-size: small; + background-color: #C3D9FF; +} + +.wizard-footer { + padding: 5px; + font-weight: bold; + font-size: small; + text-align: right; + background-color: #CDEB8B +} + +.source-selection-hover:hover { + cursor: pointer; +} + + + +.column-excluded { + background-color: #e6e0da !important; + color: #bfa698; +} + +.importSelection-sources { + padding: 30px; + display: block; + margin-top: 20px; + +} + +.importSelection-source { + padding-bottom: 20px; +} + + + +.sdmxRegistryUrlStyle { + padding-top:5px; +} + +.sdmxRegistryUrlInputStyle { + width:300px!important; +} + + +input#sdmxRegistryUrlInputFieldId-input { + width:300px!important; +} diff --git a/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/accept.png b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/accept.png new file mode 100644 index 0000000..89c8129 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/accept.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/arrow-refresh.png b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/arrow-refresh.png new file mode 100644 index 0000000..764f995 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/arrow-refresh.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/arrow-refresh_16.png b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/arrow-refresh_16.png new file mode 100644 index 0000000..72edf8a Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/arrow-refresh_16.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/arrow-refresh_32.png b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/arrow-refresh_32.png new file mode 100644 index 0000000..f3521ea Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/arrow-refresh_32.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/error.png b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/error.png new file mode 100644 index 0000000..c37bd06 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/error.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/information.png b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/information.png new file mode 100644 index 0000000..12cd1ae Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/information.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/loading.gif b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/loading.gif new file mode 100644 index 0000000..e846e1d Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/client/dataresource/resources/loading.gif differ diff --git a/src/main/webapp/CodelistMappingImportWizardTD.css b/src/main/webapp/CodelistMappingImportWizardTD.css new file mode 100644 index 0000000..7aca7ac --- /dev/null +++ b/src/main/webapp/CodelistMappingImportWizardTD.css @@ -0,0 +1,34 @@ +/** Add css rules here for your application. */ + + +/** Example rules used by the template application (remove for your app) */ +h1 { + font-size: 2em; + font-weight: bold; + color: #777777; + margin: 40px 0px 70px; + text-align: center; +} + +.sendButton { + display: block; + font-size: 16pt; +} + +/** Most GWT widgets already have a style name defined */ +.gwt-DialogBox { + width: 400px; +} + +.dialogVPanel { + margin: 5px; +} + +.serverResponseLabelError { + color: red; +} + +/** Set ids using widget.getElement().setId("idOfElement") */ +#closeButton { + margin: 15px 6px 6px; +} diff --git a/src/main/webapp/CodelistMappingImportWizardTD.html b/src/main/webapp/CodelistMappingImportWizardTD.html new file mode 100644 index 0000000..9a3eb56 --- /dev/null +++ b/src/main/webapp/CodelistMappingImportWizardTD.html @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + Web Application Starter Project + + + + + + + + + + + + + + + + + + + + + + +

Web Application Starter Project

+ + + + + + + + + + + + +
Please enter your name:
+ + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..e9b3d5b --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,46 @@ + + + + + + + + TDGWTService + org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl + + + + jUnitHostImpl + com.google.gwt.junit.server.JUnitHostImpl + + + + WorkspaceLightService + org.gcube.portlets.widgets.lighttree.server.WorkspaceServiceImpl + + + + + + TDGWTService + tdgwtservice/TDGWTService + + + jUnitHostImpl + CSVImportWizardTDManagerWidgets/junithost/* + + + + WorkspaceLightService + /CSVImportWizardTDManagerWidgets/WorkspaceLightService + + + + + + CSVImportWizardTD.html + + + diff --git a/src/test/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/GwtTestCodelistMappingImportWizardTD.java b/src/test/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/GwtTestCodelistMappingImportWizardTD.java new file mode 100644 index 0000000..1a6fccb --- /dev/null +++ b/src/test/java/org/gcube/portlets/user/td/codelistmappingimportwidget/client/GwtTestCodelistMappingImportWizardTD.java @@ -0,0 +1,82 @@ +package org.gcube.portlets.user.td.codelistmappingimportwidget.client; + +import java.util.ArrayList; + +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTService; +import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.junit.client.GWTTestCase; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.rpc.ServiceDefTarget; + +/** + * GWT JUnit integration tests must extend GWTTestCase. + * Using "GwtTest*" naming pattern exclude them from running with + * surefire during the test phase. + * + * If you run the tests using the Maven command line, you will have to + * navigate with your browser to a specific url given by Maven. + * See http://mojo.codehaus.org/gwt-maven-plugin/user-guide/testing.html + * for details. + */ +public class GwtTestCodelistMappingImportWizardTD extends GWTTestCase { + + /** + * Must refer to a valid module that sources this class. + */ + public String getModuleName() { + return "org.gcube.portlets.user.codelistmappingimportwidget.CodelistMappingImportWizardTDJUnit"; + } + + /** + * This test will send a request to the server + */ + public void testResource() { + // Create the service that we will test. + TDGWTServiceAsync tdGWTService = GWT.create(TDGWTService.class); + ServiceDefTarget target = (ServiceDefTarget) tdGWTService; + System.out.println(GWT.getModuleBaseURL() + "TDGWTService"); + target.setServiceEntryPoint(GWT.getModuleBaseURL() + "TDGWTService"); + + // Since RPC calls are asynchronous, we will need to wait for a response + // after this test method returns. This line tells the test runner to wait + // up to 7 seconds before timing out. + delayTestFinish(7000); + + // Send a request to the server. + tdGWTService.getTabularResources(new AsyncCallback>() { + + + public void onFailure(Throwable caught) { + // The request resulted in an unexpected error. + fail("Request failure: " + caught.getMessage()); + + } + + public void onSuccess(ArrayList result) { + // Shows the first three resources. + int i=0; + for(TabResource tr:result){ + i++; + System.out.println(tr.toString()); + if(i>3){ + break; + } + } + + assertTrue(result.size()>0); + + // Now that we have received a response, we need to tell the test runner + // that the test is complete. You must call finishTest() after an + // asynchronous test finishes successfully, or the test will time out. + finishTest(); + + } + }); + + } + + +} diff --git a/src/test/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/CodelistMappingImportWizardTDJUnit.gwt.xml b/src/test/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/CodelistMappingImportWizardTDJUnit.gwt.xml new file mode 100644 index 0000000..f4fed0f --- /dev/null +++ b/src/test/resources/org/gcube/portlets/user/td/codelistmappingimportwidget/CodelistMappingImportWizardTDJUnit.gwt.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/templates/INSTALL b/templates/INSTALL new file mode 100644 index 0000000..e69de29 diff --git a/templates/LICENSE b/templates/LICENSE new file mode 100644 index 0000000..cc51139 --- /dev/null +++ b/templates/LICENSE @@ -0,0 +1,6 @@ +gCube System - License +------------------------------------------------------------ + +The gCube/gCore software is licensed as Free Open Source software conveying to the EUPL (http://ec.europa.eu/idabc/eupl). +The software and documentation is provided by its authors/distributors "as is" and no expressed or +implied warranty is given for its use, quality or fitness for a particular case. \ No newline at end of file diff --git a/templates/MAINTAINERS b/templates/MAINTAINERS new file mode 100644 index 0000000..0bc9be3 --- /dev/null +++ b/templates/MAINTAINERS @@ -0,0 +1 @@ +Giancarlo Panichi (giancarlo.panichi@isti.cnr.it), CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" diff --git a/templates/README b/templates/README new file mode 100644 index 0000000..e81341a --- /dev/null +++ b/templates/README @@ -0,0 +1,40 @@ +The gCube System - ${name} +------------------------------------------------------------ + +This work has been supported by the following European projects: iMarine (FP7-INFRASTRUCTURES-2011-2) + +Authors +------- + +Giancarlo Panichi (giancarlo.panichi@isti.cnr.it), CNR Pisa, +Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" + + +Version and Release Date +------------------------ + +v. ${version} (${release.date}) + +Description +----------- + +${project.description} + +Download information +-------------------- +Source code URL: ${scm.url} + + +Documentation +------------- + +${project.description} + + +Licensing +--------- + +This software is licensed under the terms you may find in the file named "LICENSE" in this directory. + + + diff --git a/templates/changelog.xml b/templates/changelog.xml new file mode 100644 index 0000000..f9f8997 --- /dev/null +++ b/templates/changelog.xml @@ -0,0 +1,6 @@ + + + First Release + + \ No newline at end of file diff --git a/templates/descriptor.xml b/templates/descriptor.xml new file mode 100644 index 0000000..b978636 --- /dev/null +++ b/templates/descriptor.xml @@ -0,0 +1,39 @@ + + servicearchive + + tar.gz + + / + + + ${distroDirectory} + / + true + + README + LICENSE + INSTALL + MAINTAINERS + changelog.xml + + 755 + + + + + ${distroDirectory}/svnpath.txt + /${artifactId} + + + ${configDirectory}/profile.xml + / + + + target/${build.finalName}.${packaging} + /${artifactId} + + + \ No newline at end of file diff --git a/templates/profile.xml b/templates/profile.xml new file mode 100644 index 0000000..ffa3274 --- /dev/null +++ b/templates/profile.xml @@ -0,0 +1,29 @@ + + + + Service + + ${project.description} + PortletsUser + ${project.name} + 1.0.0 + + + ${project.description} + ${project.name} + ${version} + + ${project.groupId} + ${project.artifactId} + ${project.version} + + library + + ${project.build.finalName}.${project.packaging} + + + + + + + diff --git a/templates/svnpath.txt b/templates/svnpath.txt new file mode 100644 index 0000000..dcd0d22 --- /dev/null +++ b/templates/svnpath.txt @@ -0,0 +1 @@ +${scm.url} \ No newline at end of file