Example usage for com.vaadin.ui VerticalLayout addComponent

List of usage examples for com.vaadin.ui VerticalLayout addComponent

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:com.esofthead.mycollab.mobile.module.project.ui.form.field.ProjectFormAttachmentDisplayField.java

License:Open Source License

@Override
protected Component initContent() {
    ResourceService resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);
    List<Content> attachments = resourceService.getContents(
            AttachmentUtils.getProjectEntityAttachmentPath(AppContext.getAccountId(), projectid, type, typeid));
    if (CollectionUtils.isNotEmpty(attachments)) {
        VerticalLayout comp = new VerticalLayout();
        comp.setStyleName("attachment-view-panel");

        for (final Content attachment : attachments) {
            String docName = attachment.getPath();
            int lastIndex = docName.lastIndexOf("/");
            if (lastIndex != -1) {
                docName = docName.substring(lastIndex + 1, docName.length());
            }/*from   w  w w  . jav  a2s  . co  m*/

            if (MimeTypesUtil.isImageType(docName)) {
                Button b = new Button(attachment.getTitle(), new Button.ClickListener() {

                    private static final long serialVersionUID = 293396615972447886L;

                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        AttachmentPreviewView previewView = new AttachmentPreviewView(
                                VaadinResourceManager.getResourceManager()
                                        .getImagePreviewResource(attachment.getPath(), DEFAULT_SOURCE));
                        EventBusFactory.getInstance().post(new ShellEvent.PushView(this, previewView));
                    }
                });
                b.setWidth("100%");
                comp.addComponent(b);
            } else {
                Label l = new Label(attachment.getTitle());
                l.setWidth("100%");
                comp.addComponent(l);
            }
        }

        return comp;
    }
    return new Label("&nbsp;", ContentMode.HTML);
}

From source file:com.esofthead.mycollab.mobile.module.project.ui.ProjectAttachmentDisplayComp.java

License:Open Source License

private void constructUI() {
    this.setStyleName("attachment-display-comp");
    Label compHeader = new Label(AppContext.getMessage(GenericI18Enum.M_FORM_ATTACHMENT));
    compHeader.setStyleName("h2");
    this.addComponent(compHeader);
    VerticalLayout comp = new VerticalLayout();
    comp.setStyleName("attachment-view-panel");
    comp.setWidth("100%");

    for (final Content attachment : attachments) {
        Component attachmentRow = MobileAttachmentUtils.renderAttachmentRow(attachment);
        comp.addComponent(attachmentRow);
    }//from w ww . j  av a 2s.c o  m
    this.addComponent(comp);
}

From source file:com.esofthead.mycollab.mobile.module.project.ui.TimeLogEditView.java

License:Open Source License

