Example usage for com.vaadin.ui Button Button

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

Introduction

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

Prototype

public Button(Resource icon, ClickListener listener) 

Source Link

Document

Creates a new push button with a click listener.

Usage

From source file:com.esofthead.mycollab.module.project.view.milestone.MilestoneBugListComp.java

License:Open Source License

private void constructHeader() {
    final HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);/*from   w w w. ja  va2  s  .  c  o  m*/
    header.setWidth("100%");
    final Label taskGroupSelection = new Label(AppContext.getMessage(MilestoneI18nEnum.TAB_RELATED_BUGS));
    taskGroupSelection.addStyleName("h2");
    taskGroupSelection.addStyleName(UIConstants.THEME_NO_BORDER);
    header.addComponent(taskGroupSelection);
    header.setExpandRatio(taskGroupSelection, 1.0f);
    header.setComponentAlignment(taskGroupSelection, Alignment.MIDDLE_LEFT);

    this.viewGroup = new ToggleButtonGroup();

    final Button simpleDisplay = new Button(null, new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            MilestoneBugListComp.this.displaySimpleView();
        }
    });
    simpleDisplay.setIcon(MyCollabResource.newResource("icons/16/project/list_display.png"));

    this.viewGroup.addButton(simpleDisplay);

    final Button advanceDisplay = new Button(null, new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            MilestoneBugListComp.this.displayAdvancedView();
        }
    });
    advanceDisplay.setIcon(MyCollabResource.newResource("icons/16/project/bug_advanced_display.png"));
    this.viewGroup.addButton(advanceDisplay);
    header.addComponent(this.viewGroup);
    header.setComponentAlignment(this.viewGroup, Alignment.MIDDLE_RIGHT);
    this.addComponent(header);
}

From source file:com.esofthead.mycollab.module.project.view.milestone.MilestoneListViewImpl.java

License:Open Source License

private HorizontalLayout createHeaderRight() {
    final HorizontalLayout layout = new HorizontalLayout();

    this.createBtn = new Button(AppContext.getMessage(MilestoneI18nEnum.BUTTON_NEW_PHASE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override//from   w  w w.jav  a 2  s .c  o m
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance()
                            .post(new MilestoneEvent.GotoAdd(MilestoneListViewImpl.this, null));
                }
            });

    this.createBtn.setIcon(FontAwesome.PLUS);
    this.createBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    this.createBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES));
    layout.addComponent(this.createBtn);
    layout.setComponentAlignment(this.createBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}

From source file:com.esofthead.mycollab.module.project.view.milestone.MilestoneListViewImpl.java

License:Open Source License

