@Override public Element renderDom() { final Element content = Elements.createSpanElement(); content.setInnerText(header); final Element list = Elements.createUListElement(); for (final String tooltip : tooltipText) { final LIElement item = Elements.createLiElement(); item.appendChild(Elements.createTextNode(tooltip)); list.appendChild(item); } content.appendChild(list); return content; } }
public PopupWidget(final PopupResources popupResources, String title) { this.popupResources = popupResources; popupElement = Elements.createDivElement(popupResources.popupStyle().popup()); Element headerElement = Elements.createDivElement(popupResources.popupStyle().header()); headerElement.setInnerText(title); popupElement.appendChild(headerElement); popupBodyElement = Elements.createDivElement(popupResources.popupStyle().body()); popupElement.appendChild(popupBodyElement); listElement = Elements.createUListElement(); popupBodyElement.appendChild(listElement); popupListener = new EventListener() { @Override public void handleEvent(final Event evt) { if (evt instanceof MouseEvent) { final MouseEvent mouseEvent = (MouseEvent) evt; final EventTarget target = mouseEvent.getTarget(); if (target instanceof Element) { final Element elementTarget = (Element) target; if (!PopupWidget.this.popupElement.contains(elementTarget)) { hide(); evt.preventDefault(); } } } // else won't happen } }; keyboardListener = new PopupKeyDownListener(this, this.listElement); }
private Node renderAction(String title, final Action action) { final Presentation presentation = presentationFactory.getPresentation(action); Element divElement = Elements.createDivElement(style.listElement()); divElement.addEventListener( "click", new EventListener() { @Override public void handleEvent(Event evt) { ActionEvent event = new ActionEvent(presentation, actionManager); action.actionPerformed(event); } }, true); divElement.getStyle().setCursor("pointer"); divElement.getStyle().setColor(Style.getOutputLinkColor()); Element label = Elements.createDivElement(style.actionLabel()); label.setInnerText(title); divElement.appendChild(label); String hotKey = KeyMapUtil.getShortcutText(keyBindingAgent.getKeyBinding(actionManager.getId(action))); if (hotKey == null) { hotKey = " "; } else { hotKey = "<nobr> " + hotKey + " </nobr>"; } SpanElement hotKeyElement = Elements.createSpanElement(style.hotKey()); hotKeyElement.setInnerHTML(hotKey); divElement.appendChild(hotKeyElement); return divElement; }