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.oodrive.nuage.webui.VvrManagerUi.java

License:Apache License

@Override
protected void init(final VaadinRequest request) {

    // Listener to disconnect JMX connection on exit.
    addDetachListener(new DetachListener() {
        @Override//  www  . j  a  va 2s.c om
        public void detach(final DetachEvent event) {
            jmxHandler.disconnect();
        }
    });
    setPollInterval(1000);

    final Label labelLeft = new Label("");
    final Label labelRight = new Label("");

    labelLeft.setHeight("100%");
    labelRight.setHeight("100%");

    final HorizontalLayout content = new HorizontalLayout();
    content.setSizeFull();

    rootLayout.setWidth(rootLayoutWidth);
    rootLayout.setImmediate(true);
    rootLayout.addComponent(vvrManagerLayout);
    vvrManagerLayout.setMargin(false);
    vvrManagerLayout.setSpacing(true);
    vvrManagerLayout.setWidth(rootLayoutWidth);

    content.addComponent(labelLeft);
    content.addComponent(rootLayout);
    content.addComponent(labelRight);

    content.setExpandRatio(labelLeft, 0.5f);
    content.setExpandRatio(labelRight, 0.5f);

    content.setComponentAlignment(rootLayout, Alignment.TOP_CENTER);
    setContent(content);

    // Init Jmx Handler
    try {
        jmxHandler.connect();
        // Init ui
        initVvrManagerUi(jmxHandler);
    } catch (final Exception e) {
        LOGGER.error("Can not connect to JMX", e);
    }
}

From source file:com.openhris.calendar.CalendarScheduleWindow.java

VerticalLayout scheduleLayout() {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*w ww.  j  a v  a 2 s  . com*/
    layout.setSpacing(true);

    eventType = createEventTypelect();
    layout.addComponent(eventType);

    startDate = createDateField("Start Date: ");
    layout.addComponent(startDate);

    endDate = createDateField("End Date: ");
    layout.addComponent(endDate);

    caption = createTextField("Caption: ");
    layout.addComponent(caption);

    location = createTextField("Where: ");
    layout.addComponent(location);

    description = new TextArea("Description: ");
    description.setWidth("100%");
    description.setRows(3);
    layout.addComponent(description);

    color = createStyleNameSelect();
    layout.addComponent(color);

    saveEventButton = new Button("SAVE", saveEventBtnListener);
    saveEventButton.setWidth("100%");

    deleteEventButton = new Button("DELETE", deleteEventBtnListener);
    deleteEventButton.setWidth("100%");

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setWidth("100%");
    buttons.addComponent(deleteEventButton);
    buttons.addComponent(saveEventButton);
    //        buttons.addComponent(editEventButton);
    layout.addComponent(buttons);
    layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT);

    return layout;
}

From source file:com.openhris.calendar.CalendarScheduleWindow.java

VerticalLayout populateSchedule(CalendarComponentEvents.EventClick event) {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*from  w w  w . jav  a  2 s . c  om*/
    layout.setSpacing(true);

    eventType = createEventTypelect();
    eventType.setValue(basicEvent.getEventType());
    layout.addComponent(eventType);

    startDate = createDateField("Start Date: ");
    startDate.setValue(event.getCalendarEvent().getStart());
    layout.addComponent(startDate);

    endDate = createDateField("End Date: ");
    endDate.setValue(event.getCalendarEvent().getEnd());
    layout.addComponent(endDate);

    caption = createTextField("Caption: ");
    caption.setValue(event.getCalendarEvent().getCaption());
    layout.addComponent(caption);

    location = createTextField("Where: ");
    location.setValue(getBasicEvent().getLocation());
    layout.addComponent(location);

    description = new TextArea("Description: ");
    description.setWidth("100%");
    description.setRows(3);
    description.setValue(event.getCalendarEvent().getDescription());
    layout.addComponent(description);

    color = createStyleNameSelect();
    color.setValue(basicEvent.getStyleName());
    layout.addComponent(color);

    eventDataId = createTextField("id: ");
    eventDataId.setValue(getBasicEvent().getEventId());
    eventDataId.setVisible(false);
    layout.addComponent(eventDataId);

    editEventButton = new Button("EDIT", editEventBtnListener);
    editEventButton.setWidth("100%");

    deleteEventButton = new Button("DELETE", deleteEventBtnListener);
    deleteEventButton.setWidth("100%");

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setWidth("100%");
    buttons.addComponent(deleteEventButton);
    buttons.addComponent(editEventButton);
    layout.addComponent(buttons);
    layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT);

    return layout;
}