private ComponentContainer constructMilestoneBox(final SimpleMilestone milestone) {
    final CssLayout layout = new CssLayout();
    layout.addStyleName(UIConstants.MILESTONE_BOX);
    layout.setWidth("100%");

    final LabelLink milestoneLink = new LabelLink(milestone.getName(),
            ProjectLinkBuilder.generateMilestonePreviewFullLink(milestone.getProjectid(), milestone.getId()));
    milestoneLink.setStyleName("link");
    milestoneLink.addStyleName("bold");
    milestoneLink.addStyleName(UIConstants.WORD_WRAP);
    milestoneLink.addStyleName("milestone-name");
    milestoneLink.setWidth("100%");

    MHorizontalLayout milestoneHeader = new MHorizontalLayout().withWidth("100%").with(milestoneLink)
            .expand(milestoneLink);//from   w  w  w.jav  a 2 s .  c om

    PopupButton taskSettingPopupBtn = new PopupButton();
    taskSettingPopupBtn.setWidth("20px");
    MVerticalLayout filterBtnLayout = new MVerticalLayout().withWidth("100px");

    Button editButton = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    EventBusFactory.getInstance()
                            .post(new MilestoneEvent.GotoEdit(MilestoneListViewImpl.this, milestone));
                }
            });
    editButton.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES));
    editButton.setStyleName("link");
    filterBtnLayout.addComponent(editButton);

    Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    ConfirmDialogExt.show(UI.getCurrent(),
                            AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                    SiteConfiguration.getSiteName()),
                            AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                            AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                            AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                                private static final long serialVersionUID = 1L;

                                @Override
                                public void onClose(ConfirmDialog dialog) {
                                    if (dialog.isConfirmed()) {
                                        MilestoneService projectTaskService = ApplicationContextUtil
                                                .getSpringBean(MilestoneService.class);
                                        projectTaskService.removeWithSession(milestone.getId(),
                                                AppContext.getUsername(), AppContext.getAccountId());
                                        milestones.remove(milestone);
                                        displayMilestones(milestones);
                                    }
                                }
                            });
                }
            });
    deleteBtn.setStyleName("link");
    deleteBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MILESTONES));
    filterBtnLayout.addComponent(deleteBtn);

    taskSettingPopupBtn.setIcon(FontAwesome.COG);
    taskSettingPopupBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);
    taskSettingPopupBtn.setContent(filterBtnLayout);

    milestoneHeader.addComponent(taskSettingPopupBtn);
    layout.addComponent(milestoneHeader);

    MHorizontalLayout spacing = new MHorizontalLayout().withHeight("8px").withWidth("100%");
    layout.addComponent(spacing);

    final GridFormLayoutHelper layoutHelper = new GridFormLayoutHelper(1, 5, "100%", "80px");
    layoutHelper.addComponent(
            new Label(AppContext.formatDate(milestone.getStartdate(),
                    AppContext.getMessage(GenericI18Enum.FORM_EMPTY))),
            AppContext.getMessage(MilestoneI18nEnum.FORM_START_DATE_FIELD), 0, 0, Alignment.MIDDLE_LEFT);
    layoutHelper.addComponent(
            new Label(AppContext.formatDate(milestone.getEnddate(),
                    AppContext.getMessage(GenericI18Enum.FORM_EMPTY))),
            AppContext.getMessage(MilestoneI18nEnum.FORM_END_DATE_FIELD), 0, 1, Alignment.MIDDLE_LEFT);

    CssLayout linkWrapper = new CssLayout();
    linkWrapper.setWidth("100%");
    linkWrapper.addComponent(new ProjectUserLink(milestone.getOwner(), milestone.getOwnerAvatarId(),
            milestone.getOwnerFullName(), false, true));
    layoutHelper.addComponent(linkWrapper, AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE), 0, 2,
            Alignment.MIDDLE_LEFT);

    final ProgressBarIndicator progressTask = new ProgressBarIndicator(milestone.getNumTasks(),
            milestone.getNumOpenTasks());
    progressTask.setWidth("100%");

    layoutHelper.addComponent(progressTask, AppContext.getMessage(MilestoneI18nEnum.FORM_TASK_FIELD), 0, 3,
            Alignment.MIDDLE_LEFT);

    final ProgressBarIndicator progressBug = new ProgressBarIndicator(milestone.getNumBugs(),
            milestone.getNumOpenBugs());
    progressBug.setWidth("100%");

    layoutHelper.addComponent(progressBug, AppContext.getMessage(MilestoneI18nEnum.FORM_BUG_FIELD), 0, 4,
            Alignment.MIDDLE_LEFT);
    final GridLayout milestoneInfoLayout = layoutHelper.getLayout();
    milestoneInfoLayout.setWidth("100%");
    milestoneInfoLayout.setMargin(false);
    milestoneInfoLayout.setSpacing(true);
    layout.addComponent(milestoneInfoLayout);

    return layout;
}

From source file:com.esofthead.mycollab.module.project.view.milestone.MilestoneRoadmapViewImpl.java

License:Open Source License

