Example usage for com.vaadin.ui Button setData

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

Introduction

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

Prototype

public void setData(Object data) 

Source Link

Document

Sets the data object, that can be used for any application specific data.

Usage

From source file:br.com.anteros.mobileserver.util.UserMessages.java

License:Apache License

public Window confirm(String title, String message, String okTitle, String cancelTitle,
        Button.ClickListener listener) {

    if (title == null) {
        title = CONFIRM_OK_TITLE;//  ww w .j  a v  a2  s . c  o m
    }
    if (cancelTitle == null) {
        cancelTitle = CONFIRM_CANCEL_TITLE;
    }
    if (okTitle == null) {
        okTitle = CONFIRM_OK_TITLE;
    }

    final Window confirm = new Window(title);
    this.confirm = confirm;
    win.addWindow(confirm);

    confirm.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1971800928047045825L;

        public void windowClose(CloseEvent ce) {
            Object data = ce.getWindow().getData();
            if (data != null) {
                try {
                } catch (Exception exception) {
                    error("Unhandled Exception", exception);
                }
            }
        }
    });

    int chrW = 5;
    int chrH = 15;
    int txtWidth = Math.max(250, Math.min(350, message.length() * chrW));
    int btnHeight = 25;
    int vmargin = 100;
    int hmargin = 40;

    int txtHeight = 2 * chrH * (message.length() * chrW) / txtWidth;

    confirm.setWidth((txtWidth + hmargin) + "px");
    confirm.setHeight((vmargin + txtHeight + btnHeight) + "px");
    confirm.getContent().setSizeFull();

    confirm.center();
    confirm.setModal(true);

    Label text = new Label(message);
    text.setWidth("100%");
    text.setHeight("100%");

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setHeight(btnHeight + 5 + "px");
    buttons.setWidth("100%");
    buttons.setSpacing(true);
    buttons.setMargin(false);

    Button cancel = new Button(cancelTitle, listener);
    cancel.setIcon(new ThemeResource("icons/16/no.png"));
    cancel.setData(USER_CONFIRM_CANCEL);
    cancel.setClickShortcut(KeyCode.ESCAPE);
    Button ok = new Button(okTitle, listener);
    ok.setIcon(new ThemeResource("icons/16/yes.png"));
    ok.setData(USER_CONFIRM_OK);
    ok.setClickShortcut(KeyCode.ENTER);
    buttons.addComponent(ok);
    buttons.setExpandRatio(ok, 1);
    buttons.setComponentAlignment(ok, Alignment.MIDDLE_RIGHT);

    buttons.addComponent(cancel);
    buttons.setComponentAlignment(cancel, Alignment.MIDDLE_RIGHT);

    confirm.addComponent(text);
    confirm.addComponent(buttons);
    ((VerticalLayout) confirm.getContent()).setExpandRatio(text, 1f);
    confirm.setResizable(false);
    return confirm;
}

From source file:com.esofthead.mycollab.module.file.view.components.ResourcesDisplayComponent.java

License:Open Source License