From source file:com.openhris.employee.EmployeeSummaryUI.java

public EmployeeSummaryUI(int branchId) {
    this.branchId = branchId;

    setSizeFull();// w  w  w  .  j  a va  2s .c  o  m
    setSpacing(true);
    setMargin(new MarginInfo(true, true, false, false));

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

    final ComboBox employeeStatus = new ComboBox("Status: ");
    employeeStatus.setWidth("150px");
    employeeStatus.setNullSelectionAllowed(false);
    employeeStatus.addItem("employed");
    employeeStatus.addItem("resigned");
    h.addComponent(employeeStatus);

    Button generateBtn = new Button("GENERATE EMPLOYEE SUMMARY");
    generateBtn.setWidth("250px");
    generateBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (employeeStatus.getValue() == null) {
                getWindow().showNotification("Employee Status!", Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            tradeId = cs.getTradeIdByBranchId(getBranchId());
            corporateId = cs.getCorporateIdByTradeId(tradeId);

            summary.setContainerDataSource(
                    new EmployeeSummaryDataContainer(corporateId, employeeStatus.getValue().toString()));
        }
    });
    h.addComponent(generateBtn);
    h.setComponentAlignment(generateBtn, Alignment.BOTTOM_LEFT);

    Button exportTableToExcel = new Button("EXPORT TO EXCEL");
    exportTableToExcel.setWidth("250px");
    exportTableToExcel.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = -73954695086117200L;
        private ExcelExport excelExport;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            excelExport = new ExcelExport(summary, "EMPLOYEE SUMMARY");
            excelExport.excludeCollapsedColumns();
            excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " Employee Summary");
            excelExport.setExportFileName(cs.getCorporateById(corporateId).replace(",", " ").toUpperCase()
                    + "-Employee-Summary-" + ".xls");
            excelExport.export();
        }
    });
    h.addComponent(exportTableToExcel);
    h.setComponentAlignment(exportTableToExcel, Alignment.BOTTOM_LEFT);
    h.setExpandRatio(exportTableToExcel, 3);

    addComponent(h);
    addComponent(summary);
    setExpandRatio(summary, 2);
}

From source file:com.openhris.employee.PostEmploymentInfomation.java

