Example usage for com.vaadin.ui FormLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

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

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);//from  w ww.  j  a  va 2 s  .  c om
    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.ViewStemWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);//from  w  w  w .ja va2s. co  m
    form.setSpacing(true);

    CellItem ci = cis.getCellItemById(getCellItemId());
    if (ci.getCellItemId() == 0) {
        ci = hs.getCellItemById(getCellItemId());
    }

    keyList = k.getAllItemKey(getCellItemId());
    keyIndexSize = keyList.size();
    if (keyList.isEmpty()) {
        ShowErrorNotification.error("No Item Key was found for STEM: \n" + ci.getItem());
        return null;
    }
    stem = ci.getItem().replace("{key}", "<u>" + keyList.get(getKeyIndex()) + "</u>");

    label.setValue("<b>STEM</b>: " + getStem());
    label.setContentMode(ContentMode.HTML);
    form.addComponent(label);

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

    OptionGroup options = new OptionGroup();
    options.addItems(ci.getOptionA(), ci.getOptionB(), ci.getOptionC(), ci.getOptionD());
    options.addValueChangeListener((Property.ValueChangeEvent event) -> {
        boolean result = k.isAnswerCorrect(getCellItemId(), getItemKey(),
                CommonUtilities.escapeSingleQuote(event.getProperty().getValue()));
        if (result) {
            Notification.show("Correct Answer!", Notification.Type.TRAY_NOTIFICATION);
        } else {
            Notification.show("Wrong Answer", Notification.Type.TRAY_NOTIFICATION);
        }
    });
    h1.addComponent(options);
    h1.setComponentAlignment(options, Alignment.MIDDLE_CENTER);
    form.addComponent(h1);

    GridLayout g = new GridLayout(2, 2);
    g.setWidth("100%");
    g.setSpacing(true);

    prev = new Button();
    prev.setWidth("50px");
    prev.setIcon(FontAwesome.ANGLE_DOUBLE_LEFT);
    prev.addStyleName(ValoTheme.BUTTON_PRIMARY);
    prev.addStyleName(ValoTheme.BUTTON_SMALL);
    prev.addClickListener(prevBtnClickListener);
    g.addComponent(prev, 0, 0);
    g.setComponentAlignment(prev, Alignment.MIDDLE_LEFT);

    next = new Button();
    next.setWidth("50px");
    next.setIcon(FontAwesome.ANGLE_DOUBLE_RIGHT);
    next.addStyleName(ValoTheme.BUTTON_PRIMARY);
    next.addStyleName(ValoTheme.BUTTON_SMALL);
    next.addClickListener(nextBtnClickListener);
    g.addComponent(next, 1, 0);
    g.setComponentAlignment(next, Alignment.MIDDLE_RIGHT);

    if (getKeyIndexSize() == 1) {
        prev.setEnabled(false);
        next.setEnabled(false);
    }

    populateDataTable();
    g.addComponent(table, 0, 1, 1, 1);
    g.setComponentAlignment(table, Alignment.MIDDLE_CENTER);
    form.addComponent(g);

    return form;
}

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);//  ww w  .  j  a va2s  .c o 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;
}

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

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);//www.  j  a  v a  2s. com

    int itemNo = 1;
    Label caseTopic;
    Label stem;
    Map<Integer, Map<Integer, Integer>> tqCoverage = tq.getTQCoverage(getTQCoverageId());
    for (Map.Entry<Integer, Map<Integer, Integer>> tqCases : tqCoverage.entrySet()) {
        Integer tqCaseId = tqCases.getKey();

        caseTopic = new Label();
        caseTopic.setValue(ccs.getCellCaseById(tqCaseId).getCaseTopic());
        caseTopic.setContentMode(ContentMode.HTML);
        form.addComponent(caseTopic);

        Map<Integer, Integer> value = tqCases.getValue();
        for (Map.Entry<Integer, Integer> itemIds : value.entrySet()) {
            Integer itemId = itemIds.getKey();
            Integer itemKeyId = itemIds.getValue();

            List<String> keyList = k.getAllItemKey(itemId);
            if (keyList.isEmpty()) {
                ShowErrorNotification
                        .error("No Item Key was found for STEM: \n" + cis.getCellItemById(itemId).getItem());
                return null;
            }

            stem = new Label();
            //                stem.setValue(itemNo+". "+cis.getCellItemById(itemId).getItem().replace("{key}", keyList.get(0)));
            stem.setValue(itemNo + ". "
                    + cis.getCellItemById(itemId).getItem().replace("{key}", k.getItemKeyById(itemKeyId)));
            stem.setContentMode(ContentMode.HTML);
            form.addComponent(stem);

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

            glayout.addComponent(new Label("A) " + cis.getCellItemById(itemId).getOptionA(), ContentMode.HTML),
                    0, 0);
            glayout.addComponent(new Label("C) " + cis.getCellItemById(itemId).getOptionC(), ContentMode.HTML),
                    0, 1);
            glayout.addComponent(new Label("B) " + cis.getCellItemById(itemId).getOptionB(), ContentMode.HTML),
                    1, 0);
            glayout.addComponent(new Label("D) " + cis.getCellItemById(itemId).getOptionD(), ContentMode.HTML),
                    1, 1);
            form.addComponent(glayout);

            itemNo++;
        }
    }

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

    Button delete = new Button("DELETE");
    delete.setWidth("200px");
    delete.setIcon(FontAwesome.TRASH_O);
    delete.addStyleName(ValoTheme.BUTTON_PRIMARY);
    delete.addStyleName(ValoTheme.BUTTON_SMALL);
    delete.addClickListener(buttonClickListener);
    h.addComponent(delete);

    Button approve = new Button("APPROVE");
    approve.setWidth("200px");
    approve.setIcon(FontAwesome.THUMBS_UP);
    approve.addStyleName(ValoTheme.BUTTON_PRIMARY);
    approve.addStyleName(ValoTheme.BUTTON_SMALL);
    approve.addClickListener(buttonClickListener);
    h.addComponent(approve);

    if (tq.isTQCoverageApproved(getTQCoverageId())) {
        approve.setVisible(false);
    } else {
        approve.setVisible(true);
    }

    form.addComponent(h);

    return form;
}

