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();
}
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);
}
Aggregations