Example usage for com.vaadin.ui Button addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:com.esofthead.mycollab.module.project.view.assignments.gantt.PredecessorWindow.java

License:Open Source License

PredecessorWindow(final GanttTreeTable taskTreeTable, final GanttItemWrapper ganttItemWrapper) {
    super("Edit predecessors");
    this.setModal(true);
    this.setResizable(false);
    this.setWidth("650px");
    this.center();
    this.taskTreeTable = taskTreeTable;
    this.ganttItemWrapper = ganttItemWrapper;

    MVerticalLayout content = new MVerticalLayout();
    this.setContent(content);
    Label headerLbl = new Label(
            String.format("Row %d: %s", ganttItemWrapper.getGanttIndex(), ganttItemWrapper.getName()));
    headerLbl.addStyleName(ValoTheme.LABEL_H2);
    content.add(headerLbl);/*from  w  ww  .j av a  2 s.c o m*/

    CssLayout preWrapper = new CssLayout();
    content.with(preWrapper);

    MHorizontalLayout headerLayout = new MHorizontalLayout();
    headerLayout.addComponent(new ELabel("Row").withWidth(ROW_WDITH));
    headerLayout.addComponent(new ELabel("Task").withWidth(TASK_WIDTH));
    headerLayout.addComponent(new ELabel("Dependency").withWidth(PRE_TYPE_WIDTH));
    headerLayout.addComponent(new ELabel("Lag").withWidth(LAG_WIDTH));
    predecessorsLayout = new PredecessorsLayout();
    new Restrain(predecessorsLayout).setMaxHeight("600px");

    preWrapper.addComponent(headerLayout);
    preWrapper.addComponent(predecessorsLayout);

    MHorizontalLayout buttonControls = new MHorizontalLayout();
    content.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);

    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    PredecessorWindow.this.close();
                }
            });
    cancelBtn.addStyleName(UIConstants.BUTTON_OPTION);

    Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            List<TaskPredecessor> predecessors = predecessorsLayout.buildPredecessors();
            EventBusFactory.getInstance()
                    .post(new GanttEvent.ModifyPredecessors(ganttItemWrapper, predecessors));
            PredecessorWindow.this.close();
        }
    });
    saveBtn.addStyleName(UIConstants.BUTTON_ACTION);
    buttonControls.with(cancelBtn, saveBtn);
}

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

License:Open Source License

private void displayWorkflowControl() {
    if (BugStatus.Open.name().equals(this.beanItem.getStatus())
            || BugStatus.ReOpened.name().equals(this.beanItem.getStatus())) {
        this.bugWorkflowControl.removeAllComponents();
        final ButtonGroup navButton = new ButtonGroup();
        final Button startProgressBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_START_PROGRESS),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override//from   ww  w  . j  a  va 2s.  c om
                    public void buttonClick(final ClickEvent event) {
                        beanItem.setStatus(BugStatus.InProgress.name());
                        final BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class);
                        bugService.updateSelectiveWithSession(beanItem, AppContext.getUsername());
                        displayWorkflowControl();
                    }
                });
        startProgressBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
        navButton.addButton(startProgressBtn);

        final Button resolveBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_RESOLVED),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        UI.getCurrent().addWindow(new ResolvedInputWindow(BugReadViewImpl.this, beanItem));
                    }
                });
        resolveBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
        navButton.addButton(resolveBtn);

        final Button wontFixBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_WONTFIX),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        UI.getCurrent().addWindow(new WontFixExplainWindow(BugReadViewImpl.this, beanItem));
                    }
                });
        wontFixBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
        navButton.addButton(wontFixBtn);
        this.bugWorkflowControl.addComponent(navButton);
    } else if (BugStatus.InProgress.name().equals(this.beanItem.getStatus())) {
        this.bugWorkflowControl.removeAllComponents();
        final ButtonGroup navButton = new ButtonGroup();
        final Button stopProgressBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_STOP_PROGRESS),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        beanItem.setStatus(BugStatus.Open.name());
                        final BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class);
                        bugService.updateSelectiveWithSession(beanItem, AppContext.getUsername());
                        displayWorkflowControl();
                    }
                });
        stopProgressBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
        navButton.addButton(stopProgressBtn);

        final Button resolveBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_RESOLVED),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        UI.getCurrent().addWindow(new ResolvedInputWindow(BugReadViewImpl.this, beanItem));
                    }
                });
        resolveBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
        navButton.addButton(resolveBtn);
        this.bugWorkflowControl.addComponent(navButton);
    } else if (BugStatus.Verified.name().equals(this.beanItem.getStatus())) {
        this.bugWorkflowControl.removeAllComponents();
        final ButtonGroup navButton = new ButtonGroup();
        final Button reopenBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_REOPEN),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        UI.getCurrent().addWindow(new ReOpenWindow(BugReadViewImpl.this, beanItem));
                    }
                });
        reopenBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
        navButton.addButton(reopenBtn);

        this.bugWorkflowControl.addComponent(navButton);
    } else if (BugStatus.Resolved.name().equals(this.beanItem.getStatus())) {
        this.bugWorkflowControl.removeAllComponents();
        final ButtonGroup navButton = new ButtonGroup();
        final Button reopenBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_REOPEN),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        UI.getCurrent().addWindow(new ReOpenWindow(BugReadViewImpl.this, beanItem));
                    }
                });
        reopenBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
        navButton.addButton(reopenBtn);

        final Button approveNCloseBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_APPROVE_CLOSE),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        UI.getCurrent().addWindow(new ApproveInputWindow(BugReadViewImpl.this, beanItem));
                    }
                });
        approveNCloseBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
        navButton.addButton(approveNCloseBtn);
        this.bugWorkflowControl.addComponent(navButton);
    } else if (BugStatus.Resolved.name().equals(this.beanItem.getStatus())) {
        this.bugWorkflowControl.removeAllComponents();
        final ButtonGroup navButton = new ButtonGroup();
        final Button reopenBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_REOPEN),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        UI.getCurrent().addWindow(new ReOpenWindow(BugReadViewImpl.this, beanItem));
                    }
                });
        reopenBtn.setStyleName(UIConstants.THEME_BROWN_LINK);
        navButton.addButton(reopenBtn);

        this.bugWorkflowControl.addComponent(navButton);
    }
    this.bugWorkflowControl.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS));
}

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

