Example usage for com.vaadin.ui TextArea TextArea

List of usage examples for com.vaadin.ui TextArea TextArea

Introduction

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

Prototype

public TextArea(ValueChangeListener<String> valueChangeListener) 

Source Link

Document

Constructs a new TextArea with a value change listener.

Usage

From source file:com.salsaw.msalsa.PhylogeneticTreeView.java

License:Apache License

public PhylogeneticTreeView(ClustalFileMapper clustalFileMapper) throws IOException {
    initializeUiComponents();/*from   w w  w.j  av  a2 s.  c o m*/

    // Download alignment file
    Button aligmentButton = new Button("Download alignment");
    Resource resAlignment = new FileResource(new File(clustalFileMapper.getAlignmentFilePath()));
    FileDownloader fdAln = new FileDownloader(resAlignment);
    fdAln.extend(aligmentButton);
    mainLayout.addComponent(aligmentButton);
    mainLayout.setComponentAlignment(aligmentButton, Alignment.MIDDLE_CENTER);

    // Download tree file
    Button downloadTreeButton = new Button("Download phylogentic tree");
    Resource resTree = new FileResource(new File(clustalFileMapper.getTreeFilePath()));
    FileDownloader fdTree = new FileDownloader(resTree);
    fdTree.extend(downloadTreeButton);
    mainLayout.addComponent(downloadTreeButton);
    mainLayout.setComponentAlignment(downloadTreeButton, Alignment.MIDDLE_CENTER);

    // Add and center with HTML div
    svgHTMLPhylogenticTree = new Label("<div id='svgCanvas'></div>", ContentMode.HTML);
    svgHTMLPhylogenticTree.setWidth("-1px");
    svgHTMLPhylogenticTree.setHeight("-1px");
    mainLayout.addComponent(svgHTMLPhylogenticTree);
    mainLayout.setComponentAlignment(svgHTMLPhylogenticTree, Alignment.MIDDLE_CENTER);

    // Add tab with aligment content
    String aligmentFileContent = new String(
            Files.readAllBytes(Paths.get(clustalFileMapper.getAlignmentFilePath())));
    TextArea aligmentFileTextArea = new TextArea("M-SALSA Aligment");
    aligmentFileTextArea.setWordwrap(false);
    aligmentFileTextArea.setValue(aligmentFileContent);
    aligmentFileTextArea.setWidth("100%");
    aligmentFileTextArea.setHeight("100%");
    mainLayout.addComponent(aligmentFileTextArea);
    mainLayout.setComponentAlignment(aligmentFileTextArea, Alignment.MIDDLE_CENTER);

    // Add JavaScript component to generate phylogentic tree
    JsPhyloSVG jsPhyloSVG = new JsPhyloSVG(getPhylogeneticTreeFileContent(clustalFileMapper));
    mainLayout.addComponent(jsPhyloSVG);

    setCompositionRoot(mainLayout);
}

From source file:com.save.client.RemoveAccountWindow.java

VerticalLayout getVLayout() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSpacing(true);/*from w  ww  .ja  v a  2  s . co m*/
    vlayout.setMargin(true);
    vlayout.setSizeFull();

    final TextArea remarks = new TextArea("Remarks: ");
    remarks.setRows(2);
    remarks.setWidth("100%");
    vlayout.addComponent(remarks);

    Button removeBtn = new Button("REMOVE ACCOUNT?");
    removeBtn.setWidth("100%");
    removeBtn.addClickListener((Button.ClickEvent event) -> {
        if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) {
            Notification.show("Add Remarks!", Notification.Type.ERROR_MESSAGE);
            return;
        }

        boolean result = clientService.removeAccount(getClientId(), remarks.getValue().trim().toLowerCase());
        if (result) {
            close();
        }
    });
    vlayout.addComponent(removeBtn);

    return vlayout;
}

From source file:com.save.clients.AcknowledgementPromoForm.java