private HorizontalLayout createHeaderRight() {
    MHorizontalLayout layout = new MHorizontalLayout();

    createBtn = new Button(AppContext.getMessage(MilestoneI18nEnum.NEW), new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override/*w  w  w .ja v  a2  s.  co  m*/
        public void buttonClick(final Button.ClickEvent event) {
            SimpleMilestone milestone = new SimpleMilestone();
            milestone.setSaccountid(AppContext.getAccountId());
            milestone.setProjectid(CurrentProjectVariables.getProjectId());
            UI.getCurrent().addWindow(new MilestoneAddWindow(milestone));
        }
    });
    createBtn.setIcon(FontAwesome.PLUS);
    createBtn.setStyleName(UIConstants.BUTTON_ACTION);
    createBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES));
    layout.with(createBtn);

    Button printBtn = new Button("", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            UI.getCurrent().addWindow(new MilestoneCustomizeReportOutputWindow(new LazyValueInjector() {
                @Override
                protected Object doEval() {
                    return baseCriteria;
                }
            }));
        }
    });
    printBtn.setIcon(FontAwesome.PRINT);
    printBtn.addStyleName(UIConstants.BUTTON_OPTION);
    printBtn.setDescription(AppContext.getMessage(GenericI18Enum.ACTION_EXPORT));
    layout.addComponent(printBtn);

    Button kanbanBtn = new Button("Board", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            EventBusFactory.getInstance()
                    .post(new MilestoneEvent.GotoList(MilestoneRoadmapViewImpl.this, null));
        }
    });
    kanbanBtn.setDescription("Board View");
    kanbanBtn.setIcon(FontAwesome.TH);

    Button roadmapBtn = new Button("List");
    roadmapBtn.setDescription("Roadmap");
    roadmapBtn.setIcon(VaadinIcons.CUBE);

    ToggleButtonGroup viewButtons = new ToggleButtonGroup();
    viewButtons.addButton(roadmapBtn);
    viewButtons.addButton(kanbanBtn);
    viewButtons.withDefaultButton(roadmapBtn);
    layout.with(viewButtons);

    return layout;
}

From source file:com.esofthead.mycollab.module.project.view.milestone.ToggleGenericTaskSummaryField.java

License:Open Source License

ToggleGenericTaskSummaryField(final ProjectGenericTask genericTask) {
    this.genericTask = genericTask;
    this.setWidth("100%");
    titleLinkLbl = new ELabel(buildGenericTaskLink(), ContentMode.HTML).withWidthUndefined();
    titleLinkLbl.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    titleLinkLbl.addStyleName(UIConstants.LABEL_WORD_WRAP);
    this.addComponent(titleLinkLbl);
    if ((genericTask.isTask() && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS))
            || (genericTask.isBug() && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS))
            || (genericTask.isRisk()//from  w w w  . j a  v  a  2 s .com
                    && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.RISKS))) {
        this.addStyleName("editable-field");
        buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false);
        Button instantEditBtn = new Button(null, new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
                if (isRead) {
                    removeComponent(titleLinkLbl);
                    removeComponent(buttonControls);
                    final TextField editField = new TextField();
                    editField.setValue(genericTask.getName());
                    editField.setWidth("100%");
                    editField.focus();
                    addComponent(editField);
                    removeStyleName("editable-field");
                    editField.addValueChangeListener(new Property.ValueChangeListener() {
                        @Override
                        public void valueChange(Property.ValueChangeEvent event) {
                            updateFieldValue(editField);
                        }
                    });
                    editField.addBlurListener(new FieldEvents.BlurListener() {
                        @Override
                        public void blur(FieldEvents.BlurEvent event) {
                            updateFieldValue(editField);
                        }
                    });
                    isRead = !isRead;
                }
            }
        });
        instantEditBtn.setDescription("Edit task name");
        instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
        instantEditBtn.setIcon(FontAwesome.EDIT);
        buttonControls.with(instantEditBtn);

        this.addComponent(buttonControls);
    }
}

From source file:com.esofthead.mycollab.module.project.view.milestone.ToggleMilestoneSummaryField.java

License:Open Source License

