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.etest.view.systemadministration.SemestralTeam.AddSemestralTeamMembersWindow.java

Window editTeamMemberPositionWindow(int facultyRowId) {
    Window sub = new Window();
    sub.setCaption("REMOVE TEAM MEMBER");
    sub.setWidth("250px");
    sub.setModal(true);/*from   w w  w .  j  av  a  2  s .com*/
    sub.center();

    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();
    vlayout.setSpacing(true);
    vlayout.setMargin(true);

    String name = fs.getFacultyNameById(facultyRowId);
    vlayout.addComponent(new Label("Set " + name.toUpperCase() + " as Team Leader."));

    Button updateBtn = new Button("UPDATE");
    updateBtn.setWidth("100%");
    updateBtn.setIcon(FontAwesome.USER);
    updateBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    updateBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    updateBtn.addClickListener((Button.ClickEvent event) -> {
        int userId = us.getUserIdByFacultyId(facultyRowId);
        boolean result = tts.updateTeamTeach(getTeamTeachId(), userId);
        if (result) {
            sub.close();
            populateDataTable();
            close();
        }
    });
    vlayout.addComponent(updateBtn);

    sub.setContent(vlayout);
    sub.getContent().setHeightUndefined();

    return sub;
}

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

public RemoveSemestralTeamWindow(int teamTeachId) {
    this.teamTeachId = teamTeachId;

    setCaption("DELETE WINDOW");
    setWidth("270px");
    setModal(true);//from   w  w  w  .  ja  v  a  2 s.  c o m
    center();

    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();
    vlayout.setMargin(true);

    Button removeBtn = new Button("REMOVE SEMESTRAL TEAM?");
    removeBtn.setWidth("100%");
    removeBtn.setIcon(FontAwesome.TRASH_O);
    removeBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    removeBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    removeBtn.addClickListener((Button.ClickEvent event) -> {
        boolean result = tts.removeSemestralTeam(getTeamTeachId());
        if (result) {
            close();
        }
    });
    removeBtn.setImmediate(true);
    vlayout.addComponent(removeBtn);

    setContent(vlayout);
    getContent().setHeightUndefined();
}

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

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("400px");
    form.setSpacing(true);/*from   ww w .j a v  a  2 s.co  m*/

    subjects = CommonComboBox.getSubjectFromCurriculum("Subject..");
    subjects.setCaption("Curriculum: ");
    subjects.setIcon(FontAwesome.SEARCH);
    form.addComponent(subjects);

    schoolYear = CommonComboBox.getSchoolYear("School Year..");
    schoolYear.setCaption("School Year: ");
    schoolYear.setIcon(FontAwesome.SEARCH);
    form.addComponent(schoolYear);

    semester = CommonComboBox.getNormCourseOfferingComboBox("Semester..");
    semester.setCaption("Semester: ");
    semester.setIcon(FontAwesome.SEARCH);
    form.addComponent(semester);

    faculty = CommonComboBox.getAllFaculty("Select Faculty..");
    faculty.setCaption("Team Leader: ");
    faculty.setIcon(FontAwesome.USER);
    form.addComponent(faculty);

    Button saveBtn = new Button("Enroll Semestral Team");
    saveBtn.setWidth("100%");
    saveBtn.setIcon(FontAwesome.SAVE);
    saveBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    saveBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    saveBtn.addClickListener(saveBtnClickListener);
    saveBtn.setImmediate(true);
    form.addComponent(saveBtn);

    return form;
}

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