VerticalLayout acknowledgementFormContent() {
    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();//from   w ww. jav  a 2 s  . c om
    content.setMargin(true);
    content.setSpacing(true);

    GridLayout glayout = new GridLayout(4, 5);
    glayout.setWidth("100%");
    glayout.setSpacing(true);

    entryDate = new DateField("Date: ");
    entryDate.setWidth("100%");
    glayout.addComponent(entryDate, 0, 0);

    promoItem = new TextField("Promo Items: ");
    promoItem.setWidth("100%");
    glayout.addComponent(promoItem, 1, 0, 3, 0);

    promoAmount = new TextField("Amount: ");
    promoAmount.setWidth("100%");
    promoAmount.setStyleName("align-right");
    glayout.addComponent(promoAmount, 0, 1);

    quantity = new TextField("Quantity: ");
    quantity.setWidth("100%");
    quantity.setStyleName("align-right");
    glayout.addComponent(quantity, 1, 1);

    productItems = CommonComboBox.productItems();
    productItems.setWidth("100%");
    glayout.addComponent(productItems, 2, 1, 3, 1);

    startDate = new DateField("From: ");
    startDate.setWidth("100%");
    glayout.addComponent(startDate, 0, 2);

    endDate = new DateField("To: ");
    endDate.setWidth("100%");
    glayout.addComponent(endDate, 1, 2);

    salesRep.setWidth("100%");
    glayout.addComponent(salesRep, 2, 2, 3, 2);

    areaSales.setWidth("100%");
    glayout.addComponent(areaSales, 2, 3, 3, 3);

    remarks = new TextArea("Remarks: ");
    remarks.setWidth("100%");
    remarks.setRows(4);
    glayout.addComponent(remarks, 0, 3, 1, 4);

    Button submitBtn = new Button();
    submitBtn.setCaption("SAVE");
    submitBtn.setWidth("100%");
    submitBtn.addClickListener(this);
    glayout.addComponent(submitBtn, 2, 4, 3, 4);
    glayout.setComponentAlignment(submitBtn, Alignment.BOTTOM_CENTER);

    if (getPromoId() != 0) {
        PromoDeals pd = pds.getPromoDealById(getPromoId());
        submitBtn.setCaption("UPDATE");
        entryDate.setValue(pd.getEntryDate());
        startDate.setValue(pd.getStartDate());
        endDate.setValue(pd.getEndDate());
        promoItem.setValue(pd.getPromoItem());
        promoAmount.setValue(String.valueOf(pd.getPromoAmount()));
        quantity.setValue(String.valueOf(pd.getQuantity()));
        productItems.setValue(pd.getProductId());
        areaSales.setValue(pd.getAreaSalesId());
        salesRep.setValue(pd.getSalesRepId());
        remarks.setValue(pd.getRemarks());
    }

    content.addComponent(glayout);
    return content;
}

From source file:com.save.employee.EmploymentInformationForm.java

public EmploymentInformationForm(HorizontalSplitPanel hsplit, int employeeId) {
    this.hsplit = hsplit;
    this.employeeId = employeeId;

    setMargin(new MarginInfo(true, true, false, false));
    setWidth("80%");
    addStyleName("light");
    setReadOnly(readOnly);//from  w  w  w . j a  va 2  s  .  c  om
    setImmediate(true);

    editBtn = new Button(EDIT_BUTTON_CAPTION);
    editBtn.addClickListener(editBtnListener);
    editBtn.setImmediate(true);

    cancelBtn = new Button(CANCEL_BTN_CAPTION, cancelBtnListener);
    cancelBtn.setImmediate(true);
    cancelBtn.setEnabled(false);

    //        addBtn = new Button(ADD_BUTTON_CAPTION, addBtnListener);
    //        addBtn.setImmediate(true);

    //        Label section = new Label("Employment Info");
    //        section.addStyleName("h1");
    //        section.addStyleName("colored");
    //        addComponent(section);

    position = new PositionComboBox();
    addComponent(position);

    department = new DepartmentComboBox();
    addComponent(department);

    employmentStatus = CommonComboBox.employmentStatus("Status: ");
    addComponent(employmentStatus);

    remarks = new TextArea("Remarks: ");
    remarks.setWidth("100%");
    remarks.setRequired(true);
    remarks.setRequiredError("Required Remarks");
    addComponent(remarks);

    if (getEmployeeId() != 0) {
        EmployeePositionHistory eph = es.getEmployeesEmploymentDataById(getEmployeeId());

        position.setValue(eph.getPosition());
        department.setValue(eph.getDepartment());
        employmentStatus.setValue(eph.getEmploymentStatus());
        remarks.setValue(eph.getRemarks());
    }

    footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, true, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    addComponent(footer);
    footer.addComponent(editBtn);
    footer.addComponent(cancelBtn);
    //        footer.addComponent(addBtn);

    //        Label lastModified = new Label("Last modified by you a minute ago");
    //        lastModified.addStyleName("light");
    //        footer.addComponent(lastModified);

    disableFields(false);
}

