gpt4 book ai didi

com.github.bordertech.wcomponents.WebUtilities.getClosestOfClass()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 16:15:05 28 4
gpt4 key购买 nike

本文整理了Java中com.github.bordertech.wcomponents.WebUtilities.getClosestOfClass()方法的一些代码示例,展示了WebUtilities.getClosestOfClass()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebUtilities.getClosestOfClass()方法的具体详情如下:
包路径:com.github.bordertech.wcomponents.WebUtilities
类名称:WebUtilities
方法名:getClosestOfClass

WebUtilities.getClosestOfClass介绍

[英]Attempts to find the nearest component (may be the component itself) that is assignable to the given class.
[中]尝试查找可分配给给定类的最近组件(可能是组件本身)。

代码示例

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

/**
 * Returns the closest WApplication instance (ancestor component) from the given base component.
 *
 * @param base the component from which we start scanning up the tree for a WApplication instance
 * @return the closest WApplication instance from the given base component
 */
public static WApplication instance(final WComponent base) {
  WApplication appl = WebUtilities.getClosestOfClass(WApplication.class, base);
  return appl;
}

代码示例来源:origin: com.github.bordertech.wcomponents/wcomponents-core

@Test
public void testGetClosestOfClass() {
  WContainer root = new WContainer();
  WTabSet tabs = new WTabSet();
  WDropdown dropdown = new WDropdown();
  WTextField text = new WTextField();
  root.add(tabs);
  tabs.addTab(dropdown, "dropdown tab", WTabSet.TAB_MODE_SERVER);
  tabs.addTab(text, "text tab", WTabSet.TAB_MODE_SERVER);
  Assert.assertNull("Incorrect ancestor returned", WebUtilities.getClosestOfClass(
      WTabSet.class, null));
  Assert.assertSame("Incorrect ancestor returned", tabs, WebUtilities.getClosestOfClass(
      WTabSet.class, dropdown));
  Assert.assertSame("Incorrect ancestor returned", tabs, WebUtilities.getClosestOfClass(
      WComponent.class, tabs));
  Assert.assertSame("Incorrect ancestor returned", dropdown,
      WebUtilities.getClosestOfClass(WComponent.class, dropdown));
  Assert.assertSame("Incorrect ancestor returned", root, WebUtilities.getClosestOfClass(
      WComponent.class, root));
  Assert.assertNull("Incorrect ancestor returned", WebUtilities.getClosestOfClass(
      WButton.class, dropdown));
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com