Search in sources :

Example 6 with VALUE

use of org.jboss.hal.dmr.ModelDescriptionConstants.VALUE in project console by hal.

the class JndiParser method readChildren.

private void readChildren(JsArray<Node<JndiContext>> nodes, Node<JndiContext> parent, List<Property> children) {
    children.stream().filter(child -> child.getValue().isDefined()).forEach(child -> {
        ModelNode modelNode = child.getValue();
        JndiContext jndiContext = jndiContext(parent, child.getName(), modelNode);
        if (modelNode.hasDefined(VALUE)) {
            pushEntry(nodes, parent, child.getName(), jndiContext);
        } else {
            Node<JndiContext> node = pushFolder(nodes, parent, child.getName(), jndiContext);
            if (modelNode.hasDefined(CHILDREN)) {
                readChildren(nodes, node, modelNode.get(CHILDREN).asPropertyList());
            } else if (child.getValue().getType() == ModelType.OBJECT) {
                readChildren(nodes, node, child.getValue().asPropertyList());
            }
        }
    });
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Property(org.jboss.hal.dmr.Property) Strings(com.google.common.base.Strings) List(java.util.List) CLASS_NAME(org.jboss.hal.dmr.ModelDescriptionConstants.CLASS_NAME) VALUE(org.jboss.hal.dmr.ModelDescriptionConstants.VALUE) Ids(org.jboss.hal.resources.Ids) CHILDREN(org.jboss.hal.dmr.ModelDescriptionConstants.CHILDREN) Node(org.jboss.hal.ballroom.tree.Node) JsArray(elemental2.core.JsArray) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) ModelType(org.jboss.hal.dmr.ModelType) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 7 with VALUE

use of org.jboss.hal.dmr.ModelDescriptionConstants.VALUE in project console by hal.

the class HeaderView method updateBreadcrumb.