ToggleMilestoneSummaryField(final SimpleMilestone milestone, int maxLength) {
    this.milestone = milestone;
    this.maxLength = maxLength;
    this.setWidth("100%");
    titleLinkLbl = new ELabel(buildMilestoneLink(), ContentMode.HTML).withStyleName(ValoTheme.LABEL_H3)
            .withWidthUndefined();// w ww .ja va2  s. c o  m
    titleLinkLbl.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    titleLinkLbl.addStyleName(UIConstants.LABEL_WORD_WRAP);
    this.addComponent(titleLinkLbl);
    buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false);
    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) {
        this.addStyleName("editable-field");
        Button instantEditBtn = new Button(null, new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
                if (isRead) {
                    ToggleMilestoneSummaryField.this.removeComponent(titleLinkLbl);
                    ToggleMilestoneSummaryField.this.removeComponent(buttonControls);
                    final TextField editField = new TextField();
                    editField.setValue(milestone.getName());
                    editField.setWidth("100%");
                    editField.focus();
                    ToggleMilestoneSummaryField.this.addComponent(editField);
                    ToggleMilestoneSummaryField.this.removeStyleName("editable-field");
                    editField.addValueChangeListener(new Property.ValueChangeListener() {
                        @Override
                        public void valueChange(Property.ValueChangeEvent event) {
                            updateFieldValue(editField);
                        }
                    });
                    editField.addBlurListener(new FieldEvents.BlurListener() {
                        @Override
                        public void blur(FieldEvents.BlurEvent event) {
                            updateFieldValue(editField);
                        }
                    });
                    isRead = !isRead;
                }
            }
        });
        instantEditBtn.setDescription("Edit task name");
        instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
        instantEditBtn.setIcon(FontAwesome.EDIT);
        buttonControls.with(instantEditBtn);
        this.addComponent(buttonControls);
    }
}

From source file:com.esofthead.mycollab.module.project.view.page.PageListNoItemView.java

License:Open Source License

protected MHorizontalLayout createControlButtons() {
    Button createPageBtn = new Button(actionMessage(), actionListener());
    createPageBtn.setEnabled(hasPermission());
    createPageBtn.addStyleName(UIConstants.THEME_GREEN_LINK);

    Button createPageGroupBtn = new Button(AppContext.getMessage(Page18InEnum.BUTTON_NEW_GROUP),
            new Button.ClickListener() {
                @Override//from  w ww .j  a v  a2s. c  o m
                public void buttonClick(Button.ClickEvent event) {
                    UI.getCurrent().addWindow(new GroupPageAddWindow());
                }
            });
    createPageGroupBtn.setEnabled(hasPermission());
    createPageGroupBtn.addStyleName(UIConstants.THEME_GREEN_LINK);

    MHorizontalLayout links = new MHorizontalLayout();
    links.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    links.with(createPageBtn, new Label(" or "), createPageGroupBtn);
    return links;
}

From source file:com.esofthead.mycollab.module.project.view.page.PageListViewImpl.java

License:Open Source License