From source file:com.save.employee.maintenance.MRFormWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);/*from  w  ww  . j av a  2s.  c  o  m*/

    formType = CommonComboBox.getFormType("Select Form Type..");
    formType.setValue(1);
    formType.setWidth("60%");
    form.addComponent(formType);

    area = CommonComboBox.areas();
    area.setWidth("60%");
    form.addComponent(area);

    plateNo = new TextField("Plate No: ");
    plateNo.setWidth("60%");
    form.addComponent(plateNo);

    dateCovered = new DateField("Date Covered: ");
    dateCovered.setWidth("60%");
    form.addComponent(dateCovered);

    amount = new TextField("Amount: ");
    amount.setWidth("60%");
    amount.addStyleName("align-right");
    form.addComponent(amount);

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

    actionButton = new Button();
    actionButton.setCaption("SAVE");
    actionButton.setWidth("100%");
    actionButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    actionButton.addClickListener(buttonClickListener);
    form.addComponent(actionButton);

    formType.addValueChangeListener((Property.ValueChangeEvent e) -> {
        if (e.getProperty().getValue().toString().equals("1")) {
            if (getMrId() != 0) {
                actionButton.setCaption("UPDATE");
            } else {
                actionButton.setCaption("SAVE");
            }
            panel.setCaption("MAINTENANCE FORM");
        } else {
            if (getMrId() != 0) {
                actionButton.setCaption("UPDATE");
            } else {
                actionButton.setCaption("SAVE");
            }
            panel.setCaption("REIMBURSEMENT FORM");
        }
    });

    editForm();
    viewForm(form);

    return form;
}

From source file:com.save.employee.RemoveAccountWindow.java

VerticalLayout getVLayout() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSpacing(true);//from w  ww  . j av  a  2 s  .  c o  m
    vlayout.setMargin(true);
    vlayout.setSizeFull();

    final TextArea remarks = new TextArea("Remarks: ");
    remarks.setRows(2);
    remarks.setWidth("100%");
    vlayout.addComponent(remarks);

    Button removeBtn = new Button("REMOVE ACCOUNT?");
    removeBtn.setWidth("100%");
    removeBtn.addClickListener((Button.ClickEvent event) -> {
        if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) {
            Notification.show("Add Remarks!", Notification.Type.ERROR_MESSAGE);
            return;
        }

        boolean result = employeeService.removeAccount(getEmployeeId(),
                remarks.getValue().trim().toLowerCase());
        if (result) {
            close();
        }
    });
    vlayout.addComponent(removeBtn);

    return vlayout;
}

From source file:com.save.employee.request.RequestFormWindow.java

