From 5006b0c392448b4b3ee18c99ccf7d620c31493b4 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 16 Oct 2015 16:40:44 +0000 Subject: [PATCH] 915: TDM - Support the Spanish language Task-Url: https://support.d4science.org/issues/915 Updated Spanish Support git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-import-widget@119850 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../csvimportwidget/client/CSVConfigCard.java | 185 +++++++++-------- .../client/CSVErrorWindow.java | 110 +++++----- .../client/CSVImportWizardTDMessages.java | 175 +++++++++++++++- .../client/CSVTableDetailCard.java | 139 +++++++------ .../client/CSVWorkSpaceSelectionCard.java | 1 - .../csvimportwidget/client/CsvCheckPanel.java | 189 +++++++++--------- .../client/FileUploadPanel.java | 69 ++++--- .../client/csvgrid/CSVGrid.java | 20 +- .../client/csvgrid/CSVGridMessages.java | 25 +++ .../client/csvgrid/CSVGridView.java | 32 +-- .../CSVImportWizardTDMessages.properties | 62 ++++++ .../CSVImportWizardTDMessages_es.properties | 62 ++++++ .../CSVImportWizardTDMessages_it.properties | 62 ++++++ .../client/csvgrid/CSVGridMessages.properties | 4 + .../csvgrid/CSVGridMessages_es.properties | 4 + .../csvgrid/CSVGridMessages_it.properties | 5 + 16 files changed, 797 insertions(+), 347 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages.java create mode 100644 src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages.properties create mode 100644 src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages_es.properties create mode 100644 src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages_it.properties create mode 100644 src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages.properties create mode 100644 src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages_es.properties create mode 100644 src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages_it.properties diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVConfigCard.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVConfigCard.java index 1c801b0..7a97072 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVConfigCard.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVConfigCard.java @@ -10,6 +10,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVRowError; import org.gcube.portlets.user.td.gwtservice.shared.csv.CheckCSVSession; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.file.HeaderPresence; +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; @@ -54,36 +55,44 @@ import com.sencha.gxt.widget.core.client.tips.ToolTipConfig; * */ public class CSVConfigCard extends WizardCard { + private static CSVImportWizardTDMessages msgs= GWT.create(CSVImportWizardTDMessages.class); + private CommonMessages msgsCommon; + + private static final String DEFAULT_DELIMETER = ","; + private static final String DEFAULT_COMMENT = "#"; + private static final long ERRORLIMIT = 100; + private CSVImportSession csvImportSession; - protected static final String DEFAULT_DELIMETER = ","; - protected static final String DEFAULT_COMMENT = "#"; - protected static final long ERRORLIMIT = 100; - protected CSVImportSession csvImportSession; + private SimpleComboBox comboEncodings; + private SimpleComboBox comboHeader; + private TextField customDelimiterField; + private Radio radioOtherDelimiter; + private Radio radioCommaDelimiter; + private Radio radioSpaceDelimiter; + private Radio radioTabDelimiter; + private Radio radioSemicolonDelimiter; + private TextField commentField; + private CsvCheckPanel csvCheckPanel; - protected SimpleComboBox encodings; - protected SimpleComboBox header; - protected TextField customDelimiterField; - protected Radio otherDelimiter; - protected Radio commaDelimiter; - protected Radio spaceDelimiter; - protected Radio tabDelimiter; - protected Radio semicoloDelimiter; - protected TextField commentField; - protected CsvCheckPanel csvCheckPanel; + private CSVGrid gridCSVSample; - protected CSVGrid csvSample; + public CSVConfigCard(final CSVImportSession csvImportSession) { - super("CSV configuration", ""); + super(msgs.csvConfiguration(), ""); if (csvImportSession == null) { Log.error("CSVImportSession is null"); } this.csvImportSession = csvImportSession; - + initMessages(); FormPanel panel = createPanel(); setCenterWidget(panel,new MarginData(0)); } + + protected void initMessages(){ + msgsCommon = GWT.create(CommonMessages.class); + } protected FormPanel createPanel() { FormPanel panel = new FormPanel(); @@ -93,21 +102,21 @@ public class CSVConfigCard extends WizardCard { VerticalLayoutContainer content = new VerticalLayoutContainer(); panel.add(content); - encodings = new SimpleComboBox( + comboEncodings = new SimpleComboBox( new StringLabelProvider()); - encodings.setToolTip("The CSV file encoding"); - encodings.setTabIndex(0); - encodings.setEditable(false); - encodings.setForceSelection(true); - encodings.setTriggerAction(TriggerAction.ALL); - encodings.addSelectionHandler(new SelectionHandler() { + comboEncodings.setToolTip(msgs.comboEncodingsToolTip()); + comboEncodings.setTabIndex(0); + comboEncodings.setEditable(false); + comboEncodings.setForceSelection(true); + comboEncodings.setTriggerAction(TriggerAction.ALL); + comboEncodings.addSelectionHandler(new SelectionHandler() { public void onSelection(SelectionEvent event) { updateGrid(); } }); - content.add(new FieldLabel(encodings, "File encoding")); + content.add(new FieldLabel(comboEncodings, msgs.comboEncodingsLabel())); LabelProvider labelProvider = new LabelProvider() { @@ -116,39 +125,39 @@ public class CSVConfigCard extends WizardCard { } }; - header = new SimpleComboBox(labelProvider); - header.setToolTip("The CSV file header"); - header.setTabIndex(0); - header.setEditable(false); - header.setForceSelection(true); - header.setTriggerAction(TriggerAction.ALL); + comboHeader = new SimpleComboBox(labelProvider); + comboHeader.setToolTip(msgs.comboHeaderToolTip()); + comboHeader.setTabIndex(0); + comboHeader.setEditable(false); + comboHeader.setForceSelection(true); + comboHeader.setTriggerAction(TriggerAction.ALL); for (HeaderPresence headerPresence : HeaderPresence.values()) - header.add(headerPresence); - header.setValue(HeaderPresence.NONE); - header.addSelectionHandler(new SelectionHandler() { + comboHeader.add(headerPresence); + comboHeader.setValue(HeaderPresence.NONE); + comboHeader.addSelectionHandler(new SelectionHandler() { public void onSelection(SelectionEvent event) { updateGrid(); } }); - content.add(new FieldLabel(header, "Header")); + content.add(new FieldLabel(comboHeader, msgs.comboHeaderLabel())); - commaDelimiter = new Radio(); - commaDelimiter.setBoxLabel("Comma"); - commaDelimiter.setValue(true); + radioCommaDelimiter = new Radio(); + radioCommaDelimiter.setBoxLabel(msgs.radioCommaDelimiterLabel()); + radioCommaDelimiter.setValue(true); - spaceDelimiter = new Radio(); - spaceDelimiter.setBoxLabel("Space"); + radioSpaceDelimiter = new Radio(); + radioSpaceDelimiter.setBoxLabel(msgs.radioSpaceDelimiterLabel()); - tabDelimiter = new Radio(); - tabDelimiter.setBoxLabel("Tab"); + radioTabDelimiter = new Radio(); + radioTabDelimiter.setBoxLabel(msgs.radioTabDelimiterLabel()); - semicoloDelimiter = new Radio(); - semicoloDelimiter.setBoxLabel("Semicolon"); + radioSemicolonDelimiter = new Radio(); + radioSemicolonDelimiter.setBoxLabel(msgs.radioSemicolonDelimiterLabel()); - otherDelimiter = new Radio(); - otherDelimiter.setBoxLabel("Other delimiter"); + radioOtherDelimiter = new Radio(); + radioOtherDelimiter.setBoxLabel(msgs.radioOtherDelimiterLabel()); customDelimiterField = new TextField(); customDelimiterField.setEnabled(false); @@ -161,10 +170,10 @@ public class CSVConfigCard extends WizardCard { public void onValueChange(ValueChangeEvent event) { customDelimiterField.validate(); - if (otherDelimiter.getValue() + if (radioOtherDelimiter.getValue() && !customDelimiterField.isValid()){ UtilsGXT3 - .alert("Attention","Insert a valid delimiter else comma is used!"); + .alert(msgsCommon.attention(),msgs.insertAvalidDelimiterElseCommaIsUsed()); } updateGrid(); @@ -172,11 +181,11 @@ public class CSVConfigCard extends WizardCard { } }); ToggleGroup delimitersGroup = new ToggleGroup(); - delimitersGroup.add(commaDelimiter); - delimitersGroup.add(spaceDelimiter); - delimitersGroup.add(tabDelimiter); - delimitersGroup.add(semicoloDelimiter); - delimitersGroup.add(otherDelimiter); + delimitersGroup.add(radioCommaDelimiter); + delimitersGroup.add(radioSpaceDelimiter); + delimitersGroup.add(radioTabDelimiter); + delimitersGroup.add(radioSemicolonDelimiter); + delimitersGroup.add(radioOtherDelimiter); delimitersGroup .addValueChangeHandler(new ValueChangeHandler>() { @@ -184,18 +193,18 @@ public class CSVConfigCard extends WizardCard { public void onValueChange( ValueChangeEvent> event) { - customDelimiterField.setEnabled(otherDelimiter + customDelimiterField.setEnabled(radioOtherDelimiter .getValue()); - if (!otherDelimiter.getValue()) + if (!radioOtherDelimiter.getValue()) customDelimiterField.clearInvalid(); else customDelimiterField.validate(); - if (otherDelimiter.getValue() + if (radioOtherDelimiter.getValue() && !customDelimiterField.isValid()){ UtilsGXT3 - .alert("Attention","Insert a valid delimiter else comma is used!"); + .alert(msgsCommon.attention(),msgs.insertAvalidDelimiterElseCommaIsUsed()); } updateGrid(); @@ -203,19 +212,19 @@ public class CSVConfigCard extends WizardCard { }); HorizontalPanel delimitersPanel = new HorizontalPanel(); - delimitersPanel.add(commaDelimiter); - delimitersPanel.add(spaceDelimiter); - delimitersPanel.add(tabDelimiter); - delimitersPanel.add(semicoloDelimiter); - delimitersPanel.add(otherDelimiter); + delimitersPanel.add(radioCommaDelimiter); + delimitersPanel.add(radioSpaceDelimiter); + delimitersPanel.add(radioTabDelimiter); + delimitersPanel.add(radioSemicolonDelimiter); + delimitersPanel.add(radioOtherDelimiter); delimitersPanel.add(customDelimiterField); new ToolTip(delimitersPanel, new ToolTipConfig( - "The delimiter use to delimit the CSV fields")); - content.add(new FieldLabel(delimitersPanel, "Delimiter")); + msgs.delimitersPanelToolTip())); + content.add(new FieldLabel(delimitersPanel, msgs.delimitersPanelLabel())); commentField = new TextField(); - commentField.setToolTip("The character used as comment line prefix"); + commentField.setToolTip(msgs.commentFieldToolTip()); commentField.setValue(DEFAULT_COMMENT); commentField.setAllowBlank(false); commentField.getValidators().add(new MaxLengthValidator(1)); @@ -228,10 +237,10 @@ public class CSVConfigCard extends WizardCard { } }); - content.add(new FieldLabel(commentField, "Comment")); + content.add(new FieldLabel(commentField, msgs.commentFieldLabel())); - csvSample = new CSVGrid(); - content.add(csvSample, new VerticalLayoutData(1, -1)); + gridCSVSample = new CSVGrid(); + content.add(gridCSVSample, new VerticalLayoutData(1, -1)); content.add(new HTML("
")); @@ -278,8 +287,8 @@ public class CSVConfigCard extends WizardCard { SessionExpiredType.EXPIREDONSERVER)); } else { UtilsGXT3 - .alert("An error occured checking the file", - "Please retry, if the error perstists change the CSV configuration"); + .alert(msgs.anErrorOccuredCheckingTheFileHead(), + msgs.anErrorOccuredCheckingTheFile()); } } @@ -306,15 +315,15 @@ public class CSVConfigCard extends WizardCard { resetCheckMessage(); - csvSample.mask("Updating..."); + gridCSVSample.mask(msgs.gridCSVSampleMask()); GWT.log("updating CSV config"); - HeaderPresence headerPresence = header.getCurrentValue(); + HeaderPresence headerPresence = comboHeader.getCurrentValue(); char delimiter = getSelectedDelimiter(); - String encoding = encodings.getCurrentValue(); + String encoding = comboEncodings.getCurrentValue(); char commentChar = commentField.getValue().charAt(0); TDGWTServiceAsync.INSTANCE.configureCSVParser(encoding, headerPresence, @@ -330,8 +339,8 @@ public class CSVConfigCard extends WizardCard { Log.error("Failed updating CSV config", caught); setEnableNextButton(false); UtilsGXT3 - .alert("An error occured checking the file", - "Please retry, if the error perstists change the CSV configuration"); + .alert(msgs.anErrorOccuredCheckingTheFileHead(), + msgs.anErrorOccuredCheckingTheFile()); } } @@ -345,8 +354,8 @@ public class CSVConfigCard extends WizardCard { Log.info("Column HEADER: " + name); // csvImportSession.getId() - csvSample.configureColumns(result); - csvSample.unmask(); + gridCSVSample.configureColumns(result); + gridCSVSample.unmask(); setEnableNextButton(false); @@ -356,7 +365,7 @@ public class CSVConfigCard extends WizardCard { } protected char getSelectedDelimiter() { - if (otherDelimiter.getValue()) { + if (radioOtherDelimiter.getValue()) { String custom=customDelimiterField.getValue(); if(custom!=null && !custom.isEmpty()){ return custom.charAt(0); @@ -365,16 +374,16 @@ public class CSVConfigCard extends WizardCard { } } else { - if (commaDelimiter.getValue()) { + if (radioCommaDelimiter.getValue()) { return ','; } else { - if (spaceDelimiter.getValue()) { + if (radioSpaceDelimiter.getValue()) { return ' '; } else { - if (tabDelimiter.getValue()) { + if (radioTabDelimiter.getValue()) { return '\t'; } else { - if (semicoloDelimiter.getValue()) { + if (radioSemicolonDelimiter.getValue()) { return ';'; } } @@ -388,7 +397,7 @@ public class CSVConfigCard extends WizardCard { public void setup() { setEnableBackButton(false); setEnableNextButton(false); - encodings.focus(); + comboEncodings.focus(); TDGWTServiceAsync.INSTANCE .getAvailableCharset(new AsyncCallback() { @@ -400,9 +409,9 @@ public class CSVConfigCard extends WizardCard { + result.getDefaultCharset()); for (String charset : result.getCharsetList()) - encodings.add(charset); + comboEncodings.add(charset); - encodings.setValue(result.getDefaultCharset()); + comboEncodings.setValue(result.getDefaultCharset()); updateGrid(); } @@ -418,8 +427,8 @@ public class CSVConfigCard extends WizardCard { SessionExpiredType.EXPIREDONSERVER)); } else { Log.error("Error loading charset list", caught); - showErrorAndHide("Error loading charset list", - "Error loading charset list", caught.getLocalizedMessage(), caught); + showErrorAndHide(msgs.errorLoadingCharsetListHead(), + msgs.errorLoadingCharsetList(), caught.getLocalizedMessage(), caught); } } }); @@ -461,7 +470,7 @@ public class CSVConfigCard extends WizardCard { @Override public void dispose() { csvImportSession - .setColumnToImportMask(csvSample.getImportColumnsMask()); + .setColumnToImportMask(gridCSVSample.getImportColumnsMask()); } } diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVErrorWindow.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVErrorWindow.java index 3e2de66..130c3ac 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVErrorWindow.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVErrorWindow.java @@ -4,8 +4,6 @@ import java.util.ArrayList; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVRowError; - - import com.google.gwt.core.client.GWT; import com.sencha.gxt.core.client.ValueProvider; import com.sencha.gxt.data.shared.ListStore; @@ -22,70 +20,80 @@ import com.sencha.gxt.widget.core.client.grid.Grid; /** * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it * */ public class CSVErrorWindow extends Window { - - private static final CSVRowErrorProperties props = GWT.create(CSVRowErrorProperties.class); - - protected Grid grid; - protected ListStore store; - - public CSVErrorWindow() - { - setHeadingText("CSV error details"); + + private static final CSVRowErrorProperties props = GWT + .create(CSVRowErrorProperties.class); + private CSVImportWizardTDMessages msgs; + + private Grid gridErrors; + private ListStore storeGridErrors; + + public CSVErrorWindow() { + initMessages(); + setHeadingText(msgs.csvErrorWindowHead()); setModal(true); setBlinkModal(true); setWidth(600); setHeight(350); - + createGrid(); - add(grid); - - TextButton close = new TextButton("Close"); - close.addSelectHandler(new SelectHandler() { - - + add(gridErrors); + + TextButton btnClose = new TextButton(msgs.btnCloseText()); + btnClose.addSelectHandler(new SelectHandler() { + public void onSelect(SelectEvent event) { hide(); } }); - - addButton(close); + + addButton(btnClose); setButtonAlign(BoxLayoutPack.CENTER); } - - protected void createGrid() - { - ArrayList> columns = new ArrayList>(); - - columns.add(new ColumnConfig(props.lineNumber(), 30, "# line")); - columns.add(new ColumnConfig(props.lineValue(), 60, "Line")); - columns.add(new ColumnConfig(props.errorDescription(), 160, "Error")); - - ColumnModel columnModel = new ColumnModel(columns); - - store = new ListStore(props.id()); - - grid = new Grid(store, columnModel); - grid.getView().setForceFit(true); - } - - public void updateGrid(ArrayList errors) - { - store.clear(); - store.addAll(errors); - } - - protected interface CSVRowErrorProperties extends PropertyAccess { - - ModelKeyProvider id(); - ValueProvider lineNumber(); - ValueProvider lineValue(); - ValueProvider errorDescription(); + protected void initMessages() { + msgs = GWT.create(CSVImportWizardTDMessages.class); + } + + protected void createGrid() { + ArrayList> columns = new ArrayList>(); + + columns.add(new ColumnConfig(props.lineNumber(), + 30, msgs.gridErrorColumnNLine())); + columns.add(new ColumnConfig(props.lineValue(), + 60, msgs.gridErrorCololumnLine())); + columns.add(new ColumnConfig(props + .errorDescription(), 160, msgs.gridErrorCololumnError())); + + ColumnModel columnModel = new ColumnModel( + columns); + + storeGridErrors = new ListStore(props.id()); + + gridErrors = new Grid(storeGridErrors, columnModel); + gridErrors.getView().setForceFit(true); + } + + public void updateGrid(ArrayList errors) { + storeGridErrors.clear(); + storeGridErrors.addAll(errors); + } + + protected interface CSVRowErrorProperties extends + PropertyAccess { + + ModelKeyProvider id(); + + ValueProvider lineNumber(); + + ValueProvider lineValue(); + + ValueProvider errorDescription(); } } 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 index 16df063..89af9b0 100644 --- 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 @@ -1,6 +1,7 @@ package org.gcube.portlets.user.td.csvimportwidget.client; import com.google.gwt.i18n.client.Messages; +import com.sencha.gxt.widget.core.client.form.FieldLabel.FieldLabelAppearance; /** * @@ -22,8 +23,180 @@ public interface CSVImportWizardTDMessages extends Messages { @DefaultMessage("Workspace Selection") String workspaceSelection(); - @DefaultMessage("Error retrieving the file from the workspace.") + @DefaultMessage("CSV Configuration") + String csvConfiguration(); + + @DefaultMessage("Error retrieving the file from the workspace!") String errorRetrievingTheFileFromWorkspace(); + @DefaultMessage("The CSV file encoding") + String comboEncodingsToolTip(); + + @DefaultMessage("File encoding") + String comboEncodingsLabel(); + + @DefaultMessage("The CSV file header") + String comboHeaderToolTip(); + + @DefaultMessage("Header") + String comboHeaderLabel(); + + @DefaultMessage("Comma") + String radioCommaDelimiterLabel(); + + @DefaultMessage("Space") + String radioSpaceDelimiterLabel(); + + @DefaultMessage("Tab") + String radioTabDelimiterLabel(); + + @DefaultMessage("Semicolon") + String radioSemicolonDelimiterLabel(); + + @DefaultMessage("Other delimiter") + String radioOtherDelimiterLabel(); + + @DefaultMessage("Insert a valid delimiter else comma is used!") + String insertAvalidDelimiterElseCommaIsUsed(); + + @DefaultMessage("The delimiter use to delimit the CSV fields") + String delimitersPanelToolTip(); + + @DefaultMessage("Delimiter") + String delimitersPanelLabel(); + + @DefaultMessage("The character used as comment line prefix") + String commentFieldToolTip(); + + @DefaultMessage("Comment") + String commentFieldLabel(); + + @DefaultMessage("An error occured checking the file") + String anErrorOccuredCheckingTheFileHead(); + + @DefaultMessage("Please retry, if the error perstists change the CSV configuration!") + String anErrorOccuredCheckingTheFile(); + + @DefaultMessage("Updating...") + String gridCSVSampleMask(); + + @DefaultMessage("Error loading charset list") + String errorLoadingCharsetListHead(); + + @DefaultMessage("Error loading charset list!") + String errorLoadingCharsetList(); + + @DefaultMessage("Tabular Resource Detail") + String tabularResourceDetail(); + + @DefaultMessage("Details") + String csvTableDetailCardFormHeader(); + + @DefaultMessage("Information") + String fieldSetInformationHead(); + + @DefaultMessage("Enter a name...") + String fieldNameEmptyText(); + + @DefaultMessage("Name") + String fieldNameLabel(); + + @DefaultMessage("Enter a description...") + String txtAreaDescriptionEmptyText(); + + @DefaultMessage("Description") + String txtAreaDescriptionLabel(); + + @DefaultMessage("Enter rights...") + String txtAreaRightsEmptyText(); + + @DefaultMessage("Rights") + String txtAreaRightsLabel(); + + @DefaultMessage("Valid From") + String fieldValidFromLabel(); + + @DefaultMessage("Valid Until To") + String fieldValidUntilToLabel(); + + @DefaultMessage("Licence") + String comboLicencesLabel(); + + @DefaultMessage("Error retrieving licences!") + String errorRetrievingLicences(); + + @DefaultMessage("Fill in name field!") + String fillInNameField(); + + @DefaultMessage("Fill in description field!") + String fillInDescriptionField(); + + @DefaultMessage("Fill in rights field!") + String fillInRightsField(); + + @DefaultMessage("Valid From field is higher than Valid Until To field!") + String validFromFieldIsHigherThanValidUntilToField(); + + @DefaultMessage("Check configuration") + String btnCheckConfigurationText(); + + @DefaultMessage("Skip invalid lines") + String chBoxSkipInvalidLabel(); + + @DefaultMessage("Failed (more than {0} errors)") + String failedMoreThanNumberErrors(int errorlimit); + + @DefaultMessage("Failed ({0} errors)") + String failedErrors(int size); + + @DefaultMessage("Check the configuration before submit it") + String checkTheConfigurationBeforeSubmit(); + + @DefaultMessage("Checking the configuration...") + String checkingTheConfiguration(); + + @DefaultMessage("Click to obtain more information") + String clickToObtainMoreInformation(); + + @DefaultMessage("Failed") + String failed(); + + @DefaultMessage("Correct.") + String correct(); + + @DefaultMessage("Close") + String btnCloseText(); + + @DefaultMessage("CSV error details") + String csvErrorWindowHead(); + + @DefaultMessage("# line") + String gridErrorColumnNLine(); + + @DefaultMessage("Line") + String gridErrorCololumnLine(); + + @DefaultMessage("Error") + String gridErrorCololumnError(); + + @DefaultMessage("Select the csv file to import") + FieldLabelAppearance fUpFieldLabel(); + + @DefaultMessage("Upload") + String btnUploadText(); + + @DefaultMessage("Cancel") + String btnCancelText(); + + @DefaultMessage("CSV file missing") + String csvFileMissingHead(); + + @DefaultMessage("Please specify a CSV file") + String csvFileMissing(); + + @DefaultMessage("Error uploading the csv file") + String errorUploadingCSVFileHead(); + + } diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVTableDetailCard.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVTableDetailCard.java index b36e367..c9c93c3 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVTableDetailCard.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CSVTableDetailCard.java @@ -12,6 +12,7 @@ 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.gwtservice.shared.licenses.LicenceData; import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; +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; @@ -54,9 +55,11 @@ import com.sencha.gxt.widget.core.client.form.TextField; * */ public class CSVTableDetailCard extends WizardCard { - - private final String TABLEDETAILPANELWIDTH = "100%"; - private final String TABLEDETAILPANELHEIGHT = "100%"; + + private static final String TABLEDETAILPANELWIDTH = "100%"; + private static final String TABLEDETAILPANELHEIGHT = "100%"; + private static CSVImportWizardTDMessages msgs= GWT.create(CSVImportWizardTDMessages.class); + private CommonMessages msgsCommon; private CSVImportSession importSession; private CSVTableDetailCard thisCard; @@ -64,23 +67,24 @@ public class CSVTableDetailCard extends WizardCard { private VerticalLayoutContainer p; private VerticalPanel tableDetailPanel; - private TextField name; - private TextArea description; - private TextArea rights; - private DateField validFrom; - private DateField validUntilTo; + private TextField fieldName; + private TextArea txtAreaDescription; + private TextArea txtAreaRights; + private DateField fieldValidFrom; + private DateField fieldValidUntilTo; private TabResource detail; private ListLoader> loader; private ComboBox comboLicences; + public CSVTableDetailCard(final CSVImportSession importSession) { - super("Tabular Resource Detail", ""); - + super(msgs.tabularResourceDetail(), ""); this.importSession = importSession; thisCard = this; - + initMessages(); + tableDetailPanel = new VerticalPanel(); tableDetailPanel.setSpacing(4); @@ -88,43 +92,43 @@ public class CSVTableDetailCard extends WizardCard { tableDetailPanel.setHeight(TABLEDETAILPANELHEIGHT); FramedPanel form = new FramedPanel(); - form.setHeadingText("Details"); + form.setHeadingText(msgs.csvTableDetailCardFormHeader()); - FieldSet fieldSet = new FieldSet(); - fieldSet.setHeadingText("Information"); - fieldSet.setCollapsible(false); + FieldSet fieldSetInformation = new FieldSet(); + fieldSetInformation.setHeadingText(msgs.fieldSetInformationHead()); + fieldSetInformation.setCollapsible(false); - form.add(fieldSet, new MarginData(new Margins(0))); + form.add(fieldSetInformation, new MarginData(new Margins(0))); p = new VerticalLayoutContainer(); - fieldSet.add(p, new MarginData(new Margins(0))); + fieldSetInformation.add(p, new MarginData(new Margins(0))); - name = new TextField(); - name.setAllowBlank(false); - name.setEmptyText("Enter a name..."); - name.setValue(importSession.getLocalFileName()); - p.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1)); + fieldName = new TextField(); + fieldName.setAllowBlank(false); + fieldName.setEmptyText(msgs.fieldNameEmptyText()); + fieldName.setValue(importSession.getLocalFileName()); + p.add(new FieldLabel(fieldName, msgs.fieldNameLabel()), new VerticalLayoutData(1, -1)); - description = new TextArea(); - description.setAllowBlank(false); - description.setEmptyText("Enter a description..."); - description.setValue("File CSV"); - p.add(new FieldLabel(description, "Description"), + txtAreaDescription = new TextArea(); + txtAreaDescription.setAllowBlank(false); + txtAreaDescription.setEmptyText(msgs.txtAreaDescriptionEmptyText()); + txtAreaDescription.setValue("CSV"); + p.add(new FieldLabel(txtAreaDescription, msgs.txtAreaDescriptionLabel()), new VerticalLayoutData(1, -1)); - rights = new TextArea(); - rights.setEmptyText("Enter rights..."); - rights.setAllowBlank(false); - p.add(new FieldLabel(rights, "Rights"), new VerticalLayoutData(1, -1)); + txtAreaRights = new TextArea(); + txtAreaRights.setEmptyText(msgs.txtAreaRightsEmptyText()); + txtAreaRights.setAllowBlank(false); + p.add(new FieldLabel(txtAreaRights, msgs.txtAreaRightsLabel()), new VerticalLayoutData(1, -1)); - validFrom = new DateField(); - validFrom.setValue(new Date()); - p.add(new FieldLabel(validFrom, "Valid From"), new VerticalLayoutData( + fieldValidFrom = new DateField(); + fieldValidFrom.setValue(new Date()); + p.add(new FieldLabel(fieldValidFrom, msgs.fieldValidFromLabel()), new VerticalLayoutData( 1, -1)); - validUntilTo = new DateField(); - p.add(new FieldLabel(validUntilTo, "Valid Until To"), + fieldValidUntilTo = new DateField(); + p.add(new FieldLabel(fieldValidUntilTo, msgs.fieldValidUntilToLabel()), new VerticalLayoutData(1, -1)); // Combo Licences @@ -174,7 +178,7 @@ public class CSVTableDetailCard extends WizardCard { Log.trace("Combo Licence created"); // / - p.add(new FieldLabel(comboLicences, "Licence"), new VerticalLayoutData( + p.add(new FieldLabel(comboLicences, msgs.comboLicencesLabel()), new VerticalLayoutData( 1, -1)); tableDetailPanel.add(form); @@ -182,6 +186,11 @@ public class CSVTableDetailCard extends WizardCard { setCenterWidget(tableDetailPanel, new MarginData(0)); } + + protected void initMessages(){ + msgsCommon = GWT.create(CommonMessages.class); + } + protected void loadData(ListLoadConfig loadConfig, final AsyncCallback> callback) { @@ -197,8 +206,8 @@ public class CSVTableDetailCard extends WizardCard { } else { Log.error("load combo failure:" + caught.getLocalizedMessage()); - showErrorAndHide("Error", - "Error retrieving licences.", + showErrorAndHide(msgsCommon.error(), + msgs.errorRetrievingLicences(), caught.getLocalizedMessage(), caught); } callback.onFailure(caught); @@ -257,30 +266,30 @@ public class CSVTableDetailCard extends WizardCard { } }; - if (name.getValue() == null || name.getValue().isEmpty() - || !name.isValid()) { - d = new AlertMessageBox("Attention!", "Fill in name field"); + if (fieldName.getValue() == null || fieldName.getValue().isEmpty() + || !fieldName.isValid()) { + d = new AlertMessageBox(msgsCommon.attention(), msgs.fillInNameField()); d.addHideHandler(hideHandler); d.show(); } else { - if (description.getValue() == null - || description.getValue().isEmpty() - || !description.isValid()) { - d = new AlertMessageBox("Attention!", - "Fill in description field"); + if (txtAreaDescription.getValue() == null + || txtAreaDescription.getValue().isEmpty() + || !txtAreaDescription.isValid()) { + d = new AlertMessageBox(msgsCommon.attention(), + msgs.fillInDescriptionField()); d.addHideHandler(hideHandler); d.show(); } else { - if (rights.getValue() == null || rights.getValue().isEmpty() - || !rights.isValid()) { - d = new AlertMessageBox("Attention!", - "Fill in rights field"); + if (txtAreaRights.getValue() == null || txtAreaRights.getValue().isEmpty() + || !txtAreaRights.isValid()) { + d = new AlertMessageBox(msgsCommon.attention(), + msgs.fillInRightsField()); d.addHideHandler(hideHandler); d.show(); } else { - name.setReadOnly(true); - description.setReadOnly(true); - rights.setReadOnly(true); + fieldName.setReadOnly(true); + txtAreaDescription.setReadOnly(true); + txtAreaRights.setReadOnly(true); goNext(); } } @@ -290,19 +299,19 @@ public class CSVTableDetailCard extends WizardCard { protected void goNext() { try { detail = new TabResource(); - detail.setName(name.getCurrentValue()); - detail.setDescription(description.getCurrentValue()); - detail.setRight(rights.getCurrentValue()); - detail.setValidFrom(validFrom.getCurrentValue()); - detail.setValidUntilTo(validUntilTo.getCurrentValue()); + detail.setName(fieldName.getCurrentValue()); + detail.setDescription(txtAreaDescription.getCurrentValue()); + detail.setRight(txtAreaRights.getCurrentValue()); + detail.setValidFrom(fieldValidFrom.getCurrentValue()); + detail.setValidUntilTo(fieldValidUntilTo.getCurrentValue()); - if (validFrom.getCurrentValue() != null - && validUntilTo.getCurrentValue() != null - && validFrom.getCurrentValue().compareTo( - validUntilTo.getCurrentValue()) > 0) { + if (fieldValidFrom.getCurrentValue() != null + && fieldValidUntilTo.getCurrentValue() != null + && fieldValidFrom.getCurrentValue().compareTo( + fieldValidUntilTo.getCurrentValue()) > 0) { Log.debug("Attention Valid From field is higher than Valid Until To field"); - AlertMessageBox d = new AlertMessageBox("Attention!", - "Valid From field is higher than Valid Until To field"); + AlertMessageBox d = new AlertMessageBox(msgsCommon.attention(), + msgs.validFromFieldIsHigherThanValidUntilToField()); d.addHideHandler(new HideHandler() { public void onHide(HideEvent event) { 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 4146b83..4f6afa2 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 @@ -51,7 +51,6 @@ public class CSVWorkSpaceSelectionCard extends WizardCard { super(msgs.csvImportFromWorkspace(), ""); this.importSession = importSession; thisCard = this; - initMessages(); p = new VerticalLayoutContainer(); diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CsvCheckPanel.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CsvCheckPanel.java index a3edf1e..4daa6d6 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CsvCheckPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/CsvCheckPanel.java @@ -2,10 +2,10 @@ package org.gcube.portlets.user.td.csvimportwidget.client; import java.util.ArrayList; - import org.gcube.portlets.user.td.csvimportwidget.client.dataresource.ResourceBundle; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVRowError; +import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.user.client.ui.Anchor; @@ -21,170 +21,173 @@ import com.sencha.gxt.widget.core.client.tips.ToolTipConfig; /** * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it * */ public class CsvCheckPanel extends VerticalPanel { - - protected static final int ERRORLIMIT = 100; - - protected static final Image successImage = new Image(ResourceBundle.INSTANCE.csvCheckSuccess()); - protected static final Image failureImage = new Image(ResourceBundle.INSTANCE.csvCheckFailure()); - protected static final Image informationImage = new Image(ResourceBundle.INSTANCE.information()); - protected static final Image loadingImage = new Image(ResourceBundle.INSTANCE.loading()); - - protected CardLayoutContainer messagePanel; - - protected HorizontalPanel checkMessagePanel; - protected HorizontalPanel failureMessagePanel; - protected HorizontalPanel successMessagePanel; - protected HorizontalPanel infoMessagePanel; - - protected TextButton checkConfiguration; - protected TextButton showErrorButton; - protected CheckBox skipInvalidCheckBox; - protected Anchor errorAnchor; - - protected CSVErrorWindow errorWindow = new CSVErrorWindow(); - - public CsvCheckPanel() - { + + private static final int ERRORLIMIT = 100; + + private static final Image successImage = new Image( + ResourceBundle.INSTANCE.csvCheckSuccess()); + private static final Image failureImage = new Image( + ResourceBundle.INSTANCE.csvCheckFailure()); + private static final Image informationImage = new Image( + ResourceBundle.INSTANCE.information()); + private static final Image loadingImage = new Image( + ResourceBundle.INSTANCE.loading()); + + private CardLayoutContainer messagePanel; + + private HorizontalPanel checkMessagePanel; + private HorizontalPanel failureMessagePanel; + private HorizontalPanel successMessagePanel; + private HorizontalPanel infoMessagePanel; + + private TextButton btnCheckConfiguration; + private CheckBox chBoxSkipInvalid; + private Anchor errorAnchor; + + private CSVErrorWindow errorWindow = new CSVErrorWindow(); + + private CSVImportWizardTDMessages msgs; + + public CsvCheckPanel() { + initMessages(); + setSpacing(2); - + VerticalPanel checkPanel = new VerticalPanel(); checkPanel.setSpacing(6); - - checkConfiguration = new TextButton("Check configuration"); - checkPanel.add(checkConfiguration); - + + btnCheckConfiguration = new TextButton(msgs.btnCheckConfigurationText()); + checkPanel.add(btnCheckConfiguration); + messagePanel = createMessagesPanel(); checkPanel.add(messagePanel); - + add(checkPanel); - + HorizontalPanel skipPanel = new HorizontalPanel(); skipPanel.setSpacing(4); - - skipInvalidCheckBox = new CheckBox(); - skipInvalidCheckBox.setBoxLabel("Skip invalid lines"); - skipPanel.add(skipInvalidCheckBox); + + chBoxSkipInvalid = new CheckBox(); + chBoxSkipInvalid.setBoxLabel(msgs.chBoxSkipInvalidLabel()); + skipPanel.add(chBoxSkipInvalid); add(skipPanel); - + setActiveInfoPanel(); } + protected void initMessages() { + msgs = GWT.create(CSVImportWizardTDMessages.class); + } + /** * @return */ public TextButton getCheckConfiguration() { - return checkConfiguration; + return btnCheckConfiguration; } /** * @return the skipInvalidCheckBox */ public CheckBox getSkipInvalidCheckBox() { - return skipInvalidCheckBox; + return chBoxSkipInvalid; } - protected CardLayoutContainer createMessagesPanel() - { + protected CardLayoutContainer createMessagesPanel() { CardLayoutContainer messagesPanel = new CardLayoutContainer(); - + infoMessagePanel = createInfoPanel(); messagesPanel.add(infoMessagePanel); - + checkMessagePanel = createCheckPanel(); messagesPanel.add(checkMessagePanel); - + failureMessagePanel = createFailurePanel(); messagesPanel.add(failureMessagePanel); - + successMessagePanel = createSuccessPanel(); messagesPanel.add(successMessagePanel); - + return messagesPanel; } - - public void setActiveInfoPanel() - { + + public void setActiveInfoPanel() { messagePanel.setActiveWidget(infoMessagePanel); - skipInvalidCheckBox.setVisible(false); + chBoxSkipInvalid.setVisible(false); } - - public void setActiveCheckingPanel() - { + + public void setActiveCheckingPanel() { messagePanel.setActiveWidget(checkMessagePanel); - skipInvalidCheckBox.setVisible(false); + chBoxSkipInvalid.setVisible(false); } - - public void setActiveSuccess() - { + + public void setActiveSuccess() { messagePanel.setActiveWidget(successMessagePanel); - skipInvalidCheckBox.setVisible(false); + chBoxSkipInvalid.setVisible(false); } - - public void setActiveFailure(ArrayList errors) - { - if (errors.size() >= ERRORLIMIT) errorAnchor.setHTML("Failed (more than "+ERRORLIMIT+" errors)"); - else errorAnchor.setHTML("Failed ("+errors.size()+" errors)"); - + + public void setActiveFailure(ArrayList errors) { + if (errors.size() >= ERRORLIMIT) + errorAnchor.setHTML(msgs.failedMoreThanNumberErrors(ERRORLIMIT)); + else + errorAnchor.setHTML(msgs.failedErrors(errors.size())); + errorWindow.updateGrid(errors); messagePanel.setActiveWidget(failureMessagePanel); - skipInvalidCheckBox.setVisible(true); - skipInvalidCheckBox.setValue(false); - + chBoxSkipInvalid.setVisible(true); + chBoxSkipInvalid.setValue(false); + } - - protected HorizontalPanel createInfoPanel() - { + + protected HorizontalPanel createInfoPanel() { HorizontalPanel infoPanel = new HorizontalPanel(); infoPanel.setSpacing(3); infoPanel.add(informationImage); - HTML message = new HTML("Check the configuration before submit it"); + HTML message = new HTML(msgs.checkTheConfigurationBeforeSubmit()); infoPanel.add(message); return infoPanel; } - - protected HorizontalPanel createCheckPanel() - { + + protected HorizontalPanel createCheckPanel() { HorizontalPanel checkPanel = new HorizontalPanel(); checkPanel.setSpacing(3); checkPanel.add(loadingImage); - checkPanel.add(new HTML("Checking the configuration...")); + checkPanel.add(new HTML(msgs.checkingTheConfiguration())); return checkPanel; } - - protected HorizontalPanel createFailurePanel() - { + + protected HorizontalPanel createFailurePanel() { HorizontalPanel failurePanel = new HorizontalPanel(); failurePanel.setSpacing(3); - new ToolTip(failurePanel, new ToolTipConfig("Click to obtain more information")); - + new ToolTip(failurePanel, new ToolTipConfig( + msgs.clickToObtainMoreInformation())); + failurePanel.add(failureImage); - - errorAnchor = new Anchor("Failed"); - + + errorAnchor = new Anchor(msgs.failed()); + errorAnchor.addClickHandler(new ClickHandler() { - - + public void onClick(ClickEvent event) { errorWindow.show(); } }); - + failurePanel.add(errorAnchor); - + return failurePanel; } - - protected HorizontalPanel createSuccessPanel() - { + + protected HorizontalPanel createSuccessPanel() { HorizontalPanel successPanel = new HorizontalPanel(); successPanel.setSpacing(3); successPanel.add(successImage); - successPanel.add(new HTML("Correct.")); + successPanel.add(new HTML(msgs.correct())); return successPanel; } } diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/FileUploadPanel.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/FileUploadPanel.java index 87bab9b..1fe8066 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/FileUploadPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/FileUploadPanel.java @@ -36,23 +36,24 @@ import com.sencha.gxt.widget.core.client.form.FormPanel; */ public class FileUploadPanel extends FormPanel { - protected static final String UPLOAD_SERVLET = "LocalUploadServlet"; + private static final String UPLOAD_SERVLET = "LocalUploadServlet"; - public static final int STATUS_POLLING_DELAY = 1000; + private static final int STATUS_POLLING_DELAY = 1000; - protected ResourceBundle res; - protected FileUploadField fileUploadField; - protected TextButton uploadButton; + // private ResourceBundle res; + private FileUploadField fUpField; + private TextButton btnUpload; - protected FileUploadProgressUpdater progressUpdater; + private FileUploadProgressUpdater progressUpdater; - protected ProgressBar uploadProgressBar; + private ProgressBar uploadProgressBar; - protected TextButton cancelButton; + private TextButton btnCancel; + + private CSVImportWizardTDMessages msgs; public FileUploadPanel(ResourceBundle res, final CSVUploadFileCard card, final CSVImportSession importSession) { - this.res = res; setId("LocalUploadPanel"); setLabelAlign(LabelAlign.TOP); @@ -76,22 +77,22 @@ public class FileUploadPanel extends FormPanel { content.setWidth("100%"); add(content); - fileUploadField = new FileUploadField(); - fileUploadField.setName("uploadFormElement"); - fileUploadField.setWidth("100%"); + fUpField = new FileUploadField(); + fUpField.setName("uploadFormElement"); + fUpField.setWidth("100%"); - content.add(new FieldLabel(fileUploadField, - "Select the csv file to import"), + content.add(new FieldLabel(fUpField, + msgs.fUpFieldLabel()), new VerticalLayoutData(-2, -1)); - uploadButton = new TextButton("Upload"); - content.add(uploadButton, new VerticalLayoutData(-1, -1)); + btnUpload = new TextButton(msgs.btnUploadText()); + content.add(btnUpload, new VerticalLayoutData(-1, -1)); - fileUploadField.addChangeHandler(new ChangeHandler() { + fUpField.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { - uploadButton.setEnabled(fileUploadField.isValid()); - String path = fileUploadField.getValue(); + btnUpload.setEnabled(fUpField.isValid()); + String path = fUpField.getValue(); int punto = path.lastIndexOf("."); if (punto < 0) { punto = path.length(); @@ -119,20 +120,20 @@ public class FileUploadPanel extends FormPanel { content.add(uploadProgressBar, new VerticalLayoutData(-2, -1)); uploadProgressBar.hide(); - cancelButton = new TextButton("Cancel"); - cancelButton.hide(); - content.add(cancelButton, new VerticalLayoutData(-1, -1)); + btnCancel = new TextButton(msgs.btnCancelText()); + btnCancel.hide(); + content.add(btnCancel, new VerticalLayoutData(-1, -1)); - uploadButton.addSelectHandler(new SelectHandler() { + btnUpload.addSelectHandler(new SelectHandler() { public void onSelect(SelectEvent event) { Log.info("request upload"); - if (fileUploadField.getValue() == null - || fileUploadField.getValue().equals("")) { + if (fUpField.getValue() == null + || fUpField.getValue().equals("")) { Log.info("fileUploadField is null or empty"); - UtilsGXT3.alert("CSV file missing", - "Please specify a CSV file."); + UtilsGXT3.alert(msgs.csvFileMissingHead(), + msgs.csvFileMissing()); return; } else { @@ -159,19 +160,23 @@ public class FileUploadPanel extends FormPanel { public void operationFailed(Throwable caught, String reason, String failureDetails) { - card.showErrorAndHide("Error uploading the csv file", reason, + card.showErrorAndHide(msgs.errorUploadingCSVFileHead(), reason, "", caught); } public void operationComplete() { card.setEnableNextButton(true); - cancelButton.disable(); + btnCancel.disable(); } }); } + protected void initMessages() { + msgs = GWT.create(CSVImportWizardTDMessages.class); + } + protected void startUpload() { disableUpload(); @@ -186,11 +191,11 @@ public class FileUploadPanel extends FormPanel { } protected void disableUpload() { - fileUploadField.disable(); - uploadButton.disable(); + fUpField.disable(); + btnUpload.disable(); uploadProgressBar.show(); - cancelButton.show(); + btnCancel.show(); } } diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGrid.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGrid.java index 7815d5d..0801fee 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGrid.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGrid.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import org.gcube.portlets.user.td.csvimportwidget.client.data.CSVRow; import org.gcube.portlets.user.td.csvimportwidget.client.data.CSVRowKeyProvider; import org.gcube.portlets.user.td.csvimportwidget.client.data.CSVRowValueProvider; +import org.gcube.portlets.user.td.widgetcommonevent.client.CommonMessages; import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3; import com.allen_sauer.gwt.log.client.Log; @@ -35,13 +36,17 @@ import com.sencha.gxt.widget.core.client.grid.RowNumberer; public class CSVGrid extends Grid { private static final String csvImportFileServlet = "CSVImportFileServlet"; - protected CSVGridView gridViewSample; + private CSVGridView gridViewSample; + private CSVGridMessages msgs; + private CommonMessages msgsCommon; + + public CSVGrid() { super(new ListStore(new CSVRowKeyProvider()), new ColumnModel( new ArrayList>())); - + initMessages(); setHeight(200); setBorders(true); @@ -51,10 +56,17 @@ public class CSVGrid extends Grid { gridViewSample = new CSVGridView(); setView(gridViewSample); - getView().setEmptyText("No data to show"); + getView().setEmptyText(msgs.noData()); setBorders(true); } + + protected void initMessages() { + msgs = GWT.create(CSVGridMessages.class); + msgsCommon = GWT.create(CommonMessages.class); + } + + public void configureColumns(ArrayList columnNames) { ColumnModel columnModel = createColumnModel(columnNames); ListStore store = createStore(columnNames); @@ -90,7 +102,7 @@ public class CSVGrid extends Grid { } catch (Exception e) { - UtilsGXT3.alert("Error","Error creating the store: "+e.getLocalizedMessage()); + UtilsGXT3.alert(msgsCommon.error(),msgs.errorCreatingTheStore(e.getLocalizedMessage())); Log.error("Error in creating the store: "+e.getLocalizedMessage()); e.printStackTrace(); diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages.java new file mode 100644 index 0000000..67fdce5 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages.java @@ -0,0 +1,25 @@ +package org.gcube.portlets.user.td.csvimportwidget.client.csvgrid; + +import com.google.gwt.i18n.client.Messages; + +/** + * + * @author giancarlo + * email: g.panichi@isti.cnr.it + * + */ +public interface CSVGridMessages extends Messages { + + @DefaultMessage("No data") + String noData(); + + @DefaultMessage("Error creating the store: {0}") + String errorCreatingTheStore(String localizedMessage); + + @DefaultMessage("Include") + String itmInclude(); + + @DefaultMessage("Exclude") + String itmExclude(); + +} diff --git a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridView.java b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridView.java index 5631164..5714500 100644 --- a/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridView.java +++ b/src/main/java/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridView.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import org.gcube.portlets.user.td.csvimportwidget.client.data.CSVRow; import org.gcube.portlets.user.td.csvimportwidget.client.dataresource.ResourceBundle; +import com.google.gwt.core.client.GWT; import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.event.logical.shared.SelectionHandler; import com.sencha.gxt.core.client.ValueProvider; @@ -25,10 +26,12 @@ import com.sencha.gxt.widget.core.client.menu.Menu; */ public class CSVGridView extends GridView { - protected ArrayList excludedColumns = new ArrayList(); + private ArrayList excludedColumns = new ArrayList(); + private CSVGridMessages msgs; public CSVGridView() { + initMessages(); setViewConfig(new GridViewConfig() { @@ -41,17 +44,22 @@ public class CSVGridView extends GridView { } }); } - + + protected void initMessages() { + msgs = GWT.create(CSVGridMessages.class); + + } + @Override protected Menu createContextMenu(final int colIndex) { Menu menu = new Menu(); - CheckMenuItem includeMenu = new CheckMenuItem("Include"); - includeMenu.setGroup("include"); - includeMenu.setChecked(!excludedColumns.contains(colIndex)); - menu.add(includeMenu); + CheckMenuItem itmInclude = new CheckMenuItem(msgs.itmInclude()); + itmInclude.setGroup("include"); + itmInclude.setChecked(!excludedColumns.contains(colIndex)); + menu.add(itmInclude); - includeMenu.addSelectionHandler(new SelectionHandler() { + itmInclude.addSelectionHandler(new SelectionHandler() { public void onSelection(SelectionEvent event) { @@ -61,12 +69,12 @@ public class CSVGridView extends GridView { }); - CheckMenuItem excludeMenu = new CheckMenuItem("Exclude"); - excludeMenu.setGroup("include"); - excludeMenu.setChecked(excludedColumns.contains(colIndex)); - menu.add(excludeMenu); + CheckMenuItem itmExclude = new CheckMenuItem(msgs.itmExclude()); + itmExclude.setGroup("include"); + itmExclude.setChecked(excludedColumns.contains(colIndex)); + menu.add(itmExclude); - excludeMenu.addSelectionHandler(new SelectionHandler() { + itmExclude.addSelectionHandler(new SelectionHandler() { public void onSelection(SelectionEvent event) { excludedColumns.add(colIndex); diff --git a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages.properties b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages.properties new file mode 100644 index 0000000..11a5b78 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages.properties @@ -0,0 +1,62 @@ +csvSourceSelection = CSV source selection +csvImportFileUpload = CSV Import File Upload +csvImportFromWorkspace = CSV Import From Workspace +workspaceSelection = Workspace Selection +csvConfiguration = CSV Configuration +errorRetrievingTheFileFromWorkspace = Error retrieving the file from the workspace! +comboEncodingsToolTip = The CSV file encoding +comboEncodingsLabel = File encoding +comboHeaderToolTip = The CSV file header +comboHeaderLabel = Header +radioCommaDelimiterLabel = Comma +radioSpaceDelimiterLabel = Space +radioTabDelimiterLabel = Tab +radioSemicolonDelimiterLabel = Semicolon +radioOtherDelimiterLabel = Other delimiter +insertAvalidDelimiterElseCommaIsUsed = Insert a valid delimiter else comma is used! +delimitersPanelToolTip = The delimiter use to delimit the CSV fields +delimitersPanelLabel = Delimiter +commentFieldToolTip = The character used as comment line prefix +commentFieldLabel = Comment +anErrorOccuredCheckingTheFileHead = An error occured checking the file +anErrorOccuredCheckingTheFile = Please retry, if the error perstists change the CSV configuration! +gridCSVSampleMask = Updating... +errorLoadingCharsetListHead = Error loading charset list +errorLoadingCharsetList = Error loading charset list! +tabularResourceDetail = Tabular Resource Detail +csvTableDetailCardFormHeader = Details +fieldSetInformationHead = Information +fieldNameEmptyText = Enter a name... +fieldNameLabel = Name +txtAreaDescriptionEmptyText = Enter a description... +txtAreaDescriptionLabel = Description +txtAreaRightsEmptyText = Enter rights... +txtAreaRightsLabel = Rights +fieldValidFromLabel = Valid From +fieldValidUntilToLabel = Valid Until To +comboLicencesLabel = Licence +errorRetrievingLicences = Error retrieving licences! +fillInNameField = Fill in name field! +fillInDescriptionField = Fill in description field! +fillInRightsField = Fill in rights field! +validFromFieldIsHigherThanValidUntilToField = Valid From field is higher than Valid Until To field! +btnCheckConfigurationText = Check configuration +chBoxSkipInvalidLabel = Skip invalid lines +failedMoreThanNumberErrors = Failed (more than {0} errors) +failedErrors = Failed ({0} errors) +checkTheConfigurationBeforeSubmit = Check the configuration before submit it +checkingTheConfiguration = Checking the configuration... +clickToObtainMoreInformation = Click to obtain more information +failed = Failed +correct = Correct. +btnCloseText = Close +csvErrorWindowHead = CSV error details +gridErrorColumnNLine = # line +gridErrorCololumnLine = Line +gridErrorCololumnError = Error +fUpFieldLabel = Select the csv file to import +btnUploadText = Upload +btnCancelText = Cancel +csvFileMissingHead = CSV file missing +csvFileMissing = Please specify a CSV file +errorUploadingCSVFileHead = Error uploading the csv file diff --git a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages_es.properties b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages_es.properties new file mode 100644 index 0000000..aaa9c3d --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages_es.properties @@ -0,0 +1,62 @@ +csvSourceSelection = Seleccionar CSV fuente +csvImportFileUpload = Cargar Archivo +csvImportFromWorkspace = Cargar Archivo desde el Workspace +workspaceSelection = Workspace Seleccionar +csvConfiguration = CSV Configuración +errorRetrievingTheFileFromWorkspace = Error al recuperar el archivo desde el workspace! +comboEncodingsToolTip = CSV archivo codificación +comboEncodingsLabel = Codificación +comboHeaderToolTip = CSV archivo encabezamiento +comboHeaderLabel = Encabezamiento +radioCommaDelimiterLabel = , +radioSpaceDelimiterLabel = Space +radioTabDelimiterLabel = Tab +radioSemicolonDelimiterLabel = ; +radioOtherDelimiterLabel = Otro +insertAvalidDelimiterElseCommaIsUsed = Inserte un delimitador válido otra se utiliza comas! +delimitersPanelToolTip = El uso delimitador para delimitar los campos +delimitersPanelLabel = Delimitador +commentFieldToolTip = El carácter se utiliza como prefijo de comentario +commentFieldLabel = Comentario +anErrorOccuredCheckingTheFileHead = Se produjo un error comprobando el archivo +anErrorOccuredCheckingTheFile = Por favor vuelva a intentar, si los perstists error cambiar la configuración CSV! +gridCSVSampleMask = Actualización... +errorLoadingCharsetListHead = Error al cargar la lista de caracteres +errorLoadingCharsetList = Error al cargar la lista de caracteres! +tabularResourceDetail = Tabular Resource Detalle +csvTableDetailCardFormHeader = Detalles +fieldSetInformationHead = Información +fieldNameEmptyText = Introducir nombre... +fieldNameLabel = Nombre +txtAreaDescriptionEmptyText = Introducir descripción... +txtAreaDescriptionLabel = Descripción +txtAreaRightsEmptyText = Introducir licencia... +txtAreaRightsLabel = Derèchos +fieldValidFromLabel = Válida Desde +fieldValidUntilToLabel = Válida Hasta +comboLicencesLabel = Licencia +errorRetrievingLicences = Error al recuperar licencias! +fillInNameField = Introducir el nombre! +fillInDescriptionField = Introducir descripción! +fillInRightsField = Introducir derèchos! +validFromFieldIsHigherThanValidUntilToField = Válida Desde es mayor que Válida Hasta ! +btnCheckConfigurationText = Controlar +chBoxSkipInvalidLabel = Saltar no válidas +failedMoreThanNumberErrors = Falló (mayor que {0} errores) +failedErrors = Falló ({0} errores) +checkTheConfigurationBeforeSubmit = Compruebe la configuración antes de continuar +checkingTheConfiguration = Comprobar... +clickToObtainMoreInformation = Mas informacion +failed = Falló +correct = Correcto. +btnCloseText = Cerrar +csvErrorWindowHead = CSV errores detalle +gridErrorColumnNLine = # línea +gridErrorCololumnLine = Línea +gridErrorCololumnError = Error +fUpFieldLabel = Seleccione el archivo CSV para importar +btnUploadText = Cargar +btnCancelText = Anular +csvFileMissingHead = CSV archivo que falta +csvFileMissing = Especifica el archivo CSV +errorUploadingCSVFileHead = Error cargando el archivo CSV diff --git a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages_it.properties b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages_it.properties new file mode 100644 index 0000000..86ff758 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/CSVImportWizardTDMessages_it.properties @@ -0,0 +1,62 @@ +csvSourceSelection = CSV seleziona sorgente +csvImportFileUpload = Carica File +csvImportFromWorkspace = Carica Dal Workspace +workspaceSelection = Workspace Seleziona +csvConfiguration = CSV Configurazione +errorRetrievingTheFileFromWorkspace = Errore recuperando il file dal workspace! +comboEncodingsToolTip = CSV file codifica +comboEncodingsLabel = File codifica +comboHeaderToolTip = CSV file intestazione +comboHeaderLabel = Intestazione +radioCommaDelimiterLabel = , +radioSpaceDelimiterLabel = Spazio +radioTabDelimiterLabel = Tab +radioSemicolonDelimiterLabel = ; +radioOtherDelimiterLabel = Altro +insertAvalidDelimiterElseCommaIsUsed = Inserisci un delimitatore altrimenti sarà usata la virgola! +delimitersPanelToolTip = Il delimitatore usato per delimitare i campi del CSV +delimitersPanelLabel = Delimitatore +commentFieldToolTip = Il carattere commento +commentFieldLabel = Commento +anErrorOccuredCheckingTheFileHead = Errore controllando il file +anErrorOccuredCheckingTheFile = Riprova, se l''errore pesiste cambia la configurazione del CSV! +gridCSVSampleMask = Aggiornando... +errorLoadingCharsetListHead = Errore caricando la lista dei caratteri +errorLoadingCharsetList = Errre caricando la lista dei caratteri! +tabularResourceDetail = Dettaglio Tabular Resource +csvTableDetailCardFormHeader = Dettagli +fieldSetInformationHead = Informazioni +fieldNameEmptyText = Inserisci un nome... +fieldNameLabel = Nome +txtAreaDescriptionEmptyText = Inserisci una descrizione... +txtAreaDescriptionLabel = Descrizione +txtAreaRightsEmptyText = Inserisci i diritti... +txtAreaRightsLabel = Diritti +fieldValidFromLabel = Valida Dal +fieldValidUntilToLabel = Valida Fino Al +comboLicencesLabel = Licenza +errorRetrievingLicences = Errore recuperando le licenze! +fillInNameField = Compila il campo nome! +fillInDescriptionField = Compila il campo descrizione! +fillInRightsField = Compila il campo diritti! +validFromFieldIsHigherThanValidUntilToField = Il campo Valida Dal ha una data maggiore di Valida Fino Al! +btnCheckConfigurationText = Controlla +chBoxSkipInvalidLabel = Ignora righe invalide +failedMoreThanNumberErrors = Fallito (Più di {0} errori) +failedErrors = Faillito ({0} errori) +checkTheConfigurationBeforeSubmit = Controlla la configurazione prima di procedere +checkingTheConfiguration = Controllo configurazione... +clickToObtainMoreInformation = Clicca per più informazioni +failed = Fallito +correct = Corretto. +btnCloseText = Chiudi +csvErrorWindowHead = Dettaglio errori +gridErrorColumnNLine = # linea +gridErrorCololumnLine = Linea +gridErrorCololumnError = Errore +fUpFieldLabel = Seleziona il file csv +btnUploadText = Carica +btnCancelText = Cancella +csvFileMissingHead = CSV file non trovato +csvFileMissing = Specifica un file CSV +errorUploadingCSVFileHead = Errore caricando il file csv diff --git a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages.properties b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages.properties new file mode 100644 index 0000000..a1f1513 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages.properties @@ -0,0 +1,4 @@ +noData = No data +errorCreatingTheStore = Error creating the store: {0} +itmInclude = Include +itmExclude = Exclude diff --git a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages_es.properties b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages_es.properties new file mode 100644 index 0000000..5720aa2 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages_es.properties @@ -0,0 +1,4 @@ +noData = Ninguno datos +errorCreatingTheStore = Error, creando el store: {0} +itmInclude = Incluir +itmExclude = Excluir diff --git a/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages_it.properties b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages_it.properties new file mode 100644 index 0000000..2c98e58 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/csvimportwidget/client/csvgrid/CSVGridMessages_it.properties @@ -0,0 +1,5 @@ +noData = Nessun dato +errorCreatingTheStore = Errore creando lo store: {0} +itmInclude = Includi +itmExclude = Escludi +