Search in sources :

Example 1 with NOT_AVAILABLE

use of org.jboss.hal.resources.Names.NOT_AVAILABLE in project console by hal.

the class FinderColumn method newColumnButton.

private HTMLElement newColumnButton(ColumnAction<T> action) {
    HtmlContentBuilder<? extends HTMLElement> builder;
    if (!action.actions.isEmpty()) {
        HTMLElement button;
        HTMLElement ul;
        builder = div().css(dropdown).add(button = button().css(btn, btnFinder, dropdownToggle).id(action.id).data(UIConstants.TOGGLE, UIConstants.DROPDOWN).aria(UIConstants.EXPANDED, UIConstants.FALSE).element()).add(ul = ul().css(dropdownMenu).id(Ids.uniqueId()).attr(UIConstants.ROLE, UIConstants.MENU).aria(UIConstants.LABELLED_BY, action.id).element());
        if (action.title != null) {
            button.textContent = action.title;
        } else if (action.element != null) {
            button.appendChild(action.element);
        } else {
            button.textContent = NOT_AVAILABLE;
        }
        button.appendChild(span().css(caret).element());
        for (ColumnAction<T> liAction : action.actions) {
            HTMLElement a;
            ul.appendChild(li().attr(UIConstants.ROLE, UIConstants.PRESENTATION).add(a = a().id(liAction.id).attr(UIConstants.ROLE, UIConstants.MENUITEM).attr(UIConstants.TABINDEX, "-1").on(click, event -> {
                if (liAction.handler != null) {
                    liAction.handler.execute(this);
                }
            }).element()).element());
            if (liAction.title != null) {
                a.textContent = liAction.title;
            } else if (liAction.element != null) {
                a.appendChild(liAction.element);
            } else {
                a.textContent = NOT_AVAILABLE;
            }
        }
    } else {
        builder = button().css(btn, btnFinder).id(action.id).on(click, event -> {
            if (action.handler != null) {
                action.handler.execute(this);
            }
        });
        if (action.title != null) {
            builder.textContent(action.title);
        } else if (action.element != null) {
            builder.add(action.element);
        } else {
            builder.textContent(NOT_AVAILABLE);
        }
    }
    return builder.element();
}
Also used : IsElement(org.jboss.gwt.elemento.core.IsElement) HTMLInputElement(elemental2.dom.HTMLInputElement) Constraint(org.jboss.hal.meta.security.Constraint) LoggerFactory(org.slf4j.LoggerFactory) Tooltip(org.jboss.hal.ballroom.Tooltip) HtmlContentBuilder(org.jboss.gwt.elemento.core.builder.HtmlContentBuilder) DATA_BREADCRUMB(org.jboss.hal.core.finder.Finder.DATA_BREADCRUMB) FormItemValidation(org.jboss.hal.ballroom.form.FormItemValidation) KeyboardEvent(elemental2.dom.KeyboardEvent) EventType.keyup(org.jboss.gwt.elemento.core.EventType.keyup) AuthorisationDecision(org.jboss.hal.meta.security.AuthorisationDecision) HTMLElement(elemental2.dom.HTMLElement) Escape(org.jboss.gwt.elemento.core.Key.Escape) Map(java.util.Map) NodeList(elemental2.dom.NodeList) EventType.keydown(org.jboss.gwt.elemento.core.EventType.keydown) ArrowUp(org.jboss.gwt.elemento.core.Key.ArrowUp) Elements.header(org.jboss.gwt.elemento.core.Elements.header) ROLE(org.jboss.hal.resources.UIConstants.ROLE) Key(org.jboss.gwt.elemento.core.Key) Predicate(java.util.function.Predicate) Set(java.util.Set) CSS(org.jboss.hal.resources.CSS) EventType.click(org.jboss.gwt.elemento.core.EventType.click) DATA_FILTER(org.jboss.hal.core.finder.Finder.DATA_FILTER) List(java.util.List) UIConstants(org.jboss.hal.resources.UIConstants) Callback(org.jboss.hal.spi.Callback) NamedObject(org.jboss.hal.spi.NamedObject) Attachable(org.jboss.hal.ballroom.Attachable) HASH(org.jboss.hal.resources.UIConstants.HASH) Element(elemental2.dom.Element) Iterables(com.google.common.collect.Iterables) DragEvent(elemental2.dom.DragEvent) Constraints(org.jboss.hal.meta.security.Constraints) HashMap(java.util.HashMap) TABINDEX(org.jboss.hal.resources.UIConstants.TABINDEX) GWT(com.google.gwt.core.client.GWT) GROUP(org.jboss.hal.resources.UIConstants.GROUP) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) UniqueNameValidation(org.jboss.hal.ballroom.form.UniqueNameValidation) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration) NOT_AVAILABLE(org.jboss.hal.resources.Names.NOT_AVAILABLE) JsHelper(org.jboss.hal.js.JsHelper) EventCallbackFn(org.jboss.gwt.elemento.core.EventCallbackFn) Constants(org.jboss.hal.resources.Constants) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Ids(org.jboss.hal.resources.Ids) InputType.text(org.jboss.gwt.elemento.core.InputType.text) Collectors.toList(java.util.stream.Collectors.toList) HTMLDivElement(elemental2.dom.HTMLDivElement) EventType.bind(org.jboss.gwt.elemento.core.EventType.bind) Strings(org.jboss.hal.resources.Strings) Collections(java.util.Collections) Elements(org.jboss.gwt.elemento.core.Elements) HTMLElement(elemental2.dom.HTMLElement) GWT(com.google.gwt.core.client.GWT)