public ComponentContainer layout2() {
    HorizontalLayout hlayout = new HorizontalLayout();
    hlayout.setSpacing(true);/* w  w w . j  ava 2  s . c om*/
    hlayout.setWidth("100%");

    GridLayout glayout2 = new GridLayout(2, 2);
    glayout2.setSpacing(true);

    final PopupDateField endDate = new HRISPopupDateField("Exit Date: ");
    endDate.setWidth("250px");
    endDate.setDateFormat("MM/dd/yyyy");
    glayout2.addComponent(endDate, 0, 0);
    glayout2.setComponentAlignment(endDate, Alignment.BOTTOM_LEFT);

    Button endDateBtn = new Button("RESIGN");
    endDateBtn.setWidth("150px");
    endDateBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (endDate.getValue() == null || endDate.getValue().toString().trim().isEmpty()) {
                getWindow().showNotification("Enter End Date.", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            Window window = new ConfirmResignWindow(getEmployeeId(),
                    utilities.convertDateFormat(endDate.getValue().toString().trim().toLowerCase()));
            if (window.getParent() == null) {
                getWindow().addWindow(window);
            }
        }
    });
    glayout2.addComponent(endDateBtn, 1, 0);
    glayout2.setComponentAlignment(endDateBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        endDateBtn.setEnabled(true);
    } else {
        endDateBtn.setEnabled(false);
    }

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

    final PopupDateField entryDateFromEmp = new HRISPopupDateField("Entry Date from Employment: ");
    entryDateFromEmp.setWidth("250px");
    entryDateFromEmp.setDateFormat("MM/dd/yyyy");
    entryDateFromEmp.setValue(utilities.parsingDate(employeeService.getEmploymentEntryDate(getEmployeeId())));
    glayout2.addComponent(entryDateFromEmp, 0, 1);
    glayout2.setComponentAlignment(entryDateFromEmp, Alignment.BOTTOM_LEFT);

    Button entryDateFromEmpBtn = new Button("EDIT");
    entryDateFromEmpBtn.setWidth("150px");
    entryDateFromEmpBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (!GlobalVariables.getUserRole().equals("administrator")) {
                getWindow().showNotification(
                        "You need to be an ADMINISTRATOR to EDIT date entry of employment.",
                        Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            Window sub = new EditEmploymentDateEntryWindow(getEmployeeId(),
                    utilities.convertDateFormat(entryDateFromEmp.getValue().toString()));
            if (sub.getParent() == null) {
                getWindow().addWindow(sub);
            }
        }
    });
    glayout2.addComponent(entryDateFromEmpBtn, 1, 1);
    glayout2.setComponentAlignment(entryDateFromEmpBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        entryDateFromEmpBtn.setEnabled(true);
    } else {
        entryDateFromEmpBtn.setEnabled(false);
    }

    return hlayout;
}

From source file:com.openhris.payroll.contributions.AFLUI.java

public AFLUI(int branchId) {
    this.branchId = branchId;

    setSizeFull();/*from w w  w .  j  av a2 s . com*/
    setSpacing(true);
    setMargin(new MarginInfo(true, true, false, false));

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

    final PopupDateField payrollDateField = new HRISPopupDateField("Payroll Month and Year");
    payrollDateField.setWidth("200px");
    h.addComponent(payrollDateField);

    Button generateBtn = new Button("GENERATE AFL");
    generateBtn.setWidth("200px");
    generateBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            tradeId = cs.getTradeIdByBranchId(getBranchId());
            corporateId = cs.getCorporateIdByTradeId(tradeId);

            afl.setContainerDataSource(new AFLContainer(corporateId,
                    util.parsingDate(util.convertDateFormat(payrollDateField.getValue().toString()))));
        }
    });
    h.addComponent(generateBtn);
    h.setComponentAlignment(generateBtn, Alignment.BOTTOM_LEFT);

    Button exportTableToExcel = new Button("EXPORT TO EXCEL");
    exportTableToExcel.setWidth("200px");
    exportTableToExcel.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = -73954695086117200L;
        private ExcelExport excelExport;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            excelExport = new ExcelExport(afl, "AFL Remitance");
            excelExport.excludeCollapsedColumns();
            excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " AFL Remitances");
            excelExport.setExportFileName(
                    cs.getCorporateById(corporateId).replace(",", " ").toUpperCase() + "-AFL-Remitance-"
                            + util.convertDateFormat(payrollDateField.getValue().toString()) + ".xls");
            excelExport.export();
        }

    });
    h.addComponent(exportTableToExcel);
    h.setComponentAlignment(exportTableToExcel, Alignment.BOTTOM_LEFT);
    h.setExpandRatio(exportTableToExcel, 2);

    addComponent(h);
    addComponent(afl);
    setExpandRatio(afl, 2);
}

From source file:com.openhris.payroll.contributions.BankDebitMemoUI.java