private void initHeader() {
    Label headerText = new ProjectViewHeader(ProjectTypeConstants.PAGE,
            AppContext.getMessage(Page18InEnum.VIEW_LIST_TITLE));

    headerLayout.with(headerText).alignAll(Alignment.MIDDLE_LEFT).expand(headerText);

    Label sortLbl = new Label(AppContext.getMessage(Page18InEnum.OPT_SORT_LABEL));
    sortLbl.setSizeUndefined();/*from  w  ww .ja  v  a 2 s .com*/
    headerLayout.with(sortLbl).withAlign(sortLbl, Alignment.MIDDLE_RIGHT);

    ToggleButtonGroup sortGroup = new ToggleButtonGroup();
    headerLayout.with(sortGroup).withAlign(sortGroup, Alignment.MIDDLE_RIGHT);

    SortButton sortDateBtn = new SortButton(AppContext.getMessage(Page18InEnum.OPT_SORT_BY_DATE),
            new Button.ClickListener() {

                private static final long serialVersionUID = -6987503077975316907L;

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    dateSourceAscend = !dateSourceAscend;
                    if (dateSourceAscend) {
                        Collections.sort(resources, Ordering.from(dateSort));
                    } else {
                        Collections.sort(resources, Ordering.from(dateSort).reverse());
                    }
                    displayPages(resources);

                }
            });
    sortGroup.addButton(sortDateBtn);

    SortButton sortNameBtn = new SortButton(AppContext.getMessage(Page18InEnum.OPT_SORT_BY_NAME),
            new Button.ClickListener() {

                private static final long serialVersionUID = 2847554379518387585L;

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    nameSortAscend = !nameSortAscend;
                    if (nameSortAscend) {
                        Collections.sort(resources, Ordering.from(nameSort));
                    } else {
                        Collections.sort(resources, Ordering.from(nameSort).reverse());
                    }
                    displayPages(resources);

                }
            });
    sortGroup.addButton(sortNameBtn);

    SortButton sortKindBtn = new SortButton(AppContext.getMessage(Page18InEnum.OPT_SORT_BY_KIND),
            new Button.ClickListener() {

                private static final long serialVersionUID = 2230933690084074590L;

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    kindSortAscend = !kindSortAscend;
                    if (kindSortAscend) {
                        Collections.sort(resources, Ordering.from(kindSort));
                    } else {
                        Collections.sort(resources, Ordering.from(kindSort).reverse());
                    }
                    displayPages(resources);

                }
            });
    sortGroup.addButton(sortKindBtn);

    sortGroup.setDefaultButton(sortDateBtn);

    final Button newGroupBtn = new Button(AppContext.getMessage(Page18InEnum.BUTTON_NEW_GROUP),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final Button.ClickEvent event) {
                    UI.getCurrent().addWindow(new PageGroupWindow());
                }
            });
    newGroupBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    newGroupBtn.setIcon(FontAwesome.PLUS);
    newGroupBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES));
    headerLayout.with(newGroupBtn).withAlign(newGroupBtn, Alignment.MIDDLE_RIGHT);

    final Button newPageBtn = new Button(AppContext.getMessage(Page18InEnum.BUTTON_NEW_PAGE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final Button.ClickEvent event) {
                    EventBusFactory.getInstance().post(new PageEvent.GotoAdd(this, null));
                }
            });
    newPageBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    newPageBtn.setIcon(FontAwesome.PLUS);
    newPageBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES));

    headerText.setStyleName(UIConstants.HEADER_TEXT);
    headerLayout.with(newPageBtn).withAlign(newPageBtn, Alignment.MIDDLE_RIGHT);
}

From source file:com.esofthead.mycollab.module.project.view.page.PageListViewImpl.java

License:Open Source License

private Layout displayFolderBlock(final Folder resource) {
    MHorizontalLayout container = new MHorizontalLayout().withWidth("100%").withStyleName("page-item-block");

    FontIconLabel iconResource = new FontIconLabel(FontAwesome.FOLDER_OPEN);
    iconResource.addStyleName("icon-48px");

    VerticalLayout block = new VerticalLayout();
    block.setWidth("600px");
    HorizontalLayout headerPanel = new HorizontalLayout();
    Button folderLink = new Button(resource.getName(), new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override//from ww w.  j av a2  s  .  c  o m
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance()
                    .post(new PageEvent.GotoList(PageListViewImpl.this, resource.getPath()));

        }
    });
    folderLink.addStyleName("link");
    folderLink.addStyleName("h3");
    headerPanel.addComponent(folderLink);
    block.addComponent(headerPanel);
    block.addComponent(new Label(StringUtils.trimHtmlTags(resource.getDescription())));

    Label lastUpdateInfo = new Label(AppContext.getMessage(Page18InEnum.LABEL_LAST_UPDATE,
            ProjectLinkBuilder.generateProjectMemberHtmlLink(resource.getCreatedUser(),
                    CurrentProjectVariables.getProjectId()),
            AppContext.formatDateTime(resource.getCreatedTime().getTime())), ContentMode.HTML);
    lastUpdateInfo.addStyleName("last-update-info");
    block.addComponent(lastUpdateInfo);

    MHorizontalLayout controlBtns = new MHorizontalLayout().withStyleName("control-btns");
    Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() {

        private static final long serialVersionUID = -5387015552598157076L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent().addWindow(new PageGroupWindow(resource));
        }
    });
    editBtn.setIcon(FontAwesome.EDIT);
    editBtn.setStyleName("link");
    editBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES));
    controlBtns.addComponent(editBtn);

    Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE),
            new Button.ClickListener() {

                private static final long serialVersionUID = -5387015552598157076L;

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    ConfirmDialogExt.show(UI.getCurrent(),
                            AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                    SiteConfiguration.getSiteName()),
                            AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                            AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                            AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                                private static final long serialVersionUID = 1L;

                                @Override
                                public void onClose(ConfirmDialog dialog) {
                                    if (dialog.isConfirmed()) {
                                        PageService wikiService = ApplicationContextUtil
                                                .getSpringBean(PageService.class);
                                        wikiService.removeResource(resource.getPath());
                                        resources.remove(resource);
                                        displayPages(resources);
                                    }
                                }
                            });

                }
            });
    deleteBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PAGES));
    deleteBtn.setIcon(FontAwesome.TRASH_O);
    deleteBtn.setStyleName("link");
    controlBtns.addComponent(deleteBtn);

    block.addComponent(controlBtns);

    HorizontalLayout footer = new HorizontalLayout();
    block.addComponent(footer);

    MHorizontalLayout wrapper = new MHorizontalLayout();
    wrapper.with(iconResource, block);
    container.with(wrapper);
    return container;
}

