Example usage for com.vaadin.ui Button addListener

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

Introduction

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

Prototype

@Override
    public Registration addListener(Component.Listener listener) 

Source Link

Usage

From source file:ro.zg.netcell.vaadin.action.user.LoginHandler.java

License:Apache License

private Component getOpenidLoginComponent(final ActionContext actionContext,
        final Map.Entry<String, String> entry) {
    final Button lb = new Button();

    lb.setIcon(OpenGroupsResources.getIcon(entry.getKey() + ".png"));
    lb.addStyleName(BaseTheme.BUTTON_LINK);
    String providerName = entry.getKey();
    providerName = Character.toUpperCase(providerName.charAt(0)) + providerName.substring(1);
    lb.setDescription(OpenGroupsResources.getMessage("openid.login.message", providerName));
    lb.addListener(new ClickListener() {

        @Override// w ww. ja  v  a2s.  c  o m
        public void buttonClick(ClickEvent event) {
            actionContext.getApp().openIdLogin(entry.getValue());
            actionContext.getWindow().removeWindow(lb.getWindow());
        }
    });
    return lb;
}

From source file:ro.zg.netcell.vaadin.action.user.LoginHandler.java

License:Apache License

private void addFooterActions(final ComponentContainer container, final OpenGroupsApplication app,
        final ActionContext ac) {
    UserActionList actionsList = ActionsManager.getInstance().getGlobalActions(ActionLocations.LOGIN_FOOTER);
    if (actionsList != null && actionsList.getActions() != null) {
        final Window window = ac.getWindow();
        for (final UserAction ua : actionsList.getActions().values()) {
            Button link = new Button(ua.getDisplayName());
            link.addStyleName(BaseTheme.BUTTON_LINK);
            container.addComponent(link);
            link.addListener(new ClickListener() {

                @Override/*w  ww . j  a va  2  s .c  o m*/
                public void buttonClick(ClickEvent event) {
                    window.removeWindow(container.getWindow());
                    ua.executeHandler(null, app, null, ac);
                }
            });
        }
    }
}

From source file:ro.zg.netcell.vaadin.action.user.UpdateUserHandler.java

License:Apache License

private void showSuccessMessage(final OpenGroupsApplication app, final ComponentContainer container,
        final UserAction ua, final ActionContext ac) {
    container.removeAllComponents();//from   www . j a v a2s .  c o  m
    Label msg = new Label(getMessage("user.data.succesfully.updated"));
    Button button = new Button(getMessage("new.user.data.update"));

    button.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            ua.executeHandler(null, app, container, ac);
        }
    });

    container.addComponent(msg);
    container.addComponent(button);
}

From source file:ro.zg.netcell.vaadin.DataTranslationUtils.java

License:Apache License

public static Form createFormFromInputParameterList(List<InputParameter> list) {
    final Form form = new Form();
    form.setItemDataSource(inputParameterListToPropertysetItem(list));
    for (InputParameter p : list) {
        Field f = form.getField(p.getName());
        f.setRequired(p.isMandatory());/*from   w  w  w  .j  a va  2 s  . co m*/
    }
    form.setWidth("40%");
    form.setHeight("30%");
    form.getLayout().setMargin(true);
    Button submitButton = new Button("Submit");
    form.getFooter().addComponent(submitButton);
    submitButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            form.commit();
        }
    });
    Button discardButton = new Button("Discard");
    form.getFooter().addComponent(discardButton);
    discardButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            form.discard();
        }
    });
    form.setImmediate(true);

    return form;
}

From source file:ro.zg.netcell.vaadin.ExtendedForm.java

License:Apache License

public void populateFromInputParameterList(List<InputParameter> list) {
    setItemDataSource(DataTranslationUtils.inputParameterListToPropertysetItem(list));
    for (InputParameter p : list) {
        String pName = p.getName();
        Field f = getField(pName);
        f.setRequired(p.isMandatory());/*from   w  ww. ja  v a2s.  co  m*/
        if (pName.equals("password")) {
            ((TextField) f).setSecret(true);
        }
        Object value = p.getValue();
        if (value != null) {
            f.setPropertyDataSource(new ObjectProperty(value));
        }
    }

    Button submitButton = new Button("Submit");
    getFooter().addComponent(submitButton);
    submitButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            commit();
            fireCommitEvent();
        }
    });
    Button discardButton = new Button("Discard");
    getFooter().addComponent(discardButton);
    discardButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            discard();
        }
    });
}