@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void updateBreadcrumb(FinderContext finderContext) {
    clearBreadcrumb();
    FinderPath currentPath = new FinderPath();
    for (HandlerRegistration handler : breadcrumbHandlers) {
        handler.removeHandler();
    }
    breadcrumbHandlers.clear();
    for (Iterator<FinderSegment> iterator = finderContext.getPath().iterator(); iterator.hasNext(); ) {
        FinderSegment<Object> segment = iterator.next();
        if (segment.getColumnId() == null || segment.getItemId() == null) {
            // we need to ignore half filled segments which occur when removing items from a column
            break;
        }
        boolean last = !iterator.hasNext();
        currentPath.append(segment.getColumnId(), segment.getItemId());
        HtmlContentBuilder<HTMLLIElement> builder = li();
        if (last) {
            builder.css(active);
        }
        HTMLElement key = span().css(CSS.key).element();
        if (finderContext.getToken() != null) {
            PlaceRequest keyRequest = new PlaceRequest.Builder().nameToken(finderContext.getToken()).with("path", currentPath.toString()).build();
            key.appendChild(a().css(clickable).on(click, event -> presenter.goTo(keyRequest)).textContent(segment.getColumnTitle()).element());
        } else {
            key.textContent = segment.getColumnTitle();
        }
        builder.add(key).add(span().css(arrow).innerHtml(SafeHtmlUtils.fromSafeConstant("&#8658;")));
        HTMLElement value = span().css(CSS.value).element();
        if (segment.supportsDropdown()) {
            value.classList.add(dropdown);
            HTMLElement a;
            String id = Ids.build(segment.getColumnId(), VALUE);
            value.appendChild(a = a().css(clickable).id(id).data(UIConstants.TOGGLE, UIConstants.DROPDOWN).aria(UIConstants.HAS_POPUP, UIConstants.TRUE).aria(UIConstants.EXPANDED, UIConstants.FALSE).attr(UIConstants.ROLE, UIConstants.BUTTON).element());
            breadcrumbHandlers.add(bind(a, click, event -> {
                Element ul = a.nextElementSibling;
                segment.dropdown(finderContext, items -> {
                    Elements.removeChildrenFrom(ul);
                    if (items.isEmpty()) {
                        HTMLElement empty = li().css(CSS.empty).textContent(HeaderView.this.resources.constants().noItems()).element();
                        ul.appendChild(empty);
                    } else {
                        for (DropdownItem<Object> dropdownItem : items) {
                            HTMLElement element = li().add(a().css(clickable).on(click, e -> dropdownItem.onSelect(finderContext)).textContent(dropdownItem.getTitle())).element();
                            ul.appendChild(element);
                        }
                    }
                });
            }));
            String breadcrumbValue = segment.getItemTitle();
            if (breadcrumbValue.length() > MAX_BREADCRUMB_VALUE_LENGTH) {
                a.appendChild(span().textContent(abbreviateMiddle(breadcrumbValue, MAX_BREADCRUMB_VALUE_LENGTH) + " ").title(breadcrumbValue).element());
            } else {
                a.appendChild(span().textContent(breadcrumbValue + " ").element());
            }
            a.appendChild(span().css(caret).element());
            value.appendChild(ul().css(dropdownMenu, valueDropdown).aria(UIConstants.LABELLED_BY, id).element());
        } else {
            String breadcrumbValue = segment.getItemTitle();
            if (breadcrumbValue.length() > MAX_BREADCRUMB_VALUE_LENGTH) {
                value.textContent = abbreviateMiddle(breadcrumbValue, MAX_BREADCRUMB_VALUE_LENGTH);
                value.title = breadcrumbValue;
            } else {
                value.textContent = segment.getItemTitle();
            }
        }
        builder.add(value);
        breadcrumb.insertBefore(builder.element(), breadcrumbToolsItem);
    }
}
Also used : HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration) PlaceRequest(com.gwtplatform.mvp.shared.proxy.PlaceRequest) Environment(org.jboss.hal.config.Environment) Endpoints(org.jboss.hal.config.Endpoints) LoggerFactory(org.slf4j.LoggerFactory) Tooltip(org.jboss.hal.ballroom.Tooltip) FinderSegment(org.jboss.hal.core.finder.FinderSegment) HtmlContentBuilder(org.jboss.gwt.elemento.core.builder.HtmlContentBuilder) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) VALUE(org.jboss.hal.dmr.ModelDescriptionConstants.VALUE) HTMLElement(elemental2.dom.HTMLElement) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Message(org.jboss.hal.spi.Message) HalViewImpl(org.jboss.hal.core.mvp.HalViewImpl) User(org.jboss.hal.config.User) Elements.i(org.jboss.gwt.elemento.core.Elements.i) Places(org.jboss.hal.core.mvp.Places) Names(org.jboss.hal.resources.Names) Settings(org.jboss.hal.config.Settings) Set(java.util.Set) CSS(org.jboss.hal.resources.CSS) EventType.click(org.jboss.gwt.elemento.core.EventType.click) FinderPath(org.jboss.hal.core.finder.FinderPath) MAX_BREADCRUMB_VALUE_LENGTH(org.jboss.hal.client.skeleton.HeaderPresenter.MAX_BREADCRUMB_VALUE_LENGTH) Collectors.joining(java.util.stream.Collectors.joining) Roles(org.jboss.hal.config.Roles) List(java.util.List) UIConstants(org.jboss.hal.resources.UIConstants) CSS.nav(org.jboss.hal.resources.CSS.nav) StreamSupport.stream(java.util.stream.StreamSupport.stream) Role(org.jboss.hal.config.Role) Segment(org.jboss.hal.core.modelbrowser.ModelBrowserPath.Segment) Element(elemental2.dom.Element) Strings.abbreviateMiddle(org.jboss.hal.resources.Strings.abbreviateMiddle) FontAwesomeSize.large(org.jboss.hal.resources.FontAwesomeSize.large) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration) ModelBrowser(org.jboss.hal.core.modelbrowser.ModelBrowser) SafeHtmlUtils(com.google.gwt.safehtml.shared.SafeHtmlUtils) AccessControl(org.jboss.hal.core.accesscontrol.AccessControl) Logger(org.slf4j.Logger) RBAC(org.jboss.hal.config.AccessControlProvider.RBAC) Iterator(java.util.Iterator) Ids(org.jboss.hal.resources.Ids) PlaceRequest(com.gwtplatform.mvp.shared.proxy.PlaceRequest) DropdownItem(org.jboss.hal.core.finder.FinderSegment.DropdownItem) ModelBrowserPath(org.jboss.hal.core.modelbrowser.ModelBrowserPath) FinderContext(org.jboss.hal.core.finder.FinderContext) HTMLLIElement(elemental2.dom.HTMLLIElement) Elements.nav(org.jboss.gwt.elemento.core.Elements.nav) NameTokens(org.jboss.hal.meta.token.NameTokens) Resources(org.jboss.hal.resources.Resources) EventType.bind(org.jboss.gwt.elemento.core.EventType.bind) RUN_AS(org.jboss.hal.config.Settings.Key.RUN_AS) Elements(org.jboss.gwt.elemento.core.Elements) HTMLElement(elemental2.dom.HTMLElement) FinderSegment(org.jboss.hal.core.finder.FinderSegment) HTMLElement(elemental2.dom.HTMLElement) Element(elemental2.dom.Element) HTMLLIElement(elemental2.dom.HTMLLIElement) HTMLLIElement(elemental2.dom.HTMLLIElement) FinderPath(org.jboss.hal.core.finder.FinderPath) DropdownItem(org.jboss.hal.core.finder.FinderSegment.DropdownItem)

Aggregations

VALUE (org.jboss.hal.dmr.ModelDescriptionConstants.VALUE)7 List (java.util.List)6 Map (java.util.Map)6 Ids (org.jboss.hal.resources.Ids)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 ModelNode (org.jboss.hal.dmr.ModelNode)5 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)5 Names (org.jboss.hal.resources.Names)5 Strings (com.google.common.base.Strings)4 HTMLElement (elemental2.dom.HTMLElement)4 Inject (javax.inject.Inject)4 Environment (org.jboss.hal.config.Environment)4 FinderPath (org.jboss.hal.core.finder.FinderPath)4 Operation (org.jboss.hal.dmr.Operation)4 Metadata (org.jboss.hal.meta.Metadata)4 NameTokens (org.jboss.hal.meta.token.NameTokens)4 Resources (org.jboss.hal.resources.Resources)4 Message (org.jboss.hal.spi.Message)4 Set (java.util.Set)3