Example usage for com.vaadin.ui Button addClickListener

List of usage examples for com.vaadin.ui Button addClickListener

Introduction

In this page you can find the example usage for com.vaadin.ui Button addClickListener.

Prototype

public Registration addClickListener(ClickListener listener) 

Source Link

Document

Adds the button click listener.

Usage

From source file:cz.zcu.pia.social.network.frontend.components.profile.friends.ComponentFriends.java

/**
 * Adds following to table/*from  www .jav  a 2 s  .c om*/
 * @param followingList  following List
 */
private void addFollowingToTable(List<Following> followingList) {
    for (Following f : followingList) {
        Button removeFollow = new Button(msgs.getMessage("component.friends.remove.following"));
        removeFollow.setData(f);
        removeFollow.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                Following f = (Following) event.getButton().getData();
                table.removeItem(f.getId());
                followingService.removeFollow(f);
            }
        });
        table.addItem(new Object[] { f.getFeeder().getName(), f.getFeeder().getSurname(),
                getTimeStamp(f.getFollowingSince()), removeFollow }, f.getId());
    }
}

From source file:cz.zcu.pia.social.network.frontend.components.profile.friends.ComponentManageFriendRequest.java

/**
 * Adds content//from   w w w.j a  v a2 s .  c o  m
 */
private void addContent() {
    Long userId = securityHelper.getLogedInUser().getId();
    List<FriendRequest> friendRequestList = friendRequestService.getFriendRequests(userId);
    for (FriendRequest fr : friendRequestList) {
        Button accept = new Button(msgs.getMessage("request.accept"));
        accept.setData(fr);
        accept.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                FriendRequest fr = (FriendRequest) event.getButton().getData();
                friendRequestService.confirmFriendRequest(fr);
                table.removeItem(fr.getId());
                parentReference.reload();
            }
        });
        Button deny = new Button(msgs.getMessage("request.deny"));
        HorizontalLayout wrapper = new HorizontalLayout();
        wrapper.setSpacing(true);
        wrapper.addComponent(accept);
        wrapper.addComponent(deny);
        if (fr.isDenyed()) {
            deny.setEnabled(false);
        } else {
            deny.setData(fr);
            deny.addClickListener(new Button.ClickListener() {

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    FriendRequest fr = (FriendRequest) event.getButton().getData();
                    friendRequestService.denyFriendRequest(fr);
                    event.getButton().setEnabled(false);
                }
            });
        }
        table.addItem(new Object[] { fr.getUserSender().getName(), fr.getUserSender().getSurname(),
                getTimeStamp(fr.getDateSent()), wrapper }, fr.getId());
    }

}

From source file:cz.zcu.pia.social.network.frontend.components.profile.profile.ComponentEditProfile.java

@Override
protected HorizontalLayout getRegisterButton() {
    HorizontalLayout wrapper = new HorizontalLayout();

    confirm = new Button(msgs.getMessage("save"));
    confirm.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    confirm.addClickListener(new Button.ClickListener() {

        @Override/*ww w.ja  v  a  2s.c o  m*/
        public void buttonClick(Button.ClickEvent event) {
            confirmButtonFunction(event);
        }

    });
    Button swapButton = new Button(msgs.getMessage("back"));
    swapButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            resetValues();
            parentReference.swapComponents();
        }
    });

    wrapper.addComponent(swapButton);
    wrapper.addComponent(confirm);

    wrapper.setSpacing(true);
    return wrapper;
}

From source file:cz.zcu.pia.social.network.frontend.components.profile.profile.ComponentProfilePost.java

/**
 * Gets add friend button/* w  w w . ja  v a 2s  .com*/
 * @return add friend button
 */