private void initUI() {
    headerPanel = new HorizontalLayout();
    headerPanel.setWidth("100%");
    headerPanel.setStyleName("summary-info-panel");
    headerPanel.setMargin(new MarginInfo(true, false, true, false));
    headerPanel.setHeightUndefined();//  ww w  .j ava 2 s .co  m
    content.addComponent(headerPanel);
    constructSpentTimeEntryPanel();
    constructRemainTimeEntryPanel();

    this.tableItem = new DefaultPagedBeanList<ItemTimeLoggingService, ItemTimeLoggingSearchCriteria, SimpleItemTimeLogging>(
            ApplicationContextUtil.getSpringBean(ItemTimeLoggingService.class), new TimeLogRowHandler()) {

        private static final long serialVersionUID = -4549910960891655297L;

        @Override
        protected void renderRows() {
            int i = 0;
            Date currentDate = new GregorianCalendar(2100, 1, 1).getTime();
            for (final SimpleItemTimeLogging item : currentListData) {
                if (!DateUtils.isSameDay(item.getLogforday(), currentDate)) {
                    Label dateLbl = new Label(AppContext.formatDate(item.getLogforday()));
                    dateLbl.setStyleName("log-day");
                    listContainer.addComponent(dateLbl);
                    currentDate = item.getLogforday();
                }
                final Component row = getRowDisplayHandler().generateRow(item, i);
                listContainer.addComponent(row);
                i++;
            }
        }

    };

    this.tableItem.setWidth("100%");
    content.addComponent(tableItem);
    content.setExpandRatio(tableItem, 1.0f);

    VerticalLayout controlBtns = new VerticalLayout();
    controlBtns.setSpacing(true);
    controlBtns.setWidth("100%");
    controlBtns.setMargin(true);
    controlBtns.addStyleName("edit-btn-layout");
    controlBtns.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    Button addNewEntryBtn = new Button(AppContext.getMessage(TimeTrackingI18nEnum.M_DIALOG_ADD_TIME_LOG_ENTRY),
            new Button.ClickListener() {

                private static final long serialVersionUID = -2540265040691537699L;

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    UI.getCurrent().addWindow(new NewTimeLogEntryWindow());
                }
            });
    addNewEntryBtn.setWidth("100%");
    controlBtns.addComponent(addNewEntryBtn);

    Button updateRemainTimeBtn = new Button(
            AppContext.getMessage(TimeTrackingI18nEnum.M_DIALOG_UPDATE_REMAIN_HOURS),
            new Button.ClickListener() {

                private static final long serialVersionUID = 9215577509351959739L;

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    UI.getCurrent().addWindow(new UpdateRemainTimeWindow());
                }
            });
    updateRemainTimeBtn.setWidth("100%");
    controlBtns.addComponent(updateRemainTimeBtn);

    NavigationBarQuickMenu editBtn = new NavigationBarQuickMenu();
    editBtn.setButtonCaption(null);
    editBtn.setStyleName("edit-btn");
    editBtn.setContent(controlBtns);
    this.setRightComponent(editBtn);
}

From source file:com.esofthead.mycollab.mobile.module.project.ui.TimeLogEditView.java

License:Open Source License

private void constructSpentTimeEntryPanel() {
    final VerticalLayout totalLayout = new VerticalLayout();
    totalLayout.setMargin(new MarginInfo(false, true, false, true));
    totalLayout.setStyleName("summary-block");
    totalLayout.addStyleName("total-time");
    totalLayout.setWidth("100%");
    final Label lbTimeInstructTotal = new Label(
            AppContext.getMessage(TimeTrackingI18nEnum.OPT_TOTAL_SPENT_HOURS));
    lbTimeInstructTotal.setStyleName("block-label");
    totalLayout.addComponent(lbTimeInstructTotal);
    this.totalSpentTimeLbl = new Label("_");
    this.totalSpentTimeLbl.setStyleName("block-value");
    this.totalSpentTimeLbl.addStyleName("numberTotal");
    totalLayout.addComponent(this.totalSpentTimeLbl);

    headerPanel.addComponent(totalLayout);
}

From source file:com.esofthead.mycollab.mobile.module.project.ui.TimeLogEditView.java

License:Open Source License

private void constructRemainTimeEntryPanel() {
    final VerticalLayout updateLayout = new VerticalLayout();
    updateLayout.setMargin(new MarginInfo(false, true, false, true));
    updateLayout.setStyleName("summary-block");
    updateLayout.addStyleName("remain-time");
    updateLayout.setWidth("100%");

    final Label lbTimeInstructTotal = new Label(
            AppContext.getMessage(TimeTrackingI18nEnum.OPT_REMAINING_WORK_HOURS));
    lbTimeInstructTotal.setStyleName("block-label");
    updateLayout.addComponent(lbTimeInstructTotal);
    this.remainTimeLbl = new Label("_");
    this.remainTimeLbl.setStyleName("block-value");
    this.remainTimeLbl.addStyleName("numberTotal");
    updateLayout.addComponent(this.remainTimeLbl);

    this.headerPanel.addComponent(updateLayout);
}

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

License:Open Source License