public ResourcesDisplayComponent(final String rootPath, final Folder rootFolder) {
    this.setSpacing(true);
    this.baseFolder = rootFolder;
    this.rootPath = rootPath;
    externalResourceService = ApplicationContextUtil.getSpringBean(ExternalResourceService.class);
    externalDriveService = ApplicationContextUtil.getSpringBean(ExternalDriveService.class);
    resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);

    VerticalLayout mainBodyLayout = new VerticalLayout();
    mainBodyLayout.setSpacing(true);/*w  ww  . j  a  va 2  s  .com*/
    mainBodyLayout.addStyleName("box-no-border-left");

    // file breadcrum ---------------------
    HorizontalLayout breadcrumbContainer = new HorizontalLayout();
    breadcrumbContainer.setMargin(false);
    fileBreadCrumb = new FileBreadcrumb(rootPath);
    breadcrumbContainer.addComponent(fileBreadCrumb);
    mainBodyLayout.addComponent(breadcrumbContainer);

    // Construct controllGroupBtn
    controllGroupBtn = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true));

    final Button selectAllBtn = new Button();
    selectAllBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    selectAllBtn.setIcon(FontAwesome.SQUARE_O);
    selectAllBtn.setData(false);
    selectAllBtn.setImmediate(true);
    selectAllBtn.setDescription("Select all");

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

        @Override
        public void buttonClick(ClickEvent event) {
            if (!(Boolean) selectAllBtn.getData()) {
                selectAllBtn.setIcon(FontAwesome.CHECK_SQUARE_O);
                selectAllBtn.setData(true);
                resourcesContainer.setAllValues(true);
            } else {
                selectAllBtn.setData(false);
                selectAllBtn.setIcon(FontAwesome.SQUARE_O);
                resourcesContainer.setAllValues(false);
            }
        }
    });
    controllGroupBtn.with(selectAllBtn).withAlign(selectAllBtn, Alignment.MIDDLE_LEFT);

    Button goUpBtn = new Button("Up");
    goUpBtn.setIcon(FontAwesome.ARROW_UP);

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

        @Override
        public void buttonClick(ClickEvent event) {
            Folder parentFolder;
            if (baseFolder instanceof ExternalFolder) {
                if (baseFolder.getPath().equals("/")) {
                    parentFolder = baseFolder;
                } else {
                    parentFolder = externalResourceService.getParentResourceFolder(
                            ((ExternalFolder) baseFolder).getExternalDrive(), baseFolder.getPath());
                }
            } else if (!baseFolder.getPath().equals(rootPath)) {
                parentFolder = resourceService.getParentFolder(baseFolder.getPath());
            } else {
                parentFolder = baseFolder;
            }

            resourcesContainer.constructBody(parentFolder);
            baseFolder = parentFolder;
            fileBreadCrumb.gotoFolder(baseFolder);
        }
    });
    goUpBtn.setDescription("Back to parent folder");
    goUpBtn.setStyleName(UIConstants.THEME_BROWN_LINK);
    goUpBtn.setDescription("Go up");

    controllGroupBtn.with(goUpBtn).withAlign(goUpBtn, Alignment.MIDDLE_LEFT);

    ButtonGroup navButton = new ButtonGroup();
    navButton.addStyleName(UIConstants.THEME_BROWN_LINK);
    Button createBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CREATE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    AddNewFolderWindow addnewFolderWindow = new AddNewFolderWindow();
                    UI.getCurrent().addWindow(addnewFolderWindow);
                }
            });
    createBtn.setIcon(FontAwesome.PLUS);
    createBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    createBtn.setDescription("Create new folder");
    createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(createBtn);

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

        @Override
        public void buttonClick(ClickEvent event) {
            MultiUploadContentWindow multiUploadWindow = new MultiUploadContentWindow();
            UI.getCurrent().addWindow(multiUploadWindow);
        }
    });
    uploadBtn.setIcon(FontAwesome.UPLOAD);
    uploadBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    uploadBtn.setDescription("Upload");

    uploadBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(uploadBtn);

    Button downloadBtn = new Button("Download");

    LazyStreamSource streamSource = new LazyStreamSource() {
        private static final long serialVersionUID = 1L;

        @Override
        protected StreamSource buildStreamSource() {
            Collection<Resource> selectedResources = getSelectedResources();
            return StreamDownloadResourceUtil.getStreamSourceSupportExtDrive(selectedResources);
        }

        @Override
        public String getFilename() {
            Collection<Resource> selectedResources = getSelectedResources();
            return StreamDownloadResourceUtil.getDownloadFileName(selectedResources);
        }
    };
    OnDemandFileDownloader downloaderExt = new OnDemandFileDownloader(streamSource);
    downloaderExt.extend(downloadBtn);

    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    downloadBtn.setDescription("Download");
    downloadBtn.setEnabled(AppContext.canRead(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(downloadBtn);

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

        @Override
        public void buttonClick(ClickEvent event) {
            Collection<Resource> selectedResources = getSelectedResources();
            if (CollectionUtils.isNotEmpty(selectedResources)) {
                MoveResourceWindow moveResourceWindow = new MoveResourceWindow(selectedResources);
                UI.getCurrent().addWindow(moveResourceWindow);
            } else {
                NotificationUtil.showWarningNotification("Please select at least one item to move");
            }
        }
    });
    moveToBtn.setIcon(FontAwesome.ARROWS);
    moveToBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    moveToBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    moveToBtn.setDescription("Move to");
    navButton.addButton(moveToBtn);

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

                @Override
                public void buttonClick(ClickEvent event) {
                    Collection<Resource> selectedResources = getSelectedResources();
                    if (CollectionUtils.isEmpty(selectedResources)) {
                        NotificationUtil.showWarningNotification("Please select at least one item to delete");
                    } else {
                        deleteResourceAction();
                    }
                }
            });
    deleteBtn.setIcon(FontAwesome.TRASH_O);
    deleteBtn.addStyleName(UIConstants.THEME_RED_LINK);
    deleteBtn.setDescription("Delete resource");
    deleteBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));

    navButton.addButton(deleteBtn);
    controllGroupBtn.addComponent(navButton);

    mainBodyLayout.addComponent(controllGroupBtn);

    resourcesContainer = new ResourcesContainer(baseFolder);

    mainBodyLayout.addComponent(resourcesContainer);
    this.addComponent(mainBodyLayout);
}

