Example usage for com.vaadin.ui HasComponents getParent

List of usage examples for com.vaadin.ui HasComponents getParent

Introduction

In this page you can find the example usage for com.vaadin.ui HasComponents getParent.

Prototype

@Override
public HasComponents getParent();

Source Link

Document

Gets the parent component of the component.

Usage

From source file:com.esofthead.mycollab.vaadin.ui.UIUtils.java

License:Open Source License

public static <T> T getRoot(Component container, Class<T> type) {
    HasComponents parent = container.getParent();
    while (parent != null) {
        if (type.isAssignableFrom(parent.getClass())) {
            return (T) parent;
        } else {/*from   www .  j  a va2s. c  o  m*/
            parent = parent.getParent();
        }
    }
    return null;
}

From source file:org.semanticsoft.vaaclipse.p2.install.ui.impl.ContainerP2Views.java

License:Open Source License

@Override
public void initUI() {
    // TODO Auto-generated method stub

    mainLayout.removeAllComponents();/*  w w  w  . j  av  a  2  s .co  m*/
    mainLayout.addComponent((Component) listUI.get(0).getUIComponent());

    selectedBasicUI = listUI.get(0);
    final CssLayout cssLayout = new CssLayout();

    cssLayout.addComponent(buttonPrevies);
    cssLayout.addComponent(buttonNext);
    buttonNext.setEnabled(true);
    buttonInstall.setEnabled(false);
    buttonPrevies.setEnabled(false);

    cssLayout.addComponent(buttonInstall);

    buttonInstall.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub

            boolean validate = listUI.get(maxViews - 1).validate();

            if (validate) {
                installService.installNewSoftware(listUI.get(maxViews - 1).getRepositories());

                HasComponents parent = buttonNext.getParent();
                while (!(parent instanceof Window)) {

                    parent = parent.getParent();
                }

                Window w = (Window) parent;
                w.close();
                Notification.show("Software installed");
            }

        }
    });

    Button.ClickListener listenerButton = new Button.ClickListener() {

        int index = 0;
        IBasicUI iBasicUIWas = null;
        IBasicUI iBasicUI = null;

        @Override
        public void buttonClick(ClickEvent event) {
            // TODO Auto-generated method stub

            if (event.getButton() == buttonNext) {

                boolean validate = listUI.get(index).validate();

                if (index < maxViews - 1 && validate) {
                    mainLayout.removeAllComponents();
                    index++;
                    iBasicUIWas = iBasicUI;
                    if (iBasicUI == null) {
                        iBasicUIWas = listUI.get(0);
                    }
                    iBasicUI = listUI.get(index);

                    iBasicUI.addRepositories(iBasicUIWas.getRepositories());
                    mainLayout.addComponent((Component) iBasicUI.getUIComponent());
                    handleButtons();
                }
            } else if (event.getButton() == buttonPrevies) {

                if (index > -1) {

                    if (index > 0)
                        mainLayout.removeAllComponents();
                    index--;
                    if (iBasicUI == null) {
                        iBasicUIWas = listUI.get(0);
                    }
                    iBasicUIWas = iBasicUI;
                    iBasicUI = listUI.get(index);

                    iBasicUI.addRepositories(iBasicUIWas.getRepositories());
                    mainLayout.addComponent((Component) iBasicUI.getUIComponent());
                    handleButtons();
                }
            }

            mainLayout.addComponent(cssLayout);
        }

        private void handleButtons() {
            if (index == 0) {
                buttonPrevies.setEnabled(false);
                buttonInstall.setEnabled(false);
            } else if (index == maxViews - 1) {
                buttonNext.setEnabled(false);
                buttonInstall.setEnabled(true);

            }

            if (index > 0) {
                buttonPrevies.setEnabled(true);

            }
            if (index < maxViews - 1) {
                buttonNext.setEnabled(true);

            }
        }
    };
    buttonNext.addClickListener(listenerButton);
    buttonPrevies.addClickListener(listenerButton);
    mainLayout.addComponent(cssLayout);
}

From source file:ui.form.AchievementFormTranslate.java

public Window getWindow() {
    HasComponents hc = getParent();
    while (hc != null && !(hc instanceof UI)) {
        if (hc instanceof Window) {
            return (Window) hc;
        }//  w w  w  .  ja v  a 2 s . co  m
        hc = hc.getParent();
    }
    return null;
}

From source file:ui.item.QAView.java

License:Apache License

public LifetimeList<T> getList() {
    HasComponents hc = getParent();
    while (hc != null && !(hc instanceof UI)) {
        if (hc instanceof LifetimeList) {
            return (LifetimeList<T>) hc;
        }/* ww w .j a  v a  2 s.  com*/
        hc = hc.getParent();
    }
    return null;
}

From source file:ui.window.LifetimeWindow.java

License:Apache License

public LifetimeList getList() {
    HasComponents parent = this.getParent();
    while (parent != null) {
        if (parent instanceof LifetimeList) {
            return (LifetimeList) parent;
        }//from www .  j  a v  a  2 s  .  c o m
        parent = parent.getParent();
    }
    return null;
}