Example usage for com.vaadin.ui AbstractComponent findAncestor

List of usage examples for com.vaadin.ui AbstractComponent findAncestor

Introduction

In this page you can find the example usage for com.vaadin.ui AbstractComponent findAncestor.

Prototype

public <T extends HasComponents> T findAncestor(Class<T> parentType) 

Source Link

Document

Returns the closest ancestor with the given type.

Usage

From source file:com.foc.web.unitTesting.FocUnitTestingCommand.java

License:Apache License

/**
 * Gets an FocXMLGuiComponent by name.//from  ww  w  .  ja va2 s  . co  m
 * 
 * @param navigationLayout
 *          Name of the FocXMLLayout to look in.
 * @param componentName
 *          Name of the component.
 * @return the FocXMLGuiComponent
 */
protected FocXMLGuiComponent findComponent(FocXMLLayout navigationLayout, final String componentName,
        boolean failIfNotFound) throws Exception {
    FocXMLGuiComponent component = null;
    if (navigationLayout == null) {
        getLogger().addFailure("NavigationLayout null in findComponent: " + componentName);
    } else {
        component = (FocXMLGuiComponent) navigationLayout.getComponentByName(componentName);

        if (component == null) {
            if (failIfNotFound) {
                Globals.logString("Could not find component " + componentName + ".");
                navigationLayout.debug_PrintAllComponents();
                getLogger().addFailure("Could not find component " + componentName + ".");
            }
        } else {
            AbstractComponent comp = (AbstractComponent) component;

            FVMoreLayout moreLayout = comp.findAncestor(FVMoreLayout.class);

            if (moreLayout != null && !moreLayout.isExtended()) {
                moreLayout.setExtended(true);
            }
            getLogger().addInfo("Component " + componentName + " found.");
        }
    }
    return component;
}