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:com.hybridbpm.ui.component.document.DocumentColumnGenerator.java

License:Apache License

@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
    Document document = (Document) itemId;
    Button button = new Button(document.getName());
    button.setData(document);//from  ww w .  j a  va2s .  c o  m
    button.addStyleName(ValoTheme.BUTTON_LINK);
    if (Objects.equals(document.getType(), Document.TYPE.FILE)) {
        OnDemandFileDownloader onDemandFileDownloader = new OnDemandFileDownloader(document.getId().toString(),
                document.getName());
        onDemandFileDownloader.extend(button);
        button.setDescription(Translate.getMessage("btnDownload"));
    } else {
        button.setDescription(Translate.getMessage("btnOpen"));
        button.addClickListener(clickListener);
    }
    return button;
}

From source file:com.klwork.explorer.ui.business.flow.act.MyTaskRelatedContentComponent.java

License:Apache License

protected Button getAddButton() {
    // Add content button
    Button addRelatedContentButton = new Button();
    addRelatedContentButton.setCaption("");
    ////ww w.j  a v  a  2 s.  c  om
    //addRelatedContentButton.addStyleName(ExplorerLayout.STYLE_ADD);
    addRelatedContentButton.addClickListener(new com.vaadin.ui.Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
            CreateAttachmentPopupWindow popup = new CreateAttachmentPopupWindow();
            //??
            if (task.getProcessInstanceId() != null) {
                popup.setProcessInstanceId(task.getProcessInstanceId());
            }

            // Add listener to update attachments when added
            popup.addListener(new SubmitEventListener() {

                private static final long serialVersionUID = 1L;

                @Override
                protected void submitted(SubmitEvent event) {
                    taskForm.notifyRelatedContentChanged();
                }

                @Override
                protected void cancelled(SubmitEvent event) {
                    // No attachment was added so updating UI isn't
                    // needed.
                }
            });

            ViewToolManager.showPopupWindow(popup);
        }
    });
    return addRelatedContentButton;
}

From source file:com.klwork.explorer.ui.business.flow.act.UploadWorkTaskContentComponent.java

License:Apache License

protected Button getAddButton() {
    // Add content button
    Button addRelatedContentButton = new Button();
    addRelatedContentButton.setCaption("?");

    ////from w  w  w  .  java  2  s  . c om
    //addRelatedContentButton.addStyleName(ExplorerLayout.STYLE_ADD);
    addRelatedContentButton.addClickListener(new com.vaadin.ui.Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
            List types = new ArrayList();
            types.add("file");
            CreateAttachmentPopupWindow popup = new CreateAttachmentPopupWindow(types);
            //??
            popup.setTaskId(taskId);

            // Add listener to update attachments when added
            popup.addListener(new SubmitEventListener() {

                private static final long serialVersionUID = 1L;

                @Override
                protected void submitted(SubmitEvent event) {
                    //taskForm.notifyRelatedContentChanged();
                    refreshTaskAttachments();
                }

                @Override
                protected void cancelled(SubmitEvent event) {
                    // No attachment was added so updating UI isn't
                    // needed.
                }
            });

            ViewToolManager.showPopupWindow(popup);
        }
    });
    return addRelatedContentButton;
}

From source file:com.klwork.explorer.ui.business.organization.GroupMenuBar.java

License:Apache License

protected void initActions() {
    Button newCaseButton = new Button();
    newCaseButton.setCaption(i18nManager.getMessage(Messages.EXPAND_MENU_INVITE));
    //WW_TODO Fix
    newCaseButton.setIcon(Images.TASK_16);
    addButton(newCaseButton);// w ww . j  a  v a  2s. co m

    newCaseButton.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {

        }
    });
}

From source file:com.klwork.explorer.ui.business.outproject.OutProjectManagerMenuBar.java

License:Apache License

protected void initActions() {
    Button newCaseButton = new Button();
    newCaseButton.setCaption(i18nManager.getMessage(Messages.EXPAND_MENU_INVITE));
    // WW_TODO Fix
    newCaseButton.setIcon(Images.TASK_16);
    addButton(newCaseButton);//from w  ww  . j  av a 2s . com

    newCaseButton.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {

        }
    });
}

From source file:com.klwork.explorer.ui.business.project.TodoSharePopupWindow.java

License:Apache License

