diff --git a/distro/README b/distro/README index e8e7a37..70ff3b2 100644 --- a/distro/README +++ b/distro/README @@ -39,7 +39,7 @@ Documentation tabular-data-csv-import-widget allows csv import from file and workspace Documentation is available on-line from the Projects Documentation Wiki: - https://gcube.wiki.gcube-system.org/gcube/index.php/Tabular_Data_Manager + http://wiki.gcube-system.org/gcube/Tabular_Data_Manager Licensing diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages.java new file mode 100644 index 0000000..16df063 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages.java @@ -0,0 +1,29 @@ +package org.gcube.portlets.user.td.csvimportwidget.client; + +import com.google.gwt.i18n.client.Messages; + +/** + * + * @author giancarlo + * email: g.panichi@isti.cnr.it + * + */ +public interface CSVImportWizardTDMessages extends Messages { + + @DefaultMessage("CSV source selection") + String csvSourceSelection(); + + @DefaultMessage("CSV Import File Upload") + String csvImportFileUpload(); + + @DefaultMessage("CSV Import From Workspace") + String csvImportFromWorkspace(); + + @DefaultMessage("Workspace Selection") + String workspaceSelection(); + + @DefaultMessage("Error retrieving the file from the workspace.") + String errorRetrievingTheFileFromWorkspace(); + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVUploadFileCard.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVUploadFileCard.java index 931ec3f..457a0e7 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVUploadFileCard.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVUploadFileCard.java @@ -7,6 +7,7 @@ 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.core.shared.GWT; import com.google.gwt.user.client.Command; import com.sencha.gxt.widget.core.client.container.MarginData; @@ -17,12 +18,15 @@ import com.sencha.gxt.widget.core.client.container.MarginData; * */ public class CSVUploadFileCard extends WizardCard { - protected CSVImportSession importSession; - protected FileUploadPanel fileUploadPanel; - protected CSVUploadFileCard thisCard; + private static CSVImportWizardTDMessages msgs= GWT.create(CSVImportWizardTDMessages.class); + + + private CSVImportSession importSession; + private FileUploadPanel fileUploadPanel; + private CSVUploadFileCard thisCard; public CSVUploadFileCard(final CSVImportSession importSession) { - super("CSV Import File Upload", ""); + super(msgs.csvImportFileUpload(), ""); this.thisCard = this; this.importSession = importSession; diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVWorkSpaceSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVWorkSpaceSelectionCard.java index 714e45b..4146b83 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVWorkSpaceSelectionCard.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVWorkSpaceSelectionCard.java @@ -11,6 +11,7 @@ import java.util.List; 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.user.td.widgetcommonevent.client.CommonMessages; 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; @@ -21,6 +22,7 @@ import org.gcube.portlets.widgets.wsexplorer.shared.Item; import org.gcube.portlets.widgets.wsexplorer.shared.ItemType; import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.core.shared.GWT; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.rpc.AsyncCallback; import com.sencha.gxt.core.client.util.Margins; @@ -35,20 +37,23 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti * */ public class CSVWorkSpaceSelectionCard extends WizardCard { + private static CSVImportWizardTDMessages msgs= GWT.create(CSVImportWizardTDMessages.class); + + private CSVImportSession importSession; + private CSVWorkSpaceSelectionCard thisCard; - protected CSVImportSession importSession; - protected CSVWorkSpaceSelectionCard thisCard; + private VerticalLayoutContainer p; + private WorkspaceExplorerSelectPanel wpanel; - protected ItemType item; - protected VerticalLayoutContainer p; - protected WorkspaceExplorerSelectPanel wpanel; + private CommonMessages msgsCommon; public CSVWorkSpaceSelectionCard(final CSVImportSession importSession) { - super("CSV Import From Workspace", ""); - + super(msgs.csvImportFromWorkspace(), ""); this.importSession = importSession; thisCard = this; - + + initMessages(); + p = new VerticalLayoutContainer(); Log.debug("Set Workspace Panel"); @@ -66,8 +71,7 @@ public class CSVWorkSpaceSelectionCard extends WizardCard { FilterCriteria filterCriteria = new FilterCriteria(allowedMimeTypes, allowedFileExtensions, new HashMap()); - wpanel = new WorkspaceExplorerSelectPanel(new String( - "Workspace Selection"), filterCriteria, selectableTypes); + wpanel = new WorkspaceExplorerSelectPanel(msgs.workspaceSelection(), filterCriteria, selectableTypes); WorskpaceExplorerSelectNotificationListener handler = new WorskpaceExplorerSelectNotificationListener() { @@ -122,6 +126,10 @@ public class CSVWorkSpaceSelectionCard extends WizardCard { setCenterWidget(p, new MarginData(0)); } + + protected void initMessages(){ + msgsCommon = GWT.create(CommonMessages.class); + } @Override public void setup() { @@ -170,8 +178,8 @@ public class CSVWorkSpaceSelectionCard extends WizardCard { SessionExpiredType.EXPIREDONSERVER)); } else { thisCard.showErrorAndHide( - "Error", - "Error retrieving the file from the workspace.", + msgsCommon.error(), + msgs.errorRetrievingTheFileFromWorkspace(), caught.getLocalizedMessage(), caught); } } diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/SourceSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/SourceSelectionCard.java index 0e14e15..0ceff2f 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/SourceSelectionCard.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/SourceSelectionCard.java @@ -9,6 +9,7 @@ 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.core.shared.GWT; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.user.client.Command; @@ -25,14 +26,18 @@ import com.sencha.gxt.widget.core.client.form.Radio; * */ public class SourceSelectionCard extends WizardCard { + + private static CSVImportWizardTDMessages msgs= GWT.create(CSVImportWizardTDMessages.class); + + private final FileSource fileSource = FileSource.INSTANCE; + private final WorkspaceSource workspaceSource = WorkspaceSource.INSTANCE; - protected final CSVImportSession importSession; - - final FileSource fileSource = FileSource.INSTANCE; - final WorkspaceSource workspaceSource = WorkspaceSource.INSTANCE; + private final CSVImportSession importSession; + + public SourceSelectionCard(final CSVImportSession importSession) { - super("CSV source selection", ""); + super(msgs.csvSourceSelection(), ""); this.importSession = importSession; // Default diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressBarUpdater.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressBarUpdater.java index b2d95ce..d7a3c74 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressBarUpdater.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressBarUpdater.java @@ -3,62 +3,73 @@ */ package org.gcube.portlets.user.td.csvimportwidget.client.progress; - import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.core.client.GWT; import com.sencha.gxt.widget.core.client.ProgressBar; /** - * Updates a {@link ProgressBar} progress and text based on {@link CSVImportProgressListener} events. + * Updates a {@link ProgressBar} progress and text based on + * {@link CSVImportProgressListener} events. * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it * */ public class FileUploadProgressBarUpdater implements FileUploadProgressListener { - - protected ProgressBar progressBar; - + + private ProgressBar progressBar; + private FileUploadProgressMessages msgs; + /** * Creates a new {@link ProgressBar} updater. - * @param progressBar the {@link ProgressBar} to update. + * + * @param progressBar + * the {@link ProgressBar} to update. */ public FileUploadProgressBarUpdater(ProgressBar progressBar) { + initMessages(); this.progressBar = progressBar; - this.progressBar.updateProgress(0, "Please Wait..."); + this.progressBar.updateProgress(0, msgs.pleaseWait()); + } + + protected void initMessages() { + msgs = GWT.create(FileUploadProgressMessages.class); } - /** * {@inheritDoc} */ public void operationComplete() { Log.info("File upload complete"); - progressBar.updateProgress(1, "File upload completed."); - + progressBar.updateProgress(1, msgs.fileUploadCompleted()); + } /** * {@inheritDoc} */ - public void operationFailed(Throwable caught, String reason, String failureDetails) { + public void operationFailed(Throwable caught, String reason, + String failureDetails) { Log.info("File upload failed"); - progressBar.updateText("File upload failed."); + progressBar.updateText(msgs.fileUploadFailed()); } public void operationInitializing() { Log.info("File upload inizializing"); - progressBar.updateProgress(0, "Initializing..."); + progressBar.updateProgress(0, msgs.initializing()); } public void operationUpdate(float elaborated) { - Log.info("File upload elaborated: "+elaborated); - if (elaborated>=0 && elaborated<1) { - Log.trace("progress "+elaborated); - int elab=new Float(elaborated*100).intValue(); - progressBar.updateProgress(elaborated,elab+"% Uploading..."); + Log.info("File upload elaborated: " + elaborated); + if (elaborated >= 0 && elaborated < 1) { + Log.trace("progress " + elaborated); + int elab = new Float(elaborated * 100).intValue(); + progressBar.updateProgress(elaborated, + String.valueOf(elab) + msgs.percUploading()); } - if (elaborated == 1) progressBar.updateProgress(1, "Completing..."); - + if (elaborated == 1) + progressBar.updateProgress(1, msgs.completing()); + } } diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressMessages.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressMessages.java new file mode 100644 index 0000000..71515ec --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressMessages.java @@ -0,0 +1,39 @@ +package org.gcube.portlets.user.td.csvimportwidget.client.progress; + +import com.google.gwt.i18n.client.Messages; + +/** + * + * @author giancarlo + * email: g.panichi@isti.cnr.it + * + */ +public interface FileUploadProgressMessages extends Messages { + + // + @DefaultMessage("Please Wait...") + String pleaseWait(); + + @DefaultMessage("File upload completed.") + String fileUploadCompleted(); + + @DefaultMessage("File Upload Failed") + String fileUploadFailedHead(); + + @DefaultMessage("File upload failed.") + String fileUploadFailed(); + + @DefaultMessage("Initializing...") + String initializing(); + + @DefaultMessage("% Uploading...") + String percUploading(); + + @DefaultMessage("Completing...") + String completing(); + + @DefaultMessage("Failed getting operation updates") + String failedGettingOperarionUpdateds(); + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressUpdater.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressUpdater.java index 53bf7d0..78c538e 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressUpdater.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressUpdater.java @@ -9,119 +9,127 @@ 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.core.shared.GWT; 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 CSVImportProgressListener}. + * This {@link Timer} retrieves {@link OperationProgress} from the specified + * {@link OperationProgressSource} with the scheduled interval. The retrieved + * information are spread to the subscribed {@link CSVImportProgressListener}. * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it * */ public class FileUploadProgressUpdater extends Timer { - protected ArrayList listeners = new ArrayList(); + private ArrayList listeners = new ArrayList(); + private static FileUploadProgressMessages msgs = GWT + .create(FileUploadProgressMessages.class); - /** * {@inheritDoc} */ @Override public void run() { Log.debug("requesting operation progress"); - TDGWTServiceAsync.INSTANCE.getFileUploadMonitor(new AsyncCallback() { + 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, + msgs.failedGettingOperarionUpdateds(), 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( + msgs.fileUploadFailedHead()), result + .getFailureReason(), result + .getFailureDetails()); + break; + case COMPLETED: + cancel(); + Log.debug("File Upload Completed"); + fireOperationComplete(); + break; + default: + break; + } + + } + + }); - - 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("File Upload Failed") ,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()+" ->
"; + + protected String getStack(Throwable e) { + String message = e.getLocalizedMessage() + " ->
"; Throwable c = e.getCause(); - if (c!=null) message += getStack(c); + 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 fireOperationInitializing() { + for (FileUploadProgressListener listener : listeners) + listener.operationInitializing(); } - protected void fireOperationComplete() - { - for (FileUploadProgressListener listener:listeners) listener.operationComplete(); + protected void fireOperationUpdate(float elaborated) { + for (FileUploadProgressListener listener : listeners) + listener.operationUpdate(elaborated); } - - protected void fireOperationFailed(Throwable caught, String failure, String failureDetails) - { - for (FileUploadProgressListener listener:listeners) listener.operationFailed(caught, failure, failureDetails); + + 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 CSVImportProgressListener} to this {@link FileUploadProgressUpdater}. - * @param listener the listener to add. + * Add a new {@link CSVImportProgressListener} to this + * {@link FileUploadProgressUpdater}. + * + * @param listener + * the listener to add. */ - public void addListener(FileUploadProgressListener listener) - { + public void addListener(FileUploadProgressListener listener) { listeners.add(listener); } /** - * Removes the specified {@link CSVImportProgressListener} from this {@link FileUploadProgressUpdater}. - * @param listener the listener to remove. + * Removes the specified {@link CSVImportProgressListener} from this + * {@link FileUploadProgressUpdater}. + * + * @param listener + * the listener to remove. */ - public void removeListener(FileUploadProgressListener listener) - { + public void removeListener(FileUploadProgressListener listener) { listeners.remove(listener); } } diff --git a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/CSVImportWizardTD.gwt.xml b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/CSVImportWizardTD.gwt.xml index 1ea35b2..2465911 100644 --- a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/CSVImportWizardTD.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/CSVImportWizardTD.gwt.xml @@ -2,6 +2,7 @@ + @@ -27,6 +28,26 @@ + + diff --git a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/Messages.properties b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/Messages.properties deleted file mode 100644 index c222555..0000000 --- a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/Messages.properties +++ /dev/null @@ -1,2 +0,0 @@ -sendButton = Send -nameField = Enter your name \ No newline at end of file diff --git a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/Messages_fr.properties b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/Messages_fr.properties deleted file mode 100644 index b4a7627..0000000 --- a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/Messages_fr.properties +++ /dev/null @@ -1,2 +0,0 @@ -sendButton = Envoyer -nameField = Entrez votre nom \ No newline at end of file diff --git a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressMessages.properties b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressMessages.properties new file mode 100644 index 0000000..37086aa --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressMessages.properties @@ -0,0 +1,8 @@ +pleaseWait = Please Wait... +fileUploadCompleted = File upload completed. +fileUploadFailedHead = File Upload Failed +fileUploadFailed = File upload failed. +initializing = Initializing... +percUploading = % Uploading... +completing = Completing... +failedGettingOperarionUpdateds = Failed getting operation updates diff --git a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressMessages_es.properties b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressMessages_es.properties new file mode 100644 index 0000000..f4bd4ed --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressMessages_es.properties @@ -0,0 +1,8 @@ +pleaseWait = Por Favor, Espera... +fileUploadCompleted = Carga de archivo completada. +fileUploadFailedHead = Carga de Archivo Fallido +fileUploadFailed = Carga de archivos fallido. +initializing = Inicialización... +percUploading = % Cargando... +completing = Completar... +failedGettingOperarionUpdateds = Error al recuperar información sobre la operación diff --git a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressMessages_it.properties b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressMessages_it.properties new file mode 100644 index 0000000..df91da3 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/progress/FileUploadProgressMessages_it.properties @@ -0,0 +1,8 @@ +pleaseWait = Attendere... +fileUploadCompleted = Caricamento file completato. +fileUploadFailedHead = Caricamento File Fallito +fileUploadFailed = Caricamento file fallito. +initializing = Inizzializazione... +percUploading = % Carimento... +completing = Completamento... +failedGettingOperarionUpdateds = Errore recuperando informazioni sull''operazione