2013-10-24 15:32:03 +02:00
|
|
|
package org.gcube.portlets.user.td.csvimportwidget.client;
|
2013-10-24 12:32:40 +02:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2013-10-24 14:39:01 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVRowError;
|
2013-10-24 12:32:40 +02:00
|
|
|
|
|
|
|
import com.google.gwt.core.client.GWT;
|
|
|
|
import com.sencha.gxt.core.client.ValueProvider;
|
|
|
|
import com.sencha.gxt.data.shared.ListStore;
|
|
|
|
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
|
|
|
import com.sencha.gxt.data.shared.PropertyAccess;
|
|
|
|
import com.sencha.gxt.widget.core.client.Window;
|
|
|
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
|
|
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
|
|
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
|
|
|
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
|
|
|
|
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
|
|
|
|
import com.sencha.gxt.widget.core.client.grid.Grid;
|
|
|
|
|
|
|
|
/**
|
2013-10-24 15:32:03 +02:00
|
|
|
*
|
2015-10-16 18:40:44 +02:00
|
|
|
* @author "Giancarlo Panichi" <a
|
|
|
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
2013-10-24 12:32:40 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class CSVErrorWindow extends Window {
|
2015-10-16 18:40:44 +02:00
|
|
|
|
|
|
|
private static final CSVRowErrorProperties props = GWT
|
|
|
|
.create(CSVRowErrorProperties.class);
|
|
|
|
private CSVImportWizardTDMessages msgs;
|
|
|
|
|
|
|
|
private Grid<CSVRowError> gridErrors;
|
|
|
|
private ListStore<CSVRowError> storeGridErrors;
|
|
|
|
|
|
|
|
public CSVErrorWindow() {
|
|
|
|
initMessages();
|
|
|
|
setHeadingText(msgs.csvErrorWindowHead());
|
2013-10-24 12:32:40 +02:00
|
|
|
setModal(true);
|
|
|
|
setBlinkModal(true);
|
|
|
|
setWidth(600);
|
|
|
|
setHeight(350);
|
2015-10-16 18:40:44 +02:00
|
|
|
|
2013-10-24 12:32:40 +02:00
|
|
|
createGrid();
|
2015-10-16 18:40:44 +02:00
|
|
|
add(gridErrors);
|
|
|
|
|
|
|
|
TextButton btnClose = new TextButton(msgs.btnCloseText());
|
|
|
|
btnClose.addSelectHandler(new SelectHandler() {
|
|
|
|
|
2013-10-24 12:32:40 +02:00
|
|
|
public void onSelect(SelectEvent event) {
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
});
|
2015-10-16 18:40:44 +02:00
|
|
|
|
|
|
|
addButton(btnClose);
|
2013-10-24 12:32:40 +02:00
|
|
|
setButtonAlign(BoxLayoutPack.CENTER);
|
|
|
|
}
|
2015-10-16 18:40:44 +02:00
|
|
|
|
|
|
|
protected void initMessages() {
|
|
|
|
msgs = GWT.create(CSVImportWizardTDMessages.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void createGrid() {
|
2013-10-24 12:32:40 +02:00
|
|
|
ArrayList<ColumnConfig<CSVRowError, ?>> columns = new ArrayList<ColumnConfig<CSVRowError, ?>>();
|
2015-10-16 18:40:44 +02:00
|
|
|
|
|
|
|
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);
|
2013-10-24 12:32:40 +02:00
|
|
|
}
|
2015-10-16 18:40:44 +02:00
|
|
|
|
|
|
|
public void updateGrid(ArrayList<CSVRowError> errors) {
|
|
|
|
storeGridErrors.clear();
|
|
|
|
storeGridErrors.addAll(errors);
|
2013-10-24 12:32:40 +02:00
|
|
|
}
|
2015-10-16 18:40:44 +02:00
|
|
|
|
|
|
|
protected interface CSVRowErrorProperties extends
|
|
|
|
PropertyAccess<CSVRowError> {
|
|
|
|
|
|
|
|
ModelKeyProvider<CSVRowError> id();
|
|
|
|
|
|
|
|
ValueProvider<CSVRowError, Integer> lineNumber();
|
|
|
|
|
|
|
|
ValueProvider<CSVRowError, String> lineValue();
|
|
|
|
|
|
|
|
ValueProvider<CSVRowError, String> errorDescription();
|
2013-10-24 12:32:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|