private Button getAddFriendButton() {
    Button addFriend;

    Friends friends = friendsService.getFriend(securityHelper.getLogedInUser(), user);
    if (friends == null) {
        addFriend = new Button(msgs.getMessage("profile.add.friend"));

    } else {

        addFriend = new Button(msgs.getMessage("profile.remove.friend"));
        addFriend.setData(friends);
    }

    addFriend.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (event.getButton().getCaption().equals(msgs.getMessage("profile.add.friend"))) {
                FriendRequest request = friendRequestService.getFriendRequest(securityHelper.getLogedInUser(),
                        user);
                if (request != null && !request.isDenyed()) {
                    Notification.show(msgs.getMessage("request.sent"), Notification.Type.HUMANIZED_MESSAGE);
                    return;
                }
                FriendRequest fr = new FriendRequest(securityHelper.getLogedInUser(), user);
                friendRequestService.persist(fr);
                event.getButton().setEnabled(false);
            } else {
                Friends friends = (Friends) event.getButton().getData();
                friendsService.delete(friends);
            }
        }
    });
    return addFriend;
}

From source file:cz.zcu.pia.social.network.frontend.components.profile.profile.ComponentProfilePost.java

/**
 * Gets follower button/*from   w ww  .  j av  a 2  s  .co  m*/
 * @return follower button
 */
private Button getFollowerButton() {
    Button addFollower;

    if (followingService.getFollower(securityHelper.getLogedInUser(), user) == null) {
        addFollower = new Button(msgs.getMessage("profile.add.follower"));
    } else {
        addFollower = new Button(msgs.getMessage("unfollow"));

    }
    addFollower.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (event.getButton().getCaption().equals(msgs.getMessage("profile.add.follower"))) {
                followingService.addFollow(securityHelper.getLogedInUser(), user);
                event.getButton().setCaption(msgs.getMessage("unfollow"));
            } else {
                followingService.removeFollow(securityHelper.getLogedInUser(), user);
                event.getButton().setCaption(msgs.getMessage("profile.add.follower"));
            }
        }
    });
    return addFollower;
}

From source file:de.kaiserpfalzEdv.vaadin.LoginScreen.java

License:Apache License

private Component buildLoginForm() {
    FormLayout loginForm = new FormLayout();

    loginForm.addStyleName("login-form");
    loginForm.setSizeUndefined();/*  w w w  .  ja v a  2  s . com*/
    loginForm.setMargin(false);

    loginForm.addComponent(username = new TextField(translate("login.name.caption")));
    username.setDescription(translate("login.name.description"));
    username.setWidth(15, Unit.EM);
    loginForm.addComponent(password = new PasswordField(translate("login.password.caption")));
    password.setWidth(15, Unit.EM);
    password.setDescription(translate("login.password.description"));
    CssLayout buttons = new CssLayout();
    buttons.setStyleName("buttons");
    loginForm.addComponent(buttons);

    login = new Button(translate("login.login-button.caption"));
    buttons.addComponent(login);
    login.setDescription(translate("login.login-button.description"));
    login.setDisableOnClick(true);
    login.addClickListener(event -> {
        try {
            login();
        } finally {
            login.setEnabled(true);
        }
    });
    login.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    login.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    Button forgotPassword;
    buttons.addComponent(forgotPassword = new Button(translate("login.password-forgotten.caption")));
    forgotPassword.setDescription(translate("login.password-forgotten.description"));
    forgotPassword.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            NotificationPayload notification = new NotificationPayload("login.password-forgotten.text");
            bus.post(new NotificationEvent(this, notification));
        }
    });
    forgotPassword.addStyleName(ValoTheme.BUTTON_LINK);
    return loginForm;
}

From source file:de.metas.procurement.webui.ui.view.DailyReportingView.java

License:Open Source License

