public void addAction(final EventListener<MouseEvent> onclick, final String label) { final HTMLElement a = getDocument().createElement("a"); a.setTextContent(label); a.setOnclick(onclick); final HTMLElement li = getDocument().createElement("li"); li.appendChild(a); actionsItems.appendChild(li); } }
private static void mergeAttribute(final DataFieldMeta meta, final HTMLElement beanElement, final HTMLElement templateElement, final String name, final String value) { final ConflictStrategy strategy = meta.getStrategy(name); // Merge all class names regardless of strategy if (name.equals("class")) { DOMUtil.tokenStream(templateElement.getClassList()) .filter(token -> !beanElement.getClassList().contains(token)) .forEach(token -> beanElement.getClassList().add(token)); } // Merge individual properties in style only using the strategy when both elements have a value. else if (name.equals("style")) { Stream<String> propertyNameStream = DOMUtil.cssPropertyNameStream(templateElement.getStyle()); if (ConflictStrategy.USE_BEAN.equals(strategy)) { propertyNameStream = propertyNameStream .filter(propertyName -> { final String beanPropertyValue = beanElement.getStyle().getPropertyValue(propertyName); return beanPropertyValue == null || beanPropertyValue.isEmpty(); }); } propertyNameStream .forEach(propertyName -> beanElement.getStyle().setProperty(propertyName, templateElement.getStyle().getPropertyValue(propertyName), "")); } // Use strategy to decide which value is used. else { final String beanValue = beanElement.getAttribute(name); if (ConflictStrategy.USE_TEMPLATE.equals(strategy) || beanValue == null || beanValue.isEmpty()) { beanElement.setAttribute(name, value); } } }
private HTMLElement defaultOption() { final HTMLElement option = Window.getDocument().createElement("option"); option.setAttribute("value", ""); option.setAttribute("disabled", ""); option.setAttribute("selected", ""); option.setTextContent(translationService.getTranslation(SourceConfigurationPageView_SelectOption_placeholder)); return option; }
private void addComponent(final int index, final M item) { final C component = createComponent(item); final HTMLElement element = Assert.notNull(elementAccessor.apply(component)); if (index < components.size()) { root.insertBefore(element, Assert.notNull(elementAccessor.apply(components.get(index)))); } else { root.appendChild(element); } components.add(index, component); for (final Consumer<C> handler : creationHandlers) { handler.accept(component); } }
@Override public void showProperty(String property) { HTMLElement strong = document.createElement("strong"); strong.setTextContent(property); HTMLElement li = document.createElement("li"); li.appendChild(strong); properties.appendChild(li); }
/** * @param element * Must not be null. * @param className * The name of a CSS class. Must not be null. * @return True iff the given element has the given CSS class as part of its class list. */ public static boolean hasCSSClass(final HTMLElement element, final String className) { return element.getClassList().contains(className); }
public void addRequiredIndicator() { final HTMLElement e = document.createElement("i"); addCSSClass(e, "fa"); addCSSClass(e, "fa-star"); final CSSStyleDeclaration css = e.getStyle(); css.setProperty("font-size", "6px"); css.setProperty("padding-right", "5px"); css.setProperty("padding-left", "2px"); css.setProperty("color", "#b94a48"); final HTMLElement sup = document.createElement("sup"); sup.appendChild(e); label.appendChild(sup); }
public void showConflict(String field, String message) { fieldContainer.setTextContent(field); helpMessageContainer.setTextContent(message); }
protected void checkContentConflicts() { activeHandlers.clear(); allHandlers.forEach(conflictsHandler -> { if (conflictsHandler.checkConflicts(content, this::displayConflict)) { this.activeHandlers.add(conflictsHandler); } }); if (!activeHandlers.isEmpty()) { this.canDisplay = true; this.view.getElement().appendChild(conflictsDisplayer.getElement()); } }
row.getClassList().add(RowSizeBuilder.buildRowSize(layoutRow.getHeight())); row.getClassList().add("uf-le-overflow"); column.getClassList().add("uf-perspective-col"); column.getClassList().add("uf-perspective-col"); } else if (!layoutColumn.getHeight().isEmpty()) { column.getClassList().add("uf-perspective-row-" + layoutColumn.getHeight()); column); column.getClassList().add("uf-perspective-rendered-col"); row.appendChild(column); row.getClassList().add("uf-perspective-rendered-row"); parentWidget.appendChild(row);
@Override public void renderForInputId(String inputId, String label, boolean required, String helpMessage) { init(); getElement().appendChild(labelText); labelText.setTextContent(label); getElement().setAttribute("for", inputId); setRequired(required); setHelpMessage(helpMessage); }
@Override public void setRequired(boolean required) { if (this.required == required) { return; } this.required = required; if (!required) { getElement().removeChild(this.fieldRequired.getElement()); } else { getElement().appendChild(this.fieldRequired.getElement()); } }
@JsOverlay public static CustomGroupItem createAnchor(final String text, final IconType iconType, final Command command) { final CustomGroupItem anchor = (CustomGroupItem) Window.getDocument().createElement("a"); anchor.setClassName(Styles.LIST_GROUP_ITEM); if (iconType != null) { final HTMLElement icon = Window.getDocument().createElement("i"); icon.getClassList().add("fa"); icon.getClassList().add(iconType.getCssName()); anchor.setInnerHTML(icon.getOuterHTML() + " " + text); } else { anchor.setTextContent(checkNotEmpty("text", text)); } anchor.setHref("#"); //can't use lambda here; GWT limitation (bug!)! anchor.setOnclick(new EventListener() { @Override public void call(final Event event) { command.execute(); } }); return anchor; }
@Override public LayoutInstance build(LayoutTemplate layoutTemplate, LayoutGeneratorDriver driver) { HTMLElement container = driver.createContainer(); container.setId(CONTAINER_ID); container.getClassList().add("uf-perspective-container"); container.getClassList().add("uf-perspective-rendered-container"); applyCssToElement(layoutTemplate.getLayoutProperties(), container); LayoutInstance layoutInstance = new LayoutInstance(container); List<LayoutRow> rows = layoutTemplate.getRows(); generateRows(layoutTemplate, layoutInstance, driver, rows, container); return layoutInstance; }
@Override public void setVisible(boolean visible) { getElement().setHidden(!visible); } }
void updateDataUUID() { getElement().setAttribute("data-uuid", getItem().getUUID()); }
public void initWithSingleItem(String itemsLineId, String item) { this.itemsLineId = itemsLineId; final HTMLElement itemText = createElement("span"); itemText.setTextContent(item); final HTMLElement li = createElement("li"); li.appendChild(itemText); getVisibleUnorderedList().appendChild(li); }
private boolean isOverBootstrapSelectContainer(final HTMLElement e) { if (!e.getClassList().contains(BOOTSTRAP_SELECT_CLASS)) { return false; } else if (!e.getClassList().contains(BOOTSTRAP_SELECT_OPEN_CLASS)) { return false; } return true; } }
@Override public void setup(final String name, final String date, final String pipeline) { this.name.setTextContent(name); this.date.setTextContent(date); this.pipeline.setTextContent(pipeline); }