Example usage for com.vaadin.ui Button addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

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

Table populateDataTable() {
    table.removeAllItems();//from   www  .java2s .c  om
    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);/*from w w w. j  av  a 2s .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.itemanalysis.FileUploadWindow.java

Button viewTableProportion() {
    Button button = new Button("View Proportion Table");
    button.setWidthUndefined();//from ww  w.  j a v  a  2 s .com
    button.addStyleName(ValoTheme.BUTTON_LINK);
    button.addClickListener((Button.ClickEvent event) -> {
        Window sub = new ProportionDataTable(getStudentNoAndAnswer(), getUpperGroupStudentNo(),
                getLowerGroupStudentNo(), tq.getCellItemIdByTQCoverageId(getTqCoverageId()), getTqCoverageId(),
                getGroupTotalForProportion());
        if (sub.getParent() == null) {
            UI.getCurrent().addWindow(sub);
        }
    });

    return button;
}

From source file:com.etest.view.tq.itemanalysis.FileUploadWindow.java

Button viewStudentsTotalScore() {
    Button button = new Button("View Students Total Scores");
    button.setWidthUndefined();//from   w  w w  .  j  a v  a  2s . co m
    button.addStyleName(ValoTheme.BUTTON_LINK);
    button.addClickListener((Button.ClickEvent event) -> {
        Window sub = new StudentsTotalScoreWindow(getStudentNoAndTotalScore());
        if (sub.getParent() == null) {
            UI.getCurrent().addWindow(sub);
        }
    });
    return button;
}

From source file:com.etest.view.tq.itemanalysis.FileUploadWindow.java

Button approveItemAnalysis() {
    Button button = new Button("Approve Item Analysis");
    button.setWidthUndefined();//  ww w. j a  v a  2s.  c o  m
    button.addStyleName(ValoTheme.BUTTON_LINK);
    button.addClickListener((Button.ClickEvent event) -> {
        boolean result = tq.saveItemAnalysis(getItemAnalysisGrid(), getTqCoverageId());
        if (result) {
            close();
        }
    });

    return button;
}

From source file:com.etest.view.tq.itemanalysis.TQItemAnalysisUI.java

public Table populateDataTable() {
    removeAllItems();/*from  w  ww. j a v a 2  s  . com*/
    int i = 0;
    for (TQCoverage t : tq.getAllTQCoverage()) {
        VerticalLayout v = new VerticalLayout();
        v.setWidth("100%");

        Button analyze = new Button();
        analyze.setWidthUndefined();
        analyze.setData(t.getTqCoverageId());
        analyze.setCaption((t.getAnalyzed() == 0) ? "Unanalyze" : "Analyzed");
        analyze.setIcon(FontAwesome.BULLSEYE);
        analyze.addStyleName(ValoTheme.BUTTON_LINK);
        analyze.addStyleName(ValoTheme.BUTTON_TINY);
        analyze.addStyleName(ValoTheme.BUTTON_QUIET);
        analyze.addStyleName("button-container");
        analyze.setEnabled(t.getAnalyzed() == 0);
        analyze.addClickListener(buttonClickListener);
        v.addComponent(analyze);
        v.setComponentAlignment(analyze, Alignment.MIDDLE_LEFT);

        Button view = new Button("View");
        view.setWidthUndefined();
        view.setData(t.getTqCoverageId());
        view.setIcon(FontAwesome.VIDEO_CAMERA);
        view.addStyleName(ValoTheme.BUTTON_LINK);
        view.addStyleName(ValoTheme.BUTTON_TINY);
        view.addStyleName(ValoTheme.BUTTON_QUIET);
        view.addStyleName("button-container");
        view.setVisible((t.getAnalyzed() != 0));
        view.addClickListener(buttonClickListener);
        v.addComponent(view);
        v.setComponentAlignment(view, Alignment.MIDDLE_LEFT);

        addItem(new Object[] { t.getExamTitle(), cs.getCurriculumById(t.getCurriculumId()).getSubject(),
                t.getDateCreated(), t.getTotalHoursCoverage(), t.getTotalItems(), v }, i);
        i++;
    }
    setPageLength(size());

    return this;
}

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 ww  .  j  av  a2  s .com*/
    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;
}

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

