Search in sources :

Example 1 with ExpressionContext

use of org.jboss.hal.ballroom.form.AbstractFormItem.ExpressionContext in project console by hal.

the class ReadOnlyAppearance method safeApply.

// ------------------------------------------------------ decorations
@Override
protected <C> void safeApply(Decoration decoration, C context) {
    switch(decoration) {
        case DEFAULT:
            defaultValue.textContent = String.valueOf(context);
            if (isApplied(HINT)) {
                valueContainer.insertBefore(defaultValue, hintElement);
            } else {
                valueContainer.appendChild(defaultValue);
            }
            break;
        case DEPRECATED:
            markAsDeprecated((Deprecation) context);
            break;
        case EXPRESSION:
            ExpressionContext ec = (ExpressionContext) context;
            expressionHandler = bind(expressionLink, click, event -> ec.callback.resolveExpression(masked ? backupValue : valueElement.textContent));
            if (isApplied(HINT)) {
                valueContainer.insertBefore(expressionLink, hintElement);
            } else {
                valueContainer.appendChild(expressionLink);
            }
            break;
        case HINT:
            hintElement.textContent = String.valueOf(context);
            valueContainer.appendChild(hintElement);
            break;
        case RESTRICTED:
            valueElement.textContent = "";
            Elements.removeChildrenFrom(valueContainer);
            valueContainer.appendChild(restrictedMarker);
            break;
        case SENSITIVE:
            if (isApplied(EXPRESSION)) {
                valueContainer.insertBefore(peekLink, expressionLink);
            } else {
                valueContainer.appendChild(peekLink);
            }
            mask();
            break;
        // not supported
        case ENABLED:
        case INVALID:
        case REQUIRED:
        case SUGGESTIONS:
            break;
        default:
            break;
    }
}
Also used : Elements.div(org.jboss.gwt.elemento.core.Elements.div) CSS.controlLabel(org.jboss.hal.resources.CSS.controlLabel) CSS.clickable(org.jboss.hal.resources.CSS.clickable) EXPRESSION(org.jboss.hal.ballroom.form.Decoration.EXPRESSION) CSS.formGroup(org.jboss.hal.resources.CSS.formGroup) CSS.halFormLabel(org.jboss.hal.resources.CSS.halFormLabel) READONLY(org.jboss.hal.ballroom.form.Form.State.READONLY) Strings(com.google.common.base.Strings) HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration) SENSITIVE(org.jboss.hal.ballroom.form.Decoration.SENSITIVE) CSS.formControlStatic(org.jboss.hal.resources.CSS.formControlStatic) ExpressionContext(org.jboss.hal.ballroom.form.AbstractFormItem.ExpressionContext) Elements.p(org.jboss.gwt.elemento.core.Elements.p) HTMLElement(elemental2.dom.HTMLElement) Deprecation(org.jboss.hal.dmr.Deprecation) HINT(org.jboss.hal.ballroom.form.Decoration.HINT) CSS.marginRight5(org.jboss.hal.resources.CSS.marginRight5) HIDDEN(org.jboss.hal.resources.UIConstants.HIDDEN) CSS.hint(org.jboss.hal.resources.CSS.hint) Ids(org.jboss.hal.resources.Ids) MASK_CHARACTER(org.jboss.hal.resources.UIConstants.MASK_CHARACTER) Set(java.util.Set) CSS(org.jboss.hal.resources.CSS) EventType.click(org.jboss.gwt.elemento.core.EventType.click) Elements.label(org.jboss.gwt.elemento.core.Elements.label) TRUE(org.jboss.hal.resources.UIConstants.TRUE) EventType.bind(org.jboss.gwt.elemento.core.EventType.bind) CSS.empty(org.jboss.hal.resources.CSS.empty) Elements.span(org.jboss.gwt.elemento.core.Elements.span) CSS.halFormInput(org.jboss.hal.resources.CSS.halFormInput) Elements(org.jboss.gwt.elemento.core.Elements) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) ExpressionContext(org.jboss.hal.ballroom.form.AbstractFormItem.ExpressionContext)

Aggregations

Strings (com.google.common.base.Strings)1 HandlerRegistration (com.google.web.bindery.event.shared.HandlerRegistration)1 HTMLElement (elemental2.dom.HTMLElement)1 Set (java.util.Set)1 Elements (org.jboss.gwt.elemento.core.Elements)1 Elements.div (org.jboss.gwt.elemento.core.Elements.div)1 Elements.label (org.jboss.gwt.elemento.core.Elements.label)1 Elements.p (org.jboss.gwt.elemento.core.Elements.p)1 Elements.span (org.jboss.gwt.elemento.core.Elements.span)1 EventType.bind (org.jboss.gwt.elemento.core.EventType.bind)1 EventType.click (org.jboss.gwt.elemento.core.EventType.click)1 ExpressionContext (org.jboss.hal.ballroom.form.AbstractFormItem.ExpressionContext)1 EXPRESSION (org.jboss.hal.ballroom.form.Decoration.EXPRESSION)1 HINT (org.jboss.hal.ballroom.form.Decoration.HINT)1 SENSITIVE (org.jboss.hal.ballroom.form.Decoration.SENSITIVE)1 READONLY (org.jboss.hal.ballroom.form.Form.State.READONLY)1 Deprecation (org.jboss.hal.dmr.Deprecation)1 CSS (org.jboss.hal.resources.CSS)1 CSS.clickable (org.jboss.hal.resources.CSS.clickable)1 CSS.controlLabel (org.jboss.hal.resources.CSS.controlLabel)1