use of org.activityinfo.ui.client.component.importDialog.model.ColumnAction in project activityinfo by bedatadriven.
the class ColumnActionSelector method updateTypeStyles.
public void updateTypeStyles(FieldTypeClass sourceType) {
for (Map.Entry<ColumnAction, RadioButton> entry : buttons.entrySet()) {
final ColumnAction columnAction = entry.getKey();
if (columnAction instanceof MapExistingAction) {
final ImportTarget target = ((MapExistingAction) columnAction).getTarget();
final FieldTypeClass targetType = target.getFormField().getType().getTypeClass();
final RadioButton button = entry.getValue();
button.removeStyleName(ColumnMappingStyles.INSTANCE.typeNotMatched());
button.removeStyleName(ColumnMappingStyles.INSTANCE.typeMatched());
if (targetType == sourceType || (sourceType == FieldTypeClass.FREE_TEXT && targetType == FieldTypeClass.REFERENCE)) {
button.addStyleName(ColumnMappingStyles.INSTANCE.typeMatched());
} else {
button.addStyleName(ColumnMappingStyles.INSTANCE.typeNotMatched());
}
}
}
}
use of org.activityinfo.ui.client.component.importDialog.model.ColumnAction in project activityinfo by bedatadriven.
the class ColumnMappingGrid method refreshColumnStyles.
/**
* Updates the column styles to match the column's current binding
*/
public void refreshColumnStyles(int columnIndex) {
// update the column styles
final SourceColumn sourceColumn = model.getSourceColumn(columnIndex);
ColumnAction binding = model.getColumnAction(sourceColumn);
toggleColumnStyle(columnIndex, ColumnMappingStyles.INSTANCE.stateIgnored(), binding != null && binding == IgnoreAction.INSTANCE);
toggleColumnStyle(columnIndex, ColumnMappingStyles.INSTANCE.stateBound(), binding != null && binding != IgnoreAction.INSTANCE);
toggleColumnStyle(columnIndex, ColumnMappingStyles.INSTANCE.stateUnset(), binding == null);
// update the mapping description
Cell.Context context = new Cell.Context(MAPPING_HEADER_ROW, columnIndex, null);
SafeHtmlBuilder html = new SafeHtmlBuilder();
headerCell.render(context, sourceColumn, html);
getTableHead(MAPPING_HEADER_ROW, columnIndex).setInnerSafeHtml(html.toSafeHtml());
}
use of org.activityinfo.ui.client.component.importDialog.model.ColumnAction in project activityinfo by bedatadriven.
the class ColumnActionSelector method updateStyles.
public void updateStyles() {
for (Map.Entry<ColumnAction, RadioButton> entry : buttons.entrySet()) {
final ColumnAction columnAction = entry.getKey();
if (columnAction instanceof MapExistingAction) {
final ImportTarget target = ((MapExistingAction) columnAction).getTarget();
final RadioButton button = entry.getValue();
button.removeStyleName(ColumnMappingStyles.INSTANCE.stateBound());
button.removeStyleName(ColumnMappingStyles.INSTANCE.stateUnset());
if (!importModel.getMappedColumns(target.getFormField().getId()).isEmpty()) {
button.addStyleName(ColumnMappingStyles.INSTANCE.stateBound());
} else if (target.getFormField().isRequired()) {
button.addStyleName(ColumnMappingStyles.INSTANCE.stateUnset());
}
}
}
}
use of org.activityinfo.ui.client.component.importDialog.model.ColumnAction in project activityinfo by bedatadriven.
the class GridHeaderCell method render.
@Override
public void render(Context context, SourceColumn column, SafeHtmlBuilder sb) {
if (context.getIndex() == ColumnMappingGrid.SOURCE_COLUMN_HEADER_ROW) {
sb.append(SafeHtmlUtils.fromTrustedString("<span title='" + column.getHeader() + "'>"));
sb.appendEscaped(column.getHeader());
sb.append(SafeHtmlUtils.fromTrustedString("</span>"));
} else {
ColumnAction action = model.getColumnAction(column);
if (action == null) {
sb.appendHtmlConstant(I18N.CONSTANTS.chooseFieldHeading());
} else if (action == IgnoreAction.INSTANCE) {
sb.appendEscaped(I18N.CONSTANTS.ignoreColumnAction());
} else if (action instanceof MapExistingAction) {
String label = ((MapExistingAction) action).getTarget().getLabel();
sb.append(SafeHtmlUtils.fromTrustedString("<span title='" + label + "'>"));
sb.appendEscaped(label);
sb.append(SafeHtmlUtils.fromTrustedString("</span>"));
}
}
}
Aggregations