本文整理汇总了Java中com.vaadin.ui.TabSheet.CloseHandler类的典型用法代码示例。如果您正苦于以下问题:Java CloseHandler类的具体用法?Java CloseHandler怎么用?Java CloseHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloseHandler类属于com.vaadin.ui.TabSheet包,在下文中一共展示了CloseHandler类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test2
import com.vaadin.ui.TabSheet.CloseHandler; //导入依赖的package包/类
@Test
public void test2() {
FVerticalLayout c1 = new FVerticalLayout();
FHorizontalLayout c2 = new FHorizontalLayout();
FGridLayout c3 = new FGridLayout();
FCssLayout c4 = new FCssLayout();
FVerticalLayout c5 = new FVerticalLayout();
FTabSheet tabSheet = new FTabSheet().withCaption("My TabSheet")
.withSelectedTabChangeListener(event -> System.out.println("tab changed"))
.withTab(c1)
.withTab(c2, 0)
.withTab(c3, "tab 3")
.withTab(c4, "tab 4", VaadinIcons.ADD_DOCK)
.withTab(c5, "tab 5", VaadinIcons.COMMENTS, 1)
.withSelectedTab(0)
.withTabsVisible(false)
.withCloseHandler(new CloseHandler() {
private static final long serialVersionUID = 6764130489982068799L;
@Override
public void onTabClose(TabSheet tabsheet, Component tabContent) {
System.out.println("tab closed");
}
});
tabSheet.removeComponent(c5);
assertEquals("My TabSheet", tabSheet.getCaption());
assertEquals(1, tabSheet.getListeners(SelectedTabChangeEvent.class).size());
assertEquals(4, tabSheet.getComponentCount());
assertEquals(c1, tabSheet.getTab(1).getComponent());
assertEquals(c2, tabSheet.getTab(0).getComponent());
assertEquals(c3, tabSheet.getTab(2).getComponent());
assertEquals(c4, tabSheet.getTab(3).getComponent());
assertNull(tabSheet.getTab(c5));
assertEquals(c2, tabSheet.getSelectedTab());
assertFalse(tabSheet.isTabCaptionsAsHtml());
assertFalse(tabSheet.isTabsVisible());
}
示例2: withCloseHandler
import com.vaadin.ui.TabSheet.CloseHandler; //导入依赖的package包/类
/**
* Provide a custom {@link CloseHandler} for this TabSheet if you wish to
* perform some additional tasks when a user clicks on a tabs close button,
* e.g. show a confirmation dialogue before removing the tab.
*
* To remove the tab, if you provide your own close handler, you must call
* {@link #removeComponent(Component)} yourself.
*
* The default CloseHandler for TabSheet will only remove the tab.
*
* @param handler
* the close handler
* @return this for method chaining
* @see TabSheet#setCloseHandler(CloseHandler)
*/
@SuppressWarnings("unchecked")
public default THIS withCloseHandler(CloseHandler handler) {
((TabSheet) this).setCloseHandler(handler);
return (THIS) this;
}