From source file:com.etest.view.notification.NotificationMainUI.java

Table populateNoficationTable() {
    notificationTable.removeAllItems();//from   w ww.jav  a2s  .  c  om
    int i = 0;
    for (EtestNotification en : ns.getAllNotificationByUser(
            CommonUtilities.convertStringToInt(VaadinSession.getCurrent().getAttribute("userId").toString()))) {
        VerticalLayout v = new VerticalLayout();
        v.setWidth("100%");

        Button read = new Button();
        read.setWidthUndefined();
        read.setCaption((en.getStatus() == 0) ? "unread" : "read");
        read.setData(en.getNotificationId());
        read.setIcon(FontAwesome.VIDEO_CAMERA);
        read.addStyleName(ValoTheme.BUTTON_LINK);
        read.addStyleName(ValoTheme.BUTTON_TINY);
        read.addStyleName(ValoTheme.BUTTON_QUIET);
        read.addStyleName("button-container");
        read.addClickListener(buttonClickListener);
        v.addComponent(read);
        v.setComponentAlignment(read, Alignment.MIDDLE_LEFT);

        message.setContentMode(ContentMode.HTML);

        String[] split = en.getNotice().split(" ");
        int cellCaseId;
        if (split[0].equals("CellCaseID")) {
            message.setCaption(en.getRemarks() + en.getNotice());
            cellCaseId = CommonUtilities.convertStringToInt(split[1].replace("#", ""));
        } else {
            cellCaseId = cis.getCellItemById(CommonUtilities.convertStringToInt(split[1].replace("#", "")))
                    .getCellCaseId();
            message.setCaption(en.getRemarks() + en.getNotice() + " from CellCaseID #" + cellCaseId);
        }

        Button approve = new Button("status");
        approve.setSizeFull();
        approve.addStyleName(ValoTheme.BUTTON_LINK);
        approve.addStyleName(ValoTheme.BUTTON_TINY);
        approve.addStyleName(ValoTheme.BUTTON_QUIET);
        approve.addStyleName("button-container");
        v.addComponent(approve);
        v.setComponentAlignment(approve, Alignment.MIDDLE_LEFT);

        if (ccs.getCellCaseById(cellCaseId).getApprovalStatus() == 0) {
            approve.setIcon(FontAwesome.THUMBS_DOWN);
        } else {
            approve.setIcon(FontAwesome.THUMBS_UP);
        }

        notificationTable.addItem(new Object[] { message.getCaption().toString(),
                ss.getUsernameById(en.getSenderId()), en.getNoteDate(), v }, i);
        i++;
    }
    notificationTable.setPageLength(0);
    notificationTable.setHeight("100%");

    return notificationTable;
}

From source file:com.etest.view.systemadministration.CurriculumMainUI.java