From source file:com.fnc.view.ui.AlphaListMainUI.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("50%");

    corporation.setCaption("Corporation: ");
    corporation.addStyleName(ValoTheme.COMBOBOX_SMALL);
    trade.setCaption("Trade: ");
    trade.addStyleName(ValoTheme.COMBOBOX_SMALL);
    branch.setCaption("Branch: ");
    branch.addStyleName(ValoTheme.COMBOBOX_SMALL);

    corporation.addValueChangeListener(new CorporateComboBoxPropertyListener(trade, trade.getCaption()));
    form.addComponent(corporation);//w w  w .j av a2s.c om

    trade.addValueChangeListener(new CorporateComboBoxPropertyListener(branch, branch.getCaption()));
    form.addComponent(trade);

    branch.addValueChangeListener(branchPropertyChangeListener);
    form.addComponent(branch);

    HorizontalLayout h = new HorizontalLayout();
    h.setCaption("Year: ");
    h.setWidth("100%");
    h.setSpacing(true);

    h.addComponent(selectYear());
    h.addComponent(alphaListButton());

    form.addComponent(h);

    return form;
}

From source file:com.fnc.view.ui.thirteenth.ThirteenthMonthUI.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("50%");

    corporation.setCaption("Corporation: ");
    corporation.addStyleName(ValoTheme.COMBOBOX_SMALL);
    trade.setCaption("Trade: ");
    trade.addStyleName(ValoTheme.COMBOBOX_SMALL);
    branch.setCaption("Branch: ");
    branch.addStyleName(ValoTheme.COMBOBOX_SMALL);

    corporation.addValueChangeListener(new CorporateComboBoxPropertyListener(trade, trade.getCaption()));
    form.addComponent(corporation);/*ww  w.  ja v  a 2  s .c  om*/

    trade.addValueChangeListener(new CorporateComboBoxPropertyListener(branch, branch.getCaption()));
    form.addComponent(trade);

    branch.addValueChangeListener(branchPropertyChangeListener);
    form.addComponent(branch);

    HorizontalLayout h = new HorizontalLayout();
    h.setCaption("Year: ");
    h.setWidth("100%");
    h.setSpacing(true);

    h.addComponent(selectYear());
    h.addComponent(button());

    form.addComponent(h);

    return form;
}

From source file:com.hivesys.dashboard.view.preferences.PreferencesView.java

License:Apache License

