Search in sources :

Example 1 with DATA_BREADCRUMB

use of org.jboss.hal.core.finder.Finder.DATA_BREADCRUMB 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)1 HTMLAnchorElement (elemental2.dom.HTMLAnchorElement)1 HTMLElement (elemental2.dom.HTMLElement)1 HTMLLIElement (elemental2.dom.HTMLLIElement)1 HTMLUListElement (elemental2.dom.HTMLUListElement)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)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 IsElement (org.jboss.gwt.elemento.core.IsElement)1 HtmlContentBuilder (org.jboss.gwt.elemento.core.builder.HtmlContentBuilder)1 PatternFly (org.jboss.hal.ballroom.PatternFly)1 DATA_BREADCRUMB (org.jboss.hal.core.finder.Finder.DATA_BREADCRUMB)1 DATA_FILTER (org.jboss.hal.core.finder.Finder.DATA_FILTER)1 AuthorisationDecision (org.jboss.hal.meta.security.AuthorisationDecision)1 ElementGuard (org.jboss.hal.meta.security.ElementGuard)1 CSS (org.jboss.hal.resources.CSS)1 Constants (org.jboss.hal.resources.Constants)1 Ids (org.jboss.hal.resources.Ids)1