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.etest.view.testbank.cellitem.CellCaseItemWindow.java

Table populateDataTable() {
    table.removeAllItems();/*  w  w  w.j a va 2s .c  o m*/
    int i = 0;
    for (CellItem ci : cis.getCellItemByCase(getCellCaseId())) {
        VerticalLayout v = new VerticalLayout();
        v.setSizeFull();

        Button edit = new Button("modify");
        edit.setWidth("100%");
        edit.setData(ci.getCellItemId());
        edit.setIcon(FontAwesome.PENCIL);
        edit.addStyleName(ValoTheme.BUTTON_LINK);
        edit.addStyleName(ValoTheme.BUTTON_TINY);
        edit.addStyleName(ValoTheme.BUTTON_QUIET);
        edit.addClickListener(modifyBtnClickListener);
        v.addComponent(edit);
        v.setComponentAlignment(edit, Alignment.MIDDLE_LEFT);

        Button approve = new Button("status");
        approve.setWidth("100%");
        approve.setData(ci.getCellItemId());
        approve.addStyleName(ValoTheme.BUTTON_LINK);
        approve.addStyleName(ValoTheme.BUTTON_TINY);
        approve.addStyleName(ValoTheme.BUTTON_QUIET);
        v.addComponent(approve);
        v.setComponentAlignment(approve, Alignment.MIDDLE_LEFT);

        Button view = new Button("view");
        view.setWidth("100%");
        view.setData(ci.getCellItemId());
        view.setIcon(FontAwesome.PLAY_CIRCLE);
        view.addStyleName(ValoTheme.BUTTON_LINK);
        view.addStyleName(ValoTheme.BUTTON_TINY);
        view.addStyleName(ValoTheme.BUTTON_QUIET);
        view.addClickListener(modifyBtnClickListener);
        v.addComponent(view);
        v.setComponentAlignment(view, Alignment.MIDDLE_LEFT);

        if (ci.getApproveItemStatus() == 0) {
            approve.setIcon(FontAwesome.THUMBS_DOWN);
        } else {
            approve.setIcon(FontAwesome.THUMBS_UP);
        }

        Label label = new Label(ci.getItem());
        label.setStyleName("label-padding");

        table.addItem(new Object[] { ci.getCellItemId(), label, v }, i);
        i++;
    }
    table.setPageLength(table.size());

    return table;
}