Component buildRequestForm() {
    GridLayout glayout = new GridLayout(4, 7);
    glayout.setSizeFull();/* w ww .j a va2s.co  m*/
    glayout.setSpacing(true);
    glayout.setMargin(true);

    controlNo = new TextField("Control No.");
    controlNo.setWidth("100%");
    controlNo.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    glayout.addComponent(controlNo, 0, 0);

    dateOfActivity = new DateField("Date of Activity: ");
    dateOfActivity.setWidth("100%");
    dateOfActivity.addStyleName(ValoTheme.DATEFIELD_SMALL);
    glayout.addComponent(dateOfActivity, 1, 0);

    area = CommonComboBox.areas();
    area.setWidth("100%");
    glayout.addComponent(area, 2, 0);

    activity = new TextField("Activity: ");
    activity.setWidth("100%");
    activity.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    glayout.addComponent(activity, 0, 1, 1, 1);

    venue = new TextField("Venue: ");
    venue.setWidth("100%");
    venue.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    glayout.addComponent(venue, 0, 2, 1, 2);

    requirements = new TextArea("Requirements: ");
    requirements.setWidth("100%");
    requirements.addStyleName(ValoTheme.TEXTAREA_SMALL);
    glayout.addComponent(requirements, 2, 1, 3, 2);

    Label lodging = new Label("Lodging: ");
    lodging.setWidthUndefined();
    glayout.addComponent(lodging, 0, 3);
    glayout.setComponentAlignment(lodging, Alignment.MIDDLE_CENTER);

    lodgingPax = new TextField("Pax: ");
    lodgingPax.setWidth("100%");
    lodgingPax.setValue("0");
    lodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    lodgingPax.addStyleName("align-right");
    glayout.addComponent(lodgingPax, 1, 3);

    lodgingAmount = new TextField("Amount: ");
    lodgingAmount.setWidth("100%");
    lodgingAmount.setValue("0.00");
    lodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    lodgingAmount.addStyleName("align-right");
    lodgingAmount.setEnabled(false);
    lodgingAmount.setImmediate(true);
    glayout.addComponent(lodgingAmount, 3, 3);

    lodgingBudget = new TextField("Budget: ");
    lodgingBudget.setWidth("100%");
    lodgingBudget.setValue("0.00");
    lodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    lodgingBudget.addStyleName("align-right");
    lodgingBudget.addValueChangeListener((ValueChangeEvent event) -> {
        if (!CommonUtilities.checkInputIfInteger(lodgingPax.getValue().trim())) {
            Notification.show("Enter a numeric value for Pax", Notification.Type.ERROR_MESSAGE);
            return;
        }

        if (!CommonUtilities.checkInputIfDouble(lodgingBudget.getValue().trim())) {
            Notification.show("Enter a numeric value for Budget", Notification.Type.ERROR_MESSAGE);
            return;
        }

        lodgingAmount.setValue(String.valueOf(CommonUtilities.convertStringToInt(lodgingPax.getValue().trim())
                * CommonUtilities.convertStringToDouble(lodgingBudget.getValue().trim())));
    });
    lodgingBudget.setImmediate(true);
    glayout.addComponent(lodgingBudget, 2, 3);

    Label meals = new Label("Meals: ");
    meals.setWidthUndefined();
    glayout.addComponent(meals, 0, 4);
    glayout.setComponentAlignment(meals, Alignment.MIDDLE_CENTER);

    mealsPax = new TextField("Pax: ");
    mealsPax.setWidth("100%");
    mealsPax.setValue("0");
    mealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    mealsPax.addStyleName("align-right");
    glayout.addComponent(mealsPax, 1, 4);

    mealsAmount = new TextField("Amount: ");
    mealsAmount.setWidth("100%");
    mealsAmount.setValue("0.00");
    mealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    mealsAmount.addStyleName("align-right");
    mealsAmount.setEnabled(false);
    mealsAmount.setImmediate(liquidated);
    glayout.addComponent(mealsAmount, 3, 4);

    mealsBudget = new TextField("Budget: ");
    mealsBudget.setWidth("100%");
    mealsBudget.setValue("0.00");
    mealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    mealsBudget.addStyleName("align-right");
    mealsBudget.addValueChangeListener((ValueChangeEvent event) -> {
        if (!CommonUtilities.checkInputIfInteger(mealsPax.getValue().trim())) {
            Notification.show("Enter a numeric value for Pax", Notification.Type.ERROR_MESSAGE);
            return;
        }

        if (!CommonUtilities.checkInputIfDouble(mealsBudget.getValue().trim())) {
            Notification.show("Enter a numeric value for Budget", Notification.Type.ERROR_MESSAGE);
            return;
        }

        mealsAmount.setValue(String.valueOf(CommonUtilities.convertStringToInt(mealsPax.getValue().trim())
                * CommonUtilities.convertStringToDouble(mealsBudget.getValue().trim())));
    });
    mealsAmount.setImmediate(true);
    glayout.addComponent(mealsBudget, 2, 4);

    others = new TextArea("Others: ");
    others.setWidth("100%");
    others.setRows(3);
    others.addStyleName(ValoTheme.TEXTAREA_SMALL);
    glayout.addComponent(others, 0, 5, 2, 6);

    othersAmount = new TextField("Amount: ");
    othersAmount.setWidth("100%");
    othersAmount.setValue("0.00");
    othersAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    othersAmount.addStyleName("align-right");
    glayout.addComponent(othersAmount, 3, 5);
    glayout.setComponentAlignment(othersAmount, Alignment.TOP_CENTER);

    Button rlButton = new Button();
    rlButton.setCaption("SAVE");
    rlButton.setWidth("100%");
    rlButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    rlButton.addStyleName(ValoTheme.BUTTON_SMALL);
    rlButton.addClickListener(buttonClickListener);
    glayout.addComponent(rlButton, 3, 6);
    glayout.setComponentAlignment(rlButton, Alignment.TOP_CENTER);

    if (getRequestId() != 0) {
        LiquidationForm lf = rls.getRLById(getRequestId());
        controlNo.setValue(String.valueOf(lf.getControlNo()));
        dateOfActivity.setValue(lf.getDateOfActivity());
        area.setValue(lf.getAreaId());
        activity.setValue(lf.getActivity());
        requirements.setValue(lf.getRequirements());
        venue.setValue(lf.getVenue());
        others.setValue(lf.getOthersRemarks());
        othersAmount.setValue(String.valueOf(lf.getOthersAmount()));
        lodgingAmount.setValue(String.valueOf(lf.getLodgingAmount()));
        mealsAmount.setValue(String.valueOf(lf.getMealsAmount()));
        if (getLiquidated() == true) {
            setCaption("LIQUIDATE FROM");
            rlButton.setCaption("LIQUIDATE");
            controlNo.setReadOnly(liquidated);
            dateOfActivity.setReadOnly(liquidated);
            area.setReadOnly(liquidated);
            activity.setReadOnly(liquidated);
            requirements.setReadOnly(liquidated);
            venue.setReadOnly(liquidated);
        } else {
            rlButton.setCaption("EDIT");
            lodgingPax.setValue(String.valueOf(lf.getLodgingPax()));
            lodgingBudget.setValue(String.valueOf(lf.getLodgingBudget()));
            mealsPax.setValue(String.valueOf(lf.getMealsPax()));
            mealsBudget.setValue(String.valueOf(lf.getMealsBudget()));
            rlButton.setEnabled(rls.getRLById(getRequestId()).getLiquidated() == 0);
        }
        //            delete.setVisible(true);
    }

    return glayout;
}

