Project

General

Profile

Download (2.14 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.vaadin.themes.valo;
10

    
11
import com.vaadin.server.FontAwesome;
12
import com.vaadin.ui.Button;
13
import com.vaadin.ui.Button.ClickEvent;
14
import com.vaadin.ui.Button.ClickListener;
15
import com.vaadin.ui.Component;
16
import com.vaadin.ui.ComponentContainer;
17
import com.vaadin.ui.CssLayout;
18
import com.vaadin.ui.HorizontalLayout;
19
import com.vaadin.ui.themes.ValoTheme;
20

    
21
/**
22
 * @author a.kohlbecker
23
 * @since Feb 24, 2017
24
 *
25
 */
26
@SuppressWarnings("serial")
27
public class ValoMenuLayout extends HorizontalLayout {
28

    
29
    CssLayout contentArea = new CssLayout();
30

    
31
    CssLayout menuArea = new CssLayout();
32

    
33
    public ValoMenuLayout() {
34

    
35
        setSizeFull();
36

    
37
        menuArea.setPrimaryStyleName(ValoTheme.MENU_ROOT);
38

    
39
        contentArea.setPrimaryStyleName("valo-content");
40
        contentArea.addStyleName("v-scrollable");
41
        contentArea.setSizeFull();
42

    
43
        addComponents(menuArea, contentArea);
44
        setExpandRatio(contentArea, 1);
45
    }
46

    
47
    public ComponentContainer getContentContainer() {
48
        return contentArea;
49
    }
50

    
51
    public void addMenu(Component menu) {
52
        menu.addStyleName(ValoTheme.MENU_PART);
53
        menuArea.addComponent(menu);
54
    }
55

    
56
    protected void init() {
57

    
58
        final CssLayout menu = new CssLayout();
59
        Button showMenu = new Button("Menu", new ClickListener() {
60
            @Override
61
            public void buttonClick(ClickEvent event) {
62
                if (menu.getStyleName().contains("valo-menu-visible")) {
63
                    menu.removeStyleName("valo-menu-visible");
64
                } else {
65
                    menu.addStyleName("valo-menu-visible");
66
                }
67
            }
68
        });
69
        showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
70
        showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
71
        showMenu.addStyleName("valo-menu-toggle");
72
        showMenu.setIcon(FontAwesome.LIST);
73
        menu.addComponent(showMenu);
74

    
75
    }
76

    
77
}
    (1-1/1)