Search in sources :

Example 1 with Modal.$

use of org.jboss.hal.ballroom.dialog.Modal.$ 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)

Aggregations

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 HTMLElement (elemental2.dom.HTMLElement)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 JsFunction (jsinterop.annotations.JsFunction)1 JsIgnore (jsinterop.annotations.JsIgnore)1 JsMethod (jsinterop.annotations.JsMethod)1 JsType (jsinterop.annotations.JsType)1 Elements (org.jboss.gwt.elemento.core.Elements)1 EventType.bind (org.jboss.gwt.elemento.core.EventType.bind)1 EventType.click (org.jboss.gwt.elemento.core.EventType.click)1