Search in sources :

Example 1 with State

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

the class AbstractFormItem method attach.

/**
 * Calls {@code SuggestHandler.attach()} in case there was one registered. If you override this method, please call
 * {@code super.attach()} to keep this behaviour.
 */
@Override
public void attach() {
    if (form != null) {
        // if there's a back reference use it to attach only the appearances which are supported by the form
        for (Map.Entry<State, Appearance<T>> entry : appearances.entrySet()) {
            State state = entry.getKey();
            if (form.getStateMachine().supports(state)) {
                Appearance<T> appearance = entry.getValue();
                appearance.attach();
            }
        }
        if (form.getStateMachine().supports(State.EDITING) && suggestHandler instanceof Attachable) {
            ((Attachable) suggestHandler).attach();
        }
    } else {
        appearances.values().forEach(Appearance::attach);
        if (suggestHandler instanceof Attachable) {
            ((Attachable) suggestHandler).attach();
        }
    }
}
Also used : State(org.jboss.hal.ballroom.form.Form.State) Attachable(org.jboss.hal.ballroom.Attachable) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 Attachable (org.jboss.hal.ballroom.Attachable)1 State (org.jboss.hal.ballroom.form.Form.State)1