public TodoSharePopupWindow(String projectId) {
    super("0");
    this.socialUserWeiboService = ViewToolManager.getBean("socialUserWeiboService");
    this.socialSinaService = ViewToolManager.getBean("socialSinaService");
    this.socialUserAccountService = ViewToolManager.getBean("socialUserAccountService");
    this.socialMainService = ViewToolManager.getBean("socialMainService");
    this.i18nManager = ViewToolManager.getI18nManager();

    this.projectId = projectId;//id

    initTodoListImage(projectId);//  w  ww . j  av  a 2 s . c o m
    mainLayout = new VerticalLayout() {
        {
            setSizeFull();
            setSpacing(true);
            setMargin(new MarginInfo(true, true, false, true));

            addComponent(new HorizontalLayout() {// ?,?
                {
                    // setSizeFull();
                    // setSpacing(true);
                    setWidth("100%");
                    // setSpacing(true);
                    // setMargin(true);
                    /*Image image = initFaceComponet();
                    addComponent(image);
                    setExpandRatio(image, 1.2f);
                    setComponentAlignment(image, Alignment.MIDDLE_LEFT);*/
                    //
                    Label inputFontField = initInputFontField();
                    addComponent(inputFontField);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(inputFontField, Alignment.MIDDLE_RIGHT);
                    setExpandRatio(inputFontField, 0.2f);
                }
            });

            // ?

            weiboContentTA.setWidth("100%");
            weiboContentTA.setColumns(25);
            weiboContentTA.focus();
            addComponent(weiboContentTA);

            /*Label descriptionField = new Label();
            descriptionField.addStyleName("wb_text");
            descriptionField.setContentMode(ContentMode.HTML);
            descriptionField.setValue();
            addComponent(descriptionField);*/

            accountGroup = new OptionGroup("?????");
            accountGroup.setMultiSelect(true);
            accountGroup.setStyleName("horizontal");
            addComponent(accountGroup);
            SocialUserAccountQuery query = new SocialUserAccountQuery();
            query.setOwnUser(LoginHandler.getLoggedInUser().getId());

            List<SocialUserAccount> list = socialUserAccountService.findSocialUserAccountByQueryCriteria(query,
                    null);
            for (Iterator iterator = list.iterator(); iterator.hasNext();) {
                SocialUserAccount s = (SocialUserAccount) iterator.next();
                String p = s.getId();
                Item i = accountGroup.addItem(p);
                accountGroup.setItemCaption(p, s.queryTypeName() + "_" + s.getName());
            }

            // 
            HorizontalLayout buttonLayout = new HorizontalLayout() {
                {
                    setSpacing(true);
                    setSizeFull();

                    Image image = initFaceComponet();//
                    addComponent(image);
                    setComponentAlignment(image, Alignment.TOP_LEFT);
                    // setMargin(true);
                    Button okButton = new Button("?");
                    addComponent(okButton);
                    setComponentAlignment(okButton, Alignment.TOP_RIGHT);

                    okButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            handlerSendWeibo();
                            Notification.show("??", Notification.Type.HUMANIZED_MESSAGE);
                            close();
                        }
                    });
                    setExpandRatio(okButton, 1.0f);

                    Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
                    addComponent(cancleButton);
                    setComponentAlignment(cancleButton, Alignment.TOP_RIGHT);

                    cancleButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            // handleFormSubmit();
                            close();
                        }
                    });
                }
            };
            addComponent(buttonLayout);
            setExpandRatio(buttonLayout, 1f);

        }
    };
    setContent(mainLayout);
    setMainLayout(mainLayout);
    setWeiboContentTextArea(weiboContentTA);
}

From source file:com.klwork.explorer.ui.business.query.SocialListQuery.java

License:Apache License

public void initReAuthorButton(SocialUserAccount sc, HorizontalLayout buttonLayout) {
    if (checkExpried(sc)) {//??
        Integer scType = sc.getType();
        Button authorButton = new Button("?");
        authorButton.setDescription("?????");
        authorButton.addStyleName(Reindeer.BUTTON_LINK);
        authorButton.addClickListener(new ClickListener() {
            public void buttonClick(ClickEvent event) {
                //socialAccountList.openReAuthorityBrowserWindow(opener);
            }/*ww  w . ja v  a  2 s  .c o m*/
        });

        //??button?
        socialAccountList.initButtonByBrowWindow(scType, authorButton);
        buttonLayout.addComponent(authorButton);
    }
}

