Example usage for com.vaadin.ui Button setIcon

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

Introduction

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

Prototype

@Override
public void setIcon(Resource icon) 

Source Link

Document

Sets the component's icon.

Usage

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

License:Open Source License

public MilestoneAddWindow(final SimpleMilestone milestone) {
    if (milestone.getId() == null) {
        setCaption("New milestone");
    } else {/*from   ww  w.  j  a va2s . c  o m*/
        setCaption("Edit milestone");
    }
    this.setWidth("800px");
    this.setModal(true);
    this.setResizable(false);
    VerticalLayout content = new VerticalLayout();
    this.setContent(content);
    final AdvancedEditBeanForm<SimpleMilestone> editForm = new AdvancedEditBeanForm<>();
    content.addComponent(editForm);
    editForm.setFormLayoutFactory(new DefaultDynaFormLayout(ProjectTypeConstants.MILESTONE,
            MilestoneDefaultFormLayoutFactory.getForm(), Milestone.Field.id.name()));
    final MilestoneEditFormFieldFactory milestoneEditFormFieldFactory = new MilestoneEditFormFieldFactory(
            editForm);
    editForm.setBeanFormFieldFactory(milestoneEditFormFieldFactory);
    editForm.setBean(milestone);

    MHorizontalLayout buttonControls = new MHorizontalLayout()
            .withMargin(new MarginInfo(true, true, true, false));
    buttonControls.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT);

    Button updateAllBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_UPDATE_OTHER_FIELDS),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent clickEvent) {
                    EventBusFactory.getInstance()
                            .post(new MilestoneEvent.GotoAdd(MilestoneAddWindow.this, milestone));
                    close();
                }
            });
    updateAllBtn.addStyleName(UIConstants.BUTTON_LINK);

    Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            if (editForm.validateForm()) {
                MilestoneService milestoneService = AppContextUtil.getSpringBean(MilestoneService.class);
                Integer milestoneId;
                if (milestone.getId() == null) {
                    milestoneId = milestoneService.saveWithSession(milestone, AppContext.getUsername());
                } else {
                    milestoneService.updateWithSession(milestone, AppContext.getUsername());
                    milestoneId = milestone.getId();
                }

                AttachmentUploadField uploadField = milestoneEditFormFieldFactory.getAttachmentUploadField();
                String attachPath = AttachmentUtils.getProjectEntityAttachmentPath(AppContext.getAccountId(),
                        milestone.getProjectid(), ProjectTypeConstants.MILESTONE, "" + milestone.getId());
                uploadField.saveContentsToRepo(attachPath);

                EventBusFactory.getInstance()
                        .post(new MilestoneEvent.NewMilestoneAdded(MilestoneAddWindow.this, milestoneId));
                EventBusFactory.getInstance().post(new AssignmentEvent.NewAssignmentAdd(MilestoneAddWindow.this,
                        ProjectTypeConstants.MILESTONE, milestoneId));
                close();
            }
        }
    });
    saveBtn.setIcon(FontAwesome.SAVE);
    saveBtn.setStyleName(UIConstants.BUTTON_ACTION);
    saveBtn.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent clickEvent) {
                    close();
                }
            });
    cancelBtn.setStyleName(UIConstants.BUTTON_OPTION);
    buttonControls.with(updateAllBtn, cancelBtn, saveBtn);
    content.addComponent(buttonControls);
    content.setComponentAlignment(buttonControls, Alignment.MIDDLE_RIGHT);
}

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 ww .jav  a2s. c om*/
    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.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/*from   ww  w  .  j av a  2  s .c om*/
        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()/*  w w w . ja  v a 2s  .  c om*/
                    && 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();//from w w w. j a va 2 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.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 w  w  .  j  a va 2 s  . c o  m
    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/*w  w  w  .j  av  a  2s  .  c  om*/
        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   w  ww .  j a  v a2  s . c o m
        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;
}

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

License:Open Source License