Table populateDataTable() {
    table.removeAllItems();//from   ww  w  .j  a v a 2  s  .  c  om
    int i = 0;
    for (Curriculum c : cs.getAllCurriculum()) {
        HorizontalLayout h = new HorizontalLayout();
        h.setWidth("100%");

        Button edit = new Button("edit");
        edit.setSizeFull();
        edit.setIcon(FontAwesome.PENCIL);
        edit.setData(c.getCurriculumId());
        edit.addStyleName(ValoTheme.BUTTON_LINK);
        edit.addStyleName(ValoTheme.BUTTON_TINY);
        edit.addStyleName("button-container");
        edit.addClickListener(buttonClickListener);
        h.addComponent(edit);

        Button delete = new Button("del");
        delete.setSizeFull();
        delete.setIcon(FontAwesome.TRASH_O);
        delete.setData(c.getCurriculumId());
        delete.addStyleName(ValoTheme.BUTTON_LINK);
        delete.addStyleName(ValoTheme.BUTTON_TINY);
        delete.addStyleName("button-container");
        delete.addClickListener(buttonClickListener);
        h.addComponent(delete);

        table.addItem(new Object[] {
                //                c.getCurriculumId(),
                CommonVariableMap.getYearLevel(c.getYearLevel()), c.getSubject(), c.getDescriptiveTitle(),
                CommonVariableMap.getNormCourseOffering(c.getNormCourseOffering()), h }, i);
        i++;
    }
    table.setPageLength(table.size());

    //        table.getListeners(ItemClickEvent.class).stream().forEach((listener) -> {
    //            table.removeListener(ItemClickEvent.class, listener);
    //        });
    //        
    //        table.addItemClickListener((ItemClickEvent event) -> {
    //            Property itemProperty = event.getItem().getItemProperty("id");
    //            
    //            Window sub = new CurriculumFormWindow(CommonUtilities.convertStringToInt(itemProperty.getValue().toString()));
    //            if(sub.getParent() == null){
    //                UI.getCurrent().addWindow(sub);
    //            }
    //            sub.addCloseListener((Window.CloseEvent e) -> {
    //                populateDataTable();
    //            });
    //        });

    return table;
}

From source file:com.etest.view.systemadministration.FacultyMainUI.java

Table populateDataTable() {
    table.removeAllItems();//from   w w w. j a v  a 2 s.c  o  m
    int i = 0;
    for (Users u : fs.getAllFaculty()) {
        HorizontalLayout hlayout = new HorizontalLayout();
        hlayout.setWidth("100%");

        Button edit = new Button("edit");
        edit.setWidth("100%");
        edit.setData(u.getFacultyId());
        edit.setIcon(FontAwesome.PENCIL);
        edit.addStyleName(ValoTheme.BUTTON_LINK);
        edit.addStyleName(ValoTheme.BUTTON_TINY);
        edit.addStyleName("button-container");
        edit.addClickListener(modifyBtnClickListener);
        hlayout.addComponent(edit);

        Button delete = new Button("del");
        delete.setWidth("100%");
        delete.setData(u.getFacultyId());
        delete.setIcon(FontAwesome.TRASH_O);
        delete.addStyleName(ValoTheme.BUTTON_LINK);
        delete.addStyleName(ValoTheme.BUTTON_TINY);
        delete.addStyleName("button-container");
        delete.addClickListener(modifyBtnClickListener);
        hlayout.addComponent(delete);

        table.addItem(new Object[] { u.getName().toUpperCase(), u.getUsername_(), u.getUserType(), hlayout },
                new Integer(i));
        i++;
    }
    table.setPageLength(table.size());

    //        table.getListeners(ItemClickEvent.class).stream().forEach((listener) -> {
    //            table.removeListener(ItemClickEvent.class, listener);
    //        });

    //        table.addItemClickListener((ItemClickEvent event) -> {
    //            Property itemProperty = event.getItem().getItemProperty("name");
    //            facultyId = fs.getFacultyIdByName(itemProperty.getValue().toString());
    //            
    //            Window sub = new FacultyFormWindow(facultyId);
    //            if(sub.getParent() == null){
    //                UI.getCurrent().addWindow(sub);
    //            }
    //        });

    return table;
}

From source file:com.etest.view.systemadministration.HousekeepingMainUI.java

Table populateDataTable() {
    table.removeAllItems();//from w ww  .jav  a 2 s  . c om
    int i = 0;
    for (CellItem ci : hs.getAllItemsFromArchive()) {
        VerticalLayout v = new VerticalLayout();
        v.setWidth("100%");

        Button recycle = new Button("recycle");
        recycle.setWidthUndefined();
        recycle.setData(ci.getCellItemId());
        recycle.setIcon(FontAwesome.RECYCLE);
        recycle.addStyleName(ValoTheme.BUTTON_LINK);
        recycle.addStyleName(ValoTheme.BUTTON_TINY);
        recycle.addStyleName(ValoTheme.BUTTON_QUIET);
        recycle.addStyleName("button-container");
        v.addComponent(recycle);
        v.setComponentAlignment(recycle, Alignment.MIDDLE_LEFT);

        Button view = new Button("view");
        view.setWidthUndefined();
        view.setData(ci.getCellItemId());
        view.setIcon(FontAwesome.COFFEE);
        view.addStyleName(ValoTheme.BUTTON_LINK);
        view.addStyleName(ValoTheme.BUTTON_TINY);
        view.addStyleName(ValoTheme.BUTTON_QUIET);
        view.addStyleName("button-container");
        view.addClickListener(buttonClickListener);
        v.addComponent(view);
        v.setComponentAlignment(view, Alignment.MIDDLE_LEFT);

        table.addItem(new Object[] { ci.getCellItemId(), ci.getItem(), v }, i);
        i++;
    }
    table.setPageLength(table.size());

    return table;
}