From source file:com.klwork.explorer.ui.business.social.DiscussPopupWindow.java

License:Apache License

public VerticalLayout initMainLayout(final SocialUserWeibo userWeibo) {
    return new VerticalLayout() {
        {/*from   w ww .  ja  va 2s. com*/
            setSizeFull();
            setSpacing(true);
            setMargin(new MarginInfo(true, true, false, true));

            Label descriptionField = new Label();
            descriptionField.addStyleName("wb_text");
            descriptionField.setContentMode(ContentMode.HTML);
            descriptionField.setValue(
                    "@" + userWeibo.getUserScreenName() + ":" + mainPage.textTranslate(userWeibo.getText()));
            addComponent(descriptionField);

            addComponent(new HorizontalLayout() {// ?,?
                {
                    setWidth("100%");

                    //
                    Label inputFontField = initInputFontField();
                    addComponent(inputFontField);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(inputFontField, Alignment.MIDDLE_RIGHT);
                    setExpandRatio(inputFontField, 0.2f);
                }
            });

            // ?
            weiboContentTA = new TextArea("");
            weiboContentTA.setWidth("100%");
            weiboContentTA.setColumns(25);
            weiboContentTA.focus();
            addComponent(weiboContentTA);
            scheduleEventFieldGroup.bind(weiboContentTA, "content");

            // ?
            addComponent(new HorizontalLayout() {
                {
                    setSpacing(true);
                    // setSizeFull();
                    // setMargin(true);
                    CheckBox simuField = CommonFieldHandler.createCheckBox("");
                    simuField.addValueChangeListener(new Property.ValueChangeListener() {

                        private static final long serialVersionUID = -7104996493482558021L;

                        @Override
                        public void valueChange(ValueChangeEvent event) {
                            Object value = event.getProperty().getValue();
                        }

                    });
                    addComponent(simuField);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(simuField, Alignment.MIDDLE_LEFT);

                    Label commentLable = new Label();
                    commentLable.setContentMode(ContentMode.HTML);
                    commentLable.setValue("????");

                    addComponent(commentLable);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(commentLable, Alignment.MIDDLE_LEFT);

                    Image image = initFaceComponet();//
                    addComponent(image);
                }
            });

            // 
            HorizontalLayout buttonLayout = new HorizontalLayout() {
                {
                    setSpacing(true);
                    setSizeFull();
                    // setMargin(true);
                    Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
                    addComponent(okButton);
                    setComponentAlignment(okButton, Alignment.TOP_RIGHT);

                    okButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            BinderHandler.commit(scheduleEventFieldGroup);
                            int ret = socialService.discussWeibo(weiboForwardSend);
                            if (ret == 1) {
                                Notification.show("??", Notification.Type.HUMANIZED_MESSAGE);
                            }
                            close();
                        }
                    });
                    setExpandRatio(okButton, 1.0f);

                    Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
                    addComponent(cancleButton);
                    setComponentAlignment(cancleButton, Alignment.TOP_RIGHT);

                    cancleButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            close();
                        }
                    });
                }
            };
            addComponent(buttonLayout);
            setExpandRatio(buttonLayout, 1f);

        }
    };
}

From source file:com.klwork.explorer.ui.business.social.SaveToNotePopupWindow.java

License:Apache License

