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.klwork.explorer.ui.business.social.WeiboSendPopupWindow.java

License:Apache License

public WeiboSendPopupWindow(final SocialUserAccount socialUserAccount) {
    super(socialUserAccount.getType().toString());
    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.socialUserAccount = socialUserAccount;

    scheduleEventFieldGroup.setBuffered(true);
    if (currentBeanItem != null) {
        scheduleEventFieldGroup.setItemDataSource(currentBeanItem);
    }/*from w w  w  .jav a  2s  .  co 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);
            scheduleEventFieldGroup.bind(weiboContentTA, "content");

            /*
             * 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(socialUserAccount.getOwnUser());

            List<SocialUserAccount> list = socialUserAccountService.findSocialUserAccountByQueryCriteria(query,
                    null);
            for (Iterator iterator = list.iterator(); iterator.hasNext();) {
                SocialUserAccount s = (SocialUserAccount) iterator.next();
                String p = s.getId();
                if (p.equals(socialUserAccount.getId())) {
                    continue;
                }
                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) {
                            BinderHandler.commit(scheduleEventFieldGroup);
                            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.custom.SelectUsersPopupWindow.java

License:Apache License

protected void initSelectMyselfButton(HorizontalLayout searchLayout) {
    final LoggedInUser loggedInUser = LoginHandler.getLoggedInUser();
    if (ignoredUserIds == null || !ignoredUserIds.contains(loggedInUser.getId())) {
        Button meButton = new Button(i18nManager.getMessage(Messages.PEOPLE_SELECT_MYSELF));
        meButton.setIcon(Images.USER_16);
        searchLayout.addComponent(meButton);
        searchLayout.setComponentAlignment(meButton, Alignment.MIDDLE_LEFT);

        if (multiSelect) {
            meButton.addClickListener(new ClickListener() {
                public void buttonClick(ClickEvent event) {
                    selectUser(loggedInUser.getId(), loggedInUser.getFullName());
                }/*from w ww.j  a  v  a 2s. c  om*/
            });
        } else {
            meButton.addClickListener(new ClickListener() {
                public void buttonClick(ClickEvent event) {
                    addMatchingUser(loggedInUser.getId(), loggedInUser.getFullName());
                    matchingUsersTable.select(loggedInUser.getId());
                    fireEvent(new SubmitEvent(doneButton, SubmitEvent.SUBMITTED));
                    close();
                }
            });
        }
    }
}

From source file:com.klwork.explorer.ui.mainlayout.MainMenuBar.java

License:Apache License

protected void initButtons() {
    // TODO: fixed widths based on i18n strings?
    Button taskButton = addMenuButton(ViewManager.MAIN_NAVIGATION_TASK,
            i18nManager.getMessage(Messages.MAIN_MENU_TASKS), Images.MAIN_MENU_TASKS, false, 80);
    taskButton.addClickListener(new ShowTasksClickListener());
    menuItemButtons.put(ViewManager.MAIN_NAVIGATION_TASK, taskButton);

    Button processButton = addMenuButton(ViewManager.MAIN_NAVIGATION_PROCESS, "",
            Images.MAIN_MENU_PROCESS, false, 80);
    processButton.addClickListener(new ShowProcessDefinitionsClickListener());
    menuItemButtons.put(ViewManager.MAIN_NAVIGATION_PROCESS, processButton);

    Button reportingButton = addMenuButton(ViewManager.MAIN_NAVIGATION_REPORT,
            i18nManager.getMessage(Messages.MAIN_MENU_REPORTS), Images.MAIN_MENU_REPORTS, false, 80);
    reportingButton.addClickListener(new ShowReportsClickListener());
    menuItemButtons.put(ViewManager.MAIN_NAVIGATION_REPORT, reportingButton);

    /*//from w w w.j  a v a2s  . c  o  m
     * if (xx.getLoggedInUser().isAdmin()) { Button manageButton =
     * addMenuButton(ViewManager.MAIN_NAVIGATION_MANAGE,
     * i18nManager.getMessage(Messages.MAIN_MENU_MANAGEMENT),
     * Images.MAIN_MENU_MANAGE, false, 90); manageButton.addListener(new
     * ShowManagementClickListener());
     * menuItemButtons.put(ViewManager.MAIN_NAVIGATION_MANAGE,
     * manageButton); }
     */
}

From source file:com.klwork.explorer.ui.task.NewTodoToTaskPopupWindow.java

License:Apache License

protected void initCreateTaskButton() {
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setWidth(100, Unit.PERCENTAGE);
    form.addComponent(buttonLayout);/*  ww w .j a  v a 2s. c om*/

    Button createButton = new Button(i18nManager.getMessage(Messages.BUTTON_CREATE));
    buttonLayout.addComponent(createButton);
    buttonLayout.setComponentAlignment(createButton, Alignment.BOTTOM_RIGHT);

    createButton.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            handleFormSubmit();
        }
    });
}

From source file:com.klwork.explorer.ui.task.ProcessInstanceEventsPanel.java

License:Apache License

protected void addInputField() {
    HorizontalLayout hLayout = new HorizontalLayout();
    hLayout.setSpacing(true);//from w w w.  j  a va 2s  .c o m
    hLayout.setWidth(100, Unit.PERCENTAGE);
    pMainContent.addComponent(hLayout);
    // ?
    initAddEventInput(hLayout);

    Button addCommentButton = new Button(i18nManager.getMessage(Messages.TASK_ADD_COMMENT));
    hLayout.addComponent(addCommentButton);
    hLayout.setComponentAlignment(addCommentButton, Alignment.MIDDLE_LEFT);
    addCommentButton.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            addNewComment(commentInputField.getValue().toString());
        }
    });
}