License:Open Source License

public BugTableDisplay(String viewId, TableViewField requiredColumn, List<TableViewField> displayColumns) {
    super(ApplicationContextUtil.getSpringBean(BugService.class), SimpleBug.class, viewId, requiredColumn,
            displayColumns);//www . j  av a2  s  . c  om

    this.addGeneratedColumn("id", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(final Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            final Button bugSettingBtn = new Button(null, FontAwesome.COG);
            bugSettingBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);

            final ContextMenu contextMenu = new ContextMenu();
            contextMenu.setAsContextMenuOf(bugSettingBtn);

            contextMenu.addItemClickListener(new ContextMenuItemClickListener() {

                @Override
                public void contextMenuItemClicked(ContextMenuItemClickEvent event) {
                    if (((ContextMenuItem) event.getSource()).getData() == null) {
                        return;
                    }

                    String category = ((MenuItemData) ((ContextMenuItem) event.getSource()).getData())
                            .getAction();
                    String value = ((MenuItemData) ((ContextMenuItem) event.getSource()).getData()).getKey();
                    if ("status".equals(category)) {
                        if (AppContext.getMessage(BugStatus.Verified).equals(value)) {
                            UI.getCurrent().addWindow(new ApproveInputWindow(BugTableDisplay.this, bug));
                        } else if (AppContext.getMessage(BugStatus.InProgress).equals(value)) {
                            bug.setStatus(BugStatus.InProgress.name());
                            BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class);
                            bugService.updateWithSession(bug, AppContext.getUsername());
                        } else if (AppContext.getMessage(BugStatus.Open).equals(value)) {
                            UI.getCurrent().addWindow(new ReOpenWindow(BugTableDisplay.this, bug));
                        } else if (AppContext.getMessage(BugStatus.Resolved).equals(value)) {
                            UI.getCurrent().addWindow(new ResolvedInputWindow(BugTableDisplay.this, bug));
                        }
                    } else if ("severity".equals(category)) {
                        bug.setSeverity(value);
                        BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class);
                        bugService.updateWithSession(bug, AppContext.getUsername());
                        refresh();
                    } else if ("priority".equals(category)) {
                        bug.setPriority(value);
                        BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class);
                        bugService.updateWithSession(bug, AppContext.getUsername());
                        refresh();
                    } else if ("action".equals(category)) {
                        if ("edit".equals(value)) {
                            EventBusFactory.getInstance()
                                    .post(new BugEvent.GotoEdit(BugTableDisplay.this, bug));
                        } else if ("delete".equals(value)) {
                            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()) {
                                                BugService bugService = ApplicationContextUtil
                                                        .getSpringBean(BugService.class);
                                                bugService.removeWithSession(bug.getId(),
                                                        AppContext.getUsername(), AppContext.getAccountId());
                                                refresh();
                                            }
                                        }
                                    });

                        }
                    }

                }
            });

            bugSettingBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS));

            bugSettingBtn.addClickListener(new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    displayContextMenuItem(contextMenu, bug, event.getClientX(), event.getClientY());
                }
            });
            return bugSettingBtn;
        }
    });

    this.addGeneratedColumn("assignuserFullName", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new ProjectUserLink(bug.getAssignuser(), bug.getAssignUserAvatarId(),
                    bug.getAssignuserFullName());
        }
    });

    this.addGeneratedColumn("loguserFullName", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new ProjectUserLink(bug.getLogby(), bug.getLoguserAvatarId(), bug.getLoguserFullName());
        }
    });

    this.addGeneratedColumn("summary", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {

            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);

            String bugname = "[%s-%s] %s";
            bugname = String.format(bugname, CurrentProjectVariables.getProject().getShortname(),
                    bug.getBugkey(), bug.getSummary());
            LabelLink b = new LabelLink(bugname,
                    ProjectLinkBuilder.generateBugPreviewFullLink(bug.getBugkey(), bug.getProjectShortName()));

            if (StringUtils.isNotBlank(bug.getPriority())) {
                b.setIconLink(ProjectResources.getIconResourceLink12ByBugPriority(bug.getPriority()));
            }

            b.setDescription(ProjectTooltipGenerator.generateToolTipBug(AppContext.getUserLocale(), bug,
                    AppContext.getSiteUrl(), AppContext.getTimezone()));

            if (bug.isCompleted()) {
                b.addStyleName(UIConstants.LINK_COMPLETED);
            } else if (bug.isOverdue()) {
                b.addStyleName(UIConstants.LINK_OVERDUE);
            }
            return b;

        }
    });

    this.addGeneratedColumn("severity", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);

            Resource iconPriority = new ExternalResource(
                    ProjectResources.getIconResourceLink12ByBugSeverity(bug.getPriority()));

            Embedded iconEmbedded = new Embedded(null, iconPriority);
            Label lbPriority = new Label(AppContext.getMessage(BugSeverity.class, bug.getSeverity()));
            HorizontalLayout containerField = new HorizontalLayout();
            containerField.setSpacing(true);
            containerField.addComponent(iconEmbedded);
            containerField.addComponent(lbPriority);
            containerField.setExpandRatio(lbPriority, 1.0f);
            return containerField;

        }
    });

    this.addGeneratedColumn("duedate", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.formatDate(bug.getDuedate()));

        }
    });

    this.addGeneratedColumn("createdtime", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.formatDateTime(bug.getCreatedtime()));

        }
    });

    this.addGeneratedColumn("resolution", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.getMessage(BugResolution.class, bug.getResolution()));
        }
    });
    this.setWidth("100%");
}

