Example usage for com.vaadin.ui GridLayout addLayoutClickListener

List of usage examples for com.vaadin.ui GridLayout addLayoutClickListener

Introduction

In this page you can find the example usage for com.vaadin.ui GridLayout addLayoutClickListener.

Prototype

@Override
    public Registration addLayoutClickListener(LayoutClickListener listener) 

Source Link

Usage

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * This method builds library screen. This method overrides an existing
 * method./*from   www . ja  v a  2 s.  co m*/
 * 
 * @see com.m4gik.views.component.ViewScreen#build()
 */
@Override
public Layout build() {
    HorizontalLayout root = new HorizontalLayout();
    root.setSizeFull();
    root.setCaption("Media Library");
    root.setHeight("200%");
    root.setWidth("100%");

    this.content = new VerticalLayout();
    content.setSizeFull();
    root.addComponent(content);

    final GridLayout grid = new GridLayout(4, 1);
    Panel top = new Panel("Music Collection", grid);
    top.setSizeFull();
    top.addStyleName(Runo.PANEL_LIGHT);
    grid.setWidth("100%");
    grid.setMargin(true);
    grid.addStyleName(Runo.LAYOUT_DARKER);
    content.addComponent(top);
    content.setExpandRatio(top, 1);

    grid.addLayoutClickListener(new LayoutClickListener() {

        private static final long serialVersionUID = -1864555729437118182L;

        @Override
        public void layoutClick(LayoutClickEvent event) {
            for (Iterator<Component> it = grid.iterator(); it.hasNext();) {
                Component c = it.next();
                c.removeStyleName(Runo.CSSLAYOUT_SELECTABLE_SELECTED);

            }

            if (event.getChildComponent() != null) {
                event.getChildComponent().addStyleName(Runo.CSSLAYOUT_SELECTABLE_SELECTED);
            }
        }
    });

    buildAudioLibrary(grid, null);

    return root;

}

From source file:edu.kit.dama.ui.admin.MainControlPanel.java

License:Apache License

/**
 * Build the main layout.//from  w ww.  j  av a 2s. c o m
 */
private void buildMainLayout() {
    infoCell = createCell("img/128x128/information2.png", Alignment.TOP_RIGHT, 0,
            "<p>Show/edit your profile and personel settings.</p>", "help-right");
    profileCell = createCell("img/128x128/preferences.png", Alignment.TOP_LEFT, 1,
            "<p>Get information on how you use this KIT Data Manager instance.</p>", "help-left");
    administrationCell = createCell("img/128x128/gears_preferences.png", Alignment.BOTTOM_RIGHT, 2,
            "<p>Logout.</p>", "help-right");
    logoutCell = createCell("img/128x128/exit.png", Alignment.BOTTOM_LEFT, 3,
            "<p>Show KIT Data Manager settings.<br/>This view is only available for administrators and group manager</p>.",
            "help-left");

    GridLayout actionCellLayout = new UIUtils7.GridLayoutBuilder(2, 2)
            .addComponent(infoCell, Alignment.BOTTOM_RIGHT, 0, 0, 1, 1)
            .addComponent(profileCell, Alignment.BOTTOM_LEFT, 1, 0, 1, 1)
            .addComponent(administrationCell, Alignment.TOP_RIGHT, 0, 1, 1, 1)
            .addComponent(logoutCell, Alignment.TOP_LEFT, 1, 1, 1, 1).getLayout();
    actionCellLayout.setSpacing(true);
    actionCellLayout.setMargin(true);
    actionCellLayout.setSizeFull();

    actionCellLayout.addLayoutClickListener(new LayoutEvents.LayoutClickListener() {

        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {
            if (event.getClickedComponent() instanceof Image) {
                // Check if childComponent is disabled
                if (!event.getChildComponent().isEnabled()) {
                    return;
                }
                Image img = (Image) event.getClickedComponent();
                if ("image0".equals(img.getId())) {
                    parent.updateView(AdminUIMainView.VIEW.INFORMATION);
                } else if ("image1".equals(img.getId())) {
                    parent.updateView(AdminUIMainView.VIEW.PROFILE);
                } else if ("image2".equals(img.getId())) {
                    parent.updateView(AdminUIMainView.VIEW.SETTINGS);
                } else if ("image3".equals(img.getId())) {
                    parent.logout();
                }
            }
        }
    });

    mainLayout = new VerticalLayout(actionCellLayout);
    mainLayout.setSizeFull();
}