Search in sources :

Example 1 with READONLY

use of org.jboss.hal.ballroom.form.Form.State.READONLY in project console by hal.

the class AbstractForm method createElement.

// ------------------------------------------------------ ui setup
@Override
protected HTMLElement createElement() {
    HTMLElement section = section().id(id).css(formSection).element();
    formLinks = new FormLinks<>(this, stateMachine, helpTexts, event -> edit(getModel()), event -> {
        if (prepareReset != null) {
            prepareReset.beforeReset(this);
        } else {
            reset();
        }
    }, event -> {
        if (prepareRemove != null) {
            prepareRemove.beforeRemove(this);
        } else {
            remove();
        }
    });
    section.appendChild(formLinks.element());
    errorPanel = div().css(alert, alertDanger).add(span().css(Icons.ERROR)).add(errorMessage = span().element()).add(errorMessages = ul().element()).element();
    clearErrors();
    if (stateMachine.supports(EMPTY)) {
        panels.put(EMPTY, emptyState.element());
    }
    if (stateMachine.supports(READONLY)) {
        panels.put(READONLY, viewPanel());
    }
    if (stateMachine.supports(EDITING)) {
        panels.put(EDITING, editPanel());
    }
    for (HTMLElement element : panels.values()) {
        section.appendChild(element);
    }
    if (stateMachine.supports(EDIT)) {
        escCallback = (KeyboardEvent event) -> {
            if (// NON-NLS
            "Escape".equals(event.key) && stateMachine.current() == EDITING && panels.get(EDITING) != null && Elements.isVisible(panels.get(EDITING))) {
                event.preventDefault();
                cancel();
            }
        };
    }
    State current = stateMachine.current();
    if (current != null) {
        flip(current);
    } else {
        flip(panels.keySet().iterator().next());
    }
    return section;
}
Also used : LazyElement(org.jboss.gwt.elemento.core.LazyElement) Elements.a(org.jboss.gwt.elemento.core.Elements.a) Messages(org.jboss.hal.resources.Messages) Elements.setVisible(org.jboss.gwt.elemento.core.Elements.setVisible) Icons(org.jboss.hal.resources.Icons) CSS.fieldsSectionHeaderPf(org.jboss.hal.resources.CSS.fieldsSectionHeaderPf) Elements.fieldset(org.jboss.gwt.elemento.core.Elements.fieldset) VIEW(org.jboss.hal.ballroom.form.Form.Operation.VIEW) KeyboardEvent(elemental2.dom.KeyboardEvent) EventType.keyup(org.jboss.gwt.elemento.core.EventType.keyup) HTMLElement(elemental2.dom.HTMLElement) CLEAR(org.jboss.hal.ballroom.form.Form.Operation.CLEAR) Map(java.util.Map) HTMLHRElement(elemental2.dom.HTMLHRElement) CSS.fieldSectionTogglePf(org.jboss.hal.resources.CSS.fieldSectionTogglePf) CSS.form(org.jboss.hal.resources.CSS.form) HTMLLegendElement(elemental2.dom.HTMLLegendElement) Set(java.util.Set) EventType.click(org.jboss.gwt.elemento.core.EventType.click) EDIT(org.jboss.hal.ballroom.form.Form.Operation.EDIT) List(java.util.List) HTMLUListElement(elemental2.dom.HTMLUListElement) CSS.faAngleDown(org.jboss.hal.resources.CSS.faAngleDown) Attachable(org.jboss.hal.ballroom.Attachable) Elements.li(org.jboss.gwt.elemento.core.Elements.li) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) DomGlobal.setTimeout(elemental2.dom.DomGlobal.setTimeout) CSS.btnHal(org.jboss.hal.resources.CSS.btnHal) Elements.div(org.jboss.gwt.elemento.core.Elements.div) Iterables(com.google.common.collect.Iterables) Elements.ul(org.jboss.gwt.elemento.core.Elements.ul) EDITING(org.jboss.hal.ballroom.form.Form.State.EDITING) CSS.alert(org.jboss.hal.resources.CSS.alert) CSS.btnDefault(org.jboss.hal.resources.CSS.btnDefault) HashMap(java.util.HashMap) GWT(com.google.gwt.core.client.GWT) CSS.clickable(org.jboss.hal.resources.CSS.clickable) CSS.editing(org.jboss.hal.resources.CSS.editing) CSS.helpBlock(org.jboss.hal.resources.CSS.helpBlock) ArrayList(java.util.ArrayList) Elements.hr(org.jboss.gwt.elemento.core.Elements.hr) CSS.formGroup(org.jboss.hal.resources.CSS.formGroup) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) READONLY(org.jboss.hal.ballroom.form.Form.State.READONLY) CSS.btnPrimary(org.jboss.hal.resources.CSS.btnPrimary) HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration) Lists(com.google.common.collect.Lists) Elements.section(org.jboss.gwt.elemento.core.Elements.section) EventCallbackFn(org.jboss.gwt.elemento.core.EventCallbackFn) ImmutableList(com.google.common.collect.ImmutableList) SAVE(org.jboss.hal.ballroom.form.Form.Operation.SAVE) CSS.fieldsSectionPf(org.jboss.hal.resources.CSS.fieldsSectionPf) Constants(org.jboss.hal.resources.Constants) CSS.alertDanger(org.jboss.hal.resources.CSS.alertDanger) CSS.separator(org.jboss.hal.resources.CSS.separator) EmptyState(org.jboss.hal.ballroom.EmptyState) CANCEL(org.jboss.hal.ballroom.form.Form.Operation.CANCEL) EMPTY(org.jboss.hal.ballroom.form.Form.State.EMPTY) Elements.button(org.jboss.gwt.elemento.core.Elements.button) Iterator(java.util.Iterator) HTMLFieldSetElement(elemental2.dom.HTMLFieldSetElement) Ids(org.jboss.hal.resources.Ids) CSS.readonly(org.jboss.hal.resources.CSS.readonly) CSS.btn(org.jboss.hal.resources.CSS.btn) Elements.legend(org.jboss.gwt.elemento.core.Elements.legend) REMOVE(org.jboss.hal.ballroom.form.Form.Operation.REMOVE) CSS.formSection(org.jboss.hal.resources.CSS.formSection) Collectors.toList(java.util.stream.Collectors.toList) CSS.halFormOffset(org.jboss.hal.resources.CSS.halFormOffset) CSS.pullRight(org.jboss.hal.resources.CSS.pullRight) HTMLDivElement(elemental2.dom.HTMLDivElement) CSS.formHorizontal(org.jboss.hal.resources.CSS.formHorizontal) EventType.bind(org.jboss.gwt.elemento.core.EventType.bind) RESET(org.jboss.hal.ballroom.form.Form.Operation.RESET) CSS.formButtons(org.jboss.hal.resources.CSS.formButtons) Elements.span(org.jboss.gwt.elemento.core.Elements.span) Elements(org.jboss.gwt.elemento.core.Elements) MEDIUM_TIMEOUT(org.jboss.hal.resources.UIConstants.MEDIUM_TIMEOUT) HTMLElement(elemental2.dom.HTMLElement) EmptyState(org.jboss.hal.ballroom.EmptyState) KeyboardEvent(elemental2.dom.KeyboardEvent)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 GWT (com.google.gwt.core.client.GWT)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 HandlerRegistration (com.google.web.bindery.event.shared.HandlerRegistration)1 DomGlobal.setTimeout (elemental2.dom.DomGlobal.setTimeout)1 HTMLDivElement (elemental2.dom.HTMLDivElement)1 HTMLElement (elemental2.dom.HTMLElement)1 HTMLFieldSetElement (elemental2.dom.HTMLFieldSetElement)1 HTMLHRElement (elemental2.dom.HTMLHRElement)1 HTMLLegendElement (elemental2.dom.HTMLLegendElement)1 HTMLUListElement (elemental2.dom.HTMLUListElement)1 KeyboardEvent (elemental2.dom.KeyboardEvent)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1