Example 2 with NOT_AVAILABLE

use of org.jboss.hal.resources.Names.NOT_AVAILABLE in project console by hal.

the class FinderRow method drawItem.

private void drawItem() {
    Elements.removeChildrenFrom(root);
    root.id = id;
    root.dataset.set(DATA_BREADCRUMB, display.getTitle());
    // TODO getFilterData() causes a ReferenceError in SuperDevMode WTF?
    if (display.getFilterData() != null) {
        root.dataset.set(DATA_FILTER, display.getFilterData());
    }
    HTMLElement icon = display.getIcon();
    if (icon != null) {
        icon.classList.add(itemIcon);
        root.appendChild(icon);
    }
    HTMLElement itemElement;
    if (display.element() != null) {
        itemElement = display.element();
    } else if (display.getTitle() != null) {
        itemElement = span().css(itemText).textContent(display.getTitle()).element();
    } else {
        itemElement = span().css(itemText).textContent(NOT_AVAILABLE).element();
    }
    if (display.getTooltip() != null && itemElement != null) {
        itemElement.title = display.getTooltip();
        itemElement.dataset.set(UIConstants.TOGGLE, UIConstants.TOOLTIP);
        itemElement.dataset.set(UIConstants.PLACEMENT, "top");
    }
    root.appendChild(itemElement);
    // oder: 1) pin/unpin icon, 2) folder icon, 3) button(s)
    if (column.isPinnable()) {
        root.appendChild(span().css(CSS.unpin, pfIcon("close")).title(CONSTANTS.unpin()).on(click, e -> column.unpin(FinderRow.this)).data(PREVENT_SET_ITEMS, UIConstants.TRUE).element());
        root.appendChild(span().css(CSS.pin, pfIcon("thumb-tack-o")).title(CONSTANTS.pin()).on(click, e -> column.pin(FinderRow.this)).data(PREVENT_SET_ITEMS, UIConstants.TRUE).element());
    }
    if (display.nextColumn() != null) {
        folderElement = span().css(folder, fontAwesome("angle-right")).element();
        root.appendChild(folderElement);
    }
    if (!actions.isEmpty()) {
        if (actions.size() == 1) {
            ItemAction<T> action = actions.get(0);
            buttonContainer = actionLink(action, false);
        } else {
            HTMLUListElement ul = null;
            boolean firstAction = true;
            boolean ulCreated = false;
            buttonContainer = div().css(btnGroup, pullRight).data(PREVENT_SET_ITEMS, UIConstants.TRUE).element();
            for (ItemAction<T> action : actions) {
                if (firstAction) {
                    buttonContainer.appendChild(actionLink(action, false));
                    buttonContainer.appendChild(button().css(btn, btnFinder, dropdownToggle).data(UIConstants.TOGGLE, UIConstants.DROPDOWN).data(PREVENT_SET_ITEMS, UIConstants.TRUE).aria(UIConstants.HAS_POPUP, UIConstants.TRUE).aria(UIConstants.EXPANDED, UIConstants.FALSE).add(span().css(caret).data(PREVENT_SET_ITEMS, UIConstants.TRUE)).add(span().css(srOnly).data(PREVENT_SET_ITEMS, UIConstants.TRUE).textContent(CONSTANTS.toggleDropdown())).element());
                    firstAction = false;
                } else {
                    if (!ulCreated) {
                        buttonContainer.appendChild(ul = ul().css(dropdownMenu).data(PREVENT_SET_ITEMS, UIConstants.TRUE).element());
                        ulCreated = true;
                    }
                    if (action == ItemAction.SEPARATOR) {
                        ul.appendChild(li().css(divider).attr(UIConstants.ROLE, UIConstants.SEPARATOR).element());
                    } else {
                        ul.appendChild(li().data(PREVENT_SET_ITEMS, UIConstants.TRUE).add(actionLink(action, true)).element());
                    }
                }
            }
        }
        root.appendChild(buttonContainer);
        Elements.setVisible(buttonContainer, isSelected());
    }
    PatternFly.initComponents(HASH + id);
}
Also used : HTMLAnchorElement(elemental2.dom.HTMLAnchorElement) IsElement(org.jboss.gwt.elemento.core.IsElement) ElementGuard(org.jboss.hal.meta.security.ElementGuard) GWT(com.google.gwt.core.client.GWT) HtmlContentBuilder(org.jboss.gwt.elemento.core.builder.HtmlContentBuilder) DATA_BREADCRUMB(org.jboss.hal.core.finder.Finder.DATA_BREADCRUMB) NOT_AVAILABLE(org.jboss.hal.resources.Names.NOT_AVAILABLE) AuthorisationDecision(org.jboss.hal.meta.security.AuthorisationDecision) Constants(org.jboss.hal.resources.Constants) HTMLElement(elemental2.dom.HTMLElement) PatternFly(org.jboss.hal.ballroom.PatternFly) UIConstants.data(org.jboss.hal.resources.UIConstants.data) Ids(org.jboss.hal.resources.Ids) CSS(org.jboss.hal.resources.CSS) EventType.click(org.jboss.gwt.elemento.core.EventType.click) DATA_FILTER(org.jboss.hal.core.finder.Finder.DATA_FILTER) List(java.util.List) UIConstants(org.jboss.hal.resources.UIConstants) HTMLUListElement(elemental2.dom.HTMLUListElement) Collectors.toList(java.util.stream.Collectors.toList) HTMLLIElement(elemental2.dom.HTMLLIElement) HASH(org.jboss.hal.resources.UIConstants.HASH) EventType.bind(org.jboss.gwt.elemento.core.EventType.bind) Strings(org.jboss.hal.resources.Strings) Elements(org.jboss.gwt.elemento.core.Elements) HTMLElement(elemental2.dom.HTMLElement) GWT(com.google.gwt.core.client.GWT) HTMLUListElement(elemental2.dom.HTMLUListElement)