From source file:com.etest.view.systemadministration.SemestralTeam.AddSemestralTeamMembersWindow.java

Table populateDataTable() {
    table.removeAllItems();//from   w  w  w .  jav a2 s  .  c o m
    int i = 0;
    for (TeamTeach tt : tts.getAllMembersFromTeam(getTeamTeachId())) {
        String position;
        boolean isFacultyTeamLeader = tts.isFacultyTeamLeader(getTeamTeachId(), tt.getFacultyId());
        if (isFacultyTeamLeader) {
            position = "Team Leader";
        } else {
            position = "Member";
        }

        HorizontalLayout hlayout = new HorizontalLayout();
        hlayout.setWidth("100%");

        Button editPositionBtn = new Button("edit");
        editPositionBtn.setWidthUndefined();
        editPositionBtn.setData(tt.getFacultyId());
        editPositionBtn.setIcon(FontAwesome.EDIT);
        editPositionBtn.addStyleName(ValoTheme.BUTTON_LINK);
        editPositionBtn.addStyleName(ValoTheme.BUTTON_TINY);
        editPositionBtn.addClickListener(modifyBtnClickListener);
        hlayout.addComponent(editPositionBtn);

        Button removeMemberBtn = new Button("del");
        removeMemberBtn.setWidthUndefined();
        removeMemberBtn.setData(tt.getFacultyId());
        removeMemberBtn.setIcon(FontAwesome.TRASH_O);
        removeMemberBtn.addStyleName(ValoTheme.BUTTON_LINK);
        removeMemberBtn.addStyleName(ValoTheme.BUTTON_TINY);
        removeMemberBtn.addClickListener(modifyBtnClickListener);
        hlayout.addComponent(removeMemberBtn);

        if (!position.equals("Member")) {
            editPositionBtn.setEnabled(false);
            removeMemberBtn.setEnabled(false);
        }

        table.addItem(new Object[] { tt.getFacultyId(), tt.getName(), position, hlayout }, i);
        i++;
    }
    table.setPageLength(table.size());

    return table;
}

From source file:com.etest.view.systemadministration.SemestralTeamUI.java

void populateDataTable() {
    table.removeAllItems();/*from w ww . jav a 2 s  .  c  om*/
    int i = 0;
    for (TeamTeach tt : tts.getAllSemestralTeamTeach()) {
        HorizontalLayout hlayout = new HorizontalLayout();
        hlayout.setWidth("100%");

        Button membersBtn = new Button();
        membersBtn.setWidth("100%");
        membersBtn.setData(tt.getTeamTeachId());
        if (tts.countTeamMembers(tt.getTeamTeachId()) < 2) {
            membersBtn.setCaption("add");
            membersBtn.setIcon(FontAwesome.USER);
        } else {
            membersBtn.setCaption("view");
            membersBtn.setIcon(FontAwesome.USERS);
        }

        Button removeTLBtn = new Button("del");
        removeTLBtn.setWidth("100%");
        removeTLBtn.setIcon(FontAwesome.TRASH_O);
        removeTLBtn.setData(tt.getTeamTeachId());

        hlayout.addComponent(membersBtn);
        hlayout.addComponent(removeTLBtn);

        table.addItem(new Object[] { tt.getSchoolYear(),
                CommonVariableMap.getNormCourseOffering(tt.getNormCourseOffering()),
                CommonVariableMap.getYearLevel(tt.getYearLevel()), tt.getSubject(), tt.getTeamLeader(),
                hlayout }, i);
        i++;

        membersBtn.addStyleName(ValoTheme.BUTTON_LINK);
        membersBtn.addStyleName(ValoTheme.BUTTON_TINY);
        membersBtn.addClickListener(modifyBtnListener);

        removeTLBtn.addStyleName(ValoTheme.BUTTON_LINK);
        removeTLBtn.addStyleName(ValoTheme.BUTTON_TINY);
        removeTLBtn.addClickListener(modifyBtnListener);
    }
    table.setPageLength(table.size());
}

