protected CubaAccordion createComponent() { return new CubaAccordion(); }
@Override public void focus() { component.focus(); }
public String getCubaId(Tab tab) { int tabPosition = getTabPosition(tab); return getState(true).tabs.get(tabPosition).cubaId; } }
@Override public Accordion.Tab addLazyTab(String name, Element descriptor, ComponentLoader loader) { ComponentsFactory cf = AppBeans.get(ComponentsFactory.NAME); // todo replace CssLayout tabContent = cf.createComponent(CssLayout.NAME); tabContent.setStyleName("c-tabsheet-lazytab"); tabContent.setSizeFull(); Tab tab = new Tab(name, tabContent); tabs.put(name, tab); com.vaadin.ui.Component tabComponent = tabContent.unwrapComposition(com.vaadin.ui.Component.class); tabMapping.put(tabComponent, new ComponentDescriptor(name, tabContent)); com.vaadin.ui.Accordion.Tab tabControl = this.component.addTab(tabComponent); getLazyTabs().add(tabComponent); this.component.addSelectedTabChangeListener(new LazyTabChangeListener(tabContent, descriptor, loader)); context = loader.getContext(); if (!postInitTaskAdded) { context.addPostInitTask((c, w) -> initComponentTabChangeListener()); postInitTaskAdded = true; } if (getDebugId() != null) { this.component.setTestId(tabControl, AppUI.getCurrent().getTestIdManager().getTestId(getDebugId() + "." + name)); } if (AppUI.getCurrent().isTestMode()) { this.component.setCubaId(tabControl, name); } tabContent.setFrame(context.getFrame()); return tab; }
@Override public Accordion.Tab addTab(String name, Component childComponent) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); } Tab tab = new Tab(name, childComponent); this.tabs.put(name, tab); com.vaadin.ui.Component tabComponent = childComponent.unwrapComposition(com.vaadin.ui.Component.class); tabComponent.setSizeFull(); tabMapping.put(tabComponent, new ComponentDescriptor(name, childComponent)); com.vaadin.ui.Accordion.Tab tabControl = this.component.addTab(tabComponent); if (getDebugId() != null) { this.component.setTestId(tabControl, AppUI.getCurrent().getTestIdManager().getTestId(getDebugId() + "." + name)); } if (AppUI.getCurrent().isTestMode()) { this.component.setCubaId(tabControl, name); } if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else { ((FrameImplementation) frame).registerComponent(childComponent); } } childComponent.setParent(this); return tab; }
@Override public void setDebugId(String id) { super.setDebugId(id); String debugId = getDebugId(); AppUI ui = AppUI.getCurrent(); if (debugId != null && ui != null) { TestIdManager testIdManager = ui.getTestIdManager(); for (Map.Entry<com.vaadin.ui.Component, ComponentDescriptor> tabEntry : tabMapping.entrySet()) { com.vaadin.ui.Component tabComponent = tabEntry.getKey(); com.vaadin.ui.Accordion.Tab tab = component.getTab(tabComponent); ComponentDescriptor componentDescriptor = tabEntry.getValue(); String name = componentDescriptor.name; component.setTestId(tab, testIdManager.getTestId(debugId + "." + name)); } } }
@Override public Tab getSelectedTab() { com.vaadin.ui.Component component = this.component.getSelectedTab(); if (component == null) { return null; } String name = tabMapping.get(component).getName(); return tabs.get(name); }
@Override public boolean isTabCaptionsAsHtml() { return component.isTabCaptionsAsHtml(); }
@Override public int getTabIndex() { return component.getTabIndex(); }
protected com.vaadin.ui.Accordion.Tab getVaadinTab() { com.vaadin.ui.Component composition = WebComponentsHelper.getComposition(tabComponent); return WebAccordion.this.component.getTab(composition); }
component.addSelectedTabChangeListener(event -> { if (context != null) { context.executeInjectTasks();
@Override public void selectedTabChange(com.vaadin.ui.Accordion.SelectedTabChangeEvent event) { com.vaadin.ui.Component selectedTab = WebAccordion.this.component.getSelectedTab(); com.vaadin.ui.Component tabComponent = tabContent.unwrap(com.vaadin.ui.Component.class); if (selectedTab == tabComponent && getLazyTabs().remove(tabComponent)) {
public void setTestId(Tab tab, String testId) { int tabPosition = getTabPosition(tab); getState(true).tabs.get(tabPosition).id = testId; }
public void setCubaId(Tab tab, String id) { int tabPosition = getTabPosition(tab); getState(true).tabs.get(tabPosition).cubaId = id; }