From source file:com.esofthead.mycollab.module.project.view.page.PageListViewImpl.java

License:Open Source License

private Layout displayPageBlock(final Page resource) {
    MHorizontalLayout container = new MHorizontalLayout().withWidth("100%").withStyleName("page-item-block");

    FontIconLabel iconResource = new FontIconLabel(FontAwesome.FILE_WORD_O);
    iconResource.addStyleName("icon-48px");

    VerticalLayout block = new VerticalLayout();
    block.setWidth("600px");
    HorizontalLayout headerPanel = new HorizontalLayout();
    Button pageLink = new Button(resource.getSubject(), new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override/*from   ww w .j a va2  s .  com*/
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new PageEvent.GotoRead(PageListViewImpl.this, resource));

        }
    });
    pageLink.addStyleName("link");
    pageLink.addStyleName("h3");
    headerPanel.addComponent(pageLink);

    block.addComponent(headerPanel);

    block.addComponent(new Label(StringUtils.trimHtmlTags(resource.getContent())));

    Label lastUpdateInfo = new Label(AppContext.getMessage(Page18InEnum.LABEL_LAST_UPDATE,
            ProjectLinkBuilder.generateProjectMemberHtmlLink(resource.getLastUpdatedUser(),
                    CurrentProjectVariables.getProjectId()),
            AppContext.formatDateTime(resource.getLastUpdatedTime().getTime())), ContentMode.HTML);
    lastUpdateInfo.addStyleName("last-update-info");
    block.addComponent(lastUpdateInfo);

    MHorizontalLayout controlBtns = new MHorizontalLayout().withStyleName("control-btns");
    Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() {

        private static final long serialVersionUID = -5387015552598157076L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new PageEvent.GotoEdit(PageListViewImpl.this, resource));
        }
    });
    editBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES));
    editBtn.setIcon(FontAwesome.EDIT);
    editBtn.setStyleName("link");
    controlBtns.addComponent(editBtn);

    Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE),
            new Button.ClickListener() {

                private static final long serialVersionUID = 2575434171770462361L;

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    ConfirmDialogExt.show(UI.getCurrent(),
                            AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                    SiteConfiguration.getSiteName()),
                            AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                            AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                            AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                                private static final long serialVersionUID = 1L;

                                @Override
                                public void onClose(ConfirmDialog dialog) {
                                    if (dialog.isConfirmed()) {
                                        PageService wikiService = ApplicationContextUtil
                                                .getSpringBean(PageService.class);
                                        wikiService.removeResource(resource.getPath());
                                        resources.remove(resource);
                                        displayPages(resources);
                                    }
                                }
                            });

                }
            });
    deleteBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PAGES));
    deleteBtn.setIcon(FontAwesome.TRASH_O);
    deleteBtn.setStyleName("link");
    controlBtns.addComponent(deleteBtn);

    block.addComponent(controlBtns);

    MHorizontalLayout wrapper = new MHorizontalLayout();
    wrapper.with(iconResource, block);
    container.with(wrapper);
    return container;
}