Example usage for com.vaadin.ui HorizontalLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:com.etest.valo.Trees.java

License:Apache License

public Trees() {
    setMargin(true);/*from   www  .  j a v a2 s  . c o m*/

    Label h1 = new Label("Trees");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    Tree tree = new Tree();
    tree.setSelectable(true);
    tree.setMultiSelect(true);
    Container generateContainer = MainUI.generateContainer(10, true);
    tree.setContainerDataSource(generateContainer);
    tree.setDragMode(TreeDragMode.NODE);
    row.addComponent(tree);
    tree.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY);
    tree.setItemIconPropertyId(MainUI.ICON_PROPERTY);
    tree.expandItem(generateContainer.getItemIds().iterator().next());

    tree.setDropHandler(new DropHandler() {
        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        @Override
        public void drop(DragAndDropEvent event) {
            Notification.show(event.getTransferable().toString());
        }
    });

    // Add actions (context menu)
    tree.addActionHandler(MainUI.getActionHandler());
}

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

public NotificationMainUI() {
    setSizeFull();/*from   www.j av a 2s.co  m*/
    setSpacing(true);

    if (VaadinSession.getCurrent().getAttribute("userId") == null) {
        Page.getCurrent().setLocation("http://localhost:8080/");
    } else {
        addComponent(populateNoficationTable());
    }

    HorizontalLayout h = new HorizontalLayout();
    h.setWidth("950px");

    Button sendMsgBtn = new Button("Send Message");
    sendMsgBtn.setWidthUndefined();
    sendMsgBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    sendMsgBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    sendMsgBtn.addClickListener((Button.ClickEvent event) -> {
        Notification.show("Send Message!");
    });

    h.addComponent(sendMsgBtn);
    h.setComponentAlignment(sendMsgBtn, Alignment.MIDDLE_RIGHT);
    addComponent(h);
}

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

VerticalLayout buildForms() {
    VerticalLayout v = new VerticalLayout();
    v.setWidth("700px");
    v.setMargin(true);// w ww  . jav a 2  s.c om
    v.setSpacing(true);

    Label cellCase = new Label();
    cellCase.setValue("<b>Case</b>: " + ccs.getCellCaseById(getCellCaseId()).getCaseTopic());
    cellCase.setContentMode(ContentMode.HTML);
    v.addComponent(cellCase);

    Label cellItem = new Label();
    cellItem.setContentMode(ContentMode.HTML);

    Button approvalBtn = new Button();
    approvalBtn.setCaption("Approve CASE");
    approvalBtn.setWidthUndefined();
    approvalBtn.addStyleName(ValoTheme.BUTTON_TINY);
    approvalBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    approvalBtn.addClickListener(buttonClickListener);
    if (ccs.getCellCaseById(getCellCaseId()).getApprovalStatus() == 0) {
        approvalBtn.setVisible(true);
    } else {
        approvalBtn.setVisible(false);
    }
    v.addComponent(approvalBtn);

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

    approvalItemBtn.setVisible(false);
    approvalItemBtn.setWidthUndefined();
    approvalItemBtn.addStyleName(ValoTheme.BUTTON_TINY);
    approvalItemBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);

    if (getCellItemId() != 0) {
        approvalBtn.setCaption("Approve ITEM");
        CellItem ci = cis.getCellItemById(getCellItemId());
        keyList = k.getAllItemKey(getCellItemId());
        keyIndexSize = keyList.size();

        if (keyList.isEmpty()) {
            ShowErrorNotification.error("No Item Key was found for STEM: \n" + ci.getItem());
            return null;
        }

        stem = ci.getItem().replace("{key}", "<u>" + keyList.get(getKeyIndex()) + "</u>");
        cellItem.setValue("<b>STEM</b>: " + getStem());
        OptionGroup options = new OptionGroup();
        options.addItems(cis.getCellItemById(getCellItemId()).getOptionA(),
                cis.getCellItemById(getCellItemId()).getOptionB(),
                cis.getCellItemById(getCellItemId()).getOptionC(),
                cis.getCellItemById(getCellItemId()).getOptionD());
        h1.addComponent(options);
        h1.setComponentAlignment(options, Alignment.MIDDLE_CENTER);

        if (cis.getCellItemById(getCellItemId()).getCellItemStatus() == 0) {
            approvalItemBtn.setVisible(true);
        } else {
            approvalItemBtn.setVisible(false);
        }
        approvalItemBtn.addClickListener(buttonClickListener);
        approvalItemBtn.setVisible(true);
    }
    v.addComponent(approvalBtn);
    v.addComponent(cellItem);
    v.addComponent(h1);
    v.addComponent(approvalItemBtn);

    Label separator = new Label("<HR>");
    separator.setContentMode(ContentMode.HTML);
    v.addComponent(separator);

    return v;
}

From source file:com.etest.view.systemadministration.curriculum.CurriculumFormWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setMargin(true);/*from   www.  j a va  2  s.co m*/

    yearLevel.setWidth("75%");
    form.addComponent(yearLevel);

    subjectField.setWidth("75%");
    form.addComponent(subjectField);

    normCourseOffering.setWidth("75%");
    form.addComponent(normCourseOffering);

    descriptiveTitleField.setWidth("100%");
    descriptiveTitleField.setRows(3);
    descriptiveTitleField.setInputPrompt("Descriptive Title..");
    form.addComponent(descriptiveTitleField);

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

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

    Button delete = new Button("DELETE");
    delete.setWidth("100%");
    delete.setIcon(FontAwesome.ERASER);
    delete.addStyleName(ValoTheme.BUTTON_PRIMARY);
    delete.addStyleName(ValoTheme.BUTTON_SMALL);
    delete.addClickListener(buttonClickListener);

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

    if (getCurriculumId() != 0) {
        hlayout.addComponent(update);
        hlayout.addComponent(delete);
        Curriculum c = cs.getCurriculumById(getCurriculumId());
        yearLevel.setValue(c.getYearLevel());
        subjectField.setValue(c.getSubject());
        normCourseOffering.setValue(c.getNormCourseOffering());
        descriptiveTitleField.setValue(c.getDescriptiveTitle());

        if (getButtonCaption().equals("edit")) {
            delete.setVisible(false);
        } else {
            update.setVisible(false);
        }
    } else {
        hlayout.addComponent(save);
    }

    form.addComponent(hlayout);

    return form;
}

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

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

Table populateDataTable() {
    table.removeAllItems();/*from   w  w w. j  av a2 s .co 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 www . j  ava 2s  .  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.testbank.CellCaseMainUI.java

HorizontalLayout getHlayout() {
    HorizontalLayout hlayout = new HorizontalLayout();
    hlayout.setSpacing(true);//  www .j a  va  2 s  .  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.CellCaseWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);//  ww w .  j a  v  a 2 s .co  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;
}