From source file:com.etest.view.testbank.cellitem.CellItemWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);/*www .  j  a  v  a2 s .  co  m*/
    form.setSpacing(true);

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

    Button helpBtn = new Button("HELP");
    helpBtn.setWidthUndefined();
    helpBtn.setIcon(FontAwesome.TASKS);
    helpBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    helpBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    helpBtn.addClickListener((Button.ClickEvent event) -> {
        Window sub = new MultipleChoiceHelpViewer();
        if (sub.getParent() == null) {
            UI.getCurrent().addWindow(sub);
        }
    });
    hlayout.addComponent(helpBtn);
    hlayout.setComponentAlignment(helpBtn, Alignment.MIDDLE_RIGHT);
    form.addComponent(hlayout);

    bloomsTaxonomy.setCaption("Blooms Class: ");
    bloomsTaxonomy.setWidth("30%");
    form.addComponent(bloomsTaxonomy);

    stem = new TextArea("Stem: ");
    stem.setWidth("100%");
    stem.setRows(5);
    stem.setWordwrap(true);
    form.addComponent(stem);

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setCaption("Option A:");
    h1.setWidth("100%");
    h1.setSpacing(true);

    optionA = new CommonTextField("add option A", null);
    optionA.setWidth("500px");
    h1.addComponent(optionA);

    Button optionABtn = new CommonButton("OPTION A");
    optionABtn.setWidth("120px");
    optionABtn.addClickListener(updateOptionAndKeyListerner);
    h1.addComponent(optionABtn);
    h1.setComponentAlignment(optionABtn, Alignment.MIDDLE_RIGHT);
    optionABtn.setVisible(isEdit());
    form.addComponent(h1);

    HorizontalLayout h2 = new HorizontalLayout();
    h2.setCaption("Key A:");
    h2.setWidth("100%");
    h2.setSpacing(true);

    keyA = new CommonTextField("Enter a Key for Option A", null);
    keyA.setWidth("500px");
    h2.addComponent(keyA);

    Button keyABtn = new CommonButton("KEY A");
    keyABtn.setWidth("120px");
    keyABtn.addClickListener(updateOptionAndKeyListerner);
    h2.addComponent(keyABtn);
    h2.setComponentAlignment(keyABtn, Alignment.MIDDLE_RIGHT);
    keyABtn.setVisible(isEdit());
    form.addComponent(h2);

    HorizontalLayout h3 = new HorizontalLayout();
    h3.setCaption("Option B:");
    h3.setWidth("100%");
    h3.setSpacing(true);

    optionB = new CommonTextField("add option B", null);
    optionB.setWidth("500px");
    h3.addComponent(optionB);

    Button optionBBtn = new CommonButton("OPTION B");
    optionBBtn.setWidth("120px");
    optionBBtn.addClickListener(updateOptionAndKeyListerner);
    h3.addComponent(optionBBtn);
    h3.setComponentAlignment(optionBBtn, Alignment.MIDDLE_RIGHT);
    optionBBtn.setVisible(isEdit());
    form.addComponent(h3);

    HorizontalLayout h4 = new HorizontalLayout();
    h4.setCaption("Key B:");
    h4.setWidth("100%");
    h4.setSpacing(true);

    keyB = new CommonTextField("Enter a Key for Option B", null);
    keyB.setWidth("500px");
    h4.addComponent(keyB);

    Button keyBBtn = new CommonButton("KEY B");
    keyBBtn.setWidth("120px");
    keyBBtn.addClickListener(updateOptionAndKeyListerner);
    h4.addComponent(keyBBtn);
    h4.setComponentAlignment(keyBBtn, Alignment.MIDDLE_RIGHT);
    keyBBtn.setVisible(isEdit());
    form.addComponent(h4);

    HorizontalLayout h5 = new HorizontalLayout();
    h5.setCaption("Option C:");
    h5.setWidth("100%");
    h5.setSpacing(true);

    optionC = new CommonTextField("add option C", null);
    optionC.setWidth("500px");
    h5.addComponent(optionC);

    Button optionCBtn = new CommonButton("OPTION C");
    optionCBtn.setWidth("120px");
    optionCBtn.addClickListener(updateOptionAndKeyListerner);
    h5.addComponent(optionCBtn);
    h5.setComponentAlignment(optionCBtn, Alignment.TOP_RIGHT);
    optionCBtn.setVisible(isEdit());
    form.addComponent(h5);

    HorizontalLayout h6 = new HorizontalLayout();
    h6.setCaption("Key C:");
    h6.setWidth("100%");
    h6.setSpacing(true);

    keyC = new CommonTextField("Enter a Key for Option C", null);
    keyC.setWidth("500px");
    h6.addComponent(keyC);

    Button keyCBtn = new CommonButton("KEY C");
    keyCBtn.setWidth("120px");
    keyCBtn.addClickListener(updateOptionAndKeyListerner);
    h6.addComponent(keyCBtn);
    h6.setComponentAlignment(keyCBtn, Alignment.MIDDLE_RIGHT);
    keyCBtn.setVisible(isEdit());
    form.addComponent(h6);

    HorizontalLayout h7 = new HorizontalLayout();
    h7.setCaption("Option D:");
    h7.setWidth("100%");
    h7.setSpacing(true);

    optionD = new CommonTextField("add option D", null);
    optionD.setWidth("500px");
    h7.addComponent(optionD);

    Button optionDBtn = new CommonButton("OPTION D");
    optionDBtn.setWidth("120px");
    optionDBtn.addClickListener(updateOptionAndKeyListerner);
    h7.addComponent(optionDBtn);
    h7.setComponentAlignment(optionDBtn, Alignment.MIDDLE_RIGHT);
    optionDBtn.setVisible(isEdit());
    form.addComponent(h7);

    HorizontalLayout h8 = new HorizontalLayout();
    h8.setCaption("Key D:");
    h8.setWidth("100%");
    h8.setSpacing(true);

    keyD = new CommonTextField("Enter a Key for Option D", null);
    keyD.setWidth("500px");
    h8.addComponent(keyD);

    Button keyDBtn = new CommonButton("KEY D");
    keyDBtn.setWidth("120px");
    keyDBtn.addClickListener(updateOptionAndKeyListerner);
    h8.addComponent(keyDBtn);
    h8.setComponentAlignment(keyDBtn, Alignment.MIDDLE_RIGHT);
    keyDBtn.setVisible(isEdit());
    form.addComponent(h8);

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

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

    Button remove = new Button("ARCHIVE/REMOVE ITEM?");
    remove.setWidth("200px");
    remove.setIcon(FontAwesome.ARCHIVE);
    remove.addStyleName(ValoTheme.BUTTON_PRIMARY);
    remove.addStyleName(ValoTheme.BUTTON_SMALL);
    remove.addClickListener(buttonClickListener);

    Button approve = new Button("APPROVE ITEM?");
    approve.setWidth("200px");
    approve.setIcon(FontAwesome.THUMBS_O_UP);
    approve.addStyleName(ValoTheme.BUTTON_PRIMARY);
    approve.addStyleName(ValoTheme.BUTTON_SMALL);
    approve.addClickListener(buttonClickListener);

    Button edit = new Button("UPDATE");
    edit.setWidth("200px");
    edit.setIcon(FontAwesome.SAVE);
    edit.addStyleName(ValoTheme.BUTTON_PRIMARY);
    edit.addStyleName(ValoTheme.BUTTON_SMALL);
    edit.addClickListener(buttonClickListener);

    if (getCellItemId() != 0) {
        CellItem ci = cis.getCellItemById(getCellItemId());
        bloomsTaxonomy.setValue(ci.getBloomsClassId());
        bloomsTaxonomy.addValueChangeListener((Property.ValueChangeEvent event) -> {
            isBloomsChanged = true;
        });

        stem.setValue(ci.getItem());
        stem.addTextChangeListener((FieldEvents.TextChangeEvent event) -> {
            if (!stem.getValue().trim().equals(event.getText().trim())) {
                isStemChanged = true;
            }
        });

        /**
         * OPTION A
         */
        optionA.setValue(ci.getOptionA());
        isOptionAKeyExist = k.isKeyExist(getCellItemId(), ci.getOptionA());
        if (isOptionAKeyExist) {
            keyA.setValue(k.getItemKey(getCellItemId(), ci.getOptionA()));
        }
        keyA.setData(k.getItemKeyId(getCellItemId(), ci.getOptionA()));

        /**
         * OPTION B
         */
        optionB.setValue(ci.getOptionB());
        isOptionBKeyExist = k.isKeyExist(getCellItemId(), ci.getOptionB());
        if (isOptionBKeyExist) {
            keyB.setValue(k.getItemKey(getCellItemId(), ci.getOptionB()));
        }
        keyB.setData(k.getItemKeyId(getCellItemId(), ci.getOptionB()));

        /**
         * OPTION C
         */
        optionC.setValue(ci.getOptionC());
        isOptionCKeyExist = k.isKeyExist(getCellItemId(), ci.getOptionC());
        if (isOptionCKeyExist) {
            keyC.setValue(k.getItemKey(getCellItemId(), ci.getOptionC()));
        }
        keyC.setData(k.getItemKeyId(getCellItemId(), ci.getOptionC()));

        /**
         * OPTION D
         */
        optionD.setValue(ci.getOptionD());
        isOptionDKeyExist = k.isKeyExist(getCellItemId(), ci.getOptionD());
        if (isOptionDKeyExist) {
            keyD.setValue(k.getItemKey(getCellItemId(), ci.getOptionD()));
        }
        keyD.setData(k.getItemKeyId(getCellItemId(), ci.getOptionD()));

        h.addComponent(remove);
        h.setComponentAlignment(remove, Alignment.MIDDLE_RIGHT);

        h.addComponent(approve);
        h.setComponentAlignment(approve, Alignment.MIDDLE_RIGHT);

        h.addComponent(edit);
        h.setComponentAlignment(edit, Alignment.MIDDLE_RIGHT);
        form.addComponent(h);
    } else {
        h.addComponent(save);
        h.setComponentAlignment(save, Alignment.MIDDLE_RIGHT);
        form.addComponent(h);
    }

    return form;
}