void populateDataTable() {
    table.removeAllItems();/*from w ww.j av  a 2  s . co  m*/
    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.SyllabusFormWindow.java

Component buildSyllabusForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);/*from  w  ww  .j a va  2  s  .co  m*/

    subjects.setCaption("Subject: ");
    subjects.setWidth("50%");
    subjects.setIcon(FontAwesome.BOOK);
    subjects.addStyleName(ValoTheme.COMBOBOX_SMALL);
    form.addComponent(subjects);

    topicNo.setCaption("Topic No: ");
    topicNo.setWidth("50%");
    topicNo.setIcon(FontAwesome.TAG);
    topicNo.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    form.addComponent(topicNo);

    topic.setCaption("Topic: ");
    topic.setWidth("100%");
    topic.setIcon(FontAwesome.TAG);
    topic.setInputPrompt("Enter Topic..");
    topic.setRows(3);
    topic.addStyleName(ValoTheme.TEXTAREA_SMALL);
    form.addComponent(topic);

    estimatedTime.setCaption("Estimated Time: ");
    estimatedTime.setWidth("50%");
    estimatedTime.setIcon(FontAwesome.TAG);
    estimatedTime.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    form.addComponent(estimatedTime);

    Button save = new Button("SAVE");
    save.setWidth("50%");
    save.setIcon(FontAwesome.SAVE);
    save.addStyleName(ValoTheme.BUTTON_PRIMARY);
    save.addStyleName(ValoTheme.BUTTON_SMALL);
    save.addClickListener(buttonClickListener);

    Button update = new Button("UPDATE");
    update.setWidth("60%");
    update.setIcon(FontAwesome.PENCIL);
    update.addStyleName(ValoTheme.BUTTON_PRIMARY);
    update.addStyleName(ValoTheme.BUTTON_SMALL);
    update.addClickListener(buttonClickListener);

    Button remove = new Button("REMOVE");
    remove.setWidth("60%");
    remove.setIcon(FontAwesome.TRASH_O);
    remove.addStyleName(ValoTheme.BUTTON_PRIMARY);
    remove.addStyleName(ValoTheme.BUTTON_SMALL);
    remove.addClickListener(buttonClickListener);

    if (getSyllabusId() != 0) {
        s = ss.getSyllabusById(syllabusId);
        subjects.setValue(s.getCurriculumId());
        topicNo.setValue(String.valueOf(s.getTopicNo()));
        estimatedTime.setValue(String.valueOf(s.getEstimatedTime()));
        topic.setValue(s.getTopic());

        if (getButtonCaption().equals("edit")) {
            form.addComponent(update);
        } else {
            form.addComponent(remove);
        }
    } else {
        form.addComponent(save);
    }

    return form;
}

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

public SyllabusMainUI() {
    setSizeFull();//from   ww w .  ja v  a  2s  .c  om
    setMargin(true);
    setSpacing(true);

    Button addNew = new Button("ADD NEW SYLLABUS");
    addNew.setWidth("220px");
    addNew.setIcon(FontAwesome.OPENID);
    addNew.addStyleName(ValoTheme.BUTTON_LINK);
    addNew.addStyleName(ValoTheme.BUTTON_SMALL);
    addNew.addClickListener(buttonClickListener);

    addComponent(addNew);
    addComponent(dataGridPanel());
}

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

