Example usage for com.vaadin.ui GridLayout setComponentAlignment

List of usage examples for com.vaadin.ui GridLayout setComponentAlignment

Introduction

In this page you can find the example usage for com.vaadin.ui GridLayout setComponentAlignment.

Prototype

@Override
    public void setComponentAlignment(Component childComponent, Alignment alignment) 

Source Link

Usage

From source file:com.invient.vaadin.InvientChartsDemoWin.java

License:Apache License

private void registerSVGAndPrintEvent(final InvientCharts chart) {
    GridLayout gridLayout = new GridLayout(2, 1);
    gridLayout.setWidth("100%");
    gridLayout.setSpacing(true);//from   w  ww.ja  v  a  2  s.c o  m
    Button svgBtn;
    gridLayout.addComponent(svgBtn = new Button("Get SVG"));
    gridLayout.setComponentAlignment(svgBtn, Alignment.MIDDLE_RIGHT);
    Button printBtn;
    gridLayout.addComponent(printBtn = new Button("Print"));
    gridLayout.setComponentAlignment(printBtn, Alignment.MIDDLE_LEFT);
    rightLayout.addComponent(gridLayout);
    svgBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            chart.addListener(new InvientCharts.ChartSVGAvailableListener() {

                @Override
                public void svgAvailable(ChartSVGAvailableEvent chartSVGAvailableEvent) {
                    logEventInfo("[svgAvailable]" + " svg -> " + chartSVGAvailableEvent.getSVG());
                }
            });
        }
    });
    printBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            chart.print();
        }
    });
}

From source file:com.javalego.ui.vaadin.component.util.MessageBox.java

License:Apache License

/**
 * Similar to/*from  w  w  w . ja  v a2 s  . co m*/
 * {@link #MessageBox(Window, String, Icon, String, Alignment, ButtonConfig...)}
 * , but the message component is defined explicitly. The component can be
 * even a composite of a layout manager and manager further Vaadin
 * components.
 * 
 * @param messageComponent
 *            a Vaadin component
 */
public MessageBox(String dialogCaption, Icon dialogIcon, Component messageComponent, Alignment buttonsAlignment,
        ButtonConfig... buttonConfigs) {

    super();

    setResizable(false);
    setClosable(false);

    setCaption(dialogCaption);

    GridLayout mainLayout = new GridLayout(2, 2);
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);

    mainLayout.setSizeUndefined();
    messageComponent.setSizeUndefined();

    // Add Content
    if (dialogIcon == null || Icon.NONE.equals(dialogIcon)) {

        mainLayout.addComponent(messageComponent, 0, 0, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(0, 1.0f);
    } else {
        mainLayout.addComponent(messageComponent, 1, 0);

        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(1, 1.0f);

        //         Label icon = new Label();
        //         switch (dialogIcon) {
        //         case QUESTION:
        //            icon.setIcon(FontAwesome.QUESTION);
        //            break;
        //         case INFO:
        //            icon.setIcon(FontAwesome.INFO);
        //            break;
        //         case WARN:
        //            icon.setIcon(FontAwesome.WARNING);
        //            break;
        //         case ERROR:
        //            icon.setIcon(FontAwesome.STOP);
        //            break;
        //         default:
        //            break;
        //         }
        //         mainLayout.addComponent(icon, 0, 0);
    }

    // Add Buttons
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setMargin(true);
    mainLayout.addComponent(buttonLayout, 0, 1, 1, 1);
    mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment);

    for (ButtonConfig buttonConfig : buttonConfigs) {

        ButtonExt button = new ButtonExt(buttonConfig.getCaption());

        //         if (buttonConfig.buttonType == ButtonType.YES || buttonConfig.buttonType == ButtonType.OK) {
        //            button.blue();
        //         }

        button.addClickListener(new ButtonClickListener(buttonConfig.getButtonType()));
        buttonLayout.addComponent(button);
    }

    setContent(mainLayout);
}