@Override
public ComponentContainer getLayout() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(false);//from  ww w.ja v  a2s.  com
    Label header = new Label(AppContext.getMessage(BugI18nEnum.M_FORM_READ_TITLE));
    header.setStyleName("h2");
    layout.addComponent(header);

    this.informationLayout = new GridFormLayoutHelper(1, 12, "100%", "150px", Alignment.TOP_LEFT);
    this.informationLayout.getLayout().addStyleName("colored-gridlayout");
    this.informationLayout.getLayout().setMargin(false);
    this.informationLayout.getLayout().setWidth("100%");
    layout.addComponent(this.informationLayout.getLayout());
    layout.setComponentAlignment(this.informationLayout.getLayout(), Alignment.BOTTOM_CENTER);
    return layout;
}

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

License:Open Source License

private void constructUI() {
    VerticalLayout contentLayout = new VerticalLayout();
    contentLayout.setWidth("100%");
    contentLayout.addComponent(this.editForm);

    final Button reOpenBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_REOPEN),
            new Button.ClickListener() {
                @Override//from   w  w  w. ja  va  2 s .c o  m
                public void buttonClick(final Button.ClickEvent event) {

                    if (editForm.validateForm()) {
                        ReOpenView.this.bug.setStatus(BugStatus.ReOpened.name());

                        // Save bug status and assignee
                        final BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class);
                        bugService.updateSelectiveWithSession(ReOpenView.this.bug, AppContext.getUsername());

                        // Save comment
                        final String commentValue = editForm.commentArea.getValue();
                        if (commentValue != null && !commentValue.trim().equals("")) {
                            final Comment comment = new Comment();
                            comment.setComment(commentValue);
                            comment.setCreatedtime(new GregorianCalendar().getTime());
                            comment.setCreateduser(AppContext.getUsername());
                            comment.setSaccountid(AppContext.getAccountId());
                            comment.setType(CommentType.PRJ_BUG.toString());
                            comment.setTypeid("" + ReOpenView.this.bug.getId());
                            comment.setExtratypeid(CurrentProjectVariables.getProjectId());

                            final CommentService commentService = ApplicationContextUtil
                                    .getSpringBean(CommentService.class);
                            commentService.saveWithSession(comment, AppContext.getUsername());
                        }
                        ReOpenView.this.callbackForm.previewItem(bug);
                        EventBusFactory.getInstance().post(new ShellEvent.NavigateBack(this, null));
                    }

                }
            });
    reOpenBtn.setStyleName("save-btn");
    this.setRightComponent(reOpenBtn);

    this.setContent(contentLayout);
}

From source file:com.esofthead.mycollab.mobile.module.project.view.message.MessageAddViewImpl.java

License:Open Source License

public MessageAddViewImpl() {
    this.addStyleName("message-add-view");
    this.setCaption(AppContext.getMessage(MessageI18nEnum.M_VIEW_ADD_TITLE));

    this.content = new CssLayout();
    this.content.setStyleName("content-layout");
    this.content.setSizeFull();
    this.setContent(this.content);

    VerticalLayout addFormLayout = new VerticalLayout();
    addFormLayout.setStyleName("addform-layout");
    addFormLayout.setWidth("100%");

    subjectField = new TextField();
    subjectField.setStyleName("title-field");
    subjectField.setWidth("100%");
    subjectField.setInputPrompt(AppContext.getMessage(MessageI18nEnum.FORM_TITLE));
    addFormLayout.addComponent(subjectField);

    contentField = new TextArea();
    contentField.setStyleName("content-field");
    contentField.setWidth("100%");
    contentField.setInputPrompt(AppContext.getMessage(MessageI18nEnum.M_FORM_CONTENT_FIELD_PROMPT));
    addFormLayout.addComponent(contentField);

    VerticalComponentGroup bottomRow = new VerticalComponentGroup();
    bottomRow.setStyleName("bottom-row");
    bottomRow.setWidth("100%");
    isStickField = new Switch(AppContext.getMessage(MessageI18nEnum.FORM_IS_STICK), false);
    bottomRow.addComponent(isStickField);

    attachment = new MessageAttachmentField();

    attachment.setCaption(null);//from   w  w w  .j a  va2 s.c  om
    bottomRow.addComponent(attachment);

    this.content.addComponent(addFormLayout);

    this.content.addComponent(bottomRow);

    this.saveBtn = new Button(AppContext.getMessage(GenericI18Enum.M_BUTTON_DONE));
    this.saveBtn.addStyleName("save-btn");
    this.saveBtn.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -2038682412445718948L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            final SimpleMessage message = new SimpleMessage();
            message.setProjectid(CurrentProjectVariables.getProjectId());
            message.setPosteddate(new GregorianCalendar().getTime());
            if (!subjectField.getValue().toString().trim().equals("")) {
                message.setTitle(subjectField.getValue());
                message.setMessage(contentField.getValue());
                message.setPosteduser(AppContext.getUsername());
                message.setSaccountid(AppContext.getAccountId());
                message.setIsstick(isStickField.getValue());
                MessageAddViewImpl.this.fireSaveItem(message);

            } else {
                subjectField.addStyleName("errorField");
                NotificationUtil.showErrorNotification(
                        AppContext.getMessage(MessageI18nEnum.FORM_TITLE_REQUIRED_ERROR));
            }
        }
    });
    this.setRightComponent(saveBtn);
}

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