public BankDebitMemoUI(int branchId) {
    this.branchId = branchId;

    setSizeFull();//from   w  ww . j a  v a 2 s  . c  om
    setSpacing(true);
    setMargin(new MarginInfo(true, true, false, false));

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

    final PopupDateField payrollDateField = new HRISPopupDateField("Payroll Month and Year");
    payrollDateField.setWidth("200px");
    h.addComponent(payrollDateField);

    Button generateBtn = new Button("GENERATE BANK DEBIT MEMO");
    generateBtn.setWidth("200px");
    generateBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            tradeId = cs.getTradeIdByBranchId(getBranchId());
            corporateId = cs.getCorporateIdByTradeId(tradeId);

            Date date = util.parsingDate(util.convertDateFormat(payrollDateField.getValue().toString()));
            Calendar c = Calendar.getInstance();
            c.setTime(date);

            debitMemoTable.setContainerDataSource(
                    new BankDebitMemoContainer(corporateId, util.convertDateFormat(date.toString())));

        }
    });
    h.addComponent(generateBtn);
    h.setComponentAlignment(generateBtn, Alignment.BOTTOM_LEFT);

    Button exportTableToExcel = new Button("EXPORT TO EXCEL");
    exportTableToExcel.setWidth("200px");
    exportTableToExcel.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = -73954695086117200L;
        private ExcelExport excelExport;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            excelExport = new ExcelExport(debitMemoTable, "BANK DEBIT MEMO");
            excelExport.excludeCollapsedColumns();
            excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " Bank Debit Memo");
            excelExport.setExportFileName(
                    cs.getCorporateById(corporateId).replace(",", " ").toUpperCase() + "-Bank-Debit-Memo-"
                            + util.convertDateFormat(payrollDateField.getValue().toString()) + ".xls");
            excelExport.export();
        }
    });
    h.addComponent(exportTableToExcel);
    h.setComponentAlignment(exportTableToExcel, Alignment.BOTTOM_LEFT);
    h.setExpandRatio(exportTableToExcel, 2);

    addComponent(h);
    addComponent(debitMemoTable);
    setExpandRatio(debitMemoTable, 2);
}

From source file:com.openhris.payroll.contributions.HdmfUI.java

public HdmfUI(int branchId) {
    this.branchId = branchId;

    setSizeFull();//from  ww w.  j a  va 2s. com
    setSpacing(true);
    setMargin(new MarginInfo(true, true, false, false));

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

    final PopupDateField payrollDateField = new HRISPopupDateField("Payroll Month and Year");
    payrollDateField.setWidth("200px");
    h.addComponent(payrollDateField);

    Button generateBtn = new Button("GENERATE HDMF SHARE");
    generateBtn.setWidth("200px");
    generateBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            tradeId = cs.getTradeIdByBranchId(getBranchId());
            corporateId = cs.getCorporateIdByTradeId(tradeId);

            Date date = util.parsingDate(util.convertDateFormat(payrollDateField.getValue().toString()));
            Calendar c = Calendar.getInstance();
            c.setTime(date);

            hdmfTable.setContainerDataSource(
                    new HdmfDataContainer(corporateId, (1 + c.get(Calendar.MONTH)), c.get(Calendar.YEAR)));

        }
    });
    h.addComponent(generateBtn);
    h.setComponentAlignment(generateBtn, Alignment.BOTTOM_LEFT);

    Button exportTableToExcel = new Button("EXPORT TO EXCEL");
    exportTableToExcel.setWidth("200px");
    exportTableToExcel.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = -73954695086117200L;
        private ExcelExport excelExport;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            excelExport = new ExcelExport(hdmfTable, "HDMF Remitance");
            excelExport.excludeCollapsedColumns();
            excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " HDMF Remitances");
            excelExport.setExportFileName(
                    cs.getCorporateById(corporateId).replace(",", " ").toUpperCase() + "-HDMF-Remitance-"
                            + util.convertDateFormat(payrollDateField.getValue().toString()) + ".xls");
            excelExport.export();
        }
    });
    h.addComponent(exportTableToExcel);
    h.setComponentAlignment(exportTableToExcel, Alignment.BOTTOM_LEFT);
    h.setExpandRatio(exportTableToExcel, 2);

    addComponent(h);
    addComponent(hdmfTable);
    setExpandRatio(hdmfTable, 2);
}

From source file:com.openhris.payroll.contributions.PhicUI.java