public DailyReportingView() {
    super();/* w  ww  . ja  v  a 2s .  c  o  m*/

    addStyleName(STYLE);

    //
    // Top
    {
        final NavigationBar navigationBar = getNavigationBar();
        navigationBar.setCaption(i18n.get("DailyReportingView.caption"));

        final NavigationButton logoutButton = new NavigationButton(i18n.get("Logout.caption"));
        logoutButton.setTargetView(this);
        logoutButton.addClickListener(new NavigationButtonClickListener() {
            @Override
            public void buttonClick(final NavigationButtonClickEvent event) {
                onLogout();
            }
        });
        navigationBar.setRightComponent(logoutButton);
    }

    //
    // Content
    {
        final VerticalLayout content = new VerticalLayout();

        // Date
        {
            datePanel = new DateNavigation();
            datePanel.addDateChangedListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(final PropertyChangeEvent evt) {
                    onDayChanged(datePanel.getDate());
                }
            });

            final VerticalComponentGroup datePanelGroup = new VerticalComponentGroup();
            datePanelGroup.addComponent(datePanel);
            content.addComponent(datePanelGroup);
        }

        // Product buttons
        productButtons = new BeansVerticalComponentGroup<ProductQtyReport>() {
            @Override
            protected Component createItemComponent(final BeanItem<ProductQtyReport> item) {
                final ProductItemButton itemComp = new ProductItemButton();
                itemComp.setItem(item);
                return itemComp;
            };
        };
        content.addComponent(productButtons);

        setContent(content);
    }

    //
    // Toolbar (bottom)
    {
        final Button weekViewButton = new Button(i18n.get("DailyReportingView.weekViewButton"));
        weekViewButton.setStyleName("no-decoration");
        weekViewButton.setIcon(FontAwesome.CALENDAR);
        weekViewButton.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                onWeekView();
            }
        });

        final Button addProductButton = new Button(i18n.get("DailyReportingView.addProductButton"));
        addProductButton.setStyleName("no-decoration");
        addProductButton.setIcon(FontAwesome.PLUS);
        addProductButton.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                onProductAdd();
            }
        });

        final Button rfqButton = new Button(i18n.get("DailyReportingView.rfqButton"));
        rfqButton.setStyleName("no-decoration");
        rfqButton.setIcon(FontAwesome.MONEY);
        rfqButton.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                onRfQ();
            }
        });

        final ISendService sendService = MFProcurementUI.getCurrentMFSession().getSendService();
        final Button sendButton = new Button(i18n.get("DailyReportingView.sendButton"));
        sendButton.setStyleName("no-decoration");
        sendButton.setIcon(FontAwesome.CHECK);
        final TextOverlay sendButtonOverlay = TextOverlay.extend(sendButton);
        sendButtonOverlay.setPropertyDataSource(sendService.getNotSentCounterProperty());
        sendButtonOverlay.setConverter(TextOverlay.CONVERTER_PositiveCounterOrNull);
        sendButton.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                onSend();
            }
        });

        final Button infoButton = new Button(i18n.getWithDefault("InfoMessageView.caption.short", "Info"));
        infoButton.setStyleName("no-decoration");
        infoButton.setIcon(FontAwesome.INFO);
        infoButton.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                onInfo();
            }
        });

        final Toolbar toolbar = new Toolbar();
        toolbar.addComponents(weekViewButton, addProductButton, sendButton, infoButton, rfqButton);
        setToolbar(toolbar);
    }

    //
    // Initialize
    final Date today = DateUtils.getToday();
    final Date date = DateUtils.addDays(today, +1); // tomorrow (FRESH-196)
    datePanel.setDate(date);
}

From source file:de.metas.procurement.webui.ui.view.LoginView.java

License:Open Source License