From source file:com.etest.view.testbank.cellitem.CellItemWindow.java

Window modifyCellItemWindow(CellItem ci) {
    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);/*from  w  ww.ja v a  2  s.c om*/
    v.setSpacing(true);

    Window sub = new Window("MODIFY");
    sub.setWidth("400px");
    sub.setModal(true);
    sub.center();

    ComboBox actionDone = new ComboBox("Action: ");
    actionDone.setWidth("70%");
    actionDone.addStyleName(ValoTheme.COMBOBOX_SMALL);
    actionDone.setNullSelectionAllowed(false);
    actionDone.addItem("resolved");
    actionDone.addItem("clarified");
    actionDone.addItem("modified");
    actionDone.setImmediate(true);
    v.addComponent(actionDone);

    TextArea remarks = new TextArea("Remarks: ");
    remarks.setWidth("100%");
    remarks.setRows(3);
    v.addComponent(remarks);

    Button modify = new Button("UPDATE");
    modify.setWidth("70%");
    modify.setIcon(FontAwesome.EDIT);
    modify.addStyleName(ValoTheme.BUTTON_PRIMARY);
    modify.addStyleName(ValoTheme.BUTTON_SMALL);
    modify.addClickListener((Button.ClickEvent event) -> {
        if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) {
            Notification.show("Add remarks!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (actionDone.getValue() == null) {
            Notification.show("Add action!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        ci.setRemarks(remarks.getValue().trim());
        ci.setActionDone(actionDone.getValue().toString());
        boolean result = cis.modifyCellItem(ci);
        if (result) {
            sub.close();
            close();
        }
    });
    v.addComponent(modify);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.etest.view.testbank.cellitem.CellItemWindow.java

Window modifyKeyWindow(int itemKeyId, int cellItemId, String keyValue, String optionValue,
        boolean isOptionKeyExist) {
    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);/*from w  w w  . j  ava 2 s .co  m*/
    v.setSpacing(true);

    Window sub = new Window("MODIFY");
    sub.setWidth("400px");
    sub.setModal(true);
    sub.center();

    ComboBox actionDone = new ComboBox("Action: ");
    actionDone.setWidth("70%");
    actionDone.addStyleName(ValoTheme.COMBOBOX_SMALL);
    actionDone.setNullSelectionAllowed(false);
    actionDone.addItem("resolved");
    actionDone.addItem("clarified");
    actionDone.addItem("modified");
    actionDone.setImmediate(true);
    v.addComponent(actionDone);

    TextArea remarks = new TextArea("Remarks: ");
    remarks.setWidth("100%");
    remarks.setRows(3);
    v.addComponent(remarks);

    Button modify = new Button("UPDATE");
    modify.setWidth("70%");
    modify.setIcon(FontAwesome.EDIT);
    modify.addStyleName(ValoTheme.BUTTON_PRIMARY);
    modify.addStyleName(ValoTheme.BUTTON_SMALL);
    modify.addClickListener((Button.ClickEvent event) -> {
        if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) {
            Notification.show("Add remarks!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (actionDone.getValue() == null) {
            Notification.show("Add action!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        boolean result = k.modifyItemKey(itemKeyId, cellItemId, keyValue, optionValue, isOptionKeyExist,
                remarks.getValue().trim(), actionDone.getValue().toString());
        if (result) {
            Notification.show("Key SUCCESSFULLY modified", Notification.Type.TRAY_NOTIFICATION);
            sub.close();
        }
    });
    v.addComponent(modify);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.etest.view.testbank.cellitem.ViewStemWindow.java

Table populateDataTable() {
    table.removeAllItems();//ww  w.  j  av a2s  .  c  o  m
    int i = 0;
    for (ItemKeys key : k.getItemKeysByCellItemId(getCellItemId())) {
        Button delete = new Button("remove");
        delete.setWidth("100%");
        delete.setData(key.getItemKeyId());
        delete.setIcon(FontAwesome.TRASH_O);
        delete.addStyleName(ValoTheme.BUTTON_LINK);
        delete.addStyleName(ValoTheme.BUTTON_TINY);
        delete.addStyleName(ValoTheme.BUTTON_QUIET);
        delete.addClickListener(removeBtnClickListener);

        table.addItem(new Object[] { key.getItemKey(), key.getAnswer(), delete }, i);
        i++;
    }
    table.setPageLength(table.size());

    return table;
}

From source file:com.etest.view.testbank.cellitem.ViewStemWindow.java

Window removeKeyWindow(int itemKeyId) {
    Window sub = new Window("REMOVE KEY");
    sub.setWidth("300px");
    sub.setModal(true);// w ww  .j a v a  2 s.c  o m
    sub.center();

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);

    Button remove = new Button("CONFIRM REMOVE KEY?");
    remove.setWidth("100%");
    remove.setIcon(FontAwesome.TRASH_O);
    remove.addStyleName(ValoTheme.BUTTON_PRIMARY);
    remove.addStyleName(ValoTheme.BUTTON_SMALL);
    remove.addClickListener((Button.ClickEvent event) -> {
        boolean result = k.removeItemKey(itemKeyId);
        if (result) {
            sub.close();
            close();
        }
    });
    v.addComponent(remove);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.etest.view.tq.reports.OnlineQueriesUI.java

public OnlineQueriesUI() {
    setWidth("100%");
    setMargin(true);//from   w w w .  ja  va2  s  .c  o m
    setSpacing(true);

    Label lineSeparator1 = new Label();
    lineSeparator1.setContentMode(ContentMode.HTML);
    lineSeparator1.setStyleName("line-separator");

    Label lineSeparator2 = new Label();
    lineSeparator2.setContentMode(ContentMode.HTML);
    lineSeparator2.setStyleName("line-separator");

    disableAllComponents(false);

    GridLayout topGrid = new GridLayout(3, 2);
    topGrid.setWidth("800px");
    topGrid.setSpacing(true);

    VerticalLayout top = new VerticalLayout();
    top.setWidth("166px");

    graphicalInventory.addItem("Graphical Inventory");
    graphicalInventory.setWidth("300px");
    top.addComponent(graphicalInventory);
    graphicalInventory.addValueChangeListener(firstLevelOptionListener);
    graphicalInventory.setImmediate(true);

    graphicalInventoryGroup.addItem("All Subjects");

    Label subjectProportionedCaption = new Label();
    subjectProportionedCaption.setWidth("500px");
    subjectProportionedCaption
            .setCaption("A Subject's No. of Items Proportioned " + "According to the Revised Bloom's Taxonomy");
    subjectProportionedCaption.setContentMode(ContentMode.HTML);
    subjectProportionedCaption.setHeightUndefined();

    graphicalInventoryGroup.addItem(subjectProportionedCaption.getCaption());
    graphicalInventoryGroup.setWidth("400px");
    graphicalInventoryGroup.addValueChangeListener(secondLevelTopOptionListener);
    graphicalInventoryGroup.setImmediate(true);

    topGrid.addComponent(top, 0, 0);
    topGrid.addComponent(graphicalInventoryGroup, 1, 0, 2, 0);
    addComponent(topGrid);

    searchSubject1.setInputPrompt("Search Subject");
    searchSubject1.setWidth("225px");
    searchSubject1.addValueChangeListener(dropDownChangeListener);
    searchSubject1.setEnabled(false);
    topGrid.addComponent(searchSubject1, 1, 1);

    addComponent(lineSeparator1);

    GridLayout bottomGrid = new GridLayout(3, 3);
    bottomGrid.setWidth("800px");
    bottomGrid.setSpacing(true);

    VerticalLayout bottom = new VerticalLayout();
    bottom.setWidth("235px");

    itemAnalysis.addItem("Item Analysis");
    itemAnalysis.setWidth("310px");
    bottom.addComponent(itemAnalysis);
    itemAnalysis.addValueChangeListener(firstLevelOptionListener);
    itemAnalysis.setImmediate(true);

    graphicalView.addItem("Graphical View");
    graphicalView.setWidth("210px");
    graphicalView.addValueChangeListener(secondLevelBottomOptionListener);
    graphicalView.setImmediate(true);

    tabularView.addItem("Tabular View");
    tabularView.addValueChangeListener(secondLevelBottomOptionListener);
    tabularView.setImmediate(true);

    graphicalViewGroup.addItem("Summary: All Tests of a Subject");
    graphicalViewGroup.addItem("Difficulty Index of a Subject's Test");
    graphicalViewGroup.addItem("Discrimination Index of a Subject's Test");
    graphicalViewGroup.setWidth("300px");
    graphicalViewGroup.addValueChangeListener(thirdLevelBottomOptionListener);
    graphicalViewGroup.setImmediate(true);

    tabularViewGroup.addItem("Summary: All Tests of a Subject");
    tabularViewGroup.addItem("Critical values of a test");
    tabularViewGroup.addValueChangeListener(thirdLevelBottomOptionListener);
    tabularViewGroup.setImmediate(true);

    searchSubject2.setInputPrompt("Search Subject");
    searchSubject2.setWidth("225px");
    searchSubject2.addValueChangeListener(dropDownChangeListener);
    searchSubject2.setEnabled(false);
    searchTest.setWidth("225px");
    searchTest.setInputPrompt("Search Test");
    searchTest.setEnabled(false);
    searchTest.addStyleName(ValoTheme.COMBOBOX_SMALL);

    bottomGrid.addComponent(bottom, 0, 0);
    bottomGrid.addComponent(graphicalView, 1, 0);
    bottomGrid.addComponent(tabularView, 1, 1);
    bottomGrid.addComponent(graphicalViewGroup, 2, 0);
    bottomGrid.addComponent(tabularViewGroup, 2, 1);
    bottomGrid.addComponent(searchSubject2, 1, 2);
    bottomGrid.addComponent(searchTest, 2, 2);
    addComponent(bottomGrid);

    addComponent(lineSeparator2);

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

    Button calculateAndViewBtn = new Button("Calculate & View");
    calculateAndViewBtn.setWidth("300px");
    calculateAndViewBtn.addClickListener(buttonClickListener);
    h.addComponent(calculateAndViewBtn);
    h.setComponentAlignment(calculateAndViewBtn, Alignment.MIDDLE_LEFT);
    addComponent(calculateAndViewBtn);

}

From source file:com.etest.view.tq.reports.ReportGeneratorUI.java

public ReportGeneratorUI() {
    setWidth("100%");
    setMargin(true);//from  www  .  j  a v a  2  s  .c om
    setSpacing(true);

    Label lineSeparator1 = new Label();
    lineSeparator1.setContentMode(ContentMode.HTML);
    lineSeparator1.setStyleName("line-separator");

    Label lineSeparator2 = new Label();
    lineSeparator2.setContentMode(ContentMode.HTML);
    lineSeparator2.setStyleName("line-separator");

    Label lineSeparator3 = new Label();
    lineSeparator3.setContentMode(ContentMode.HTML);
    lineSeparator3.setStyleName("line-separator");

    searchSubject1.addValueChangeListener(dropDownChangeListener);
    searchSubject1.setEnabled(false);
    searchApproveTq1.setWidth("100%");
    searchApproveTq1.setInputPrompt("Search Approved TQ");
    searchApproveTq1.setEnabled(false);
    searchApproveTq1.addStyleName(ValoTheme.COMBOBOX_SMALL);

    searchSubject2.addValueChangeListener(dropDownChangeListener);
    searchSubject2.setEnabled(false);
    searchApproveTq2.setWidth("100%");
    searchApproveTq2.setInputPrompt("Search TQ Ticket No.");
    searchApproveTq2.setEnabled(false);
    searchApproveTq2.addStyleName(ValoTheme.COMBOBOX_SMALL);

    GridLayout g1 = new GridLayout(3, 1);
    g1.setWidth("70%");
    g1.setSpacing(true);

    VerticalLayout v1 = new VerticalLayout();
    v1.setWidth("5px");

    reportType1.addItem("Test Questionnaire");
    reportType1.setWidth("200px");
    reportType1.addValueChangeListener(optionChangeListener);
    reportType1.setImmediate(true);
    v1.addComponent(reportType1);
    v1.setExpandRatio(reportType1, 1);
    g1.addComponent(v1, 0, 0);
    g1.addComponent(searchSubject1, 1, 0);
    g1.addComponent(searchApproveTq1, 2, 0);

    addComponent(g1);

    addComponent(lineSeparator1);

    GridLayout g2 = new GridLayout(3, 1);
    g2.setWidth("70%");
    g2.setSpacing(true);

    VerticalLayout v2 = new VerticalLayout();
    v2.setWidth("5px");

    reportType2.addItem("Item Analysis");
    reportType2.setWidth("200px");
    reportType2.addValueChangeListener(optionChangeListener);
    reportType2.setImmediate(true);
    v2.addComponent(reportType2);
    v2.setExpandRatio(reportType2, 1);
    g2.addComponent(v2, 0, 0);
    g2.addComponent(searchSubject2, 1, 0);
    g2.addComponent(searchApproveTq2, 2, 0);

    addComponent(g2);

    addComponent(lineSeparator2);

    GridLayout g3 = new GridLayout(3, 1);
    g3.setWidth("70%");
    g3.setSpacing(true);

    VerticalLayout v3 = new VerticalLayout();
    v3.setWidth("5px");

    reportType3.addItem("Test Bank Inventory");
    reportType3.setWidth("200px");
    reportType3.addValueChangeListener(optionChangeListener);
    reportType3.setImmediate(true);

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setSpacing(true);

    testBankInventory.addItem("Summary: Case vs Items");
    testBankInventory.addItem("Summary: Items Group according to the Revised Blooms Taxonomy");
    testBankInventory.setImmediate(true);
    testBankInventory.select("Summary: Case vs Items");

    testBankInventory.setEnabled(false);
    v.addComponent(testBankInventory);

    v3.addComponent(reportType3);
    v3.setExpandRatio(reportType3, 1);
    g3.addComponent(v3, 0, 0);
    g3.setComponentAlignment(v3, Alignment.TOP_LEFT);
    g3.addComponent(v, 1, 0);
    addComponent(g3);

    //        addComponent(new Label("<HR>", ContentMode.HTML));
    addComponent(lineSeparator3);

    Button button = new Button("Calculate & Generate");
    button.addClickListener(reportBtnClickListener);
    button.setWidth("300px");

    addComponent(button);
    setComponentAlignment(button, Alignment.MIDDLE_LEFT);
}

From source file:com.etest.view.tq.TQCoverageUI.java

public TQCoverageUI() {
    setSizeFull();//from w w  w.j a  va  2 s  . co m

    addComponent(buildTQCoverageForms());
    addComponent(grid);

    footer = grid.appendFooterRow();

    grid.addItemClickListener((ItemClickEvent event) -> {
        Object itemId = event.getItemId();
        Item item = grid.getContainerDataSource().getItem(itemId);

        if (event.getPropertyId().toString().equals("Topic")) {
            Window sub = getTopicWindow(item);
            if (sub.getParent() == null) {
                UI.getCurrent().addWindow(sub);
            }
        }

        Window sub;
        if (event.getPropertyId().toString().contains("Pick")) {
            boolean isValueInTBNotZero = tq.isValueInTBNotZero(item,
                    CommonUtilities.replaceStringPickToTB(event.getPropertyId()));
            if (!isValueInTBNotZero) {
                Notification.show("There are no Items in Test Bank!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                sub = getPickWindow(item, CommonUtilities.replaceStringPickToTB(event.getPropertyId()));
                if (sub.getParent() == null) {
                    UI.getCurrent().addWindow(sub);
                }
                sub.addCloseListener((Window.CloseEvent e) -> {
                    if (tq.calculateTotalPickItemsPerTopic(grid, itemId) > CommonUtilities
                            .convertStringToDouble(item.getItemProperty("Max Items").getValue().toString())) {
                        item.getItemProperty(event.getPropertyId()).setValue(0);
                        ShowErrorNotification.error("Running Total is greater than Max Items");
                    } else {
                        item.getItemProperty("Running Total")
                                .setValue(tq.calculateTotalPickItemsPerTopic(grid, itemId));
                        footer.getCell("Running Total").setText(String.valueOf(tq.calculateRunningTotal(grid)));
                    }
                });
            }
        }

        if (event.getPropertyId().toString().equals("Max Items")) {
            double value = (double) item.getItemProperty("Max Items").getValue();
            sub = getMaxItemsWindow(item, value);
            if (sub.getParent() == null) {
                UI.getCurrent().addWindow(sub);
            }
        }
    });

    grid.getColumn("remove")
            .setRenderer(new DeleteButtonValueRenderer((ClickableRenderer.RendererClickEvent event) -> {
                grid.getContainerDataSource().removeItem(event.getItemId());
                populateGridFooter();
                footer.getCell("Running Total").setText(String.valueOf(tq.calculateRunningTotal(grid)));
            })).setWidth(100);

    footer.getCell("Topic").setText("Total");
    footer.setStyleName("align-center");

    Button generateTQ = new Button("Generate TQ");
    generateTQ.setWidth("300px");
    generateTQ.addClickListener(buttonClickListener);

    addComponent(new Label("\n"));
    addComponent(generateTQ);
    setComponentAlignment(generateTQ, Alignment.MIDDLE_RIGHT);
}

From source file:com.etest.view.tq.TQCoverageUI.java

Component buildTQCoverageForms() {
    FormLayout form = new FormLayout();
    form.setWidth("500px");

    examTitle.setCaption("Exam Title: ");
    examTitle.setWidth("100%");
    examTitle.setIcon(FontAwesome.TAG);/*from   w w w.ja  v a  2  s.  co  m*/
    examTitle.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    form.addComponent(examTitle);

    subject.setCaption("Subject: ");
    subject.setWidth("100%");
    subject.setIcon(FontAwesome.BOOK);
    subject.addStyleName(ValoTheme.COMBOBOX_SMALL);
    subject.addValueChangeListener((new CurriculumPropertyChangeListener(topic)));
    form.addComponent(subject);

    totalItems.setCaption("No. of Test Items: ");
    totalItems.setWidth("50%");
    totalItems.setValue("0");
    totalItems.setIcon(FontAwesome.TAG);
    totalItems.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    totalItems.addValueChangeListener(fieldValueListener);
    form.addComponent(totalItems);

    Button button = new Button("ADD ROW");
    button.setWidth("50%");
    button.setIcon(FontAwesome.GEAR);
    button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener((Button.ClickEvent event) -> {
        if (examTitle.getValue() == null || examTitle.getValue().trim().isEmpty()) {
            Notification.show("Select an Exam Title!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (subject.getValue() == null) {
            Notification.show("Select a Subject!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (totalItems.getValue() == null || totalItems.getValue().trim().isEmpty()) {
            Notification.show("Enter No. of Test Items!", Notification.Type.WARNING_MESSAGE);
            return;
        }

        grid.addRow(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
                null, null, null, null, null, null, null, null, null, null, null, null, null, null, "del");
    });
    form.addComponent(button);

    return form;
}