From source file:com.esofthead.mycollab.module.project.view.bug.components.BugSelectionField.java

License:Open Source License

@Override
protected Component initContent() {
    MHorizontalLayout layout = new MHorizontalLayout();
    Button browseBtn = new Button(FontAwesome.ELLIPSIS_H);
    browseBtn.addStyleName(UIConstants.BUTTON_OPTION);
    browseBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
    browseBtn.addClickListener(new Button.ClickListener() {
        @Override//from   w w w .j  a v  a  2 s .c o  m
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent().addWindow(new BugSelectionWindow(BugSelectionField.this));
        }
    });
    layout.with(suggestField, new Label("or browse"), browseBtn);
    return layout;
}

From source file:com.esofthead.mycollab.module.project.view.bug.components.ToggleBugSummaryField.java

License:Open Source License

public ToggleBugSummaryField(final BugWithBLOBs bug, int trimCharacters) {
    this.bug = bug;
    this.maxLength = trimCharacters;
    titleLinkLbl = new Label(buildBugLink(), ContentMode.HTML);
    titleLinkLbl.addStyleName(UIConstants.LABEL_WORD_WRAP);
    titleLinkLbl.setWidthUndefined();/*  ww w .j ava  2  s .  c  om*/
    this.addComponent(titleLinkLbl);
    buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false);
    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)) {
        this.addStyleName("editable-field");
        Button instantEditBtn = new Button(null, new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
                if (isRead) {
                    ToggleBugSummaryField.this.removeComponent(titleLinkLbl);
                    ToggleBugSummaryField.this.removeComponent(buttonControls);
                    final TextField editField = new TextField();
                    editField.setValue(bug.getSummary());
                    editField.setWidth("100%");
                    editField.focus();
                    ToggleBugSummaryField.this.addComponent(editField);
                    ToggleBugSummaryField.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.bug.components.ToggleBugSummaryWithDependentField.java

License:Open Source License

public ToggleBugSummaryWithDependentField(final BugWithBLOBs hostBug, final BugWithBLOBs relatedBug) {
    toggleBugSummaryField = new ToggleBugSummaryField(relatedBug);
    Button unlinkBtn = new Button(null, new Button.ClickListener() {
        @Override//from www  .  ja  v a2  s.  c  o m
        public void buttonClick(Button.ClickEvent clickEvent) {
            ConfirmDialogExt.show(UI.getCurrent(),
                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppContext.getSiteName()),
                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                    AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                    AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                        @Override
                        public void onClose(ConfirmDialog confirmDialog) {
                            RelatedBugExample ex = new RelatedBugExample();
                            ex.createCriteria().andBugidEqualTo(hostBug.getId())
                                    .andRelatedidEqualTo(relatedBug.getId());
                            RelatedBugMapper bugMapper = AppContextUtil.getSpringBean(RelatedBugMapper.class);
                            bugMapper.deleteByExample(ex);
                            UIUtils.removeChildAssociate(toggleBugSummaryField,
                                    RemoveInlineComponentMarker.class);
                        }
                    });
        }
    });
    unlinkBtn.setIcon(FontAwesome.UNLINK);
    unlinkBtn.setDescription("Remove relationship");
    unlinkBtn.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
    unlinkBtn.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    toggleBugSummaryField.addControl(unlinkBtn);
}

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

License:Open Source License

public FollowingTicketViewImpl() {
    this.setWidth("100%");

    final MVerticalLayout headerWrapper = new MVerticalLayout().withSpacing(false).withMargin(false)
            .withWidth("100%").withStyleName("projectfeed-hdr-wrapper");

    final MHorizontalLayout header = new MHorizontalLayout().withMargin(false).withWidth("100%");

    final Label layoutHeader = new Label(FontAwesome.EYE.getHtml() + " My Following Tickets", ContentMode.HTML);
    layoutHeader.addStyleName("h2");
    header.with(layoutHeader).withAlign(layoutHeader, Alignment.MIDDLE_LEFT).expand(layoutHeader);

    headerWrapper.addComponent(header);/*  ww w  .j av  a2  s  . com*/
    this.addComponent(headerWrapper);

    MHorizontalLayout controlBtns = new MHorizontalLayout().withSpacing(false)
            .withMargin(new MarginInfo(true, false, true, false)).withWidth("100%");

    final MVerticalLayout contentWrapper = new MVerticalLayout().withSpacing(false).withMargin(false)
            .withWidth("100%");
    contentWrapper.addStyleName("content-wrapper");

    contentWrapper.addComponent(controlBtns);
    this.addComponent(contentWrapper);

    final Button backBtn = new Button(AppContext.getMessage(FollowerI18nEnum.BUTTON_BACK_TO_WORKBOARD));
    backBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            EventBusFactory.getInstance()
                    .post(new ShellEvent.GotoProjectModule(FollowingTicketViewImpl.this, null));
        }
    });

    backBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    backBtn.setIcon(FontAwesome.ARROW_LEFT);

    controlBtns.addComponent(backBtn);
    controlBtns.setExpandRatio(backBtn, 1.0f);

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

        @Override
        public void buttonClick(ClickEvent event) {
            exportButtonControl.setPopupVisible(true);
        }
    });
    exportButtonControl = new SplitButton(exportBtn);
    exportButtonControl.setWidthUndefined();
    exportButtonControl.addStyleName(UIConstants.THEME_GRAY_LINK);
    exportButtonControl.setIcon(FontAwesome.EXTERNAL_LINK);

    VerticalLayout popupButtonsControl = new VerticalLayout();
    exportButtonControl.setContent(popupButtonsControl);

    Button exportPdfBtn = new Button("Pdf");
    FileDownloader pdfDownloader = new FileDownloader(constructStreamResource(ReportExportType.PDF));
    pdfDownloader.extend(exportPdfBtn);
    exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O);
    exportPdfBtn.setStyleName("link");
    popupButtonsControl.addComponent(exportPdfBtn);

    Button exportExcelBtn = new Button("Excel");
    FileDownloader excelDownloader = new FileDownloader(constructStreamResource(ReportExportType.EXCEL));
    excelDownloader.extend(exportExcelBtn);
    exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O);
    exportExcelBtn.setStyleName("link");
    popupButtonsControl.addComponent(exportExcelBtn);

    controlBtns.addComponent(exportButtonControl);

    searchPanel = new FollowingTicketSearchPanel();
    contentWrapper.addComponent(searchPanel);

    this.ticketTable = new FollowingTicketTableDisplay();
    this.ticketTable.addStyleName("full-border-table");
    this.ticketTable.setMargin(new MarginInfo(true, false, false, false));
    contentWrapper.addComponent(this.ticketTable);
}

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 {// w  w  w  . jav a 2  s .  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.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 w w w . j  av a  2s.  com*/
        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 ww w . j  a  va 2  s.  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);
    }
}