From source file:com.jiangyifen.ec2.ui.LoginLayout.java

/**
 * ?/* w  w w .j  a v a 2  s . c o m*/
 * 
 * @param panelContent ????
 * @param roleType      ?
 */
private void createLoginMainComponents(VerticalLayout panelContent, RoleType roleType) {
    GridLayout gridLayout = new GridLayout(2, 5);
    gridLayout.setSpacing(true);
    gridLayout.setMargin(true);
    panelContent.addComponent(gridLayout);
    panelContent.setComponentAlignment(gridLayout, Alignment.MIDDLE_CENTER);

    // ??
    Label username_lb = new Label("    ??", Label.CONTENT_XHTML);
    gridLayout.addComponent(username_lb, 0, 0);
    usernameTextField = new TextField();
    usernameTextField.setWidth("170px");
    usernameTextField.setValue(username);
    gridLayout.addComponent(usernameTextField, 1, 0);

    // ?
    Label password = new Label("       ?", Label.CONTENT_XHTML);
    gridLayout.addComponent(password, 0, 1);
    passwordTextField = new PasswordField();
    passwordTextField.setWidth("170px");
    gridLayout.addComponent(passwordTextField, 1, 1);

    //  ?Csr ?
    if (roleType.equals(RoleType.csr)) {
        Label extenNoLabel = new Label("       ",
                Label.CONTENT_XHTML);
        gridLayout.addComponent(extenNoLabel, 0, 2);
        extenNoField = new TextField();
        extenNoField.setWidth("170px");
        extenNoField.setValue(exten);
        gridLayout.addComponent(extenNoField, 1, 2);
    }

    // ?????
    String warningMsg = "<font color='red'>?????</font>";
    warningLabel = new Label(warningMsg, Label.CONTENT_XHTML);
    warningLabel.setVisible(false);

    gridLayout.addComponent(warningLabel, 1, 3);
    gridLayout.setComponentAlignment(warningLabel, Alignment.MIDDLE_CENTER);

    // ?
    login = new Button("  ", this);
    forget = new NativeButton("?", this);

    //???
    Map<String, String> licenseMap = LicenseManager.licenseValidate();
    String validateResult = licenseMap.get(LicenseManager.LICENSE_VALIDATE_RESULT);
    if (LicenseManager.LICENSE_VALID.equals(validateResult)) {
        SpringContextHolder.getHttpSession().removeAttribute("businessModels");
        String licensedDate = licenseMap.get(LicenseManager.LICENSE_DATE);
        try {
            Date stopDate = LicenseManager.simpleDateFormat.parse(licensedDate);
            Long times = stopDate.getTime() - new Date().getTime();
            int outdateWarnDay = (int) (times / (24 * 3600 * 1000));

            if (outdateWarnDay < 7) {
                isValid = true;
                warningLabel.setValue("<font color='red'>" + outdateWarnDay
                        + ",???</font>");
                if (outdateWarnDay < 0) {
                    warningLabel.setValue("<font color='red'>?,???</font>");
                    isValid = false;
                } else if (outdateWarnDay == 0) {
                    warningLabel.setValue(
                            "<font color='red'>?,???</font>");
                }
                warningLabel.setVisible(true);
            }
            //            //??
            //            if(roleType==RoleType.manager){
            //               login.setEnabled(true);
            //            }
            //            
        } catch (Exception e) {
            e.printStackTrace();
            login.setEnabled(false);
            forget.setEnabled(false);
        }

    } else {
        warningLabel.setVisible(true);
        warningLabel.setValue("<font color='red'>??,???</font>");
        login.setEnabled(false);
        forget.setEnabled(false);
        isValid = false;

        //chb ???
        if (roleType == RoleType.manager) {
            if (isValid == false) {
                login.setEnabled(true);
            } else {
                //normal login
            }
        }

    }

    HorizontalLayout operatorHLayout = new HorizontalLayout();
    operatorHLayout.setSpacing(true);
    operatorHLayout.addComponent(login);
    operatorHLayout.addComponent(forget);
    gridLayout.addComponent(operatorHLayout, 1, 4);
}