License:Open Source License

@Override
public ComponentContainer getLayout() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(false);/*from www.ja  va2  s.  c  o  m*/
    Label header = new Label(AppContext.getMessage(MilestoneI18nEnum.M_FORM_READ_TITLE));
    header.setStyleName("h2");
    layout.addComponent(header);

    this.informationLayout = new GridFormLayoutHelper(1, 8, "100%", "150px", Alignment.TOP_LEFT);
    this.informationLayout.getLayout().setWidth("100%");
    this.informationLayout.getLayout().addStyleName("colored-gridlayout");
    this.informationLayout.getLayout().setMargin(false);
    layout.addComponent(this.informationLayout.getLayout());
    layout.setComponentAlignment(this.informationLayout.getLayout(), Alignment.BOTTOM_CENTER);
    return layout;
}

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

License:Open Source License

@Override
public void displayDashboard() {
    mainLayout.removeAllComponents();/*from w  w  w  .ja v a 2  s .  c om*/
    SimpleProject currentProject = CurrentProjectVariables.getProject();
    VerticalLayout projectInfo = new VerticalLayout();
    projectInfo.setStyleName("project-info-layout");
    projectInfo.setWidth("100%");
    projectInfo.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    Label projectIcon = new Label("<span aria-hidden=\"true\" data-icon=\"&#xe614\"></span>");
    projectIcon.setStyleName("project-icon");
    projectIcon.setContentMode(ContentMode.HTML);
    projectIcon.setWidthUndefined();
    projectInfo.addComponent(projectIcon);

    Label projectName = new Label(StringUtils.trim(currentProject.getName(), 50, true));
    projectName.setWidth("100%");
    projectName.setStyleName("project-name");
    projectInfo.addComponent(projectName);

    GridLayout projectModulesList = new GridLayout(2, 3);
    projectModulesList.setStyleName("project-modules-layout");
    projectModulesList.setWidth("100%");
    projectModulesList.setSpacing(true);
    projectModulesList.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_MESSAGE), "&#xf04f;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_MILESTONE), "&#xf075;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_TASK), "&#xe60f;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_BUG), "&#xf188;"));

    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_FILE), "&#xf017;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_RISK), "&#xf02d;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_PROBLEM), "&#xf0d2;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_TIME), "&#xe612;"));
    //
    // projectModulesList.addComponent(new ProjectModuleButton(AppContext
    // .getMessage(ProjectCommonI18nEnum.VIEW_STANDAUP), "&#xf0c0;"));

    projectModulesList.addComponent(
            new ProjectModuleButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_USERS), "&#xe601;"), 0, 2,
            1, 2);

    mainLayout.addComponent(projectInfo);
    mainLayout.addComponent(projectModulesList);
}