Window getTopicWindow(Item item) {
    Window sub = new Window("TOPIC: ");
    sub.setWidth("500px");
    sub.setModal(true);/*from   w w w  . ja  va  2 s .  c o m*/
    sub.center();
    sub.setResizable(false);

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

    topic.setInputPrompt("Select a Topic..");
    topic.addStyleName(ValoTheme.COMBOBOX_SMALL);
    topic.setWidth("100%");
    topic.addValueChangeListener((Property.ValueChangeEvent event) -> {
        if (event.getProperty().getValue() == null) {
        } else {
            syllabusId = (int) event.getProperty().getValue();
            topicStr = topic.getItem(topic.getValue()).toString();
        }
    });
    v.addComponent(topic);

    Button button = new Button("CLOSE");
    button.setWidth("50%");
    button.setIcon(FontAwesome.TASKS);
    button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener((Button.ClickEvent event) -> {
        if (topic.getValue() == null) {
            Notification.show("Select a Topic!", Notification.Type.WARNING_MESSAGE);
        } else {
            populateGridRow(item);
            populateGridFooter();
        }
        sub.close();
    });
    v.addComponent(button);
    v.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);

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

    return sub;
}

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

Window getPickWindow(Item item, String propertyId) {
    Window sub = new Window("Field Value: ");
    sub.setWidth("150px");
    sub.setModal(true);//w ww  . j  a  v a  2s .  co  m
    sub.center();
    sub.setResizable(false);

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

    TextField field = new CommonTextField("Enter Value..", "Enter a Value: ");
    v.addComponent(field);

    Button button = new Button("CLOSE");
    button.setWidth("100%");
    button.setIcon(FontAwesome.TASKS);
    button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener((Button.ClickEvent event) -> {
        boolean isNumeric = CommonUtilities.isNumeric(field.getValue().trim());
        if (!isNumeric) {
            return;
        }

        boolean isGreaterThanInTB = tq.isGreaterThanInTB(item, propertyId, field.getValue().trim());
        if (isGreaterThanInTB) {
            Notification.show("Not allowed to exceed in total Items in Test Bank!",
                    Notification.Type.ERROR_MESSAGE);
            return;
        } else {
            item.getItemProperty(CommonUtilities.replaceStringTBToPick(propertyId))
                    .setValue(CommonUtilities.convertStringToInt(field.getValue()));
            footer.getCell(CommonUtilities.replaceStringTBToPick(propertyId)).setText(String.valueOf(
                    tq.calculateTotalPickItems(grid, CommonUtilities.replaceStringTBToPick(propertyId))));
        }
        sub.close();
    });
    v.addComponent(button);
    v.setComponentAlignment(button, Alignment.BOTTOM_CENTER);

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

    return sub;
}

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

Window getMaxItemsWindow(Item item, double previousValue) {
    Window sub = new Window("Field Value: ");
    sub.setWidth("150px");
    sub.setModal(true);/*from   w  ww .  j av a2 s . c o m*/
    sub.center();
    sub.setResizable(false);

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

    TextField field = new CommonTextField("Enter Value..", "Enter a Value: ");
    v.addComponent(field);

    Button button = new Button("CLOSE");
    button.setWidth("100%");
    button.setIcon(FontAwesome.TASKS);
    button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener((Button.ClickEvent event) -> {
        boolean isNumeric = CommonUtilities.isNumeric(field.getValue().trim());
        if (!isNumeric) {
            return;
        }

        item.getItemProperty("Max Items").setValue(CommonUtilities.convertStringToDouble(field.getValue()));
        if (tq.calculateTotalMaxItems(grid) == CommonUtilities
                .convertStringToDouble(totalItems.getValue().trim())) {
            footer.getCell("Max Items").setText(String.valueOf(tq.calculateTotalMaxItems(grid)));
        } else {
            item.getItemProperty("Max Items").setValue(previousValue);
            footer.getCell("Max Items").setText(String.valueOf(tq.calculateTotalMaxItems(grid)));
            ShowErrorNotification.warning("Total Max Items should be equal to Total Test Items");
            return;
        }

        sub.close();
    });
    v.addComponent(button);
    v.setComponentAlignment(button, Alignment.BOTTOM_CENTER);

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

    return sub;
}