From source file:com.klwork.explorer.ui.task.TaskDetailPanel.java

License:Apache License

protected void initHeader() {
    GridLayout taskDetails = new GridLayout(2, 2);
    taskDetails.setWidth(100, Unit.PERCENTAGE);
    taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    taskDetails.setSpacing(true);//  ww w .ja  va 2 s  .com
    taskDetails.setMargin(new MarginInfo(false, false, true, false));
    taskDetails.setColumnExpandRatio(1, 1.0f);
    centralLayout.addComponent(taskDetails);

    // Add image
    Embedded image = new Embedded(null, Images.TASK_50);
    //??
    taskDetails.addComponent(image, 0, 0, 0, 1);

    // Add task name
    Label nameLabel = new Label(task.getName());
    nameLabel.addStyleName(Reindeer.LABEL_H2);
    taskDetails.addComponent(nameLabel, 1, 0);
    taskDetails.setComponentAlignment(nameLabel, Alignment.MIDDLE_LEFT);

    // Properties
    HorizontalLayout propertiesLayout = new HorizontalLayout();//
    propertiesLayout.setSpacing(true);
    taskDetails.addComponent(propertiesLayout);

    propertiesLayout.addComponent(new DueDateComponent(task, i18nManager, taskService));
    propertiesLayout.addComponent(new PriorityComponent(task, i18nManager, taskService));
    //?
    initCreateTime(propertiesLayout);
}

From source file:com.klwork.explorer.ui.user.ProfilePanel.java

License:Apache License

protected void addProfileInputField(GridLayout layout, String name, AbstractField inputField,
        String inputFieldValue) {
    Label label = new Label(name + ": ");
    label.addStyleName(ExplorerLayout.STYLE_PROFILE_FIELD);
    label.setSizeUndefined();/*from w  w  w.  j  a  v  a 2 s  . com*/
    layout.addComponent(label);
    layout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);

    if (inputFieldValue != null) {
        inputField.setValue(inputFieldValue);
    }
    layout.addComponent(inputField);
    layout.setComponentAlignment(inputField, Alignment.MIDDLE_LEFT);
}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * This method builds audio library for current filter.
 * /*  w w w. jav a 2 s.c  o m*/
 * @param grid
 *            The object to locate the audio covers.
 * @param filter
 *            The filter to extract need music files.
 */
private void buildAudioLibrary(GridLayout grid, String filter) {
    AudioCollection audio = new AudioCollection();

    for (final AudioFile audioFile : audio.getAudioCollection(filter)) {

        CssLayout select = new CssLayout();
        select.addStyleName(Runo.CSSLAYOUT_SELECTABLE);

        CssLayout musicFile = new CssLayout();
        musicFile.addStyleName(Runo.CSSLAYOUT_SHADOW);
        musicFile.addComponent(createImageCover(audioFile.getCover()));
        select.addComponent(musicFile);

        musicFile.addLayoutClickListener(new LayoutClickListener() {

            private static final long serialVersionUID = 5789650754220216969L;

            @Override
            public void layoutClick(LayoutClickEvent event) {
                buildInformationPanel(audioFile);
            }
        });

        grid.addComponent(select);
        grid.setComponentAlignment(select, Alignment.MIDDLE_CENTER);
    }

    Label text = new Label("Note: This track are on Crative Common license.");
    text.addStyleName(Runo.LABEL_SMALL);
    text.setWidth("90%");
    grid.addComponent(text);
    grid.setComponentAlignment(text, Alignment.MIDDLE_CENTER);

}

From source file:com.mycollab.vaadin.web.ui.MailFormWindow.java

License:Open Source License

