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;
}
Aggregations