/** * @param uuic the user context */ private void detectRootWCs(final UIContext uuic) { rootWCsDetected = new HashSet<>(); WComponent root = WebUtilities.getTop(uuic.getUI()); rootWCsDetected.add(root); // TODO: Should report if the ui is not a root component. // Find any other root components that are storing information in the context. for (Iterator it = uuic.getComponents().iterator(); it.hasNext();) { WComponent wc = (WComponent) it.next(); root = WebUtilities.getTop(wc); rootWCsDetected.add(root); } } }
/** * Dumps all the profiling information in textual format to a StringBuffer. * * @return the profiling information in textual format. */ public StringBuffer dumpAll() { WComponent root = WebUtilities.getTop(this); Map<String, GroupData> compTallyByClass = new TreeMap<>(); GroupData compDataOverall = new GroupData(); StringBuffer out = new StringBuffer(); String className = root.getClass().getName(); out.append("<strong>The root of the WComponent tree is:</strong><br/>").append(className).append( "<br/>"); tally(root, compTallyByClass, compDataOverall, out); out.append("<strong>WComponent usage overall:</strong><br/> "); out.append(compDataOverall.total).append(" WComponent(s) in the WComponent tree.<br/>"); if (compDataOverall.total > 0) { out.append("<strong>WComponent usage by class:</strong><br/>"); for (Map.Entry<String, GroupData> entry : compTallyByClass.entrySet()) { className = entry.getKey(); GroupData dataForClass = entry.getValue(); out.append(' ').append(dataForClass.total).append(" ").append(className).append( "<br/>"); } out.append("<br/><hr/>"); } processUic(out); return out; }
/** * Retrieves the root component of a WComponent hierarchy. * * @param uic the context to retrieve the root component for. * @param comp a component in the tree. * @return the root of the tree. */ public static WComponent getRoot(final UIContext uic, final WComponent comp) { UIContextHolder.pushContext(uic); try { return WebUtilities.getTop(comp); } finally { UIContextHolder.popContext(); } }
WComponent top = WebUtilities.getTop(comp); topComponents.add(top);
WComponent top = WebUtilities.getTop(comp); topComponents.add(top);
WComponent top = WebUtilities.getTop(this); String repositoryKey; if (top instanceof WApplication) {
@Test public void testGetTop() { WContainer root = new WContainer(); WTabSet tabs = new WTabSet(); WDropdown dropdown = new WDropdown(); root.add(tabs); tabs.addTab(dropdown, "dropdown tab", WTabSet.TAB_MODE_CLIENT); Assert.assertEquals("Incorrect top component returned for child", root, WebUtilities.getTop(dropdown)); Assert.assertEquals("Incorrect top component returned for child", root, WebUtilities.getTop(tabs)); Assert.assertEquals("Incorrect top component returned for top", root, WebUtilities.getTop(root)); }
Assert.assertEquals("Incorrect parent for 'd1'", a, d1.getParent()); Assert.assertEquals("Incorrect parent for 'd2'", d1, d2.getParent()); Assert.assertEquals("Incorrect top component", a, WebUtilities.getTop(d2));
WebUtilities.getTop(component).setLocked(true);
WebUtilities.getTop(component).setLocked(true);
final int serverStep) { UIContext uic = createUIContext(); uic.setUI(WebUtilities.getTop(target)); WServlet.WServletEnvironment env = new WServlet.WServletEnvironment("/app", "http://localhost", "");