private void initUI() {
    GridLayout mainLayout = new GridLayout(1, 5);
    mainLayout.setWidth("100%");
    mainLayout.setMargin(true);/*from  w  w  w .  j  av a  2s .  c o  m*/
    mainLayout.setSpacing(true);

    CssLayout inputPanel = new CssLayout();
    inputPanel.setWidth("100%");
    inputPanel.setStyleName("mail-panel");

    inputLayout = new GridLayout(3, 4);
    inputLayout.setSpacing(true);
    inputLayout.setWidth("100%");
    inputLayout.setColumnExpandRatio(0, 1.0f);

    inputPanel.addComponent(inputLayout);

    mainLayout.addComponent(inputPanel);

    tokenFieldMailTo = new EmailTokenField();

    inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0);

    if (lstMail != null) {
        for (String mail : lstMail) {
            if (StringUtils.isNotBlank(mail)) {
                if (mail.indexOf("<") > -1) {
                    String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">"));
                    if (strMail != null && !strMail.equalsIgnoreCase("null")) {

                    }
                } else {

                }
            }
        }
    }

    final TextField subject = new TextField();
    subject.setRequired(true);
    subject.setWidth("100%");
    subjectField = createTextFieldMail("Subject:", subject);
    inputLayout.addComponent(subjectField, 0, 1);

    initButtonLinkCcBcc();

    ccField = createTextFieldMail("Cc:", tokenFieldMailCc);
    bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc);

    final RichTextArea noteArea = new RichTextArea();
    noteArea.setWidth("100%");
    noteArea.setHeight("200px");
    mainLayout.addComponent(noteArea, 0, 1);
    mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER);

    final AttachmentPanel attachments = new AttachmentPanel();
    attachments.setWidth("500px");

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);

    MButton sendBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_SEND_EMAIL), clickEvent -> {
        if (tokenFieldMailTo.getListRecipient().size() <= 0 || subject.getValue().equals("")) {
            NotificationUtil.showErrorNotification(
                    "To Email field and Subject field must be not empty! Please fulfil them before sending email.");
            return;
        }
        if (UserUIContext.getUser().getEmail() != null && UserUIContext.getUser().getEmail().length() > 0) {
            ExtMailService systemMailService = AppContextUtil.getSpringBean(ExtMailService.class);

            List<File> listFile = attachments.files();
            List<AttachmentSource> attachmentSource = null;
            if (listFile != null && listFile.size() > 0) {
                attachmentSource = new ArrayList<>();
                for (File file : listFile) {
                    attachmentSource.add(new FileAttachmentSource(file));
                }
            }

            systemMailService.sendHTMLMail(UserUIContext.getUser().getEmail(),
                    UserUIContext.getUser().getDisplayName(), tokenFieldMailTo.getListRecipient(),
                    tokenFieldMailCc.getListRecipient(), tokenFieldMailBcc.getListRecipient(),
                    subject.getValue(), noteArea.getValue(), attachmentSource, true);
            close();
        } else {
            NotificationUtil
                    .showErrorNotification("Your email is empty value, please fulfil it before sending email!");
        }
    }).withIcon(FontAwesome.SEND).withStyleName(WebThemes.BUTTON_ACTION);

    MHorizontalLayout controlsLayout = new MHorizontalLayout(attachments, cancelBtn, sendBtn)
            .expand(attachments).withFullWidth();
    mainLayout.addComponent(controlsLayout, 0, 2);
    this.setContent(mainLayout);
}

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