public VerticalLayout initMainLayout(final SocialUserWeibo userWeibo) {
    return new VerticalLayout() {
        {//from  w  w w  . ja v  a 2s.c o  m
            setSizeFull();
            setSpacing(true);
            setMargin(new MarginInfo(true, true, false, true));

            Label descriptionField = new Label();
            descriptionField.addStyleName("wb_text");
            descriptionField.setContentMode(ContentMode.HTML);
            descriptionField.setValue("");
            addComponent(descriptionField);
            // ?
            weiboContentTA = new TextArea("");
            weiboContentTA.setWidth("100%");
            weiboContentTA.setColumns(25);
            weiboContentTA.focus();
            addComponent(weiboContentTA);
            scheduleEventFieldGroup.bind(weiboContentTA, "content");

            if (hasOrginWeibo) {// 
                weiboContentTA.setValue("//@" + userWeibo.getUserScreenName() + ": " + userWeibo.getText());
            } else {
                weiboContentTA.setValue(userWeibo.getText());
                //+ mainPage.textTranslate(userWeibo.getText()));
            }

            //,
            addComponent(new VerticalLayout() {
                {
                    setSpacing(true);

                    TextField titleField = CommonFieldHandler.createTextField("");
                    scheduleEventFieldGroup.bind(titleField, "title");

                    //???
                    if (userWeibo.getText() != null && userWeibo.getText().length() > 10) {
                        titleField.setValue(userWeibo.getText().substring(0, 10));
                    }
                    addComponent(titleField);
                    // setSizeFull();
                    // setMargin(true);
                    SocialUserAccount noteAccount = socialUserAccountService
                            .findSocialUserByType(socialUserAccount.getOwnUser(), DictDef.dictInt("evernote"));
                    if (noteAccount != null) {
                        noteEntity.setUserAccountId(noteAccount.getId());
                    }

                    Map<String, String> map = socialEvernoteService.queryNotebook(noteAccount);
                    ComboBox noteMap = CommonFieldHandler.createComBox("", map, "");
                    addComponent(noteMap);
                    setComponentAlignment(noteMap, Alignment.MIDDLE_LEFT);
                }
            });

            // 
            HorizontalLayout buttonLayout = new HorizontalLayout() {
                {
                    setSpacing(true);
                    setSizeFull();
                    // setMargin(true);
                    Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
                    addComponent(okButton);
                    setComponentAlignment(okButton, Alignment.TOP_RIGHT);

                    okButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            BinderHandler.commit(scheduleEventFieldGroup);
                            //?
                            int ret = socialEvernoteService.saveWeiboToNotes(noteEntity);
                            if (ret == 1) {
                                Notification.show("??", Notification.Type.HUMANIZED_MESSAGE);
                            } else {
                                Notification.show("??!", Notification.Type.HUMANIZED_MESSAGE);
                            }
                            close();
                        }
                    });
                    setExpandRatio(okButton, 1.0f);

                    Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
                    addComponent(cancleButton);
                    setComponentAlignment(cancleButton, Alignment.TOP_RIGHT);

                    cancleButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            close();
                        }
                    });
                }
            };
            addComponent(buttonLayout);
            setExpandRatio(buttonLayout, 1f);

        }
    };
}

From source file:com.klwork.explorer.ui.business.social.TransmitPopupWindow.java

License:Apache License