From source file:ro.zg.netcell.vaadin.ExtendedForm.java

License:Apache License

public void addSubmitButton(String caption) {
    Button submitButton = new Button(caption);
    getFooter().addComponent(submitButton);
    submitButton.addListener(new ClickListener() {

        @Override//from  w w w .j av a2s .com
        public void buttonClick(ClickEvent event) {
            try {
                commit();
                fireCommitEvent();
            } catch (Validator.InvalidValueException e) {
                /* do nothing, as an error message will be displayed to the user */
            }
        }
    });
}

From source file:ro.zg.opengroups.views.UserNotificationRulesListControls.java

License:Apache License

private void displayAddNewRuleButton(final NotificationRulesList updateData) {
    Button button = new Button();
    button.addStyleName(updateData.getControlsContainerCellStyle());
    // TODO: add an icon, don't let this hardcoded text
    button.setDescription(OpenGroupsResources.getMessage("notification.rules.list.add.rule"));
    button.setIcon(OpenGroupsResources.getIcon(OpenGroupsIconsSet.ADD, OpenGroupsIconsSet.SMALL));
    if (!updateData.isNewRuleAllowed()) {
        button.setEnabled(false);//w  w  w . j a v a2 s .co m
    } else {
        button.addListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                updateData.createNewRule();
            }
        });
    }

    container.addComponent(button);
}

From source file:ro.zg.opengroups.views.UserNotificationRulesListControls.java

License:Apache License

private void displaySaveRulesButton(final NotificationRulesList updateData) {
    final Button button = new Button();
    button.addStyleName(updateData.getControlsContainerCellStyle());
    // TODO: add an icon, don't let this hardcoded text
    button.setDescription(OpenGroupsResources.getMessage("notification.rules.list.save"));
    button.setIcon(OpenGroupsResources.getIcon(OpenGroupsIconsSet.ACCEPT, OpenGroupsIconsSet.SMALL));
    if (!updateData.isSaveNeeded()) {
        button.setEnabled(false);/*from www.ja  v a2s.  c  o m*/
    } else {
        button.addListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                handleEvent(new UserEvent(NotificationUserEvents.SAVE_BUTTON_CLICKED, button, updateData));
            }
        });
    }

    container.addComponent(button);
}

From source file:ro.zg.opengroups.views.UserNotificationRuleView.java

License:Apache License

private void displayDeleteRuleButton(final MultitypeNotificationRule rule) {
    final Button button = new Button();
    button.setDescription(OpenGroupsResources.getMessage("notification.rules.list.delete.rule"));
    button.setIcon(OpenGroupsResources.getIcon(OpenGroupsIconsSet.CANCEL, OpenGroupsIconsSet.SMALL));
    CssLayout cell = addToContainer(button);
    cell.setStyleName("notification-rules-list-row-cell-delete-rule");

    button.addListener(new ClickListener() {

        @Override//from ww  w.j  av  a 2s. com
        public void buttonClick(ClickEvent event) {
            rule.delete();
        }
    });
}

From source file:ro.zg.open_groups.gui.components.CustomTabSheet.java

License:Apache License

public void addTab(final Component tabContent, String caption) {
    Button tab = tabs.get(tabContent);
    if (tab == null) {
        tab = new Button(caption);
        tab.addStyleName(BaseTheme.BUTTON_LINK);
        tabs.put(tabContent, tab);/*w  w  w . j  av  a  2s.co m*/
        /* if this is the first tab in this tabsheet select it */
        if (tabs.size() == 1) {
            if (!initialized) {
                /* laizy initialization when the first tab is added */
                initialize();
                initialized = true;
            }
            tabsArea.addComponent(tab);
            selectTab(tabContent, tab);
        } else {
            tabsArea.addComponent(tab);
        }
        /* add click listener for this tab */
        tab.addListener(new ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                selectTab(tabContent, event.getButton());
            }
        });

    } else {
        tab.setCaption(caption);
    }
}