public SchedulerMainUI() {

    setMargin(true);/*from  w  ww.jav  a2s. c o  m*/
    cal = new Calendar();

    calendarEvents();
    cal.setWidth("100%");
    cal.setHeight("100%");
    cal.setImmediate(true);

    Date today = new Date();
    calendar = new GregorianCalendar();
    calendar.setTime(today);

    updateCaptionLabel();
    initNavigationButtons();

    if (!showWeeklyView) {
        int rollAmount = calendar.get(GregorianCalendar.DAY_OF_MONTH) - 1;
        calendar.add(GregorianCalendar.DAY_OF_MONTH, -rollAmount);
        currentMonthsFirstDate = calendar.getTime();
        cal.setStartDate(currentMonthsFirstDate);
        calendar.add(GregorianCalendar.MONTH, 1);
        calendar.add(GregorianCalendar.DATE, -1);
        cal.setEndDate(calendar.getTime());
    }

    cal.setHandler(new BasicDateClickHandler() {
        @Override
        public void dateClick(CalendarComponentEvents.DateClickEvent event) {
            Calendar cal = event.getComponent();
            long currentCalDateRange = cal.getEndDate().getTime() - cal.getStartDate().getTime();

            if (currentCalDateRange < VCalendar.DAYINMILLIS) {
                // Change the date range to the current week
                cal.setStartDate(cal.getFirstDateForWeek(event.getDate()));
                cal.setEndDate(cal.getLastDateForWeek(event.getDate()));

            } else {
                // Default behaviour, change date range to one day
                super.dateClick(event);
            }
        }
    });

    addCalendarEventListeners();

    GridLayout grid = new GridLayout(5, 1);
    grid.setSizeFull();

    monthButton.setVisible(false);
    weekButton.setVisible(false);

    grid.addComponent(monthButton, 1, 0);
    grid.setComponentAlignment(monthButton, Alignment.MIDDLE_CENTER);

    monthLabel = new Label();
    monthLabel.setValue(OpenHrisUtilities.convertDateFormatForCalendar(currentMonthsFirstDate.toString()));
    monthLabel.setContentMode(Label.CONTENT_XHTML);
    monthLabel.addStyleName("month");
    grid.addComponent(monthLabel, 2, 0);
    grid.setComponentAlignment(monthLabel, Alignment.MIDDLE_CENTER);

    grid.addComponent(weekButton, 3, 0);
    grid.setComponentAlignment(weekButton, Alignment.MIDDLE_CENTER);

    grid.addComponent(nextButton, 4, 0);
    grid.setComponentAlignment(nextButton, Alignment.MIDDLE_RIGHT);

    grid.addComponent(prevButton, 0, 0);
    grid.setComponentAlignment(prevButton, Alignment.MIDDLE_LEFT);

    addComponent(grid);
    addComponent(cal);
    setExpandRatio(cal, 1);
}

From source file:com.openhris.employee.allowance.EmployeeAllowanceInformation.java