public ProjectAddBaseTemplateWindow() {
    super(AppContext.getMessage(ProjectI18nEnum.OPT_CREATE_PROJECT_FROM_TEMPLATE));
    this.setModal(true);
    this.setClosable(true);
    this.setResizable(false);
    this.setWidth("550px");
    MVerticalLayout content = new MVerticalLayout();
    GridFormLayoutHelper gridFormLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(1, 3);
    final TemplateProjectComboBox templateProjectComboBox = new TemplateProjectComboBox();
    Button helpBtn = new Button("");
    helpBtn.setIcon(FontAwesome.QUESTION_CIRCLE);
    helpBtn.addStyleName(UIConstants.BUTTON_ACTION);
    helpBtn.setDescription(AppContext.getMessage(ProjectI18nEnum.OPT_MARK_TEMPLATE_HELP));
    gridFormLayoutHelper/*from   w w w. j ava 2  s  .  c om*/
            .addComponent(
                    new MHorizontalLayout().withFullWidth().with(templateProjectComboBox, helpBtn)
                            .expand(templateProjectComboBox),
                    AppContext.getMessage(ProjectI18nEnum.FORM_TEMPLATE), 0, 0);
    final TextField prjNameField = new TextField();
    gridFormLayoutHelper.addComponent(prjNameField, AppContext.getMessage(GenericI18Enum.FORM_NAME), 0, 1);
    final TextField prjKeyField = new TextField();
    gridFormLayoutHelper.addComponent(prjKeyField, AppContext.getMessage(ProjectI18nEnum.FORM_SHORT_NAME), 0,
            2);
    MHorizontalLayout buttonControls = new MHorizontalLayout();
    content.with(gridFormLayoutHelper.getLayout(), buttonControls).withAlign(buttonControls,
            Alignment.MIDDLE_RIGHT);
    Button okBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_OK), new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            SimpleProject templatePrj = (SimpleProject) templateProjectComboBox.getValue();
            if (templatePrj == null) {
                NotificationUtil.showErrorNotification(
                        AppContext.getMessage(ProjectI18nEnum.ERROR_MUST_CHOOSE_TEMPLATE_PROJECT));
                return;
            }
            String newPrjName = prjNameField.getValue();
            if (newPrjName.length() == 0) {
                NotificationUtil.showErrorNotification("Project name must be not null");
                return;
            }
            String newPrjKey = prjKeyField.getValue();
            if (newPrjKey.length() > 3 || newPrjKey.length() == 0) {
                NotificationUtil
                        .showErrorNotification("Project key must be not null and less than 3 characters");
                return;
            }
            ProjectTemplateService projectTemplateService = AppContextUtil
                    .getSpringBean(ProjectTemplateService.class);
            if (projectTemplateService != null) {
                Integer newProjectId = projectTemplateService.cloneProject(templatePrj.getId(), newPrjName,
                        newPrjKey, AppContext.getAccountId(), AppContext.getUsername());
                EventBusFactory.getInstance().post(new ProjectEvent.GotoMyProject(this,
                        new PageActionChain(new ProjectScreenData.Goto(newProjectId))));
                close();
            }
        }
    });
    okBtn.setIcon(FontAwesome.SAVE);
    okBtn.addStyleName(UIConstants.BUTTON_ACTION);
    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent clickEvent) {
                    close();
                }
            });
    cancelBtn.addStyleName(UIConstants.BUTTON_OPTION);
    buttonControls.with(cancelBtn, okBtn);
    this.setContent(content);
}

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

License:Open Source License

private ComponentContainer constructTableActionControls() {
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth();
    layout.addStyleName(UIConstants.TABLE_ACTION_CONTROLS);

    selectOptionButton = new SelectionOptionButton(tableItem);
    selectOptionButton.setWidthUndefined();
    layout.addComponent(selectOptionButton);

    tableActionControls = new DefaultMassItemActionHandlerContainer();

    tableActionControls.addDownloadPdfActionItem();
    tableActionControls.addDownloadExcelActionItem();
    tableActionControls.addDownloadCsvActionItem();

    tableActionControls.setVisible(false);
    tableActionControls.setWidthUndefined();

    layout.addComponent(tableActionControls);
    selectedItemsNumberLabel.setWidth("100%");
    layout.with(selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel, Alignment.MIDDLE_CENTER)
            .expand(selectedItemsNumberLabel);

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

        @Override/*from  w w  w.j  av a 2s  .  c om*/
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent().addWindow(new ProjectListCustomizeWindow(tableItem));

        }
    });
    customizeViewBtn.setIcon(FontAwesome.ADJUST);
    customizeViewBtn.setDescription("Layout Options");
    customizeViewBtn.addStyleName(UIConstants.BUTTON_ACTION);
    layout.with(customizeViewBtn).withAlign(customizeViewBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}