Search in sources :

Example 1 with HASH

use of org.jboss.hal.resources.UIConstants.HASH in project console by hal.

the class PolicyElement method injectRemove.

private void injectRemove(Form<ModelNode> form, Callback callback) {
    // hacky way to inject the remove link into the form tools, depends on FormLink internals!
    String linksId = Ids.build(form.getId(), "links");
    Element formLinks = form.element().querySelector(HASH + linksId);
    if (formLinks != null) {
        HTMLLIElement removeLink = li().add(a().css(clickable).on(click, event -> callback.execute()).add(i().css(pfIcon("remove"))).data(OPERATION, REMOVE).add(span().css(formLinkLabel).textContent(resources.constants().remove()))).element();
        formLinks.insertBefore(removeLink, formLinks.lastElementChild);
    }
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Element(elemental2.dom.Element) IsElement(org.jboss.gwt.elemento.core.IsElement) OPERATION(org.jboss.hal.dmr.ModelDescriptionConstants.OPERATION) CSS.clickable(org.jboss.hal.resources.CSS.clickable) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) HTMLElement(elemental2.dom.HTMLElement) EmptyState(org.jboss.hal.ballroom.EmptyState) HasPresenter(org.jboss.hal.core.mvp.HasPresenter) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) Ids(org.jboss.hal.resources.Ids) REMOVE(org.jboss.hal.dmr.ModelDescriptionConstants.REMOVE) CSS.pfIcon(org.jboss.hal.resources.CSS.pfIcon) EventType.click(org.jboss.gwt.elemento.core.EventType.click) CUSTOM_POLICY(org.jboss.hal.dmr.ModelDescriptionConstants.CUSTOM_POLICY) HTMLLIElement(elemental2.dom.HTMLLIElement) Callback(org.jboss.hal.spi.Callback) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Resources(org.jboss.hal.resources.Resources) Attachable(org.jboss.hal.ballroom.Attachable) HASH(org.jboss.hal.resources.UIConstants.HASH) CSS.formLinkLabel(org.jboss.hal.resources.CSS.formLinkLabel) JACC_POLICY(org.jboss.hal.dmr.ModelDescriptionConstants.JACC_POLICY) NamedNode(org.jboss.hal.dmr.NamedNode) Elements(org.jboss.gwt.elemento.core.Elements) Form(org.jboss.hal.ballroom.form.Form) Element(elemental2.dom.Element) IsElement(org.jboss.gwt.elemento.core.IsElement) HTMLElement(elemental2.dom.HTMLElement) HTMLLIElement(elemental2.dom.HTMLLIElement) HTMLLIElement(elemental2.dom.HTMLLIElement)

Example 2 with HASH

use of org.jboss.hal.resources.UIConstants.HASH 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

HTMLElement (elemental2.dom.HTMLElement)2 HTMLLIElement (elemental2.dom.HTMLLIElement)2 Elements (org.jboss.gwt.elemento.core.Elements)2 EventType.click (org.jboss.gwt.elemento.core.EventType.click)2 IsElement (org.jboss.gwt.elemento.core.IsElement)2 Ids (org.jboss.hal.resources.Ids)2 HASH (org.jboss.hal.resources.UIConstants.HASH)2 GWT (com.google.gwt.core.client.GWT)1 Element (elemental2.dom.Element)1 HTMLAnchorElement (elemental2.dom.HTMLAnchorElement)1 HTMLUListElement (elemental2.dom.HTMLUListElement)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 EventType.bind (org.jboss.gwt.elemento.core.EventType.bind)1 HtmlContentBuilder (org.jboss.gwt.elemento.core.builder.HtmlContentBuilder)1 Attachable (org.jboss.hal.ballroom.Attachable)1 EmptyState (org.jboss.hal.ballroom.EmptyState)1 PatternFly (org.jboss.hal.ballroom.PatternFly)1 Form (org.jboss.hal.ballroom.form.Form)1 DATA_BREADCRUMB (org.jboss.hal.core.finder.Finder.DATA_BREADCRUMB)1