public PreferencesView() {

    user = (User) VaadinSession.getCurrent().getAttribute(User.class.getName());

    setSpacing(true);/*w w w  .j a va  2s.c o  m*/
    setMargin(true);

    Label title = new Label("Forms");
    title.addStyleName("h1");
    addComponent(title);

    final FormLayout form = new FormLayout();
    form.setMargin(false);
    form.setWidth("800px");
    form.addStyleName("light");
    addComponent(form);

    Label section = new Label("Personal Info");
    section.addStyleName("h2");
    section.addStyleName("colored");
    form.addComponent(section);

    firstNameField = new TextField("First Name");
    firstNameField.setWidth("50%");
    form.addComponent(firstNameField);

    lastNameField = new TextField("Last Name");
    lastNameField.setWidth("50%");
    form.addComponent(lastNameField);

    titleField = new ComboBox("Title");
    titleField.setInputPrompt("Please specify");
    titleField.addItem("Mr.");
    titleField.addItem("Mrs.");
    titleField.addItem("Ms.");
    titleField.setNewItemsAllowed(true);
    form.addComponent(titleField);

    usernameField = new TextField("Username");
    usernameField.setRequired(true);
    form.addComponent(usernameField);

    sexField = new OptionGroup("Sex");
    sexField.addItem(Boolean.FALSE);
    sexField.setItemCaption(Boolean.FALSE, "Female");
    sexField.addItem(Boolean.TRUE);
    sexField.setItemCaption(Boolean.TRUE, "Male");
    sexField.addStyleName("horizontal");
    form.addComponent(sexField);

    section = new Label("Contact Info");
    section.addStyleName("h3");
    section.addStyleName("colored");
    form.addComponent(section);

    emailField = new TextField("Email");
    emailField.setWidth("50%");
    emailField.setRequired(true);
    form.addComponent(emailField);

    locationField = new TextField("Location");
    locationField.setWidth("50%");
    locationField.setNullRepresentation("");
    form.addComponent(locationField);

    phoneField = new TextField("Phone");
    phoneField.setWidth("50%");
    phoneField.setNullRepresentation("");
    form.addComponent(phoneField);

    section = new Label("Additional Info");
    section.addStyleName("h4");
    section.addStyleName("colored");
    form.addComponent(section);

    websiteField = new TextField("Website");
    websiteField.setInputPrompt("http://");
    websiteField.setWidth("100%");
    form.addComponent(websiteField);

    bioField = new RichTextArea("Bio");
    bioField.setWidth("100%");
    bioField.setValue(
            "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi  dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>");
    form.addComponent(bioField);

    Button edit = new Button("Edit", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            boolean readOnly = form.isReadOnly();
            if (readOnly) {
                bioField.setReadOnly(false);
                form.setReadOnly(false);
                form.removeStyleName("light");
                event.getButton().setCaption("Save");
                event.getButton().addStyleName("primary");
            } else {
                bioField.setReadOnly(true);
                form.setReadOnly(true);
                form.addStyleName("light");
                event.getButton().setCaption("Edit");
                event.getButton().removeStyleName("primary");
            }
        }
    });

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, false, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    form.addComponent(footer);
    footer.addComponent(edit);

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

    fieldGroup = new BeanFieldGroup<>(User.class);
    fieldGroup.bindMemberFields(this);
    fieldGroup.setItemDataSource(user);

    form.setReadOnly(true);
    bioField.setReadOnly(true);

}

From source file:com.jain.common.authenticate.LoginAction.java

License:Apache License

private void createFieldGroup(VerticalLayout layout) {
    I18NProvider provider = DefaultI18NResourceProvider.instance();

    userName = new TextField("user.name");
    userName.setCursorPosition(0);/*from  w  w  w .  j  a v  a 2s.  c om*/
    userName.setRequired(true);
    userName.setRequiredError(provider.getMessage(getLocale(), "common.something.required", "user.name.title",
            JAction.LOGIN.getDisplayName()));
    userName.setDescription("user.name");
    userName.setSizeFull();
    userName.setStyleName(JNStyleConstants.J_FIELD);

    password = new PasswordField("password");
    password.setRequired(true);
    password.setRequiredError(provider.getMessage(getLocale(), "common.something.required", "password.title",
            JAction.LOGIN.getDisplayName()));
    password.setDescription("password");
    password.setSizeFull();
    password.setStyleName(JNStyleConstants.J_FIELD);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setStyleName(ApplicationTheme.VIEW);
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);
    verticalLayout.setWidth("100%");

    FormLayout formLayout = new FormLayout();
    formLayout.setStyleName(ApplicationTheme.ALTERNATE_VIEW);
    formLayout.setSpacing(true);
    formLayout.setMargin(true);
    formLayout.setWidth("100%");
    formLayout.addComponent(userName);
    formLayout.addComponent(password);

    verticalLayout.addComponent(formLayout);

    layout.addComponent(verticalLayout);
}

From source file:com.oodrive.nuage.webui.component.DeviceItemComponent.java

License:Apache License

/**
 * Create the component to take a snapshot.
 * /*ww  w.  j av  a 2  s. co  m*/
 * @return the component
 */
