use of org.activityinfo.ui.client.component.importDialog.PageChangedEvent in project activityinfo by bedatadriven.
the class ColumnMappingGrid method refreshWithNewlyParsedRows.
private void refreshWithNewlyParsedRows() {
eventBus.fireEvent(new PageChangedEvent(false, I18N.CONSTANTS.parsingRows()));
Scheduler.get().scheduleFixedPeriod(new Scheduler.RepeatingCommand() {
@Override
public boolean execute() {
SourceTable sourceTable = model.getSource();
if (!sourceTable.parsedAllRows()) {
sourceTable.parseNextRows(50);
ColumnMappingGrid.this.setRowData(model.getSource().getRows());
ColumnMappingGrid.this.getRowElement(ColumnMappingGrid.this.getRowCount() - 1).scrollIntoView();
} else {
ColumnMappingGrid.this.scrollColumnIntoView(0);
eventBus.fireEvent(new PageChangedEvent(true, ""));
return false;
}
return true;
}
}, 1);
}
use of org.activityinfo.ui.client.component.importDialog.PageChangedEvent in project activityinfo by bedatadriven.
the class ChooseSourcePage method fireStateChanged.
@Override
public void fireStateChanged() {
// validate
boolean valid = false;
PastedTable pastedTable = null;
try {
pastedTable = new PastedTable(textArea.getValue());
valid = !pastedTable.getRows().isEmpty();
if (valid) {
boolean isFirstColumnHeaderBlank = Strings.isNullOrEmpty(pastedTable.getColumnHeader(0));
if (isFirstColumnHeaderBlank) {
// first row may be occupied by attribute group name, so we just cut it
valid = false;
String source = textArea.getValue().substring(textArea.getValue().indexOf("\n") + 1);
pastedTable = new PastedTable(source);
valid = !pastedTable.getRows().isEmpty();
}
}
} catch (Exception e) {
// ignore : text is not valid
}
if (valid) {
pastedTable.guessColumnsType(JsConverterFactory.get());
model.setSource(pastedTable);
eventBus.fireEvent(new PageChangedEvent(true, ""));
} else {
eventBus.fireEvent(new PageChangedEvent(false, errorMessage(pastedTable)));
}
}
Aggregations