From source file:com.save.employee.request.ViewRLWindow.java

FormLayout buildFormLayout() {
    FormLayout f = new FormLayout();
    f.setWidth("100%");
    f.setMargin(true);//w  ww . j a v a2s.  c om

    LiquidationForm lf = rls.getRLById(getRequestId());

    controlNo = new TextField("Control No.");
    controlNo.setWidth("100%");
    controlNo.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    controlNo.setValue(String.valueOf(lf.getControlNo()));
    controlNo.setEnabled(false);
    f.addComponent(controlNo);

    dateOfActivity = new DateField("Date of Activity: ");
    dateOfActivity.setWidth("100%");
    dateOfActivity.addStyleName(ValoTheme.DATEFIELD_SMALL);
    dateOfActivity.setValue(lf.getDateOfActivity());
    dateOfActivity.setEnabled(false);
    f.addComponent(dateOfActivity);

    area = CommonComboBox.areas();
    area.setWidth("100%");
    area.setValue(lf.getAreaId());
    area.setEnabled(false);
    f.addComponent(area);

    activity = new TextField("Activity: ");
    activity.setWidth("100%");
    activity.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    activity.setValue(lf.getActivity());
    activity.setEnabled(false);
    f.addComponent(activity);

    venue = new TextField("Venue: ");
    venue.setWidth("100%");
    venue.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    venue.setValue(lf.getVenue());
    venue.setEnabled(false);
    f.addComponent(venue);

    requirements = new TextArea("Requirements: ");
    requirements.setWidth("100%");
    requirements.addStyleName(ValoTheme.TEXTAREA_SMALL);
    requirements.setValue(lf.getRequirements());
    requirements.setEnabled(false);
    f.addComponent(requirements);

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setWidth("100%");
    h1.setCaption("Request Lodging");
    h1.addStyleName("light");
    //        h1.setReadOnly(true);

    requestLodgingPax = new TextField();
    requestLodgingPax.setWidth("100%");
    requestLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestLodgingPax.addStyleName("align-right");
    requestLodgingPax.setValue("Pax: " + String.valueOf(lf.getLodgingPax()));
    requestLodgingPax.setEnabled(false);
    h1.addComponent(requestLodgingPax);

    requestLodgingBudget = new TextField();
    requestLodgingBudget.setWidth("100%");
    requestLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestLodgingBudget.addStyleName("align-right");
    requestLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLodgingBudget()));
    requestLodgingBudget.setEnabled(false);
    h1.addComponent(requestLodgingBudget);

    requestLodgingAmount = new TextField();
    requestLodgingAmount.setWidth("100%");
    requestLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestLodgingAmount.addStyleName("align-right");
    requestLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLodgingAmount()));
    requestLodgingAmount.setEnabled(false);
    h1.addComponent(requestLodgingAmount);

    f.addComponent(h1);
    f.setComponentAlignment(h1, Alignment.MIDDLE_LEFT);

    HorizontalLayout h2 = new HorizontalLayout();
    h2.setWidth("100%");
    h2.setCaption("Request Meals");
    //        h2.setReadOnly(true);

    requestMealsPax = new TextField();
    requestMealsPax.setWidth("100%");
    requestMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestMealsPax.addStyleName("align-right");
    requestMealsPax.setValue("Pax: " + String.valueOf(lf.getMealsPax()));
    requestMealsPax.setEnabled(false);
    h2.addComponent(requestMealsPax);

    requestMealsBudget = new TextField();
    requestMealsBudget.setWidth("100%");
    requestMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestMealsBudget.addStyleName("align-right");
    requestMealsBudget.setValue("Budget: " + String.valueOf(lf.getMealsBudget()));
    requestMealsBudget.setEnabled(false);
    h2.addComponent(requestMealsBudget);

    requestMealsAmount = new TextField();
    requestMealsAmount.setWidth("100%");
    requestMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestMealsAmount.addStyleName("align-right");
    requestMealsAmount.setValue("Amount: " + String.valueOf(lf.getMealsAmount()));
    requestMealsAmount.setEnabled(false);
    h2.addComponent(requestMealsAmount);

    f.addComponent(h2);
    f.setComponentAlignment(h2, Alignment.MIDDLE_LEFT);

    HorizontalLayout h3 = new HorizontalLayout();
    h3.setWidth("100%");
    h3.setCaption("Liquidated Lodging");
    //        h3.setReadOnly(true);

    liquidateLodgingPax = new TextField();
    liquidateLodgingPax.setWidth("100%");
    liquidateLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateLodgingPax.addStyleName("align-right");
    liquidateLodgingPax.setValue("Pax: " + String.valueOf(lf.getLiquidationLodgingPax()));
    liquidateLodgingPax.setEnabled(false);
    h3.addComponent(liquidateLodgingPax);

    liquidateLodgingBudget = new TextField();
    liquidateLodgingBudget.setWidth("100%");
    liquidateLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateLodgingBudget.addStyleName("align-right");
    liquidateLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationLodgingBudget()));
    liquidateLodgingBudget.setEnabled(false);
    h3.addComponent(liquidateLodgingBudget);

    liquidateLodgingAmount = new TextField();
    liquidateLodgingAmount.setWidth("100%");
    liquidateLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateLodgingAmount.addStyleName("align-right");
    liquidateLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationLodgingAmount()));
    liquidateLodgingAmount.setEnabled(false);
    h3.addComponent(liquidateLodgingAmount);

    f.addComponent(h3);
    f.setComponentAlignment(h3, Alignment.MIDDLE_LEFT);

    HorizontalLayout h4 = new HorizontalLayout();
    h4.setWidth("100%");
    h4.setCaption("Liquidated Meals");
    h4.setReadOnly(true);

    liquidateMealsPax = new TextField();
    liquidateMealsPax.setWidth("100%");
    liquidateMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateMealsPax.addStyleName("align-right");
    liquidateMealsPax.setValue("Pax: " + String.valueOf(lf.getLiquidationMealsPax()));
    liquidateMealsPax.setEnabled(false);
    h4.addComponent(liquidateMealsPax);

    liquidateMealsBudget = new TextField();
    liquidateMealsBudget.setWidth("100%");
    liquidateMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateMealsBudget.addStyleName("align-right");
    liquidateMealsBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationMealsBudget()));
    liquidateMealsBudget.setEnabled(false);
    h4.addComponent(liquidateMealsBudget);

    liquidateMealsAmount = new TextField();
    liquidateMealsAmount.setWidth("100%");
    liquidateMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateMealsAmount.addStyleName("align-right");
    liquidateMealsAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationMealsAmount()));
    liquidateMealsAmount.setEnabled(false);
    h4.addComponent(liquidateMealsAmount);

    f.addComponent(h4);
    f.setComponentAlignment(h4, Alignment.MIDDLE_LEFT);

    reimbursement = new TextField("Reimbursement: ");
    reimbursement.setWidth("50%");
    reimbursement.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    reimbursement.setValue(String.valueOf(lf.getReimbursedAmount()));
    reimbursement.setEnabled(false);
    f.addComponent(reimbursement);

    f.addStyleName("light");
    f.setReadOnly(true);

    return f;
}