public TransmitPopupWindow(final SocialUserWeibo userWeibo, final AbstractWeiboDisplayPage mainPage) {
    super(mainPage.getSocialType());
    this.socialUserWeiboService = ViewToolManager.getBean("socialUserWeiboService");
    this.socialService = AbstractSocialService.querySocialClass(mainPage.getSocialType());

    this.i18nManager = ViewToolManager.getI18nManager();

    weiboForwardSend.setWeibId(userWeibo.getWeiboId());
    weiboForwardSend.setUserAccountId(userWeibo.getUserAccountId());
    this.userWeibo = userWeibo;
    if (userWeibo.getRetweetedId() != null) {
        orginWeibo = socialUserWeiboService.findSocialUserWeiboById(userWeibo.getRetweetedId());
        hasOrginWeibo = true;//from  ww w  .jav a2s  . c o m
        weiboForwardSend.setWeibId(orginWeibo.getId());
    }

    scheduleEventFieldGroup.setBuffered(true);
    if (currentBeanItem != null) {
        scheduleEventFieldGroup.setItemDataSource(currentBeanItem);
    }

    mainLayout = new VerticalLayout() {
        {
            setSizeFull();
            setSpacing(true);
            setMargin(new MarginInfo(true, true, false, true));

            Label descriptionField = new Label();
            descriptionField.addStyleName("wb_text");
            descriptionField.setContentMode(ContentMode.HTML);
            descriptionField.setValue(
                    "@" + userWeibo.getUserScreenName() + ":" + mainPage.textTranslate(userWeibo.getText()));
            if (hasOrginWeibo) {
                descriptionField.setValue("@" + orginWeibo.getUserScreenName() + ":"
                        + mainPage.textTranslate(orginWeibo.getText()));
            }
            addComponent(descriptionField);

            addComponent(new HorizontalLayout() {// ?,?
                {
                    // setSizeFull();
                    // setSpacing(true);
                    setWidth("100%");
                    // setSpacing(true);
                    // setMargin(true);
                    /*Image image = initFaceComponet();
                    addComponent(image);
                    setExpandRatio(image, 1.2f);
                    setComponentAlignment(image, Alignment.MIDDLE_LEFT);*/
                    //
                    Label inputFontField = initInputFontField();
                    addComponent(inputFontField);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(inputFontField, Alignment.MIDDLE_RIGHT);
                    setExpandRatio(inputFontField, 0.2f);
                }
            });

            // ?

            weiboContentTA.setWidth("100%");
            weiboContentTA.setColumns(25);
            weiboContentTA.focus();
            addComponent(weiboContentTA);
            scheduleEventFieldGroup.bind(weiboContentTA, "content");
            if (hasOrginWeibo) {// 
                weiboContentTA.setValue("//@" + userWeibo.getUserScreenName() + ": " + userWeibo.getText());
            }

            // ?
            addComponent(new HorizontalLayout() {
                {
                    setSpacing(true);
                    // setSizeFull();
                    // setMargin(true);
                    CheckBox simuField = CommonFieldHandler.createCheckBox("");
                    simuField.addValueChangeListener(new Property.ValueChangeListener() {

                        private static final long serialVersionUID = -7104996493482558021L;

                        @Override
                        public void valueChange(ValueChangeEvent event) {
                            Object value = event.getProperty().getValue();
                        }

                    });
                    addComponent(simuField);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(simuField, Alignment.MIDDLE_LEFT);

                    Label commentLable = new Label();
                    commentLable.setContentMode(ContentMode.HTML);
                    commentLable.setValue("? " + "" + userWeibo.getUserScreenName());

                    addComponent(commentLable);
                    // setExpandRatio(image, 1.0f);
                    setComponentAlignment(commentLable, Alignment.MIDDLE_LEFT);

                    Image image = initFaceComponet();//
                    addComponent(image);
                }
            });

            if (hasOrginWeibo) {
                // ?
                addComponent(new HorizontalLayout() {
                    {
                        // setSizeFull();
                        setSpacing(true);
                        // setMargin(true);
                        CheckBox simuOriginalField = CommonFieldHandler.createCheckBox("");
                        simuOriginalField.addValueChangeListener(new Property.ValueChangeListener() {

                            private static final long serialVersionUID = -7104996493482558021L;

                            @Override
                            public void valueChange(ValueChangeEvent event) {
                                Object value = event.getProperty().getValue();
                            }

                        });
                        addComponent(simuOriginalField);
                        // setExpandRatio(image, 1.0f);
                        setComponentAlignment(simuOriginalField, Alignment.MIDDLE_LEFT);

                        Label commentLable = new Label();
                        commentLable.setContentMode(ContentMode.HTML);
                        commentLable
                                .setValue("? " + "" + orginWeibo.getUserScreenName());

                        addComponent(commentLable);
                        // setExpandRatio(image, 1.0f);
                        setComponentAlignment(commentLable, Alignment.MIDDLE_LEFT);
                    }
                });
            }

            // 
            HorizontalLayout buttonLayout = new HorizontalLayout() {
                {
                    setSpacing(true);
                    setSizeFull();
                    // setMargin(true);
                    Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
                    addComponent(okButton);
                    setComponentAlignment(okButton, Alignment.TOP_RIGHT);

                    okButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            BinderHandler.commit(scheduleEventFieldGroup);
                            int ret = socialService.forwardWeibo(weiboForwardSend);
                            if (ret == 1) {
                                Notification.show("??", Notification.Type.HUMANIZED_MESSAGE);
                            }
                            close();
                        }
                    });
                    setExpandRatio(okButton, 1.0f);

                    Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL));
                    addComponent(cancleButton);
                    setComponentAlignment(cancleButton, Alignment.TOP_RIGHT);

                    cancleButton.addClickListener(new ClickListener() {
                        public void buttonClick(ClickEvent event) {
                            // handleFormSubmit();
                            close();
                        }
                    });
                }
            };
            addComponent(buttonLayout);
            setExpandRatio(buttonLayout, 1f);

        }
    };
    setContent(mainLayout);
    setMainLayout(mainLayout);
    setWeiboContentTextArea(weiboContentTA);
}