Search in sources :

Example 1 with ColumnAction

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());
            }
        }
    }
}
Also used : ColumnAction(org.activityinfo.ui.client.component.importDialog.model.ColumnAction) ImportTarget(org.activityinfo.ui.client.component.importDialog.model.strategy.ImportTarget) FieldTypeClass(org.activityinfo.model.type.FieldTypeClass) MapExistingAction(org.activityinfo.ui.client.component.importDialog.model.MapExistingAction) RadioButton(org.activityinfo.ui.client.widget.RadioButton) Map(java.util.Map)

Example 2 with ColumnAction

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());
}
Also used : ColumnAction(org.activityinfo.ui.client.component.importDialog.model.ColumnAction) SourceColumn(org.activityinfo.ui.client.component.importDialog.model.source.SourceColumn) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Cell(com.google.gwt.cell.client.Cell)

Example 3 with ColumnAction

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());
            }
        }
    }
}
Also used : ColumnAction(org.activityinfo.ui.client.component.importDialog.model.ColumnAction) ImportTarget(org.activityinfo.ui.client.component.importDialog.model.strategy.ImportTarget) MapExistingAction(org.activityinfo.ui.client.component.importDialog.model.MapExistingAction) RadioButton(org.activityinfo.ui.client.widget.RadioButton) Map(java.util.Map)

Example 4 with ColumnAction

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>"));
        }
    }
}
Also used : ColumnAction(org.activityinfo.ui.client.component.importDialog.model.ColumnAction) MapExistingAction(org.activityinfo.ui.client.component.importDialog.model.MapExistingAction)

Aggregations

ColumnAction (org.activityinfo.ui.client.component.importDialog.model.ColumnAction)4 MapExistingAction (org.activityinfo.ui.client.component.importDialog.model.MapExistingAction)3 Map (java.util.Map)2 ImportTarget (org.activityinfo.ui.client.component.importDialog.model.strategy.ImportTarget)2 RadioButton (org.activityinfo.ui.client.widget.RadioButton)2 Cell (com.google.gwt.cell.client.Cell)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 FieldTypeClass (org.activityinfo.model.type.FieldTypeClass)1 SourceColumn (org.activityinfo.ui.client.component.importDialog.model.source.SourceColumn)1