From source file:com.skysql.manager.ui.ErrorDialog.java

License:Open Source License

/**
 * Instantiates a new error dialog.//from w w w.j a v  a 2s.co  m
 *
 * @param e the exception
 * @param humanizedError the humanized error
 */
public ErrorDialog(Exception e, String humanizedError) {

    if (e != null) {
        ManagerUI.error(e.getMessage());
    }

    dialogWindow = new ModalWindow("An Error has occurred", "775px");
    dialogWindow.setHeight("340px");
    dialogWindow.addCloseListener(this);
    UI current = UI.getCurrent();
    if (current.getContent() == null) {
        current.setContent(new ErrorView(Notification.Type.ERROR_MESSAGE, null));
    }
    current.addWindow(dialogWindow);

    HorizontalLayout wrapper = new HorizontalLayout();
    wrapper.setSizeFull();
    wrapper.setMargin(true);

    VerticalLayout iconLayout = new VerticalLayout();
    iconLayout.setWidth("100px");
    wrapper.addComponent(iconLayout);
    Embedded image = new Embedded(null, new ThemeResource("img/error.png"));
    iconLayout.addComponent(image);

    VerticalLayout textLayout = new VerticalLayout();
    textLayout.setHeight("100%");
    textLayout.setSpacing(true);
    wrapper.addComponent(textLayout);
    wrapper.setExpandRatio(textLayout, 1.0f);

    if (humanizedError != null || e != null) {
        String error = (humanizedError != null) ? humanizedError : e.toString();
        ManagerUI.error(error);
        Label label = new Label(error, ContentMode.HTML);
        label.addStyleName("warning");
        textLayout.addComponent(label);
        textLayout.setComponentAlignment(label, Alignment.TOP_CENTER);
    }

    if (e != null) {
        TextArea stackTrace = new TextArea("Error Log");
        stackTrace.setSizeFull();
        StringWriter sw = new StringWriter();
        e.printStackTrace(new PrintWriter(sw));
        stackTrace.setValue(sw.toString());
        textLayout.addComponent(stackTrace);
        textLayout.setComponentAlignment(stackTrace, Alignment.TOP_LEFT);
        textLayout.setExpandRatio(stackTrace, 1.0f);
    }

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Close");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            dialogWindow.close();
            //UI.getCurrent().close();
        }
    });

    Button okButton = new Button("Send Error");
    okButton.setEnabled(false);
    okButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            dialogWindow.close();
        }
    });
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) dialogWindow.getContent();
    windowLayout.setHeight("100%");
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(wrapper);
    windowLayout.setExpandRatio(wrapper, 1.0f);
    windowLayout.addComponent(buttonsBar);

}

