aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/minitutorials/v7b9/MainView.java
blob: 3764b7622efa1a99fb7f1441fb9c4ae53d026fde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.vaadin.tests.minitutorials.v7b9;

import com.vaadin.navigator.Navigator;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.ExternalResource;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Link;
import com.vaadin.ui.Panel;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

public class MainView extends Panel implements View {

    public static final String NAME = "";

    private Button logOut;

    public MainView(final Navigator navigator) {

        VerticalLayout layout = new VerticalLayout();

        Link lnk = new Link("Count",
                new ExternalResource("#!" + CountView.NAME));
        layout.addComponent(lnk);

        lnk = new Link("Message: Hello", new ExternalResource("#!"
                + MessageView.NAME + "/Hello"));
        layout.addComponent(lnk);

        lnk = new Link("Message: Bye", new ExternalResource("#!"
                + MessageView.NAME + "/Bye/Goodbye"));
        layout.addComponent(lnk);

        lnk = new Link("Private message: Secret", new ExternalResource("#!"
                + SecretView.NAME + "/Secret"));
        layout.addComponent(lnk);

        lnk = new Link("Private message: Topsecret", new ExternalResource("#!"
                + SecretView.NAME + "/Topsecret"));
        layout.addComponent(lnk);

        logOut = new Button("Logout", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {

                ((NavigationtestUI) UI.getCurrent()).setLoggedInUser(null);
                logOut.setCaption("Login");
                navigator.navigateTo(LoginView.NAME);

            }
        });
        layout.addComponent(logOut);
        setContent(layout);
    }

    @Override
    public void enter(ViewChangeEvent event) {

    }
}