Example usage for com.vaadin.ui Button setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:com.openhris.payroll.AdjustmentWindow.java

public AdjustmentWindow(int payrollId, double amountToBeReceive, double amountReceived, double adjustment) {
    this.payrollId = payrollId;
    this.amountToBeReceive = amountToBeReceive;
    this.amountReceived = amountReceived;
    this.adjustment = adjustment;

    setCaption("ADJUSTMENTS");
    setWidth("400px");

    TabSheet ts = new TabSheet();
    ts.addStyleName("bar");

    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setMargin(true);//from  w w w  .j a  v  a2  s  . co m
    vlayout.setSpacing(true);
    vlayout.setCaption("Post Adjustments");

    final TextField amount = new TextField("Amount: ");
    amount.setWidth("100%");
    vlayout.addComponent(amount);

    final TextField remarks = new TextField("Remarks");
    remarks.setWidth("100%");
    vlayout.addComponent(remarks);

    Button saveAdjustments = new Button("POST ADJUSTMENTS");
    saveAdjustments.setWidth("100%");
    saveAdjustments.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (amount.getValue() == null || amount.getValue().toString().trim().isEmpty()) {
                getWindow().showNotification("Enter Amount for adjustment.",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            } else {
                if (!utilities.checkInputIfDouble(amount.getValue().toString().trim())) {
                    getWindow().showNotification("Enter a numeric value for amount.",
                            Window.Notification.TYPE_ERROR_MESSAGE);
                    return;
                }
            }

            if (remarks.getValue() == null || remarks.getValue().toString().trim().isEmpty()) {
                getWindow().showNotification("Add remarks for adjustment.",
                        Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            double amountForAdjustment = utilities.convertStringToDouble(amount.getValue().toString().trim());
            String remarksForAdjustment = remarks.getValue().toString().trim().toLowerCase();
            boolean result = payrollService.insertAdjustmentToPayroll(getPayrollId(), getAmountToBeReceive(),
                    getAmountReceived(), amountForAdjustment, remarksForAdjustment);
            if (result) {
                adjustmentTable();
                close();
                getWindow().showNotification("Successfully added adjustment.",
                        Window.Notification.TYPE_HUMANIZED_MESSAGE);
            }
        }
    });
    vlayout.addComponent(saveAdjustments);

    ts.addComponent(vlayout);

    vlayout = new VerticalLayout();
    vlayout.setMargin(true);
    vlayout.setSpacing(true);
    vlayout.setCaption("Adjustments Table");

    Label label = new Label("Remarks: Click ID Column to delete Adjustment");
    vlayout.addComponent(label);

    vlayout.addComponent(adjustmentTable());

    Button closeBtn = new Button("CLOSE");
    closeBtn.setWidth("100%");
    closeBtn.addListener(closeBtnListener);
    vlayout.addComponent(closeBtn);

    ts.addComponent(vlayout);
    addComponent(ts);
}

From source file:com.openhris.payroll.AdjustmentWindow.java