Aggregations

GWT (com.google.gwt.core.client.GWT)2 HTMLElement (elemental2.dom.HTMLElement)2 List (java.util.List)2 Collectors.toList (java.util.stream.Collectors.toList)2 Elements (org.jboss.gwt.elemento.core.Elements)2 EventType.bind (org.jboss.gwt.elemento.core.EventType.bind)2 EventType.click (org.jboss.gwt.elemento.core.EventType.click)2 IsElement (org.jboss.gwt.elemento.core.IsElement)2 HtmlContentBuilder (org.jboss.gwt.elemento.core.builder.HtmlContentBuilder)2 DATA_BREADCRUMB (org.jboss.hal.core.finder.Finder.DATA_BREADCRUMB)2 DATA_FILTER (org.jboss.hal.core.finder.Finder.DATA_FILTER)2 AuthorisationDecision (org.jboss.hal.meta.security.AuthorisationDecision)2 CSS (org.jboss.hal.resources.CSS)2 Constants (org.jboss.hal.resources.Constants)2 Ids (org.jboss.hal.resources.Ids)2 NOT_AVAILABLE (org.jboss.hal.resources.Names.NOT_AVAILABLE)2 Strings (org.jboss.hal.resources.Strings)2 UIConstants (org.jboss.hal.resources.UIConstants)2 HASH (org.jboss.hal.resources.UIConstants.HASH)2 Iterables (com.google.common.collect.Iterables)1