@SuppressWarnings("serial")
private final AbstractComponent createTakeSnap() {

    final VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);

    final FormLayout takeSnapLayout = new FormLayout();
    takeSnapLayout.setMargin(true);
    takeSnapLayout.setImmediate(true);
    takeSnapLayout.setWidth(null);
    layout.addComponent(takeSnapLayout);
    layout.setComponentAlignment(takeSnapLayout, Alignment.MIDDLE_CENTER);

    // Enter name
    final TextField vvrName = new TextField("Name", "");
    takeSnapLayout.addComponent(vvrName);

    // take button
    final Button take = new Button("Take snapshot");
    layout.addComponent(take);
    layout.setComponentAlignment(take, Alignment.MIDDLE_CENTER);

    take.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                model.takeDeviceSnapshot(vvrName.getValue());
                Notification.show("New snapshot created", Notification.Type.TRAY_NOTIFICATION);
            } catch (final Exception e) {
                final ErrorWindow err = new ErrorWindow("Snapshot not taken: " + e.getMessage());
                err.add(model);
            }
        }
    });
    return layout;
}

From source file:com.oodrive.nuage.webui.component.DeviceItemComponent.java

License:Apache License

/**
 * Create attributes component.//from w  w w .j  a v  a  2s.c  o  m
 * 
 * @return the component
 */
private final AbstractComponent createAttributes() {

    final VerticalLayout layout = new VerticalLayout();

    final FormLayout deviceAttributesLayout = new FormLayout();
    deviceAttributesLayout.setMargin(true);
    deviceAttributesLayout.setWidth(null);
    deviceAttributesLayout.setImmediate(true);
    layout.addComponent(deviceAttributesLayout);
    layout.setComponentAlignment(deviceAttributesLayout, Alignment.MIDDLE_CENTER);

    // Enter NAME
    WebUiUtils.createFieldString(new StringAttributeOperation() {
        @Override
        public void setStringValue(final String value) {
            model.setDeviceName(value);
        }

        @Override
        public String getStringValue() {
            return model.getDeviceName();
        }
    }, "Name", deviceAttributesLayout, model);

    // Enter DESCRIPTION
    WebUiUtils.createFieldString(new StringAttributeOperation() {
        @Override
        public void setStringValue(final String value) {
            model.setDeviceDescription(value);
        }

        @Override
        public String getStringValue() {
            return model.getDeviceDescription();
        }
    }, "Description", deviceAttributesLayout, model);

    // Enter UUID (not editable)
    final TextField deviceUUID = new TextField("UUID", model.getItemUuid().toString());
    deviceUUID.setReadOnly(true);
    deviceUUID.setWidth("300px");
    deviceAttributesLayout.addComponent(deviceUUID);

    // Enter active
    final TextField deviceActive = new TextField("Active");
    if (model.isDeviceActive()) {
        deviceActive.setValue("yes");
    } else {
        deviceActive.setValue("no");
    }
    deviceActive.setReadOnly(true);
    deviceActive.setSizeFull();
    deviceAttributesLayout.addComponent(deviceActive);

    // Enter read only
    final TextField deviceReadOnly = new TextField("Read Only");
    if (model.isDeviceReadOnly()) {
        deviceReadOnly.setValue("yes");
    } else {
        deviceReadOnly.setValue("no");
    }
    deviceReadOnly.setReadOnly(true);
    deviceReadOnly.setSizeFull();
    deviceAttributesLayout.addComponent(deviceReadOnly);

    // Enter size
    WebUiUtils.createFieldLong(new LongAttributeOperation() {
        @Override
        public void setLongValue(final long value) {
            model.setDeviceSize(value);
        }

        @Override
        public long getLongValue() {
            return model.getDeviceSize();
        }

    }, "Size", deviceAttributesLayout, model);

    // Enter IQN
    WebUiUtils.createFieldString(new StringAttributeOperation() {
        @Override
        public void setStringValue(final String value) {
            model.setDeviceIqn(value);
        }

        @Override
        public String getStringValue() {
            return model.getDeviceIqn();
        }
    }, "IQN", deviceAttributesLayout, model);

    // Enter Alias
    WebUiUtils.createFieldString(new StringAttributeOperation() {
        @Override
        public void setStringValue(final String value) {
            model.setDeviceIscsiAlias(value);
        }

        @Override
        public String getStringValue() {
            return model.getDeviceIscsiAlias();
        }
    }, "iSCSI Alias", deviceAttributesLayout, model);

    // Enter iscsi block size
    WebUiUtils.createFieldInteger(new IntegerAttributeOperation() {
        @Override
        public void setIntegerValue(final int value) {
            model.setDeviceIscsiBlockSize(value);
        }

        @Override
        public int getIntegerValue() {
            return model.getDeviceIscsiBlockSize();
        }

    }, "iSCSI Block Size", deviceAttributesLayout, model, true);
    return layout;
}