Search in sources :

Example 1 with Attachable

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);
}
Also used : Arrays(java.util.Arrays) IsElement(org.jboss.gwt.elemento.core.IsElement) Iterables(com.google.common.collect.Iterables) JsMethod(jsinterop.annotations.JsMethod) HashMap(java.util.HashMap) JsCallback(org.jboss.hal.ballroom.JsCallback) GWT(com.google.gwt.core.client.GWT) ArrayList(java.util.ArrayList) Modal.$(org.jboss.hal.ballroom.dialog.Modal.$) Constants(org.jboss.hal.resources.Constants) HTMLElement(elemental2.dom.HTMLElement) JsFunction(jsinterop.annotations.JsFunction) Map(java.util.Map) PatternFly(org.jboss.hal.ballroom.PatternFly) JsType(jsinterop.annotations.JsType) DomGlobal.document(elemental2.dom.DomGlobal.document) Ids(org.jboss.hal.resources.Ids) CSS(org.jboss.hal.resources.CSS) EventType.click(org.jboss.gwt.elemento.core.EventType.click) JsIgnore(jsinterop.annotations.JsIgnore) List(java.util.List) UIConstants(org.jboss.hal.resources.UIConstants) TreeMap(java.util.TreeMap) Callback(org.jboss.hal.spi.Callback) ModalOptions(org.jboss.hal.ballroom.dialog.Modal.ModalOptions) Attachable(org.jboss.hal.ballroom.Attachable) HTMLButtonElement(elemental2.dom.HTMLButtonElement) EventType.bind(org.jboss.gwt.elemento.core.EventType.bind) Collections(java.util.Collections) SortedMap(java.util.SortedMap) Elements(org.jboss.gwt.elemento.core.Elements) HTMLElement(elemental2.dom.HTMLElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement) Attachable(org.jboss.hal.ballroom.Attachable) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap)

Example 2 with Attachable

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();
        }
    }
}
Also used : State(org.jboss.hal.ballroom.form.Form.State) Attachable(org.jboss.hal.ballroom.Attachable) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with Attachable

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++;
    }
}
Also used : CSS(org.jboss.hal.resources.CSS) HTMLLIElement(elemental2.dom.HTMLLIElement) HTMLDivElement(elemental2.dom.HTMLDivElement) Attachable(org.jboss.hal.ballroom.Attachable) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 4 with Attachable

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;
    }
}
Also used : Attachable(org.jboss.hal.ballroom.Attachable)

Aggregations

Attachable (org.jboss.hal.ballroom.Attachable)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 CSS (org.jboss.hal.resources.CSS)2 Iterables (com.google.common.collect.Iterables)1 GWT (com.google.gwt.core.client.GWT)1 DomGlobal.document (elemental2.dom.DomGlobal.document)1 HTMLButtonElement (elemental2.dom.HTMLButtonElement)1 HTMLDivElement (elemental2.dom.HTMLDivElement)1 HTMLElement (elemental2.dom.HTMLElement)1 HTMLLIElement (elemental2.dom.HTMLLIElement)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 JsFunction (jsinterop.annotations.JsFunction)1 JsIgnore (jsinterop.annotations.JsIgnore)1