public Cell createCell(Row row, Object value) { Cell cell = new Cell(value == null ? null : value.toString()); row.addChild(cell); return cell; } }
/** * Renders the list box contents. * * @param qr The search hit to render. */ @Override public Listitem render(HelpSearchHit qr) { Listitem item = new Listitem(); double score = qr.getConfidence(); item.setData(qr.getTopic()); Cell lc = new Cell(); lc.addChild(toImage(score)); String tt = StrUtil.formatMessage("@cwf.help.tab.search.score", score); lc.setHint(tt); item.addChild(lc); lc = new Cell(qr.getTopic().getLabel()); item.addChild(lc); lc = new Cell(qr.getTopic().getSource()); item.addChild(lc); return item; }
/** * Sets the title text. This sets the title text of the desktop and the browser page. * * @param text The title text. Can be null; */ public void setTitle(String text) { title.setLabel(text); if (desktopInner.getPage() != null) { desktopInner.getPage().setTitle(text); } }
@Override public void afterInitialized(BaseComponent comp) { this.root = (Window) comp; root.setAttribute("controller", this); control = (DialogControl<?>) root.getAttribute("control"); root.setTitle(control.getTitle()); icon.addClass(control.getIconClass()); message.addClass(control.getTextClass()); message.setLabel(control.getMessage()); root.addClass(control.getPanelClass()); chkRemember.setVisible(root.hasAttribute("remember")); root.setOnCanClose(() -> { control.callback(response); return true; }); if (control.getFormat() == ChoiceFormat.BUTTONS) { processButtonResponses(); } else { processListResponses(); } }
@Override public Row render(Message message) { Row row = new Row(); createCell(row, message.getCreated()); createCell(row, message.getMetadata("cwf.pub.channel")); createCell(row, message.getType()); createCell(row, message.getId()); Cell cell = createCell(row, message.getPayload()); cell.setHint(cell.getChild(Label.class).getLabel()); row.addEventForward(DblclickEvent.TYPE, grid, null); return row; }
@Override public void afterInitialized(BaseComponent root) { window = (Window) root; window.setTitle(root.getAttribute("title", "")); btnPrint.setVisible(root.getAttribute("allowPrint", false)); String text = root.getAttribute("text", ""); if (text.startsWith("<html>")) { cmpHtml.setContent(text); } else { cmpText.setLabel(text); } }
/** * Adds a cell to the grid row. * * @param row List row. * @param label Label text for cell. * @return Newly created cell. */ public Cell addCell(Row row, String label) { Cell cell = new Cell(label); row.addChild(cell); return cell; }
@Override public void afterInitialized(BaseComponent comp) { this.root = (Window) comp; root.setAttribute("controller", this); root.setTitle(root.getAttribute("title", "")); root.addClass("flavor:" + root.getAttribute("panelClass", "panel-primary")); prompt.setLabel(root.getAttribute("prompt", "")); textbox.setValue(root.getAttribute("oldValue", null)); textbox.selectAll(); updateState(); }
/** * Add a cell to the row. * * @param row Grid row to receive new cell; * @param label Text label for the cell. * @param max Maximum # of allowable cells. * @return True if a cell was added. */ private boolean addCell(Row row, String label, int max) { if (max == 0 || row.getChildCount() < max) { row.addChild(new Cell(label)); return true; } return false; } }
/** * Returns a component of a type suitable for displaying the specified text. For text that is a * URL, returns a hyperlink. For text that begins with <html>, returns an HTML component. * All other text returns a label. * * @param text Text to be displayed. * @return BaseComponent of the appropriate type. */ public static BaseComponent getTextComponent(String text) { String frag = text == null ? "" : StringUtils.substring(text, 0, 20).toLowerCase(); if (frag.contains("<html>")) { return new Html(text); } if (frag.matches("^https?:\\/\\/.+$")) { Hyperlink link = new Hyperlink(); link.setHref(text); link.setTarget("_blank"); return link; } return new Cell(text); }
/** * Convenience method for displaying a simple text message. * * @param message Message to display * @param title Caption for message. * @param clazz CSS classes to apply. * @param duration Message duration in milliseconds. * @param category Tag to classify message. * @param actionListener Optional listener for action invocation. * @return The newly created message pane. */ public MessagePane showMessage(String message, String title, String clazz, int duration, String category, IEventListener actionListener) { MessagePane pane = new MessagePane(title, category, duration, actionListener != null); pane.addClass(clazz); pane.addChild(new Cell(message)); if (actionListener != null) { pane.addEventListener("action", actionListener); } addChild(pane); return pane; }