public LoginView() {
    super();//from  w  w w  .j ava  2s . c o m
    Application.autowire(this);

    addStyleName(STYLE);

    //
    // Content
    {
        final VerticalComponentGroup content = new VerticalComponentGroup();

        final Resource logoResource = getLogoResource();
        final Image logo = new Image(null, logoResource);
        logo.addStyleName(STYLE_Logo);
        content.addComponent(logo);

        this.email = new EmailField(i18n.get("LoginView.fields.email"));
        email.addStyleName(STYLE_LoginEmail);
        email.setIcon(FontAwesome.USER);
        content.addComponent(email);

        this.password = new PasswordField(i18n.get("LoginView.fields.password"));
        password.addStyleName(STYLE_LoginPassword);
        password.setIcon(FontAwesome.LOCK);
        content.addComponent(password);

        final Button loginButton = new Button(i18n.get("LoginView.fields.loginButton"));
        loginButton.addStyleName(STYLE_LoginButton);
        loginButton.setClickShortcut(KeyCode.ENTER);
        loginButton.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                onUserLogin(email.getValue(), password.getValue());
            }
        });

        final Button forgotPasswordButton = new Button(i18n.get("LoginView.fields.forgotPasswordButton"));
        forgotPasswordButton.setStyleName(STYLE_ForgotPasswordButton);
        forgotPasswordButton.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                onForgotPassword(email.getValue());
            }
        });

        final CssLayout contentWrapper = new CssLayout(content, loginButton, forgotPasswordButton);
        contentWrapper.addStyleName(STYLE_LoginFormWrapper);
        setContent(contentWrapper);
    }

    //
    // Bottom:
    {
        //
        // Powered-by logo resource
        // Use the configured one if any; fallback to default embedded powered-by logo
        final Resource poweredByLogoResource;
        if (poweredByLogoUrl != null && !poweredByLogoUrl.trim().isEmpty()) {
            poweredByLogoResource = new ExternalResource(poweredByLogoUrl.trim());
        } else {
            poweredByLogoResource = Constants.RESOURCE_PoweredBy;
        }

        //
        // Powered-by component:
        final Component poweredByComponent;
        if (poweredByLinkUrl != null && !poweredByLinkUrl.trim().isEmpty()) {
            final Link link = new Link();
            link.setIcon(poweredByLogoResource);
            link.setResource(new ExternalResource(poweredByLinkUrl.trim()));
            link.setTargetName("_blank");
            poweredByComponent = link;
        } else {
            final Image image = new Image(null, poweredByLogoResource);
            poweredByComponent = image;
        }
        //
        poweredByComponent.addStyleName(STYLE_PoweredBy);
        setToolbar(poweredByComponent);
    }
}

From source file:de.metas.procurement.webui.ui.view.WeeklyDetailedReportingView.java

License:Open Source License

private final Button createTrendButton(final Trend trend) {
    final Button button = new Button();
    button.setStyleName("no-decoration");
    Trend.applyStyleName(button, trend);
    button.setIcon(trend.getIcon());// www  . j  a  v  a 2  s .c  o  m
    button.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            onNextWeekTrendButtonPressed(trend);
        }
    });

    trend2button.put(trend, button);
    return button;
}

From source file:de.metas.ui.web.vaadin.components.navigator.MFViewDisplay.java

License:Open Source License

public MFViewDisplay(final UI ui) {
    super();/*from w w  w  .ja v a 2  s. co  m*/

    final VerticalLayout content = new VerticalLayout();
    content.addStyleName(STYLE);

    //
    // Lane: title
    {
        final Button icon = new Button();
        icon.setPrimaryStyleName(STYLE + "-title-icon");
        icon.setIcon(FontAwesome.BARS);
        icon.addClickListener(event -> toggleMenuPanel());

        titleLabel = new Label();
        titleLabel.setPrimaryStyleName(STYLE + "-title-text");

        final HorizontalLayout panel = new HorizontalLayout(icon, titleLabel);
        panel.addStyleName(STYLE + "-title-lane");
        content.addComponent(panel);
    }

    //
    // Lane: menu
    {
        menuPanel = new MenuPanel();
        menuPanel.setHiddenByStyle(false);

        content.addComponent(menuPanel);
    }

    viewContainer = new ViewContainer();
    content.addComponent(viewContainer);

    setCompositionRoot(content);

    ui.setContent(this);
}