use of org.jboss.hal.ballroom.Attachable in project console by hal.
the class Dialog method show.
public void show() {
if (Dialog.open) {
throw new IllegalStateException("Another dialog is still open. Only one dialog can be open at a time. Please close the other dialog!");
}
reset();
if (builder.fadeIn) {
Dialog.root.classList.add(fade);
}
Dialog.dialog.classList.add(builder.size.css);
setVisible(Dialog.closeIcon, builder.closeIcon);
setTitle(builder.title);
for (HTMLElement element : builder.elements) {
Dialog.body.appendChild(element);
}
if (!builder.buttons.isEmpty()) {
for (Map.Entry<Integer, Button> entry : builder.buttons.entrySet()) {
int position = entry.getKey();
Button button = entry.getValue();
String css = btn + " " + btnHal + " " + (button.primary ? btnPrimary : btnDefault);
if (position < 0) {
css = css + " " + pullLeft;
}
HTMLButtonElement buttonElement = button(button.label).css(css).on(click, event -> {
if (button.resultCallback != null) {
if (button.resultCallback.eval()) {
close();
}
} else if (button.simpleCallback != null) {
button.simpleCallback.execute();
close();
} else {
close();
}
}).element();
Dialog.footer.appendChild(buttonElement);
buttons.put(position, buttonElement);
}
}
setVisible(Dialog.footer, !buttons.isEmpty());
attachables.forEach(Attachable::attach);
$(SELECTOR_ID).modal(ModalOptions.create(builder.closeOnEsc));
$(SELECTOR_ID).modal("show");
PatternFly.initComponents(SELECTOR_ID);
}
use of org.jboss.hal.ballroom.Attachable 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();
}
}
}
use of org.jboss.hal.ballroom.Attachable in project console by hal.
the class Wizard method initSteps.
// ------------------------------------------------------ private methods
private void initSteps() {
int index = 1;
for (Map.Entry<S, WizardStep<C, S>> entry : steps.entrySet()) {
S status = entry.getKey();
WizardStep<C, S> step = entry.getValue();
HTMLLIElement li = li().css(wizardPfStep).add(a().add(span().css(wizardPfStepNumber).textContent(String.valueOf(index))).add(span().css(wizardPfStepTitle).textContent(step.title))).element();
stepIndicators.put(status, li);
stepsNames.appendChild(li);
HTMLDivElement wrapper = div().css(wizardPfContents).add(step).element();
step.attachables.forEach(Attachable::attach);
Elements.setVisible(wrapper, false);
mainContainer.appendChild(wrapper);
stepElements.put(status, wrapper);
index++;
}
}
use of org.jboss.hal.ballroom.Attachable in project console by hal.
the class HalViewImpl method attach.
@Override
public void attach() {
if (!attached) {
PatternFly.initComponents();
for (Attachable attachable : attachables) {
attachable.attach();
}
attached = true;
}
}
Aggregations