Table populateDataTable() {
    table.removeAllItems();//from  w w w  .  j  av a 2 s .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

HorizontalLayout getHlayout() {
    HorizontalLayout hlayout = new HorizontalLayout();
    hlayout.setSpacing(true);//ww w .j a v  a 2s.  c o m

    subject.setWidth("200px");
    subject.addValueChangeListener((new CurriculumPropertyChangeListener(topic)));
    hlayout.addComponent(subject);
    hlayout.setComponentAlignment(subject, Alignment.MIDDLE_LEFT);

    topic.setInputPrompt("Select a Topic..");
    topic.addStyleName(ValoTheme.COMBOBOX_SMALL);
    topic.setWidth("500px");
    topic.addValueChangeListener((Property.ValueChangeEvent event) -> {
        if (event.getProperty().getValue() == null) {
        } else {
            syllabusId = (int) event.getProperty().getValue();
            populateDataTable();
        }
    });
    hlayout.addComponent(topic);
    hlayout.setComponentAlignment(topic, Alignment.MIDDLE_LEFT);

    Button createCellBtn = new Button("CREATE");
    createCellBtn.setWidthUndefined();
    createCellBtn.setIcon(FontAwesome.OPENID);
    createCellBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    createCellBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    createCellBtn.addClickListener((Button.ClickEvent event) -> {
        Window sub = new CellCaseWindow(0);
        if (sub.getParent() == null) {
            UI.getCurrent().addWindow(sub);
        }
        sub.addCloseListener((Window.CloseEvent e) -> {
            populateDataTable();
        });
    });
    hlayout.addComponent(createCellBtn);
    hlayout.setComponentAlignment(createCellBtn, Alignment.MIDDLE_LEFT);

    return hlayout;
}

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

Table populateDataTable() {
    table.removeAllItems();/* ww  w .  jav a2s .  c  o 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;
}

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

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);/*from   w w  w.  jav  a2s. c o m*/

    subject.setCaption("Subject: ");
    subject.setWidth("50%");
    subject.addValueChangeListener((new CurriculumPropertyChangeListener(topic)));
    form.addComponent(subject);

    topic.setCaption("Topic: ");
    topic.setWidth("80%");
    topic.setInputPrompt("Select a Topic..");
    topic.addStyleName(ValoTheme.COMBOBOX_SMALL);
    form.addComponent(topic);

    caseTopic = new TextArea();
    caseTopic.setCaption("Case: ");
    caseTopic.setWidth("100%");
    caseTopic.setRows(5);
    form.addComponent(caseTopic);

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

    Button save = new Button("SAVE");
    save.setWidth("200px");
    save.setIcon(FontAwesome.SAVE);
    save.addStyleName(ValoTheme.BUTTON_PRIMARY);
    save.addStyleName(ValoTheme.BUTTON_SMALL);
    save.addClickListener(buttonClickListener);

    Button modify = new Button("MODIFY");
    modify.setWidth("200px");
    modify.setIcon(FontAwesome.EDIT);
    modify.addStyleName(ValoTheme.BUTTON_PRIMARY);
    modify.addStyleName(ValoTheme.BUTTON_SMALL);
    modify.addClickListener(buttonClickListener);

    Button approve = new Button("APPROVE");
    approve.setWidth("200px");
    approve.setIcon(FontAwesome.THUMBS_UP);
    approve.addStyleName(ValoTheme.BUTTON_PRIMARY);
    approve.addStyleName(ValoTheme.BUTTON_SMALL);
    approve.setEnabled(UserAccess.approve());
    approve.addClickListener(buttonClickListener);

    Button delete = new Button("DELETE");
    delete.setWidth("200px");
    delete.setIcon(FontAwesome.TRASH_O);
    delete.addStyleName(ValoTheme.BUTTON_PRIMARY);
    delete.addStyleName(ValoTheme.BUTTON_SMALL);
    delete.setEnabled(UserAccess.delete());
    delete.addClickListener(buttonClickListener);

    if (getCellCaseId() != 0) {
        CellCase cc = ccs.getCellCaseById(getCellCaseId());
        subject.setValue(cc.getCurriculumId());
        topic.setValue(cc.getSyllabusId());
        caseTopic.setValue(cc.getCaseTopic());

        approve.setVisible(cc.getApprovalStatus() == 0);
        hlayout.addComponent(approve);
        hlayout.setComponentAlignment(approve, Alignment.MIDDLE_RIGHT);

        hlayout.addComponent(modify);
        hlayout.setComponentAlignment(modify, Alignment.MIDDLE_RIGHT);

        hlayout.addComponent(delete);
        hlayout.setComponentAlignment(delete, Alignment.MIDDLE_RIGHT);
    } else {
        hlayout.addComponent(save);
        hlayout.setComponentAlignment(save, Alignment.MIDDLE_RIGHT);
    }

    form.addComponent(hlayout);
    form.setComponentAlignment(hlayout, Alignment.MIDDLE_RIGHT);

    return form;
}