private Window removeAdjustment(final int adjustmentId, final double amountToBeReceive,
        final double amountReceived, final double adjustment, final int payrollId) {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setMargin(true);//from  www. j a v  a  2s . c  o  m
    vlayout.setSpacing(true);

    final Window subWindow = new Window("REMOVE ADVANCES", vlayout);
    subWindow.setWidth("200px");

    Button removeAdjBtn = new Button("REMOVE ADJUSTMENT?");
    removeAdjBtn.setWidth("100%");
    removeAdjBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            boolean result = payrollService.removeAdjustmentById(adjustmentId, amountToBeReceive,
                    amountReceived, adjustment, payrollId);
            if (result) {
                (subWindow.getParent()).removeWindow(subWindow);
                adjustmentTable();
            }
        }
    });
    subWindow.addComponent(removeAdjBtn);

    return subWindow;
}

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

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

    setSizeFull();/*from  w ww .  j a v  a2 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 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  w  w.  j av  a  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 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();/* w  ww.j av a  2  s  .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 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();//from   w  w  w  .  j a  v a2 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 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();//from   w w w.j  a  va 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 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);
}

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

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

    setSizeFull();// w  ww  .  j  ava  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 WITHHOLDING TAX");
    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);

            taxTable.setContainerDataSource(new TaxDataContainer(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(taxTable, "TAX Remitance");
            excelExport.excludeCollapsedColumns();
            excelExport.setReportTitle(cs.getCorporateById(corporateId).toUpperCase() + " TAX Remitances");
            excelExport.setExportFileName(
                    cs.getCorporateById(corporateId).replace(",", " ").toUpperCase() + "-TAX-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(taxTable);
    setExpandRatio(taxTable, 2);
}

From source file:com.openhris.payroll.PayrollAdvancesLedgerUI.java

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

    setSpacing(false);/*  w  ww. jav  a  2s .  co  m*/
    setMargin(false);
    setWidth("100%");
    setHeight("100%");
    setImmediate(true);

    final VerticalSplitPanel vsplit = new VerticalSplitPanel();

    vsplit.setImmediate(true);
    vsplit.setMargin(false);
    vsplit.setSizeFull();
    vsplit.setLocked(true);

    vsplit.setSplitPosition(90, Sizeable.UNITS_PIXELS);

    GridLayout glayout = new GridLayout(2, 1);
    glayout.setWidth("60%");
    glayout.setMargin(true);
    glayout.setSpacing(true);

    employeeComboBox(getBranchId());
    glayout.addComponent(employee, 0, 0);

    Button button = new Button();
    button.setWidth("100%");
    button.setCaption("Generate Ledger");
    button.setEnabled(UserAccessControl.isPayroll());
    button.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            System.out.println("employeeId: " + employee.getValue());
        }
    });

    glayout.addComponent(button, 1, 0);
    glayout.setComponentAlignment(button, Alignment.BOTTOM_LEFT);

    vsplit.setFirstComponent(glayout);
    addComponent(vsplit);

    setExpandRatio(vsplit, 1.0f);
}

From source file:com.openhris.payroll.PayrollSubModules.java

public Window perDiemWindow(Item item) {
    this.item = item;

    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSpacing(true);/*ww w.  jav  a 2s  . c  o  m*/
    vlayout.setMargin(true);

    final Window sub = new Window("PER DIEM", vlayout);
    sub.setWidth("220px");
    sub.setModal(true);
    sub.center();

    final TextField perDiemAmount = new TextField("Amount: ");
    perDiemAmount.setWidth("100%");
    perDiemAmount
            .setValue(util.convertStringToDouble(getPayrollTableItem().getItemProperty("per diem").toString()));
    perDiemAmount.setNullSettingAllowed(false);
    sub.addComponent(perDiemAmount);

    Button save = new Button("SAVE");
    save.setWidth("100%");
    save.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            int payrollId = util
                    .convertStringToInteger(getPayrollTableItem().getItemProperty("id").getValue().toString());
            double amountToBeReceive = util.convertStringToDouble(
                    getPayrollTableItem().getItemProperty("amount to be receive").toString());
            double amountReceived = util
                    .convertStringToDouble(getPayrollTableItem().getItemProperty("amount received").toString());
            double amount = util.convertStringToDouble(perDiemAmount.getValue().toString())
                    - util.convertStringToDouble(
                            getPayrollTableItem().getItemProperty("per diem").getValue().toString());

            boolean result = ps.addPerDiem(payrollId,
                    util.convertStringToDouble(perDiemAmount.getValue().toString()),
                    util.convertStringToDouble(
                            getPayrollTableItem().getItemProperty("per diem").getValue().toString()),
                    amountToBeReceive, amountReceived);
            if (result) {
                getPayrollTableItem().getItemProperty("amount to be receive")
                        .setValue(amountToBeReceive + amount);
                getPayrollTableItem().getItemProperty("amount received").setValue(amountReceived + amount);
                getPayrollTableItem().getItemProperty("per diem").setValue(perDiemAmount.getValue());
                (sub.getParent()).removeWindow(sub);
            }
        }
    });
    sub.addComponent(save);

    return sub;
}