@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 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 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; }