From source file:com.klwork.explorer.ui.task.TaskDetailPanel.java

License:Apache License

protected void initDescription(HorizontalLayout layout) {
    final CssLayout descriptionLayout = new CssLayout();
    descriptionLayout.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(descriptionLayout);
    layout.setExpandRatio(descriptionLayout, 1.0f);
    layout.setComponentAlignment(descriptionLayout, Alignment.MIDDLE_LEFT);

    String descriptionText = null;
    if (task.getDescription() != null && !"".equals(task.getDescription())) {
        descriptionText = task.getDescription();
    } else {//??
        descriptionText = i18nManager.getMessage(Messages.TASK_NO_DESCRIPTION);
    }// w ww  . ja v a2s.  c  om
    final Label descriptionLabel = new Label(descriptionText);
    descriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
    descriptionLayout.addComponent(descriptionLabel);

    descriptionLayout.addLayoutClickListener(new LayoutClickListener() {
        public void layoutClick(LayoutClickEvent event) {
            if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) {
                // layout for textarea + ok button
                final VerticalLayout editLayout = new VerticalLayout();
                editLayout.setSpacing(true);

                // textarea
                final TextArea descriptionTextArea = new TextArea();
                //
                descriptionTextArea.setNullRepresentation("");
                descriptionTextArea.setWidth(100, Unit.PERCENTAGE);
                descriptionTextArea.setValue(task.getDescription());
                editLayout.addComponent(descriptionTextArea);

                // ok button
                Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
                editLayout.addComponent(okButton);
                editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT);

                // replace
                descriptionLayout.replaceComponent(descriptionLabel, editLayout);

                // When OK is clicked -> update task data + ui
                okButton.addClickListener(new ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        // Update data
                        task.setDescription(descriptionTextArea.getValue().toString());
                        taskService.saveTask(task);

                        // Update UI
                        descriptionLabel.setValue(task.getDescription());
                        descriptionLayout.replaceComponent(editLayout, descriptionLabel);
                    }
                });
            }
        }
    });
}

From source file:com.klwork.explorer.ui.task.TaskDetailPanel.java

License:Apache License

protected void initProcessLink() {
    if (task.getProcessInstanceId() != null) {
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
                .processDefinitionId(task.getProcessDefinitionId()).singleResult();

        Button showProcessInstanceButton = new Button(i18nManager.getMessage(Messages.TASK_PART_OF_PROCESS,
                getProcessDisplayName(processDefinition)));
        showProcessInstanceButton.addStyleName(Reindeer.BUTTON_LINK);
        showProcessInstanceButton.addClickListener(new ClickListener() {
            public void buttonClick(ClickEvent event) {
                //viewManager.showMyProcessInstancesPage(task.getProcessInstanceId());
            }/*from w  w w  .  ja  v a  2 s  .  com*/
        });

        centralLayout.addComponent(showProcessInstanceButton);
        addEmptySpace(centralLayout);
    }
}

From source file:com.klwork.explorer.ui.task.TaskDetailPanel.java

License:Apache License

protected void initParentTaskLink() {
    if (task.getParentTaskId() != null) {
        final Task parentTask = taskService.createTaskQuery().taskId(task.getParentTaskId()).singleResult();

        Button showParentTaskButton = new Button(
                i18nManager.getMessage(Messages.TASK_SUBTASK_OF_PARENT_TASK, parentTask.getName()));
        showParentTaskButton.addStyleName(Reindeer.BUTTON_LINK);
        showParentTaskButton.addClickListener(new ClickListener() {
            public void buttonClick(ClickEvent event) {
                //viewManager.showTaskPage(parentTask.getId());
            }//from   ww  w .  j  a  v  a 2s  .  c  o m
        });

        centralLayout.addComponent(showParentTaskButton);
        addEmptySpace(centralLayout);
    }
}

From source file:com.klwork.explorer.ui.task.TaskMenuBar.java

License:Apache License

protected void initActions() {
    Button newCaseButton = new Button();
    newCaseButton.setCaption(i18nManager.getMessage(Messages.TASK_NEW));
    //WW_TODO Fix
    newCaseButton.setIcon(Images.TASK_16);
    addButton(newCaseButton);//from   ww  w . j  a va2  s .  c  o  m

    newCaseButton.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            NewTaskPopupWindow newTaskPopupWindow = new NewTaskPopupWindow();
            ViewToolManager.showPopupWindow(newTaskPopupWindow);
        }
    });
}

From source file:com.klwork.explorer.ui.task.TaskRelatedContentComponent.java

License:Apache License

protected void initActions() {
    // WW_TODO ?//from  w  w w . ja  v  a2s .  c o m
    HorizontalLayout actionsContainer = new HorizontalLayout();
    actionsContainer.setSizeFull();

    // Title
    Label processTitle = new Label(i18nManager.getMessage(Messages.TASK_RELATED_CONTENT));
    processTitle.addStyleName(ExplorerLayout.STYLE_H3);
    processTitle.setSizeFull();
    actionsContainer.addComponent(processTitle);
    actionsContainer.setComponentAlignment(processTitle, Alignment.MIDDLE_LEFT);
    actionsContainer.setExpandRatio(processTitle, 1.0f);

    // Add content button
    Button addRelatedContentButton = new Button();
    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());
            } else {
                popup.setTaskId(task.getId());
            }

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

                private static final long serialVersionUID = 1L;

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

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

            ViewToolManager.showPopupWindow(popup);
        }
    });

    actionsContainer.addComponent(addRelatedContentButton);
    actionsContainer.setComponentAlignment(processTitle, Alignment.MIDDLE_RIGHT);

    addComponent(actionsContainer);
}