ComponentContainer component() {
    GridLayout glayout = new GridLayout(3, 14);
    glayout.setSpacing(true);// ww w.j  av  a 2s  .  com
    glayout.setWidth("600px");
    glayout.setHeight("100%");

    communication = new TextField("Communication Allowance: ");
    communication.setWidth("170px");
    communication.addStyleName("numerical");
    glayout.addComponent(communication, 0, 0);

    communicationEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    communicationEntry.setWidth("150px");
    glayout.addComponent(communicationEntry, 1, 0);

    Button communicationBtn = new Button("UPDATE COMMUNICATION ALLOWANCE");
    communicationBtn.setWidth("250px");
    communicationBtn.addListener(buttonClickListener);
    glayout.addComponent(communicationBtn, 2, 0);
    glayout.setComponentAlignment(communicationBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        communicationBtn.setEnabled(true);
    } else {
        communicationBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 1, 2, 1);

    perDiem = new TextField("Per Diem: ");
    perDiem.setWidth("170px");
    perDiem.addStyleName("numerical");
    glayout.addComponent(perDiem, 0, 2);

    perDiemEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    perDiemEntry.setWidth("150px");
    glayout.addComponent(perDiemEntry, 1, 2);

    Button perDiemBtn = new Button("UPDATE PER DIEM");
    perDiemBtn.setWidth("250px");
    perDiemBtn.addListener(buttonClickListener);
    glayout.addComponent(perDiemBtn, 2, 2);
    glayout.setComponentAlignment(perDiemBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        perDiemBtn.setEnabled(true);
    } else {
        perDiemBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 3, 2, 3);

    cola = new TextField("Cola: ");
    cola.setWidth("170px");
    cola.addStyleName("numerical");
    glayout.addComponent(cola, 0, 4);

    colaEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    colaEntry.setWidth("150px");
    glayout.addComponent(colaEntry, 1, 4);

    Button colaBtn = new Button("UPDATE COLA");
    colaBtn.setWidth("250px");
    colaBtn.addListener(buttonClickListener);
    glayout.addComponent(colaBtn, 2, 4);
    glayout.setComponentAlignment(colaBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        colaBtn.setEnabled(true);
    } else {
        colaBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 5, 2, 5);

    meal = new TextField("Meal Allowance: ");
    meal.setWidth("170px");
    meal.addStyleName("numerical");
    glayout.addComponent(meal, 0, 6);

    mealEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    mealEntry.setWidth("150px");
    glayout.addComponent(mealEntry, 1, 6);

    Button mealBtn = new Button("UPDATE MEAL ALLOWANCE");
    mealBtn.setWidth("250px");
    mealBtn.addListener(buttonClickListener);
    glayout.addComponent(mealBtn, 2, 6);
    glayout.setComponentAlignment(mealBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        mealBtn.setEnabled(true);
    } else {
        mealBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 7, 2, 7);

    transportation = new TextField("Transportation Allowance: ");
    transportation.setWidth("170px");
    transportation.addStyleName("numerical");
    glayout.addComponent(transportation, 0, 8);

    transportationEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    transportationEntry.setWidth("150px");
    glayout.addComponent(transportationEntry, 1, 8);

    Button transportationBtn = new Button("UPDATE TRANSPORTATION ALLOWANCE");
    transportationBtn.setWidth("250px");
    transportationBtn.addListener(buttonClickListener);
    glayout.addComponent(transportationBtn, 2, 8);
    glayout.setComponentAlignment(transportationBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        transportationBtn.setEnabled(true);
    } else {
        transportationBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 9, 2, 9);

    others = new TextField("Other Allowances: ");
    others.setWidth("170px");
    others.addStyleName("numerical");
    glayout.addComponent(others, 0, 10);

    othersEntry = dropDown.populateEmploymentAllowanceEntry("Entry Type: ");
    othersEntry.setWidth("150px");
    glayout.addComponent(othersEntry, 1, 10);

    Button othersBtn = new Button("UPDATE OTHER ALLOWANCES");
    othersBtn.setWidth("250px");
    othersBtn.addListener(buttonClickListener);
    glayout.addComponent(othersBtn, 2, 10);
    glayout.setComponentAlignment(othersBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        othersBtn.setEnabled(true);
    } else {
        othersBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 11, 2, 11);

    afl = new TextField("Allowance for Liquidation: ");
    afl.setWidth("170px");
    afl.addStyleName("numerical");
    glayout.addComponent(afl, 0, 12);

    Button aflBtn = new Button("UPDATE AFL");
    aflBtn.setWidth("100%");
    aflBtn.addListener(buttonClickListener);
    glayout.addComponent(aflBtn, 1, 12, 2, 12);
    glayout.setComponentAlignment(aflBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        aflBtn.setEnabled(true);
    } else {
        aflBtn.setEnabled(false);
    }

    if (getEmployeeId() != null) {
        Allowances a = ais.getAllowancesByEmployee(getEmployeeId());

        communication.setValue(a.getCommunication());
        communicationEntry.setValue(
                Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY, a.getComEntryType()));

        perDiem.setValue(a.getPerDiem());
        perDiemEntry.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY,
                a.getPerDiemEntryType()));

        cola.setValue(a.getCola());
        colaEntry.setValue(
                Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY, a.getColaEntryType()));

        meal.setValue(a.getMeal());
        mealEntry.setValue(
                Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY, a.getMealEntryType()));

        transportation.setValue(a.getTransportation());
        transportationEntry.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY,
                a.getTransEntryType()));

        others.setValue(a.getOthers());
        othersEntry.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_ALLOWANCE_ENTRY,
                a.getOthersEntryType()));

        afl.setValue(a.getAllowanceForLiquidation());
    }

    return glayout;
}