From source file:com.etest.view.systemadministration.syllabus.SyllabusMainUI.java

Table populateDataTable() {
    table.removeAllItems();// w  ww . j  a v  a 2s  .  c o m
    int i = 0;
    for (Syllabus s : ss.getAllSyllabus()) {
        VerticalLayout v = new VerticalLayout();
        v.setWidth("100%");

        Button edit = new Button("edit");
        edit.setWidthUndefined();
        edit.setData(s.getSyllabusId());
        edit.setIcon(FontAwesome.PENCIL);
        edit.addStyleName(ValoTheme.BUTTON_LINK);
        edit.addStyleName(ValoTheme.BUTTON_TINY);
        edit.addStyleName("button-container");
        edit.addClickListener(buttonClickListener);
        v.addComponent(edit);

        Button delete = new Button("del");
        delete.setWidthUndefined();
        delete.setData(s.getSyllabusId());
        delete.setIcon(FontAwesome.TRASH_O);
        delete.addStyleName(ValoTheme.BUTTON_LINK);
        delete.addStyleName(ValoTheme.BUTTON_TINY);
        delete.addStyleName("button-container");
        delete.addClickListener(buttonClickListener);
        v.addComponent(delete);

        Label descriptiveTitle = new Label(s.getTopic(), ContentMode.HTML);
        descriptiveTitle.setStyleName("label-padding");

        Label topic = new Label(s.getTopic(), ContentMode.HTML);
        topic.setStyleName("label-padding");

        table.addItem(new Object[] {
                //                s.getSyllabusId(), 
                s.getSubject(), descriptiveTitle, s.getTopicNo(), topic, s.getEstimatedTime(), v }, i);
        i++;
    }
    table.setPageLength(table.size());

    return table;
}

From source file:com.etest.view.testbank.CellCaseMainUI.java

Table populateDataTable() {
    table.removeAllItems();//w w w. j  a v a  2  s  .  co m
    int i = 0;
    for (CellCase cc : ccs.getCellCaseByTopic(getSyllabusId())) {
        VerticalLayout v = new VerticalLayout();
        v.setWidth("100%");

        Button edit = new Button("modify");
        edit.setSizeFull();
        edit.setData(cc.getCellCaseId());
        edit.setIcon(FontAwesome.PENCIL);
        edit.addStyleName(ValoTheme.BUTTON_LINK);
        edit.addStyleName(ValoTheme.BUTTON_TINY);
        edit.addStyleName(ValoTheme.BUTTON_QUIET);
        edit.addStyleName("button-container");
        edit.addClickListener(modifyBtnClickListener);
        v.addComponent(edit);
        v.setComponentAlignment(edit, Alignment.MIDDLE_LEFT);

        Button approve = new Button("status");
        approve.setSizeFull();
        approve.setData(cc.getCellCaseId());
        approve.addStyleName(ValoTheme.BUTTON_LINK);
        approve.addStyleName(ValoTheme.BUTTON_TINY);
        approve.addStyleName(ValoTheme.BUTTON_QUIET);
        approve.addStyleName("button-container");
        v.addComponent(approve);
        v.setComponentAlignment(approve, Alignment.MIDDLE_LEFT);

        if (cc.getApprovalStatus() == 0) {
            approve.setIcon(FontAwesome.THUMBS_DOWN);
        } else {
            approve.setIcon(FontAwesome.THUMBS_UP);
        }

        Button stem = new Button("stems");
        stem.setSizeFull();
        stem.setData(cc.getCellCaseId());
        stem.setIcon(FontAwesome.BRIEFCASE);
        stem.addStyleName(ValoTheme.BUTTON_LINK);
        stem.addStyleName(ValoTheme.BUTTON_TINY);
        stem.addStyleName(ValoTheme.BUTTON_QUIET);
        stem.addStyleName("button-container");
        stem.addClickListener(stemBtnClickListener);
        v.addComponent(stem);
        v.setComponentAlignment(stem, Alignment.MIDDLE_LEFT);

        Label label = new Label(cc.getCaseTopic(), ContentMode.HTML);
        label.setStyleName("label-padding");

        table.addItem(new Object[] { cc.getCellCaseId(), label, cc.getUsername_(), cc.getDateCreated(), v }, i);
        i++;
    }
    table.setPageLength(table.size());

    return table;
}