public PhicUI(int branchId) {
    this.branchId = branchId;

    setSizeFull();/*w ww  . j  a  va2s . c  o m*/
    setSpacing(true);
    setMargin(new MarginInfo(true, true, false, false));

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

    final PopupDateField payrollDateField = new HRISPopupDateField("Payroll Month and Year");
    payrollDateField.setWidth("200px");
    h.addComponent(payrollDateField);

    Button generateBtn = new Button("GENERATE PHIC SHARE");
    generateBtn.setWidth("200px");
    generateBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            tradeId = cs.getTradeIdByBranchId(getBranchId());
            corporateId = cs.getCorporateIdByTradeId(tradeId);

            Date date = util.parsingDate(util.convertDateFormat(payrollDateField.getValue().toString()));
            Calendar c = Calendar.getInstance();
            c.setTime(date);

            phicTable.setContainerDataSource(
                    new PhicDataContainer(corporateId, (1 + c.get(Calendar.MONTH)), c.get(Calendar.YEAR)));

        }
    });
    h.addComponent(generateBtn);
    h.setComponentAlignment(generateBtn, Alignment.BOTTOM_LEFT);

    Button exportTableToExcel = new Button("EXPORT TO EXCEL");
    exportTableToExcel.setWidth("200px");
    exportTableToExcel.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = -73954695086117200L;
        private ExcelExport excelExport;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            excelExport = new ExcelExport(phicTable, "PHIC Remitance");
            excelExport.excludeCollapsedColumns();
            excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " PHIC Remitances");
            excelExport.setExportFileName(
                    cs.getCorporateById(corporateId).replace(",", " ").toUpperCase() + "-PHIC-Remitance-"
                            + util.convertDateFormat(payrollDateField.getValue().toString()) + ".xls");
            excelExport.export();
        }
    });
    h.addComponent(exportTableToExcel);
    h.setComponentAlignment(exportTableToExcel, Alignment.BOTTOM_LEFT);
    h.setExpandRatio(exportTableToExcel, 2);

    addComponent(h);
    addComponent(phicTable);
    setExpandRatio(phicTable, 2);
}

From source file:com.openhris.payroll.contributions.SssUI.java

public SssUI(int branchId) {
    this.branchId = branchId;

    setSizeFull();//  ww  w.ja va  2s.c o  m
    setSpacing(true);
    setMargin(new MarginInfo(true, true, false, false));

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

    final PopupDateField payrollDateField = new HRISPopupDateField("Payroll Month and Year");
    payrollDateField.setWidth("200px");
    h.addComponent(payrollDateField);

    Button generateBtn = new Button("GENERATE SSS SHARE");
    generateBtn.setWidth("200px");
    generateBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            tradeId = cs.getTradeIdByBranchId(getBranchId());
            corporateId = cs.getCorporateIdByTradeId(tradeId);

            Date date = util.parsingDate(util.convertDateFormat(payrollDateField.getValue().toString()));
            Calendar c = Calendar.getInstance();
            c.setTime(date);

            sssTable.setContainerDataSource(
                    new SssDataContainer(corporateId, (1 + c.get(Calendar.MONTH)), c.get(Calendar.YEAR)));

        }
    });
    h.addComponent(generateBtn);
    h.setComponentAlignment(generateBtn, Alignment.BOTTOM_LEFT);

    Button exportTableToExcel = new Button("EXPORT TO EXCEL");
    exportTableToExcel.setWidth("200px");
    exportTableToExcel.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = -73954695086117200L;
        private ExcelExport excelExport;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            excelExport = new ExcelExport(sssTable, "SSS Remitance");
            excelExport.excludeCollapsedColumns();
            excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " SSS Remitances");
            excelExport.setExportFileName(
                    cs.getCorporateById(corporateId).replace(",", " ").toUpperCase() + "-SSS-Remitance-"
                            + util.convertDateFormat(payrollDateField.getValue().toString()) + ".xls");
            excelExport.export();
        }
    });
    h.addComponent(exportTableToExcel);
    h.setComponentAlignment(exportTableToExcel, Alignment.BOTTOM_LEFT);
    h.setExpandRatio(exportTableToExcel, 2);

    addComponent(h);
    addComponent(sssTable);
    setExpandRatio(sssTable, 2);
}