From source file:com.skysql.manager.ui.MonitorsSettings.java

License:Open Source License

/**
 * Monitor form.//from  w ww .j  a va2s  .co m
 *
 * @param monitor the monitor
 * @param title the title
 * @param description the description
 * @param button the button
 */
public void monitorForm(final MonitorRecord monitor, String title, String description, String button) {
    final TextField monitorName = new TextField("Monitor Name");
    final TextField monitorDescription = new TextField("Description");
    final TextField monitorUnit = new TextField("Measurement Unit");
    final TextArea monitorSQL = new TextArea("SQL Statement");
    final CheckBox monitorDelta = new CheckBox("Is Delta");
    final CheckBox monitorAverage = new CheckBox("Is Average");
    final NativeSelect validationTarget = new NativeSelect("Validate SQL on");
    final NativeSelect monitorInterval = new NativeSelect("Sampling interval");
    final NativeSelect monitorChartType = new NativeSelect("Default display");

    secondaryDialog = new ModalWindow(title, null);
    UI.getCurrent().addWindow(secondaryDialog);
    secondaryDialog.addCloseListener(this);

    final VerticalLayout formContainer = new VerticalLayout();
    formContainer.setMargin(new MarginInfo(true, true, false, true));
    formContainer.setSpacing(false);

    final Form form = new Form();
    formContainer.addComponent(form);
    form.setImmediate(false);
    form.setFooter(null);
    form.setDescription(description);

    String value;

    if ((value = monitor.getName()) != null) {
        monitorName.setValue(value);
    }
    form.addField("monitorName", monitorName);
    form.getField("monitorName").setRequired(true);
    form.getField("monitorName").setRequiredError("Monitor Name is missing");
    monitorName.focus();
    monitorName.setImmediate(true);
    monitorName.addValidator(new MonitorNameValidator(monitor.getName()));

    if ((value = monitor.getDescription()) != null) {
        monitorDescription.setValue(value);
    }
    monitorDescription.setWidth("24em");
    form.addField("monitorDescription", monitorDescription);

    if ((value = monitor.getUnit()) != null) {
        monitorUnit.setValue(value);
    }
    form.addField("monitorUnit", monitorUnit);

    if ((value = monitor.getSql()) != null) {
        monitorSQL.setValue(value);
    }
    monitorSQL.setWidth("24em");
    monitorSQL.addValidator(new SQLValidator());
    form.addField("monitorSQL", monitorSQL);

    final String noValidation = "None - Skip Validation";
    validationTarget.setImmediate(true);
    validationTarget.setNullSelectionAllowed(false);
    validationTarget.addItem(noValidation);
    validationTarget.select(noValidation);
    OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class);
    ArrayList<NodeInfo> nodes = overviewPanel.getNodes();

    if (nodes == null || nodes.isEmpty()) {
        SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class);
        String systemID = systemInfo.getCurrentID();
        String systemType = systemInfo.getCurrentSystem().getSystemType();
        if (systemID.equals(SystemInfo.SYSTEM_ROOT)) {
            ClusterComponent clusterComponent = VaadinSession.getCurrent().getAttribute(ClusterComponent.class);
            systemID = clusterComponent.getID();
            systemType = clusterComponent.getSystemType();
        }
        nodes = new ArrayList<NodeInfo>();
        for (String nodeID : systemInfo.getSystemRecord(systemID).getNodes()) {
            NodeInfo nodeInfo = new NodeInfo(systemID, systemType, nodeID);
            nodes.add(nodeInfo);
        }

    }

    for (NodeInfo node : nodes) {
        validationTarget.addItem(node.getID());
        validationTarget.setItemCaption(node.getID(), node.getName());
    }
    validationTarget.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void valueChange(ValueChangeEvent event) {
            nodeID = (String) event.getProperty().getValue();
            validateSQL = nodeID.equals(noValidation) ? false : true;
        }

    });
    form.addField("validationTarget", validationTarget);

    monitorDelta.setValue(monitor.isDelta());
    form.addField("monitorDelta", monitorDelta);

    monitorAverage.setValue(monitor.isAverage());
    form.addField("monitorAverage", monitorAverage);

    SettingsValues intervalValues = new SettingsValues(SettingsValues.SETTINGS_MONITOR_INTERVAL);
    String[] intervals = intervalValues.getValues();
    for (String interval : intervals) {
        monitorInterval.addItem(Integer.parseInt(interval));
    }

    Collection<?> validIntervals = monitorInterval.getItemIds();
    if (validIntervals.contains(monitor.getInterval())) {
        monitorInterval.select(monitor.getInterval());
    } else {
        SystemInfo systemInfo = getSession().getAttribute(SystemInfo.class);
        String defaultInterval = systemInfo.getSystemRecord(systemID).getProperties()
                .get(SystemInfo.PROPERTY_DEFAULTMONITORINTERVAL);
        if (defaultInterval != null && validIntervals.contains(Integer.parseInt(defaultInterval))) {
            monitorInterval.select(Integer.parseInt(defaultInterval));
        } else if (!validIntervals.isEmpty()) {
            monitorInterval.select(validIntervals.toArray()[0]);
        } else {
            new ErrorDialog(null, "No set of permissible monitor intervals found");
        }

        monitorInterval.setNullSelectionAllowed(false);
        form.addField("monitorInterval", monitorInterval);
    }

    for (UserChart.ChartType type : UserChart.ChartType.values()) {
        monitorChartType.addItem(type.name());
    }
    monitorChartType
            .select(monitor.getChartType() == null ? UserChart.ChartType.values()[0] : monitor.getChartType());
    monitorChartType.setNullSelectionAllowed(false);
    form.addField("monitorChartType", monitorChartType);

    HorizontalLayout buttonsBar = new HorizontalLayout();
    buttonsBar.setStyleName("buttonsBar");
    buttonsBar.setSizeFull();
    buttonsBar.setSpacing(true);
    buttonsBar.setMargin(true);
    buttonsBar.setHeight("49px");

    Label filler = new Label();
    buttonsBar.addComponent(filler);
    buttonsBar.setExpandRatio(filler, 1.0f);

    Button cancelButton = new Button("Cancel");
    buttonsBar.addComponent(cancelButton);
    buttonsBar.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);

    cancelButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            form.discard();
            secondaryDialog.close();
        }
    });

    Button okButton = new Button(button);
    okButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 0x4C656F6E6172646FL;

        public void buttonClick(ClickEvent event) {
            try {
                form.setComponentError(null);
                form.commit();
                monitor.setName(monitorName.getValue());
                monitor.setDescription(monitorDescription.getValue());
                monitor.setUnit(monitorUnit.getValue());
                monitor.setSql(monitorSQL.getValue());
                monitor.setDelta(monitorDelta.getValue());
                monitor.setAverage(monitorAverage.getValue());
                monitor.setInterval((Integer) monitorInterval.getValue());
                monitor.setChartType((String) monitorChartType.getValue());
                String ID;
                if ((ID = monitor.getID()) == null) {
                    if (Monitors.setMonitor(monitor)) {
                        ID = monitor.getID();
                        select.addItem(ID);
                        select.select(ID);
                        Monitors.reloadMonitors();
                        monitorsAll = Monitors.getMonitorsList(systemType);
                    }
                } else {
                    Monitors.setMonitor(monitor);
                    ChartProperties chartProperties = getSession().getAttribute(ChartProperties.class);
                    chartProperties.setDirty(true);
                    settingsDialog.setRefresh(true);
                }

                if (ID != null) {
                    select.setItemCaption(ID, monitor.getName());
                    displayMonitorRecord(ID);
                    secondaryDialog.close();
                }

            } catch (EmptyValueException e) {
                return;
            } catch (InvalidValueException e) {
                return;
            } catch (Exception e) {
                ManagerUI.error(e.getMessage());
                return;
            }
        }
    });
    buttonsBar.addComponent(okButton);
    buttonsBar.setComponentAlignment(okButton, Alignment.MIDDLE_RIGHT);

    VerticalLayout windowLayout = (VerticalLayout) secondaryDialog.getContent();
    windowLayout.setSpacing(false);
    windowLayout.setMargin(false);
    windowLayout.addComponent(formContainer);
    windowLayout.addComponent(buttonsBar);

}