From source file:com.openhris.employee.others.OtherInformation.java

Component component() {
    GridLayout glayout = new GridLayout(2, 13);
    glayout.setSpacing(true);/*from  ww w  .j  a  va 2s.c  om*/
    glayout.setWidth("600px");
    glayout.setHeight("100%");

    tinField = new HRISTextField("TIN: ");
    glayout.addComponent(tinField, 0, 0);

    Button tinBtn = new Button("UPDATE TIN NO.");
    tinBtn.setWidth("100%");
    tinBtn.addListener(buttonClickListener);
    glayout.addComponent(tinBtn, 1, 0);
    glayout.setComponentAlignment(tinBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        tinBtn.setEnabled(true);
    } else {
        tinBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 1, 1, 1);

    employeeDependent = dropDown.populateTotalDependent("Employee's Dependent");
    employeeDependent.setWidth("100%");
    glayout.addComponent(employeeDependent, 0, 2);

    Button edBtn = new Button("UPDATE EMPLOYEE's DEPENDENT");
    edBtn.setWidth("100%");
    edBtn.addListener(buttonClickListener);
    glayout.addComponent(edBtn, 1, 2);
    glayout.setComponentAlignment(edBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        edBtn.setEnabled(true);
    } else {
        edBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 3, 1, 3);

    sssField = new HRISTextField("SSS: ");
    glayout.addComponent(sssField, 0, 4);

    Button sssbtn = new Button("UPDATE SSS NO.");
    sssbtn.setWidth("100%");
    sssbtn.addListener(buttonClickListener);
    glayout.addComponent(sssbtn, 1, 4);
    glayout.setComponentAlignment(sssbtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        sssbtn.setEnabled(true);
    } else {
        sssbtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 5, 1, 5);

    phicField = new HRISTextField("Philhealth");
    glayout.addComponent(phicField, 0, 6);

    Button phicBtn = new Button("UPDATE PHIC NO.");
    phicBtn.setWidth("100%");
    phicBtn.addListener(buttonClickListener);
    glayout.addComponent(phicBtn, 1, 6);
    glayout.setComponentAlignment(phicBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        phicBtn.setEnabled(true);
    } else {
        phicBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 7, 1, 7);

    hdmfField = new HRISTextField("HDMF: ");
    glayout.addComponent(hdmfField, 0, 8);

    Button hdmfBtn = new Button("UPDATE HDMF NO.");
    hdmfBtn.setWidth("100%");
    hdmfBtn.addListener(buttonClickListener);
    glayout.addComponent(hdmfBtn, 1, 8);
    glayout.setComponentAlignment(hdmfBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        hdmfBtn.setEnabled(true);
    } else {
        hdmfBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 9, 1, 9);

    bankAccountNo = new HRISTextField("Bank Account No: ");
    bankAccountNo.setImmediate(true);
    glayout.addComponent(bankAccountNo, 0, 10);

    Button bankAccountBtn = new Button("UPDATE BANK NO.");
    bankAccountBtn.setWidth("100%");
    bankAccountBtn.addListener(buttonClickListener);
    glayout.addComponent(bankAccountBtn, 1, 10);
    glayout.setComponentAlignment(bankAccountBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        bankAccountBtn.setEnabled(true);
    } else {
        bankAccountBtn.setEnabled(false);
    }

    if (getEmployeeId() != null) {
        EmploymentInformation ei = si.getEmployeeSalaryInformation(getEmployeeId());

        tinField.setValue(ei.getTinNo());
        sssField.setValue(ei.getSssNo());
        phicField.setValue(ei.getPhicNo());
        hdmfField.setValue(ei.gethdmfNo());
        bankAccountNo.setValue(ei.getBankAccountNo());
        employeeDependent
                .setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_DEPENDENT, ei.getTotalDependent()));
    }

    return glayout;
}