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
This commit is contained in:
Giancarlo Panichi 2015-10-16 16:40:44 +00:00
parent 60c4098000
commit 5006b0c392
16 changed files with 797 additions and 347 deletions

View File

@ -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.csv.CheckCSVSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; 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.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.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; 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.wizardwidget.client.WizardCard;
@ -54,36 +55,44 @@ import com.sencha.gxt.widget.core.client.tips.ToolTipConfig;
* *
*/ */
public class CSVConfigCard extends WizardCard { 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 = ","; private SimpleComboBox<String> comboEncodings;
protected static final String DEFAULT_COMMENT = "#"; private SimpleComboBox<HeaderPresence> comboHeader;
protected static final long ERRORLIMIT = 100; private TextField customDelimiterField;
protected CSVImportSession csvImportSession; private Radio radioOtherDelimiter;
private Radio radioCommaDelimiter;
private Radio radioSpaceDelimiter;
private Radio radioTabDelimiter;
private Radio radioSemicolonDelimiter;
private TextField commentField;
private CsvCheckPanel csvCheckPanel;
protected SimpleComboBox<String> encodings; private CSVGrid gridCSVSample;
protected SimpleComboBox<HeaderPresence> 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;
protected CSVGrid csvSample;
public CSVConfigCard(final CSVImportSession csvImportSession) { public CSVConfigCard(final CSVImportSession csvImportSession) {
super("CSV configuration", ""); super(msgs.csvConfiguration(), "");
if (csvImportSession == null) { if (csvImportSession == null) {
Log.error("CSVImportSession is null"); Log.error("CSVImportSession is null");
} }
this.csvImportSession = csvImportSession; this.csvImportSession = csvImportSession;
initMessages();
FormPanel panel = createPanel(); FormPanel panel = createPanel();
setCenterWidget(panel,new MarginData(0)); setCenterWidget(panel,new MarginData(0));
} }
protected void initMessages(){
msgsCommon = GWT.create(CommonMessages.class);
}
protected FormPanel createPanel() { protected FormPanel createPanel() {
FormPanel panel = new FormPanel(); FormPanel panel = new FormPanel();
@ -93,21 +102,21 @@ public class CSVConfigCard extends WizardCard {
VerticalLayoutContainer content = new VerticalLayoutContainer(); VerticalLayoutContainer content = new VerticalLayoutContainer();
panel.add(content); panel.add(content);
encodings = new SimpleComboBox<String>( comboEncodings = new SimpleComboBox<String>(
new StringLabelProvider<String>()); new StringLabelProvider<String>());
encodings.setToolTip("The CSV file encoding"); comboEncodings.setToolTip(msgs.comboEncodingsToolTip());
encodings.setTabIndex(0); comboEncodings.setTabIndex(0);
encodings.setEditable(false); comboEncodings.setEditable(false);
encodings.setForceSelection(true); comboEncodings.setForceSelection(true);
encodings.setTriggerAction(TriggerAction.ALL); comboEncodings.setTriggerAction(TriggerAction.ALL);
encodings.addSelectionHandler(new SelectionHandler<String>() { comboEncodings.addSelectionHandler(new SelectionHandler<String>() {
public void onSelection(SelectionEvent<String> event) { public void onSelection(SelectionEvent<String> event) {
updateGrid(); updateGrid();
} }
}); });
content.add(new FieldLabel(encodings, "File encoding")); content.add(new FieldLabel(comboEncodings, msgs.comboEncodingsLabel()));
LabelProvider<HeaderPresence> labelProvider = new LabelProvider<HeaderPresence>() { LabelProvider<HeaderPresence> labelProvider = new LabelProvider<HeaderPresence>() {
@ -116,39 +125,39 @@ public class CSVConfigCard extends WizardCard {
} }
}; };
header = new SimpleComboBox<HeaderPresence>(labelProvider); comboHeader = new SimpleComboBox<HeaderPresence>(labelProvider);
header.setToolTip("The CSV file header"); comboHeader.setToolTip(msgs.comboHeaderToolTip());
header.setTabIndex(0); comboHeader.setTabIndex(0);
header.setEditable(false); comboHeader.setEditable(false);
header.setForceSelection(true); comboHeader.setForceSelection(true);
header.setTriggerAction(TriggerAction.ALL); comboHeader.setTriggerAction(TriggerAction.ALL);
for (HeaderPresence headerPresence : HeaderPresence.values()) for (HeaderPresence headerPresence : HeaderPresence.values())
header.add(headerPresence); comboHeader.add(headerPresence);
header.setValue(HeaderPresence.NONE); comboHeader.setValue(HeaderPresence.NONE);
header.addSelectionHandler(new SelectionHandler<HeaderPresence>() { comboHeader.addSelectionHandler(new SelectionHandler<HeaderPresence>() {
public void onSelection(SelectionEvent<HeaderPresence> event) { public void onSelection(SelectionEvent<HeaderPresence> event) {
updateGrid(); updateGrid();
} }
}); });
content.add(new FieldLabel(header, "Header")); content.add(new FieldLabel(comboHeader, msgs.comboHeaderLabel()));
commaDelimiter = new Radio(); radioCommaDelimiter = new Radio();
commaDelimiter.setBoxLabel("Comma"); radioCommaDelimiter.setBoxLabel(msgs.radioCommaDelimiterLabel());
commaDelimiter.setValue(true); radioCommaDelimiter.setValue(true);
spaceDelimiter = new Radio(); radioSpaceDelimiter = new Radio();
spaceDelimiter.setBoxLabel("Space"); radioSpaceDelimiter.setBoxLabel(msgs.radioSpaceDelimiterLabel());
tabDelimiter = new Radio(); radioTabDelimiter = new Radio();
tabDelimiter.setBoxLabel("Tab"); radioTabDelimiter.setBoxLabel(msgs.radioTabDelimiterLabel());
semicoloDelimiter = new Radio(); radioSemicolonDelimiter = new Radio();
semicoloDelimiter.setBoxLabel("Semicolon"); radioSemicolonDelimiter.setBoxLabel(msgs.radioSemicolonDelimiterLabel());
otherDelimiter = new Radio(); radioOtherDelimiter = new Radio();
otherDelimiter.setBoxLabel("Other delimiter"); radioOtherDelimiter.setBoxLabel(msgs.radioOtherDelimiterLabel());
customDelimiterField = new TextField(); customDelimiterField = new TextField();
customDelimiterField.setEnabled(false); customDelimiterField.setEnabled(false);
@ -161,10 +170,10 @@ public class CSVConfigCard extends WizardCard {
public void onValueChange(ValueChangeEvent<String> event) { public void onValueChange(ValueChangeEvent<String> event) {
customDelimiterField.validate(); customDelimiterField.validate();
if (otherDelimiter.getValue() if (radioOtherDelimiter.getValue()
&& !customDelimiterField.isValid()){ && !customDelimiterField.isValid()){
UtilsGXT3 UtilsGXT3
.alert("Attention","Insert a valid delimiter else comma is used!"); .alert(msgsCommon.attention(),msgs.insertAvalidDelimiterElseCommaIsUsed());
} }
updateGrid(); updateGrid();
@ -172,11 +181,11 @@ public class CSVConfigCard extends WizardCard {
} }
}); });
ToggleGroup delimitersGroup = new ToggleGroup(); ToggleGroup delimitersGroup = new ToggleGroup();
delimitersGroup.add(commaDelimiter); delimitersGroup.add(radioCommaDelimiter);
delimitersGroup.add(spaceDelimiter); delimitersGroup.add(radioSpaceDelimiter);
delimitersGroup.add(tabDelimiter); delimitersGroup.add(radioTabDelimiter);
delimitersGroup.add(semicoloDelimiter); delimitersGroup.add(radioSemicolonDelimiter);
delimitersGroup.add(otherDelimiter); delimitersGroup.add(radioOtherDelimiter);
delimitersGroup delimitersGroup
.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() { .addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
@ -184,18 +193,18 @@ public class CSVConfigCard extends WizardCard {
public void onValueChange( public void onValueChange(
ValueChangeEvent<HasValue<Boolean>> event) { ValueChangeEvent<HasValue<Boolean>> event) {
customDelimiterField.setEnabled(otherDelimiter customDelimiterField.setEnabled(radioOtherDelimiter
.getValue()); .getValue());
if (!otherDelimiter.getValue()) if (!radioOtherDelimiter.getValue())
customDelimiterField.clearInvalid(); customDelimiterField.clearInvalid();
else else
customDelimiterField.validate(); customDelimiterField.validate();
if (otherDelimiter.getValue() if (radioOtherDelimiter.getValue()
&& !customDelimiterField.isValid()){ && !customDelimiterField.isValid()){
UtilsGXT3 UtilsGXT3
.alert("Attention","Insert a valid delimiter else comma is used!"); .alert(msgsCommon.attention(),msgs.insertAvalidDelimiterElseCommaIsUsed());
} }
updateGrid(); updateGrid();
@ -203,19 +212,19 @@ public class CSVConfigCard extends WizardCard {
}); });
HorizontalPanel delimitersPanel = new HorizontalPanel(); HorizontalPanel delimitersPanel = new HorizontalPanel();
delimitersPanel.add(commaDelimiter); delimitersPanel.add(radioCommaDelimiter);
delimitersPanel.add(spaceDelimiter); delimitersPanel.add(radioSpaceDelimiter);
delimitersPanel.add(tabDelimiter); delimitersPanel.add(radioTabDelimiter);
delimitersPanel.add(semicoloDelimiter); delimitersPanel.add(radioSemicolonDelimiter);
delimitersPanel.add(otherDelimiter); delimitersPanel.add(radioOtherDelimiter);
delimitersPanel.add(customDelimiterField); delimitersPanel.add(customDelimiterField);
new ToolTip(delimitersPanel, new ToolTipConfig( new ToolTip(delimitersPanel, new ToolTipConfig(
"The delimiter use to delimit the CSV fields")); msgs.delimitersPanelToolTip()));
content.add(new FieldLabel(delimitersPanel, "Delimiter")); content.add(new FieldLabel(delimitersPanel, msgs.delimitersPanelLabel()));
commentField = new TextField(); commentField = new TextField();
commentField.setToolTip("The character used as comment line prefix"); commentField.setToolTip(msgs.commentFieldToolTip());
commentField.setValue(DEFAULT_COMMENT); commentField.setValue(DEFAULT_COMMENT);
commentField.setAllowBlank(false); commentField.setAllowBlank(false);
commentField.getValidators().add(new MaxLengthValidator(1)); 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(); gridCSVSample = new CSVGrid();
content.add(csvSample, new VerticalLayoutData(1, -1)); content.add(gridCSVSample, new VerticalLayoutData(1, -1));
content.add(new HTML("<BR>")); content.add(new HTML("<BR>"));
@ -278,8 +287,8 @@ public class CSVConfigCard extends WizardCard {
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
UtilsGXT3 UtilsGXT3
.alert("An error occured checking the file", .alert(msgs.anErrorOccuredCheckingTheFileHead(),
"Please retry, if the error perstists change the CSV configuration"); msgs.anErrorOccuredCheckingTheFile());
} }
} }
@ -306,15 +315,15 @@ public class CSVConfigCard extends WizardCard {
resetCheckMessage(); resetCheckMessage();
csvSample.mask("Updating..."); gridCSVSample.mask(msgs.gridCSVSampleMask());
GWT.log("updating CSV config"); GWT.log("updating CSV config");
HeaderPresence headerPresence = header.getCurrentValue(); HeaderPresence headerPresence = comboHeader.getCurrentValue();
char delimiter = getSelectedDelimiter(); char delimiter = getSelectedDelimiter();
String encoding = encodings.getCurrentValue(); String encoding = comboEncodings.getCurrentValue();
char commentChar = commentField.getValue().charAt(0); char commentChar = commentField.getValue().charAt(0);
TDGWTServiceAsync.INSTANCE.configureCSVParser(encoding, headerPresence, TDGWTServiceAsync.INSTANCE.configureCSVParser(encoding, headerPresence,
@ -330,8 +339,8 @@ public class CSVConfigCard extends WizardCard {
Log.error("Failed updating CSV config", caught); Log.error("Failed updating CSV config", caught);
setEnableNextButton(false); setEnableNextButton(false);
UtilsGXT3 UtilsGXT3
.alert("An error occured checking the file", .alert(msgs.anErrorOccuredCheckingTheFileHead(),
"Please retry, if the error perstists change the CSV configuration"); msgs.anErrorOccuredCheckingTheFile());
} }
} }
@ -345,8 +354,8 @@ public class CSVConfigCard extends WizardCard {
Log.info("Column HEADER: " + name); Log.info("Column HEADER: " + name);
// csvImportSession.getId() // csvImportSession.getId()
csvSample.configureColumns(result); gridCSVSample.configureColumns(result);
csvSample.unmask(); gridCSVSample.unmask();
setEnableNextButton(false); setEnableNextButton(false);
@ -356,7 +365,7 @@ public class CSVConfigCard extends WizardCard {
} }
protected char getSelectedDelimiter() { protected char getSelectedDelimiter() {
if (otherDelimiter.getValue()) { if (radioOtherDelimiter.getValue()) {
String custom=customDelimiterField.getValue(); String custom=customDelimiterField.getValue();
if(custom!=null && !custom.isEmpty()){ if(custom!=null && !custom.isEmpty()){
return custom.charAt(0); return custom.charAt(0);
@ -365,16 +374,16 @@ public class CSVConfigCard extends WizardCard {
} }
} else { } else {
if (commaDelimiter.getValue()) { if (radioCommaDelimiter.getValue()) {
return ','; return ',';
} else { } else {
if (spaceDelimiter.getValue()) { if (radioSpaceDelimiter.getValue()) {
return ' '; return ' ';
} else { } else {
if (tabDelimiter.getValue()) { if (radioTabDelimiter.getValue()) {
return '\t'; return '\t';
} else { } else {
if (semicoloDelimiter.getValue()) { if (radioSemicolonDelimiter.getValue()) {
return ';'; return ';';
} }
} }
@ -388,7 +397,7 @@ public class CSVConfigCard extends WizardCard {
public void setup() { public void setup() {
setEnableBackButton(false); setEnableBackButton(false);
setEnableNextButton(false); setEnableNextButton(false);
encodings.focus(); comboEncodings.focus();
TDGWTServiceAsync.INSTANCE TDGWTServiceAsync.INSTANCE
.getAvailableCharset(new AsyncCallback<AvailableCharsetList>() { .getAvailableCharset(new AsyncCallback<AvailableCharsetList>() {
@ -400,9 +409,9 @@ public class CSVConfigCard extends WizardCard {
+ result.getDefaultCharset()); + result.getDefaultCharset());
for (String charset : result.getCharsetList()) for (String charset : result.getCharsetList())
encodings.add(charset); comboEncodings.add(charset);
encodings.setValue(result.getDefaultCharset()); comboEncodings.setValue(result.getDefaultCharset());
updateGrid(); updateGrid();
} }
@ -418,8 +427,8 @@ public class CSVConfigCard extends WizardCard {
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
Log.error("Error loading charset list", caught); Log.error("Error loading charset list", caught);
showErrorAndHide("Error loading charset list", showErrorAndHide(msgs.errorLoadingCharsetListHead(),
"Error loading charset list", caught.getLocalizedMessage(), caught); msgs.errorLoadingCharsetList(), caught.getLocalizedMessage(), caught);
} }
} }
}); });
@ -461,7 +470,7 @@ public class CSVConfigCard extends WizardCard {
@Override @Override
public void dispose() { public void dispose() {
csvImportSession csvImportSession
.setColumnToImportMask(csvSample.getImportColumnsMask()); .setColumnToImportMask(gridCSVSample.getImportColumnsMask());
} }
} }

View File

@ -4,8 +4,6 @@ import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVRowError; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVRowError;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.sencha.gxt.core.client.ValueProvider; import com.sencha.gxt.core.client.ValueProvider;
import com.sencha.gxt.data.shared.ListStore; import com.sencha.gxt.data.shared.ListStore;
@ -22,70 +20,80 @@ import com.sencha.gxt.widget.core.client.grid.Grid;
/** /**
* *
* @author "Giancarlo Panichi" * @author "Giancarlo Panichi" <a
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class CSVErrorWindow extends Window { public class CSVErrorWindow extends Window {
private static final CSVRowErrorProperties props = GWT.create(CSVRowErrorProperties.class); private static final CSVRowErrorProperties props = GWT
.create(CSVRowErrorProperties.class);
protected Grid<CSVRowError> grid; private CSVImportWizardTDMessages msgs;
protected ListStore<CSVRowError> store;
private Grid<CSVRowError> gridErrors;
public CSVErrorWindow() private ListStore<CSVRowError> storeGridErrors;
{
setHeadingText("CSV error details"); public CSVErrorWindow() {
initMessages();
setHeadingText(msgs.csvErrorWindowHead());
setModal(true); setModal(true);
setBlinkModal(true); setBlinkModal(true);
setWidth(600); setWidth(600);
setHeight(350); setHeight(350);
createGrid(); createGrid();
add(grid); add(gridErrors);
TextButton close = new TextButton("Close"); TextButton btnClose = new TextButton(msgs.btnCloseText());
close.addSelectHandler(new SelectHandler() { btnClose.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) { public void onSelect(SelectEvent event) {
hide(); hide();
} }
}); });
addButton(close); addButton(btnClose);
setButtonAlign(BoxLayoutPack.CENTER); setButtonAlign(BoxLayoutPack.CENTER);
} }
protected void createGrid()
{
ArrayList<ColumnConfig<CSVRowError, ?>> columns = new ArrayList<ColumnConfig<CSVRowError, ?>>();
columns.add(new ColumnConfig<CSVRowError, Integer>(props.lineNumber(), 30, "# line"));
columns.add(new ColumnConfig<CSVRowError, String>(props.lineValue(), 60, "Line"));
columns.add(new ColumnConfig<CSVRowError, String>(props.errorDescription(), 160, "Error"));
ColumnModel<CSVRowError> columnModel = new ColumnModel<CSVRowError>(columns);
store = new ListStore<CSVRowError>(props.id());
grid = new Grid<CSVRowError>(store, columnModel);
grid.getView().setForceFit(true);
}
public void updateGrid(ArrayList<CSVRowError> errors)
{
store.clear();
store.addAll(errors);
}
protected interface CSVRowErrorProperties extends PropertyAccess<CSVRowError> {
ModelKeyProvider<CSVRowError> id();
ValueProvider<CSVRowError, Integer> lineNumber(); protected void initMessages() {
ValueProvider<CSVRowError, String> lineValue(); msgs = GWT.create(CSVImportWizardTDMessages.class);
ValueProvider<CSVRowError, String> errorDescription(); }
protected void createGrid() {
ArrayList<ColumnConfig<CSVRowError, ?>> columns = new ArrayList<ColumnConfig<CSVRowError, ?>>();
columns.add(new ColumnConfig<CSVRowError, Integer>(props.lineNumber(),
30, msgs.gridErrorColumnNLine()));
columns.add(new ColumnConfig<CSVRowError, String>(props.lineValue(),
60, msgs.gridErrorCololumnLine()));
columns.add(new ColumnConfig<CSVRowError, String>(props
.errorDescription(), 160, msgs.gridErrorCololumnError()));
ColumnModel<CSVRowError> columnModel = new ColumnModel<CSVRowError>(
columns);
storeGridErrors = new ListStore<CSVRowError>(props.id());
gridErrors = new Grid<CSVRowError>(storeGridErrors, columnModel);
gridErrors.getView().setForceFit(true);
}
public void updateGrid(ArrayList<CSVRowError> errors) {
storeGridErrors.clear();
storeGridErrors.addAll(errors);
}
protected interface CSVRowErrorProperties extends
PropertyAccess<CSVRowError> {
ModelKeyProvider<CSVRowError> id();
ValueProvider<CSVRowError, Integer> lineNumber();
ValueProvider<CSVRowError, String> lineValue();
ValueProvider<CSVRowError, String> errorDescription();
} }
} }

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.td.csvimportwidget.client; package org.gcube.portlets.user.td.csvimportwidget.client;
import com.google.gwt.i18n.client.Messages; 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") @DefaultMessage("Workspace Selection")
String workspaceSelection(); 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(); 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();
} }

View File

@ -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.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData; 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.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.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; 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.wizardwidget.client.WizardCard;
@ -54,9 +55,11 @@ import com.sencha.gxt.widget.core.client.form.TextField;
* *
*/ */
public class CSVTableDetailCard extends WizardCard { public class CSVTableDetailCard extends WizardCard {
private final String TABLEDETAILPANELWIDTH = "100%"; private static final String TABLEDETAILPANELWIDTH = "100%";
private final String TABLEDETAILPANELHEIGHT = "100%"; private static final String TABLEDETAILPANELHEIGHT = "100%";
private static CSVImportWizardTDMessages msgs= GWT.create(CSVImportWizardTDMessages.class);
private CommonMessages msgsCommon;
private CSVImportSession importSession; private CSVImportSession importSession;
private CSVTableDetailCard thisCard; private CSVTableDetailCard thisCard;
@ -64,23 +67,24 @@ public class CSVTableDetailCard extends WizardCard {
private VerticalLayoutContainer p; private VerticalLayoutContainer p;
private VerticalPanel tableDetailPanel; private VerticalPanel tableDetailPanel;
private TextField name; private TextField fieldName;
private TextArea description; private TextArea txtAreaDescription;
private TextArea rights; private TextArea txtAreaRights;
private DateField validFrom; private DateField fieldValidFrom;
private DateField validUntilTo; private DateField fieldValidUntilTo;
private TabResource detail; private TabResource detail;
private ListLoader<ListLoadConfig, ListLoadResult<LicenceData>> loader; private ListLoader<ListLoadConfig, ListLoadResult<LicenceData>> loader;
private ComboBox<LicenceData> comboLicences; private ComboBox<LicenceData> comboLicences;
public CSVTableDetailCard(final CSVImportSession importSession) { public CSVTableDetailCard(final CSVImportSession importSession) {
super("Tabular Resource Detail", ""); super(msgs.tabularResourceDetail(), "");
this.importSession = importSession; this.importSession = importSession;
thisCard = this; thisCard = this;
initMessages();
tableDetailPanel = new VerticalPanel(); tableDetailPanel = new VerticalPanel();
tableDetailPanel.setSpacing(4); tableDetailPanel.setSpacing(4);
@ -88,43 +92,43 @@ public class CSVTableDetailCard extends WizardCard {
tableDetailPanel.setHeight(TABLEDETAILPANELHEIGHT); tableDetailPanel.setHeight(TABLEDETAILPANELHEIGHT);
FramedPanel form = new FramedPanel(); FramedPanel form = new FramedPanel();
form.setHeadingText("Details"); form.setHeadingText(msgs.csvTableDetailCardFormHeader());
FieldSet fieldSet = new FieldSet(); FieldSet fieldSetInformation = new FieldSet();
fieldSet.setHeadingText("Information"); fieldSetInformation.setHeadingText(msgs.fieldSetInformationHead());
fieldSet.setCollapsible(false); fieldSetInformation.setCollapsible(false);
form.add(fieldSet, new MarginData(new Margins(0))); form.add(fieldSetInformation, new MarginData(new Margins(0)));
p = new VerticalLayoutContainer(); p = new VerticalLayoutContainer();
fieldSet.add(p, new MarginData(new Margins(0))); fieldSetInformation.add(p, new MarginData(new Margins(0)));
name = new TextField(); fieldName = new TextField();
name.setAllowBlank(false); fieldName.setAllowBlank(false);
name.setEmptyText("Enter a name..."); fieldName.setEmptyText(msgs.fieldNameEmptyText());
name.setValue(importSession.getLocalFileName()); fieldName.setValue(importSession.getLocalFileName());
p.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1)); p.add(new FieldLabel(fieldName, msgs.fieldNameLabel()), new VerticalLayoutData(1, -1));
description = new TextArea(); txtAreaDescription = new TextArea();
description.setAllowBlank(false); txtAreaDescription.setAllowBlank(false);
description.setEmptyText("Enter a description..."); txtAreaDescription.setEmptyText(msgs.txtAreaDescriptionEmptyText());
description.setValue("File CSV"); txtAreaDescription.setValue("CSV");
p.add(new FieldLabel(description, "Description"), p.add(new FieldLabel(txtAreaDescription, msgs.txtAreaDescriptionLabel()),
new VerticalLayoutData(1, -1)); new VerticalLayoutData(1, -1));
rights = new TextArea(); txtAreaRights = new TextArea();
rights.setEmptyText("Enter rights..."); txtAreaRights.setEmptyText(msgs.txtAreaRightsEmptyText());
rights.setAllowBlank(false); txtAreaRights.setAllowBlank(false);
p.add(new FieldLabel(rights, "Rights"), new VerticalLayoutData(1, -1)); p.add(new FieldLabel(txtAreaRights, msgs.txtAreaRightsLabel()), new VerticalLayoutData(1, -1));
validFrom = new DateField(); fieldValidFrom = new DateField();
validFrom.setValue(new Date()); fieldValidFrom.setValue(new Date());
p.add(new FieldLabel(validFrom, "Valid From"), new VerticalLayoutData( p.add(new FieldLabel(fieldValidFrom, msgs.fieldValidFromLabel()), new VerticalLayoutData(
1, -1)); 1, -1));
validUntilTo = new DateField(); fieldValidUntilTo = new DateField();
p.add(new FieldLabel(validUntilTo, "Valid Until To"), p.add(new FieldLabel(fieldValidUntilTo, msgs.fieldValidUntilToLabel()),
new VerticalLayoutData(1, -1)); new VerticalLayoutData(1, -1));
// Combo Licences // Combo Licences
@ -174,7 +178,7 @@ public class CSVTableDetailCard extends WizardCard {
Log.trace("Combo Licence created"); Log.trace("Combo Licence created");
// / // /
p.add(new FieldLabel(comboLicences, "Licence"), new VerticalLayoutData( p.add(new FieldLabel(comboLicences, msgs.comboLicencesLabel()), new VerticalLayoutData(
1, -1)); 1, -1));
tableDetailPanel.add(form); tableDetailPanel.add(form);
@ -182,6 +186,11 @@ public class CSVTableDetailCard extends WizardCard {
setCenterWidget(tableDetailPanel, new MarginData(0)); setCenterWidget(tableDetailPanel, new MarginData(0));
} }
protected void initMessages(){
msgsCommon = GWT.create(CommonMessages.class);
}
protected void loadData(ListLoadConfig loadConfig, protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<LicenceData>> callback) { final AsyncCallback<ListLoadResult<LicenceData>> callback) {
@ -197,8 +206,8 @@ public class CSVTableDetailCard extends WizardCard {
} else { } else {
Log.error("load combo failure:" Log.error("load combo failure:"
+ caught.getLocalizedMessage()); + caught.getLocalizedMessage());
showErrorAndHide("Error", showErrorAndHide(msgsCommon.error(),
"Error retrieving licences.", msgs.errorRetrievingLicences(),
caught.getLocalizedMessage(), caught); caught.getLocalizedMessage(), caught);
} }
callback.onFailure(caught); callback.onFailure(caught);
@ -257,30 +266,30 @@ public class CSVTableDetailCard extends WizardCard {
} }
}; };
if (name.getValue() == null || name.getValue().isEmpty() if (fieldName.getValue() == null || fieldName.getValue().isEmpty()
|| !name.isValid()) { || !fieldName.isValid()) {
d = new AlertMessageBox("Attention!", "Fill in name field"); d = new AlertMessageBox(msgsCommon.attention(), msgs.fillInNameField());
d.addHideHandler(hideHandler); d.addHideHandler(hideHandler);
d.show(); d.show();
} else { } else {
if (description.getValue() == null if (txtAreaDescription.getValue() == null
|| description.getValue().isEmpty() || txtAreaDescription.getValue().isEmpty()
|| !description.isValid()) { || !txtAreaDescription.isValid()) {
d = new AlertMessageBox("Attention!", d = new AlertMessageBox(msgsCommon.attention(),
"Fill in description field"); msgs.fillInDescriptionField());
d.addHideHandler(hideHandler); d.addHideHandler(hideHandler);
d.show(); d.show();
} else { } else {
if (rights.getValue() == null || rights.getValue().isEmpty() if (txtAreaRights.getValue() == null || txtAreaRights.getValue().isEmpty()
|| !rights.isValid()) { || !txtAreaRights.isValid()) {
d = new AlertMessageBox("Attention!", d = new AlertMessageBox(msgsCommon.attention(),
"Fill in rights field"); msgs.fillInRightsField());
d.addHideHandler(hideHandler); d.addHideHandler(hideHandler);
d.show(); d.show();
} else { } else {
name.setReadOnly(true); fieldName.setReadOnly(true);
description.setReadOnly(true); txtAreaDescription.setReadOnly(true);
rights.setReadOnly(true); txtAreaRights.setReadOnly(true);
goNext(); goNext();
} }
} }
@ -290,19 +299,19 @@ public class CSVTableDetailCard extends WizardCard {
protected void goNext() { protected void goNext() {
try { try {
detail = new TabResource(); detail = new TabResource();
detail.setName(name.getCurrentValue()); detail.setName(fieldName.getCurrentValue());
detail.setDescription(description.getCurrentValue()); detail.setDescription(txtAreaDescription.getCurrentValue());
detail.setRight(rights.getCurrentValue()); detail.setRight(txtAreaRights.getCurrentValue());
detail.setValidFrom(validFrom.getCurrentValue()); detail.setValidFrom(fieldValidFrom.getCurrentValue());
detail.setValidUntilTo(validUntilTo.getCurrentValue()); detail.setValidUntilTo(fieldValidUntilTo.getCurrentValue());
if (validFrom.getCurrentValue() != null if (fieldValidFrom.getCurrentValue() != null
&& validUntilTo.getCurrentValue() != null && fieldValidUntilTo.getCurrentValue() != null
&& validFrom.getCurrentValue().compareTo( && fieldValidFrom.getCurrentValue().compareTo(
validUntilTo.getCurrentValue()) > 0) { fieldValidUntilTo.getCurrentValue()) > 0) {
Log.debug("Attention Valid From field is higher than Valid Until To field"); Log.debug("Attention Valid From field is higher than Valid Until To field");
AlertMessageBox d = new AlertMessageBox("Attention!", AlertMessageBox d = new AlertMessageBox(msgsCommon.attention(),
"Valid From field is higher than Valid Until To field"); msgs.validFromFieldIsHigherThanValidUntilToField());
d.addHideHandler(new HideHandler() { d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) { public void onHide(HideEvent event) {

View File

@ -51,7 +51,6 @@ public class CSVWorkSpaceSelectionCard extends WizardCard {
super(msgs.csvImportFromWorkspace(), ""); super(msgs.csvImportFromWorkspace(), "");
this.importSession = importSession; this.importSession = importSession;
thisCard = this; thisCard = this;
initMessages(); initMessages();
p = new VerticalLayoutContainer(); p = new VerticalLayoutContainer();

View File

@ -2,10 +2,10 @@ package org.gcube.portlets.user.td.csvimportwidget.client;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.user.td.csvimportwidget.client.dataresource.ResourceBundle; import org.gcube.portlets.user.td.csvimportwidget.client.dataresource.ResourceBundle;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVRowError; 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.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Anchor; import com.google.gwt.user.client.ui.Anchor;
@ -21,170 +21,173 @@ import com.sencha.gxt.widget.core.client.tips.ToolTipConfig;
/** /**
* *
* @author "Giancarlo Panichi" * @author "Giancarlo Panichi" <a
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class CsvCheckPanel extends VerticalPanel { public class CsvCheckPanel extends VerticalPanel {
protected static final int ERRORLIMIT = 100; private static final int ERRORLIMIT = 100;
protected static final Image successImage = new Image(ResourceBundle.INSTANCE.csvCheckSuccess()); private static final Image successImage = new Image(
protected static final Image failureImage = new Image(ResourceBundle.INSTANCE.csvCheckFailure()); ResourceBundle.INSTANCE.csvCheckSuccess());
protected static final Image informationImage = new Image(ResourceBundle.INSTANCE.information()); private static final Image failureImage = new Image(
protected static final Image loadingImage = new Image(ResourceBundle.INSTANCE.loading()); ResourceBundle.INSTANCE.csvCheckFailure());
private static final Image informationImage = new Image(
protected CardLayoutContainer messagePanel; ResourceBundle.INSTANCE.information());
private static final Image loadingImage = new Image(
protected HorizontalPanel checkMessagePanel; ResourceBundle.INSTANCE.loading());
protected HorizontalPanel failureMessagePanel;
protected HorizontalPanel successMessagePanel; private CardLayoutContainer messagePanel;
protected HorizontalPanel infoMessagePanel;
private HorizontalPanel checkMessagePanel;
protected TextButton checkConfiguration; private HorizontalPanel failureMessagePanel;
protected TextButton showErrorButton; private HorizontalPanel successMessagePanel;
protected CheckBox skipInvalidCheckBox; private HorizontalPanel infoMessagePanel;
protected Anchor errorAnchor;
private TextButton btnCheckConfiguration;
protected CSVErrorWindow errorWindow = new CSVErrorWindow(); private CheckBox chBoxSkipInvalid;
private Anchor errorAnchor;
public CsvCheckPanel()
{ private CSVErrorWindow errorWindow = new CSVErrorWindow();
private CSVImportWizardTDMessages msgs;
public CsvCheckPanel() {
initMessages();
setSpacing(2); setSpacing(2);
VerticalPanel checkPanel = new VerticalPanel(); VerticalPanel checkPanel = new VerticalPanel();
checkPanel.setSpacing(6); checkPanel.setSpacing(6);
checkConfiguration = new TextButton("Check configuration"); btnCheckConfiguration = new TextButton(msgs.btnCheckConfigurationText());
checkPanel.add(checkConfiguration); checkPanel.add(btnCheckConfiguration);
messagePanel = createMessagesPanel(); messagePanel = createMessagesPanel();
checkPanel.add(messagePanel); checkPanel.add(messagePanel);
add(checkPanel); add(checkPanel);
HorizontalPanel skipPanel = new HorizontalPanel(); HorizontalPanel skipPanel = new HorizontalPanel();
skipPanel.setSpacing(4); skipPanel.setSpacing(4);
skipInvalidCheckBox = new CheckBox(); chBoxSkipInvalid = new CheckBox();
skipInvalidCheckBox.setBoxLabel("Skip invalid lines"); chBoxSkipInvalid.setBoxLabel(msgs.chBoxSkipInvalidLabel());
skipPanel.add(skipInvalidCheckBox); skipPanel.add(chBoxSkipInvalid);
add(skipPanel); add(skipPanel);
setActiveInfoPanel(); setActiveInfoPanel();
} }
protected void initMessages() {
msgs = GWT.create(CSVImportWizardTDMessages.class);
}
/** /**
* @return * @return
*/ */
public TextButton getCheckConfiguration() { public TextButton getCheckConfiguration() {
return checkConfiguration; return btnCheckConfiguration;
} }
/** /**
* @return the skipInvalidCheckBox * @return the skipInvalidCheckBox
*/ */
public CheckBox getSkipInvalidCheckBox() { public CheckBox getSkipInvalidCheckBox() {
return skipInvalidCheckBox; return chBoxSkipInvalid;
} }
protected CardLayoutContainer createMessagesPanel() protected CardLayoutContainer createMessagesPanel() {
{
CardLayoutContainer messagesPanel = new CardLayoutContainer(); CardLayoutContainer messagesPanel = new CardLayoutContainer();
infoMessagePanel = createInfoPanel(); infoMessagePanel = createInfoPanel();
messagesPanel.add(infoMessagePanel); messagesPanel.add(infoMessagePanel);
checkMessagePanel = createCheckPanel(); checkMessagePanel = createCheckPanel();
messagesPanel.add(checkMessagePanel); messagesPanel.add(checkMessagePanel);
failureMessagePanel = createFailurePanel(); failureMessagePanel = createFailurePanel();
messagesPanel.add(failureMessagePanel); messagesPanel.add(failureMessagePanel);
successMessagePanel = createSuccessPanel(); successMessagePanel = createSuccessPanel();
messagesPanel.add(successMessagePanel); messagesPanel.add(successMessagePanel);
return messagesPanel; return messagesPanel;
} }
public void setActiveInfoPanel() public void setActiveInfoPanel() {
{
messagePanel.setActiveWidget(infoMessagePanel); messagePanel.setActiveWidget(infoMessagePanel);
skipInvalidCheckBox.setVisible(false); chBoxSkipInvalid.setVisible(false);
} }
public void setActiveCheckingPanel() public void setActiveCheckingPanel() {
{
messagePanel.setActiveWidget(checkMessagePanel); messagePanel.setActiveWidget(checkMessagePanel);
skipInvalidCheckBox.setVisible(false); chBoxSkipInvalid.setVisible(false);
} }
public void setActiveSuccess() public void setActiveSuccess() {
{
messagePanel.setActiveWidget(successMessagePanel); messagePanel.setActiveWidget(successMessagePanel);
skipInvalidCheckBox.setVisible(false); chBoxSkipInvalid.setVisible(false);
} }
public void setActiveFailure(ArrayList<CSVRowError> errors) public void setActiveFailure(ArrayList<CSVRowError> errors) {
{ if (errors.size() >= ERRORLIMIT)
if (errors.size() >= ERRORLIMIT) errorAnchor.setHTML("Failed (more than "+ERRORLIMIT+" errors)"); errorAnchor.setHTML(msgs.failedMoreThanNumberErrors(ERRORLIMIT));
else errorAnchor.setHTML("Failed ("+errors.size()+" errors)"); else
errorAnchor.setHTML(msgs.failedErrors(errors.size()));
errorWindow.updateGrid(errors); errorWindow.updateGrid(errors);
messagePanel.setActiveWidget(failureMessagePanel); messagePanel.setActiveWidget(failureMessagePanel);
skipInvalidCheckBox.setVisible(true); chBoxSkipInvalid.setVisible(true);
skipInvalidCheckBox.setValue(false); chBoxSkipInvalid.setValue(false);
} }
protected HorizontalPanel createInfoPanel() protected HorizontalPanel createInfoPanel() {
{
HorizontalPanel infoPanel = new HorizontalPanel(); HorizontalPanel infoPanel = new HorizontalPanel();
infoPanel.setSpacing(3); infoPanel.setSpacing(3);
infoPanel.add(informationImage); infoPanel.add(informationImage);
HTML message = new HTML("Check the configuration before submit it"); HTML message = new HTML(msgs.checkTheConfigurationBeforeSubmit());
infoPanel.add(message); infoPanel.add(message);
return infoPanel; return infoPanel;
} }
protected HorizontalPanel createCheckPanel() protected HorizontalPanel createCheckPanel() {
{
HorizontalPanel checkPanel = new HorizontalPanel(); HorizontalPanel checkPanel = new HorizontalPanel();
checkPanel.setSpacing(3); checkPanel.setSpacing(3);
checkPanel.add(loadingImage); checkPanel.add(loadingImage);
checkPanel.add(new HTML("Checking the configuration...")); checkPanel.add(new HTML(msgs.checkingTheConfiguration()));
return checkPanel; return checkPanel;
} }
protected HorizontalPanel createFailurePanel() protected HorizontalPanel createFailurePanel() {
{
HorizontalPanel failurePanel = new HorizontalPanel(); HorizontalPanel failurePanel = new HorizontalPanel();
failurePanel.setSpacing(3); failurePanel.setSpacing(3);
new ToolTip(failurePanel, new ToolTipConfig("Click to obtain more information")); new ToolTip(failurePanel, new ToolTipConfig(
msgs.clickToObtainMoreInformation()));
failurePanel.add(failureImage); failurePanel.add(failureImage);
errorAnchor = new Anchor("Failed"); errorAnchor = new Anchor(msgs.failed());
errorAnchor.addClickHandler(new ClickHandler() { errorAnchor.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
errorWindow.show(); errorWindow.show();
} }
}); });
failurePanel.add(errorAnchor); failurePanel.add(errorAnchor);
return failurePanel; return failurePanel;
} }
protected HorizontalPanel createSuccessPanel() protected HorizontalPanel createSuccessPanel() {
{
HorizontalPanel successPanel = new HorizontalPanel(); HorizontalPanel successPanel = new HorizontalPanel();
successPanel.setSpacing(3); successPanel.setSpacing(3);
successPanel.add(successImage); successPanel.add(successImage);
successPanel.add(new HTML("Correct.")); successPanel.add(new HTML(msgs.correct()));
return successPanel; return successPanel;
} }
} }

View File

@ -36,23 +36,24 @@ import com.sencha.gxt.widget.core.client.form.FormPanel;
*/ */
public class FileUploadPanel extends 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; // private ResourceBundle res;
protected FileUploadField fileUploadField; private FileUploadField fUpField;
protected TextButton uploadButton; 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, public FileUploadPanel(ResourceBundle res, final CSVUploadFileCard card,
final CSVImportSession importSession) { final CSVImportSession importSession) {
this.res = res;
setId("LocalUploadPanel"); setId("LocalUploadPanel");
setLabelAlign(LabelAlign.TOP); setLabelAlign(LabelAlign.TOP);
@ -76,22 +77,22 @@ public class FileUploadPanel extends FormPanel {
content.setWidth("100%"); content.setWidth("100%");
add(content); add(content);
fileUploadField = new FileUploadField(); fUpField = new FileUploadField();
fileUploadField.setName("uploadFormElement"); fUpField.setName("uploadFormElement");
fileUploadField.setWidth("100%"); fUpField.setWidth("100%");
content.add(new FieldLabel(fileUploadField, content.add(new FieldLabel(fUpField,
"Select the csv file to import"), msgs.fUpFieldLabel()),
new VerticalLayoutData(-2, -1)); new VerticalLayoutData(-2, -1));
uploadButton = new TextButton("Upload"); btnUpload = new TextButton(msgs.btnUploadText());
content.add(uploadButton, new VerticalLayoutData(-1, -1)); content.add(btnUpload, new VerticalLayoutData(-1, -1));
fileUploadField.addChangeHandler(new ChangeHandler() { fUpField.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) { public void onChange(ChangeEvent event) {
uploadButton.setEnabled(fileUploadField.isValid()); btnUpload.setEnabled(fUpField.isValid());
String path = fileUploadField.getValue(); String path = fUpField.getValue();
int punto = path.lastIndexOf("."); int punto = path.lastIndexOf(".");
if (punto < 0) { if (punto < 0) {
punto = path.length(); punto = path.length();
@ -119,20 +120,20 @@ public class FileUploadPanel extends FormPanel {
content.add(uploadProgressBar, new VerticalLayoutData(-2, -1)); content.add(uploadProgressBar, new VerticalLayoutData(-2, -1));
uploadProgressBar.hide(); uploadProgressBar.hide();
cancelButton = new TextButton("Cancel"); btnCancel = new TextButton(msgs.btnCancelText());
cancelButton.hide(); btnCancel.hide();
content.add(cancelButton, new VerticalLayoutData(-1, -1)); content.add(btnCancel, new VerticalLayoutData(-1, -1));
uploadButton.addSelectHandler(new SelectHandler() { btnUpload.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) { public void onSelect(SelectEvent event) {
Log.info("request upload"); Log.info("request upload");
if (fileUploadField.getValue() == null if (fUpField.getValue() == null
|| fileUploadField.getValue().equals("")) { || fUpField.getValue().equals("")) {
Log.info("fileUploadField is null or empty"); Log.info("fileUploadField is null or empty");
UtilsGXT3.alert("CSV file missing", UtilsGXT3.alert(msgs.csvFileMissingHead(),
"Please specify a CSV file."); msgs.csvFileMissing());
return; return;
} else { } else {
@ -159,19 +160,23 @@ public class FileUploadPanel extends FormPanel {
public void operationFailed(Throwable caught, String reason, public void operationFailed(Throwable caught, String reason,
String failureDetails) { String failureDetails) {
card.showErrorAndHide("Error uploading the csv file", reason, card.showErrorAndHide(msgs.errorUploadingCSVFileHead(), reason,
"", caught); "", caught);
} }
public void operationComplete() { public void operationComplete() {
card.setEnableNextButton(true); card.setEnableNextButton(true);
cancelButton.disable(); btnCancel.disable();
} }
}); });
} }
protected void initMessages() {
msgs = GWT.create(CSVImportWizardTDMessages.class);
}
protected void startUpload() { protected void startUpload() {
disableUpload(); disableUpload();
@ -186,11 +191,11 @@ public class FileUploadPanel extends FormPanel {
} }
protected void disableUpload() { protected void disableUpload() {
fileUploadField.disable(); fUpField.disable();
uploadButton.disable(); btnUpload.disable();
uploadProgressBar.show(); uploadProgressBar.show();
cancelButton.show(); btnCancel.show();
} }
} }

View File

@ -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.CSVRow;
import org.gcube.portlets.user.td.csvimportwidget.client.data.CSVRowKeyProvider; 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.csvimportwidget.client.data.CSVRowValueProvider;
import org.gcube.portlets.user.td.widgetcommonevent.client.CommonMessages;
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3; import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
import com.allen_sauer.gwt.log.client.Log; 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<CSVRow> { public class CSVGrid extends Grid<CSVRow> {
private static final String csvImportFileServlet = "CSVImportFileServlet"; private static final String csvImportFileServlet = "CSVImportFileServlet";
protected CSVGridView gridViewSample; private CSVGridView gridViewSample;
private CSVGridMessages msgs;
private CommonMessages msgsCommon;
public CSVGrid() { public CSVGrid() {
super(new ListStore<CSVRow>(new CSVRowKeyProvider()), super(new ListStore<CSVRow>(new CSVRowKeyProvider()),
new ColumnModel<CSVRow>( new ColumnModel<CSVRow>(
new ArrayList<ColumnConfig<CSVRow, ?>>())); new ArrayList<ColumnConfig<CSVRow, ?>>()));
initMessages();
setHeight(200); setHeight(200);
setBorders(true); setBorders(true);
@ -51,10 +56,17 @@ public class CSVGrid extends Grid<CSVRow> {
gridViewSample = new CSVGridView(); gridViewSample = new CSVGridView();
setView(gridViewSample); setView(gridViewSample);
getView().setEmptyText("No data to show"); getView().setEmptyText(msgs.noData());
setBorders(true); setBorders(true);
} }
protected void initMessages() {
msgs = GWT.create(CSVGridMessages.class);
msgsCommon = GWT.create(CommonMessages.class);
}
public void configureColumns(ArrayList<String> columnNames) { public void configureColumns(ArrayList<String> columnNames) {
ColumnModel<CSVRow> columnModel = createColumnModel(columnNames); ColumnModel<CSVRow> columnModel = createColumnModel(columnNames);
ListStore<CSVRow> store = createStore(columnNames); ListStore<CSVRow> store = createStore(columnNames);
@ -90,7 +102,7 @@ public class CSVGrid extends Grid<CSVRow> {
} catch (Exception e) { } 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()); Log.error("Error in creating the store: "+e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();

View File

@ -0,0 +1,25 @@
package org.gcube.portlets.user.td.csvimportwidget.client.csvgrid;
import com.google.gwt.i18n.client.Messages;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
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();
}

View File

@ -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.CSVRow;
import org.gcube.portlets.user.td.csvimportwidget.client.dataresource.ResourceBundle; 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.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.event.logical.shared.SelectionHandler;
import com.sencha.gxt.core.client.ValueProvider; 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<CSVRow> { public class CSVGridView extends GridView<CSVRow> {
protected ArrayList<Integer> excludedColumns = new ArrayList<Integer>(); private ArrayList<Integer> excludedColumns = new ArrayList<Integer>();
private CSVGridMessages msgs;
public CSVGridView() public CSVGridView()
{ {
initMessages();
setViewConfig(new GridViewConfig<CSVRow>() { setViewConfig(new GridViewConfig<CSVRow>() {
@ -41,17 +44,22 @@ public class CSVGridView extends GridView<CSVRow> {
} }
}); });
} }
protected void initMessages() {
msgs = GWT.create(CSVGridMessages.class);
}
@Override @Override
protected Menu createContextMenu(final int colIndex) { protected Menu createContextMenu(final int colIndex) {
Menu menu = new Menu(); Menu menu = new Menu();
CheckMenuItem includeMenu = new CheckMenuItem("Include"); CheckMenuItem itmInclude = new CheckMenuItem(msgs.itmInclude());
includeMenu.setGroup("include"); itmInclude.setGroup("include");
includeMenu.setChecked(!excludedColumns.contains(colIndex)); itmInclude.setChecked(!excludedColumns.contains(colIndex));
menu.add(includeMenu); menu.add(itmInclude);
includeMenu.addSelectionHandler(new SelectionHandler<Item>() { itmInclude.addSelectionHandler(new SelectionHandler<Item>() {
public void onSelection(SelectionEvent<Item> event) { public void onSelection(SelectionEvent<Item> event) {
@ -61,12 +69,12 @@ public class CSVGridView extends GridView<CSVRow> {
}); });
CheckMenuItem excludeMenu = new CheckMenuItem("Exclude"); CheckMenuItem itmExclude = new CheckMenuItem(msgs.itmExclude());
excludeMenu.setGroup("include"); itmExclude.setGroup("include");
excludeMenu.setChecked(excludedColumns.contains(colIndex)); itmExclude.setChecked(excludedColumns.contains(colIndex));
menu.add(excludeMenu); menu.add(itmExclude);
excludeMenu.addSelectionHandler(new SelectionHandler<Item>() { itmExclude.addSelectionHandler(new SelectionHandler<Item>() {
public void onSelection(SelectionEvent<Item> event) { public void onSelection(SelectionEvent<Item> event) {
excludedColumns.add(colIndex); excludedColumns.add(colIndex);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,4 @@
noData = No data
errorCreatingTheStore = Error creating the store: {0}
itmInclude = Include
itmExclude = Exclude

View File

@ -0,0 +1,4 @@
noData = Ninguno datos
errorCreatingTheStore = Error, creando el store: {0}
itmInclude = Incluir
itmExclude = Excluir

View File

@ -0,0 +1,5 @@
noData = Nessun dato
errorCreatingTheStore = Errore creando lo store: {0}
itmInclude = Includi
itmExclude = Escludi