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:annis.gui.ShareSingleMatchGenerator.java

License:Apache License

public ShareSingleMatchGenerator(List<ResolverEntry> visualizers, Match match, PagedResultQuery query,
        String segmentation, PluginSystem ps) {
    this.match = match;
    this.query = query;
    this.segmentation = segmentation;
    this.ps = ps;

    setResizeLazy(true);/*from w w  w . java2 s .  c om*/

    directURL = new ObjectProperty<>("");
    iframeCode = new ObjectProperty<>("");

    visContainer = new BeanItemContainer<>(ResolverEntry.class);
    visContainer.addAll(visualizers);

    txtDirectURL = new TextArea(directURL);
    txtDirectURL.setCaption("Link for publications");
    txtDirectURL.setWidth("100%");
    txtDirectURL.setHeight("-1px");
    txtDirectURL.addStyleName(ValoTheme.TEXTFIELD_LARGE);
    txtDirectURL.addStyleName("shared-text");
    txtDirectURL.setWordwrap(true);
    txtDirectURL.setReadOnly(true);

    txtIFrameCode = new TextArea(iframeCode);
    txtIFrameCode.setCaption("Code for embedding visualization into web page");
    txtIFrameCode.setWidth("100%");
    txtIFrameCode.setHeight("-1px");
    txtIFrameCode.addStyleName(ValoTheme.TEXTFIELD_LARGE);
    txtIFrameCode.addStyleName("shared-text");
    txtIFrameCode.setWordwrap(true);
    txtIFrameCode.setReadOnly(true);

    preview = new BrowserFrame();
    preview.setCaption("Preview");
    preview.addStyleName("shared-text");
    preview.setSizeFull();

    generatedLinks = new VerticalLayout(txtDirectURL, txtIFrameCode, preview);
    generatedLinks.setComponentAlignment(txtDirectURL, Alignment.TOP_LEFT);
    generatedLinks.setComponentAlignment(txtIFrameCode, Alignment.TOP_LEFT);
    generatedLinks.setExpandRatio(preview, 1.0f);

    visSelector = new Grid(visContainer);
    visSelector.setCaption("Select visualization");
    visSelector.setHeight("100%");
    visSelector.setColumns("displayName");
    visSelector.setSelectionMode(Grid.SelectionMode.SINGLE);
    visSelector.addSelectionListener(ShareSingleMatchGenerator.this);
    visSelector.select(visContainer.getIdByIndex(0));
    visSelector.setWidth("300px");
    visSelector.getColumn("displayName").setSortable(false);

    generatedLinks.setSizeFull();

    Label infoText = new Label(
            "<p style=\"font-size: 18px\" >" + "<strong>Share your match:</strong>&nbsp;"
                    + "1.&nbsp;Choose the visualization to share. 2.&nbsp;Copy the generated link or code. "
                    + "3.&nbsp;Share this link with your peers or include the code in your website. " + "</p>",
            ContentMode.HTML);

    HorizontalLayout hLayout = new HorizontalLayout(visSelector, generatedLinks);
    hLayout.setSizeFull();
    hLayout.setSpacing(true);
    hLayout.setExpandRatio(generatedLinks, 1.0f);

    Button btClose = new Button("Close");
    btClose.setSizeUndefined();
    btClose.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            getUI().removeWindow(ShareSingleMatchGenerator.this);
        }
    });

    layout = new VerticalLayout(infoText, hLayout, btClose);
    layout.setSizeFull();
    layout.setExpandRatio(hLayout, 1.0f);
    layout.setComponentAlignment(btClose, Alignment.MIDDLE_CENTER);

    setContent(layout);
}

From source file:at.jku.ce.adaptivetesting.vaadin.ui.MockQuestion.java

License:LGPL

public MockQuestion(Question question) {
    this.question = question;

    TextArea textArea = new TextArea("Question text");
    textArea.setSizeFull();//from   w ww  . j av  a 2 s .c  o m

    // Download the result
    Button button = new Button("Display current user's solution");

    button.setSizeFull();
    button.addClickListener(e -> {
        Window window = new Window("Current user solution");
        VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        window.setContent(layout);
        // Update questionText
        textArea.addTextChangeListener(ev -> questionText = ev.getText());
        textArea.setTextChangeEventMode(TextChangeEventMode.EAGER);
        Label label;
        try {
            label = new Label(toXML());
        } catch (Exception e1) {
            label = new Label(
                    "<h1>Error parsing XML</h1><p>" + e1.getMessage() + Arrays.toString(e1.getStackTrace()),
                    ContentMode.HTML);
            LogHelper.logThrowable(e1);
        }
        layout.addComponent(label);
        window.center();
        getUI().addWindow(window);
    });
    // Add components to the UI
    addComponent(textArea);
    addComponent(question);
    addComponent(button);
}

From source file:ch.bfh.ti.soed.hs16.srs.purple.view.ReservationView.java

License:Open Source License

/**
 * Shows the popup window where a reservation can be modified, deleted or inserted
 * @param res The Reservation Object (for a new reservation, fill the startDate with the current Timestamp!)
 *///from w ww . j a  v  a  2  s. c  om
@SuppressWarnings("serial")
private void showPopup(Reservation res) {
    this.res = res; //Update the member
    boolean newRes = res.getReservationID() > 0 ? false : true;
    boolean isHost = isHost(actualUser, res.getHostList());
    boolean isParticipant = isHost(actualUser, res.getParticipantList());
    final GridLayout gridLayout = new GridLayout(3, 5);
    ValueChangeListener vcl = new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            List<Room> roomList = resCont.getAllFreeRooms(new Timestamp(startDate.getValue().getTime()),
                    new Timestamp(endDate.getValue().getTime()));
            if (ReservationView.this.res.getReservationID() > 0) {
                System.out.println("Aktuellen Raum");
                rooms.addItem(ReservationView.this.res.getRoom().getRoomID());
                rooms.setItemCaption(ReservationView.this.res.getRoom().getRoomID(),
                        ReservationView.this.res.getRoom().getName() + " ("
                                + ReservationView.this.res.getRoom().getNumberOfSeats() + " Pltze)");
                rooms.select(ReservationView.this.res.getRoom().getRoomID());
            }
            for (int i = 0; i < roomList.size(); i++) {
                rooms.addItem(roomList.get(i).getRoomID());
                String caption = roomList.get(i).getName() + " (" + roomList.get(i).getNumberOfSeats()
                        + " Pltze)";
                rooms.setItemCaption(roomList.get(i).getRoomID(), caption);
            }
            if (ReservationView.this.res.getReservationID() <= 0 && actualRoom != null)
                rooms.select(actualRoom.getRoomID());
        }
    };
    popUpWindow = new Window();
    popUpWindow.center();
    popUpWindow.setModal(true);
    startDate = new DateField("Startzeit");
    startDate.setLocale(VaadinSession.getCurrent().getLocale());
    startDate.setValue(res.getStart());
    startDate.addValueChangeListener(vcl);
    startDate.setDateFormat("dd.MM.yyyy HH:mm");
    startDate.setResolution(Resolution.HOUR);
    endDate = new DateField("Endzeit");
    endDate.setValue(res.getEnd());
    endDate.addValueChangeListener(vcl);
    endDate.setDateFormat("dd.MM.yyyy HH:mm");
    endDate.setLocale(VaadinSession.getCurrent().getLocale());
    endDate.setResolution(Resolution.HOUR);
    title = new TextField("Titel");
    title.setValue(res.getTitle());
    title.setWidth(100, Unit.PERCENTAGE);
    description = new TextArea("Beschreibung");
    description.setValue(res.getDescription());
    description.setRows(3);
    description.setWidth(100, Unit.PERCENTAGE);
    hosts = new ListSelect("Reservierender");
    hosts.setMultiSelect(true);
    hosts.clear();
    for (int i = 0; i < hostList.size(); i++) {
        hosts.addItem(hostList.get(i).getUserID());
        hosts.setItemCaption(hostList.get(i).getUserID(), hostList.get(i).getUsername());
    }
    //select the hosts in list
    if (!newRes) {
        List<User> resHosts = res.getHostList();
        for (int i = 0; i < resHosts.size(); i++)
            for (int y = 0; y < hostList.size(); y++)
                if (hostList.get(y).getUserID() == resHosts.get(i).getUserID())
                    hosts.select(resHosts.get(i).getUserID());
    } else
        hosts.select(actualUser.getUserID());
    hosts.select(0);
    hosts.setRows(hostList.size() > 5 ? 5 : hostList.size());
    participantList = new ListSelect("Teilnehmer");
    participantList.setMultiSelect(true);
    participantList.clear();

    for (int i = 0; i < participant.size(); i++) {
        participantList.addItem(participant.get(i).getUserID());
        participantList.setItemCaption(participant.get(i).getUserID(), participant.get(i).getUsername());
    }
    //select the participants in list
    if (!newRes) {
        List<User> resPart = res.getParticipantList();
        for (int i = 0; i < resPart.size(); i++)
            for (int y = 0; y < participant.size(); y++)
                if (participant.get(y).getUserID() == resPart.get(i).getUserID())
                    participantList.select(resPart.get(i).getUserID());
    }
    participantList.setRows(participant.size() > 5 ? 5 : participant.size());
    rooms = new NativeSelect("Raum");
    rooms.setNullSelectionAllowed(false);
    rooms.removeAllItems();
    List<Room> roomList = resCont.getAllFreeRooms(new Timestamp(startDate.getValue().getTime()),
            new Timestamp(endDate.getValue().getTime()));
    if (!newRes) {
        rooms.addItem(res.getRoom().getRoomID());
        rooms.setItemCaption(res.getRoom().getRoomID(),
                res.getRoom().getName() + " (" + res.getRoom().getNumberOfSeats() + " Pltze)");
        rooms.select(res.getRoom().getRoomID());
    }
    for (int i = 0; i < roomList.size(); i++) {
        rooms.addItem(roomList.get(i).getRoomID());
        String caption = roomList.get(i).getName() + " (" + roomList.get(i).getNumberOfSeats() + " Pltze)";
        rooms.setItemCaption(roomList.get(i).getRoomID(), caption);
    }
    if (newRes && actualRoom != null)
        rooms.select(actualRoom.getRoomID());
    saveButton = new Button("Speichern");
    saveButton.addClickListener(clButton);
    deleteButton = new Button("Lschen");
    deleteButton.addClickListener(clButton);
    deleteButton.setVisible(res.getReservationID() > 0 ? true : false);
    if (!newRes)
        setEditable(false);
    gridLayout.addComponent(startDate, 0, 0);
    gridLayout.addComponent(endDate, 0, 1);
    gridLayout.addComponent(hosts, 1, 0, 1, 1);
    gridLayout.addComponent(participantList, 2, 0, 2, 1);
    gridLayout.addComponent(title, 0, 2);
    gridLayout.addComponent(rooms, 1, 2, 2, 2);
    gridLayout.addComponent(description, 0, 3, 1, 3);
    if (roomList.size() == 0)
        saveButton.setEnabled(false);
    if (isHost || newRes) //show buttons for edit and delete only if the user is host or its a new reservation
    {
        gridLayout.addComponent(saveButton, 0, 4);
        gridLayout.addComponent(deleteButton, 1, 4);
    }
    if (isParticipant) //show buttons for accept oder decline a reservation
    {
        acceptButton = new Button("Zusagen");
        rejectButton = new Button("Absagen");
        acceptButton.addClickListener(clButton);
        rejectButton.addClickListener(clButton);
        if (isHost(actualUser, res.getAcceptedParticipantsList())) {
            acceptButton.setEnabled(false);
            rejectButton.setEnabled(true);
        } else {
            rejectButton.setEnabled(false);
            acceptButton.setEnabled(true);
        }
        gridLayout.addComponent(acceptButton, 0, 4);
        gridLayout.addComponent(rejectButton, 1, 4);
    }
    gridLayout.setSpacing(true);
    gridLayout.setMargin(new MarginInfo(false, false, false, true));
    gridLayout.setWidth(100, Unit.PERCENTAGE);
    popUpWindow.setContent(gridLayout);
    popUpWindow.setWidth("600px");
    popUpWindow.setHeight("450px");
    popUpWindow.setCaption(res.getReservationID() > 0 ? "Reservierungsdetails" : "Neue Reservierung");
    UI.getCurrent().addWindow(popUpWindow);
}

From source file:com.anphat.customer.ui.CustomerCareHistoryDialog.java

private void buildGridCareHistory() {
    gridCareHistoryLayout = new GridLayout(2, 4);
    CommonUtils.setBasicAttributeLayout(gridCareHistoryLayout,
            BundleUtils.getString("label.history.care.caption"), false);
    locale = (Locale) VaadinSession.getCurrent().getAttribute("locale");
    if (locale == null) {
        locale = new Locale("vi");
    }// w w  w .ja  v a2 s. c om
    dfDateTracking = new DateField(BundleUtils.getString("customerCareHistoryForm.dateTracking"));
    dfDateTracking.setWidth("100%");
    dfDateTracking.setImmediate(true);
    dfDateTracking.setLocale(locale);
    gridCareHistoryLayout.addComponent(dfDateTracking, 0, 3);
    taNotes = new TextArea(BundleUtils.getString("customerCareHistoryForm.notes"));
    taNotes.setRequired(true);
    taNotes.setWidth("100%");
    gridCareHistoryLayout.addComponent(taNotes, 0, 2, 1, 2);
    cbxService = CommonUtils.buildComboBox(BundleUtils.getString("term.information.service"));
    cbxService.setNullSelectionAllowed(true);
    gridCareHistoryLayout.addComponent(cbxService, 0, 0);

    cbxCustomerServiceStatus = CommonUtils.buildComboBox(BundleUtils.getString("customerStatusForm.status"));
    cbxCustomerServiceStatus.setNullSelectionAllowed(true);
    gridCareHistoryLayout.addComponent(cbxCustomerServiceStatus, 1, 3);

    f9Contact = new MappingCombobox(BundleUtils.getString("customer.contact.name"),
            BundleUtils.getString("customerCareHistoryForm.telNumber"));
    gridCareHistoryLayout.addComponent(f9Contact.getLayout(), 1, 0);
    btnAddContact = new Button(BundleUtils.getString("label.customer.contact.addNew"));
    btnAddContact.addStyleName("v-button-link");
    btnAddContact.setDisableOnClick(true);
    ShortcutUtils.setShortkeyF2(btnAddContact);
    gridCareHistoryLayout.addComponent(btnAddContact, 1, 1);

    mainLayout.addComponent(gridCareHistoryLayout);
    GridManyButton gridManyButton = CommonUtils.getCommonButtonDialog(this);
    btnSave = gridManyButton.getBtnCommon().get(0);
    mainLayout.addComponent(gridManyButton);

    DataUtil.addFocusWindow(this, taNotes);
}

From source file:com.anphat.customer.ui.CustomerContactDialog.java

private void buildGridCustomerContact() {
    gridCustomerContact = new GridLayout(4, 1);
    gridCareHistory = new GridLayout(6, 3);
    locale = (Locale) VaadinSession.getCurrent().getAttribute("locale");
    if (locale == null) {
        locale = new Locale("vi");
    }/*from ww w.j  a v  a2 s  . c om*/
    CommonUtils.setBasicAttributeLayout(gridCustomerContact, "", false);
    CommonUtils.setBasicAttributeLayout(gridCareHistory, BundleUtils.getString("label.history.care.caption"),
            true);
    txtName = CommonUtils.buildTextField(BundleUtils.getString("customer.contact.name"), 100);
    txtEmail = CommonUtils.buildTextField(BundleUtils.getString("customer.contact.email"), 100);
    txtTelNumber = CommonUtils.buildTextField(BundleUtils.getString("customer.contact.telNumber"), 100);
    txtRegency = CommonUtils.buildTextField(BundleUtils.getString("customer.contact.regency"), 100);
    dfDateTracking = new DateField(BundleUtils.getString("customerCareHistoryForm.dateTracking"));
    dfDateTracking.setWidth("100%");
    dfDateTracking.setImmediate(true);
    dfDateTracking.setLocale(locale);
    taNotes = new TextArea(BundleUtils.getString("customerCareHistoryForm.notes"));
    taNotes.setRequired(true);
    taNotes.setWidth("100%");
    //        cboStatus = CommonUtils.buildComboBox(BundleUtils.getString("customerStatusForm.status"));
    //        cboStatus.setNullSelectionAllowed(true);
    cboRegency = CommonUtils.buildComboBox("customer.contact.regency");

    gridStatusButton = new GridLayout(1, 2);
    //        gridStatusButton.setWidth("100%");
    gridCustomerContact.addComponent(txtName, 0, 0);
    gridCustomerContact.addComponent(txtEmail, 1, 0);
    gridCustomerContact.addComponent(txtTelNumber, 2, 0);
    gridCustomerContact.addComponent(cboRegency, 3, 0);

    gridStatusButton.addComponent(dfDateTracking, 0, 1);

    ogCustStatus = getCustomerStatus();
    ogCustStatus.setMultiSelect(false);
    ogCustStatus.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
    ogCustStatus.setItemCaptionPropertyId("parName");
    ogCustStatus.addStyleName("horizontal");
    gridStatusButton.addComponent(ogCustStatus, 0, 0);

    gridCareHistory.addComponent(gridStatusButton, 0, 0, 5, 0);
    gridCareHistory.addComponent(taNotes, 0, 2, 5, 2);

    mainLayout.addComponent(gridCustomerContact);
    mainLayout.addComponent(gridCareHistory);

    lstRegency = DataUtil.getListApParams(Constants.APP_PARAMS.CUSTOMER_CONTACT_REGENCY);
    String valueRegencyDefault = Constants.NULL;
    if (!DataUtil.isListNullOrEmpty(lstRegency)) {
        valueRegencyDefault = lstRegency.get(0).getParCode();
    }

    combo = new ComboComponent();
    combo.fillDataCombo(cboRegency, Constants.NULL, valueRegencyDefault, lstRegency,
            Constants.APP_PARAMS.CUSTOMER_CONTACT_REGENCY);
    //        combo.fillDataCombo(cboStatus, Constants.NULL, valueRegencyDefault, lstCustomerStatus, Constants.APP_PARAMS.CUSTOMER_SERVICE_STATUS);
    GridManyButton gridManyButton = CommonUtils.getCommonButtonDialog(this);
    btnSave = gridManyButton.getBtnCommon().get(0);
    mainLayout.addComponent(gridManyButton);
    //        DataUtil.addFocusWindow(this, txtName);
}

From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java

License:Apache License

Panel notifications() {
    Panel p = new Panel("Notifications");
    VerticalLayout content = new VerticalLayout() {
        Notification notification = new Notification("");
        TextField title = new TextField("Title");
        TextArea description = new TextArea("Description");
        MenuBar style = new MenuBar();
        MenuBar type = new MenuBar();
        String typeString = "";
        String styleString = "";
        TextField delay = new TextField();
        {/* w  w  w  .jav  a2 s.  c om*/
            setSpacing(true);
            setMargin(true);

            title.setInputPrompt("Title for the notification");
            title.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    if (title.getValue() == null || title.getValue().length() == 0) {
                        notification.setCaption(null);
                    } else {
                        notification.setCaption(title.getValue());
                    }
                }
            });
            title.setValue("Notification Title");
            title.setWidth("100%");
            addComponent(title);

            description.setInputPrompt("Description for the notification");
            description.addStyleName("small");
            description.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    if (description.getValue() == null || description.getValue().length() == 0) {
                        notification.setDescription(null);
                    } else {
                        notification.setDescription(description.getValue());
                    }
                }
            });
            description.setValue(
                    "A more informative message about what has happened. Nihil hic munitissimus habendi senatus locus, nihil horum? Inmensae subtilitatis, obscuris et malesuada fames. Hi omnes lingua, institutis, legibus inter se differunt.");
            description.setWidth("100%");
            addComponent(description);

            Command typeCommand = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    if (selectedItem.getText().equals("Humanized")) {
                        typeString = "";
                        notification.setStyleName(styleString.trim());
                    } else {
                        typeString = selectedItem.getText().toLowerCase();
                        notification.setStyleName((typeString + " " + styleString.trim()).trim());
                    }
                    for (MenuItem item : type.getItems()) {
                        item.setChecked(false);
                    }
                    selectedItem.setChecked(true);
                }
            };

            type.setCaption("Type");
            MenuItem humanized = type.addItem("Humanized", typeCommand);
            humanized.setCheckable(true);
            humanized.setChecked(true);
            type.addItem("Tray", typeCommand).setCheckable(true);
            type.addItem("Warning", typeCommand).setCheckable(true);
            type.addItem("Error", typeCommand).setCheckable(true);
            type.addItem("System", typeCommand).setCheckable(true);
            addComponent(type);
            type.addStyleName("small");

            Command styleCommand = new Command() {
                @Override
                public void menuSelected(final MenuItem selectedItem) {
                    styleString = "";
                    for (MenuItem item : style.getItems()) {
                        if (item.isChecked()) {
                            styleString += " " + item.getText().toLowerCase();
                        }
                    }
                    if (styleString.trim().length() > 0) {
                        notification.setStyleName((typeString + " " + styleString.trim()).trim());
                    } else if (typeString.length() > 0) {
                        notification.setStyleName(typeString.trim());
                    } else {
                        notification.setStyleName(null);
                    }
                }
            };

            style.setCaption("Additional style");
            style.addItem("Dark", styleCommand).setCheckable(true);
            style.addItem("Success", styleCommand).setCheckable(true);
            style.addItem("Failure", styleCommand).setCheckable(true);
            style.addItem("Bar", styleCommand).setCheckable(true);
            style.addItem("Small", styleCommand).setCheckable(true);
            style.addItem("Closable", styleCommand).setCheckable(true);
            addComponent(style);
            style.addStyleName("small");

            CssLayout group = new CssLayout();
            group.setCaption("Fade delay");
            group.addStyleName("v-component-group");
            addComponent(group);

            delay.setInputPrompt("Infinite");
            delay.addStyleName("align-right");
            delay.addStyleName("small");
            delay.setWidth("7em");
            delay.addValueChangeListener(new ValueChangeListener() {
                @Override
                public void valueChange(final ValueChangeEvent event) {
                    try {
                        notification.setDelayMsec(Integer.parseInt(delay.getValue()));
                    } catch (Exception e) {
                        notification.setDelayMsec(-1);
                        delay.setValue("");
                    }

                }
            });
            delay.setValue("1000");
            group.addComponent(delay);

            Button clear = new Button(null, new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    delay.setValue("");
                }
            });
            clear.setIcon(FontAwesome.TIMES_CIRCLE);
            clear.addStyleName("last");
            clear.addStyleName("small");
            clear.addStyleName("icon-only");
            group.addComponent(clear);
            group.addComponent(new Label("&nbsp; msec", ContentMode.HTML));

            GridLayout grid = new GridLayout(3, 3);
            grid.setCaption("Show in position");
            addComponent(grid);
            grid.setSpacing(true);

            Button pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.TOP_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.MIDDLE_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_LEFT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_CENTER);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

            pos = new Button("", new ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    notification.setPosition(Position.BOTTOM_RIGHT);
                    notification.show(Page.getCurrent());
                }
            });
            pos.addStyleName("small");
            grid.addComponent(pos);

        }
    };
    p.setContent(content);

    return p;
}

From source file:com.cavisson.gui.dashboard.components.controls.Forms.java

License:Apache License

public Forms() {
    setSpacing(true);/*from w  ww .j a v a2  s  .  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);
    StringGenerator sg = new StringGenerator();

    TextField name = new TextField("Name");
    name.setValue(sg.nextString(true) + " " + sg.nextString(true));
    name.setWidth("50%");
    form.addComponent(name);

    DateField birthday = new DateField("Birthday");
    birthday.setValue(new Date(80, 0, 31));
    form.addComponent(birthday);

    TextField username = new TextField("Username");
    username.setValue(sg.nextString(false) + sg.nextString(false));
    username.setRequired(true);
    form.addComponent(username);

    OptionGroup sex = new OptionGroup("Sex");
    sex.addItem("Female");
    sex.addItem("Male");
    sex.select("Male");
    sex.addStyleName("horizontal");
    form.addComponent(sex);

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

    TextField email = new TextField("Email");
    email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com");
    email.setWidth("50%");
    email.setRequired(true);
    form.addComponent(email);

    TextField location = new TextField("Location");
    location.setValue(sg.nextString(true) + ", " + sg.nextString(true));
    location.setWidth("50%");
    location.setComponentError(new UserError("This address doesn't exist"));
    form.addComponent(location);

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

    HorizontalLayout wrap = new HorizontalLayout();
    wrap.setSpacing(true);
    wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    wrap.setCaption("Newsletter");
    CheckBox newsletter = new CheckBox("Subscribe to newsletter", true);
    wrap.addComponent(newsletter);

    ComboBox period = new ComboBox();
    period.setTextInputAllowed(false);
    period.addItem("Daily");
    period.addItem("Weekly");
    period.addItem("Montly");
    period.setNullSelectionAllowed(false);
    period.select("Weekly");
    period.addStyleName("small");
    period.setWidth("10em");
    wrap.addComponent(period);
    form.addComponent(wrap);

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

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

    TextArea shortbio = new TextArea("Short Bio");
    shortbio.setValue(
            "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum.");
    shortbio.setWidth("100%");
    shortbio.setRows(2);
    form.addComponent(shortbio);

    final RichTextArea bio = new RichTextArea("Bio");
    bio.setWidth("100%");
    bio.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(bio);

    form.setReadOnly(true);
    bio.setReadOnly(true);

    Button edit = new Button("Edit", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            boolean readOnly = form.isReadOnly();
            if (readOnly) {
                bio.setReadOnly(false);
                form.setReadOnly(false);
                form.removeStyleName("light");
                event.getButton().setCaption("Save");
                event.getButton().addStyleName("primary");
            } else {
                bio.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);
}

From source file:com.cavisson.gui.dashboard.components.controls.TextFields.java

License:Apache License

public TextFields() {
    setMargin(true);/*from  w  ww.j  a v  a  2  s . c om*/

    Label h1 = new Label("Text Fields");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    TextField tf = new TextField("Normal");
    tf.setInputPrompt("First name");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Custom color");
    tf.setInputPrompt("Email");
    tf.addStyleName("color1");
    row.addComponent(tf);

    tf = new TextField("User Color");
    tf.setInputPrompt("Gender");
    tf.addStyleName("color2");
    row.addComponent(tf);

    tf = new TextField("Themed");
    tf.setInputPrompt("Age");
    tf.addStyleName("color3");
    row.addComponent(tf);

    tf = new TextField("Error");
    tf.setValue("Somethings wrong");
    tf.setComponentError(new UserError("Fix it, now!"));
    row.addComponent(tf);

    tf = new TextField("Error, borderless");
    tf.setValue("Somethings wrong");
    tf.setComponentError(new UserError("Fix it, now!"));
    tf.addStyleName("borderless");
    row.addComponent(tf);

    tf = new TextField("Read-only");
    tf.setInputPrompt("Nationality");
    tf.setValue("Finnish");
    tf.setReadOnly(true);
    row.addComponent(tf);

    tf = new TextField("Small");
    tf.setValue("Field value");
    tf.addStyleName("small");
    row.addComponent(tf);

    tf = new TextField("Large");
    tf.setValue("Field value");
    tf.addStyleName("large");
    tf.setIcon(testIcon.get(true));
    row.addComponent(tf);

    tf = new TextField("Icon inside");
    tf.setInputPrompt("Ooh, an icon");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Large, Icon inside");
    tf.setInputPrompt("Ooh, an icon");
    tf.addStyleName("large");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Small, Icon inside");
    tf.setInputPrompt("Ooh, an icon");
    tf.addStyleName("small");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("16px supported by default");
    tf.setInputPrompt("Image icon");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get(true, 16));
    row.addComponent(tf);

    tf = new TextField();
    tf.setValue("Font, no caption");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField();
    tf.setValue("Image, no caption");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get(true, 16));
    row.addComponent(tf);

    CssLayout group = new CssLayout();
    group.addStyleName("v-component-group");
    row.addComponent(group);

    tf = new TextField();
    tf.setInputPrompt("Grouped with a button");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    tf.setWidth("260px");
    group.addComponent(tf);

    Button button = new Button("Do It");
    // button.addStyleName("primary");
    group.addComponent(button);

    tf = new TextField("Borderless");
    tf.setInputPrompt("Write here");
    tf.addStyleName("inline-icon");
    tf.addStyleName("borderless");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Right-aligned");
    tf.setValue("1,234");
    tf.addStyleName("align-right");
    row.addComponent(tf);

    tf = new TextField("Centered");
    tf.setInputPrompt("Guess what?");
    tf.addStyleName("align-center");
    row.addComponent(tf);

    PasswordField pwf = new PasswordField("Password");
    pwf.setInputPrompt("Secret words");
    pwf.addStyleName("inline-icon");
    pwf.setIcon(FontAwesome.LOCK);
    row.addComponent(pwf);

    pwf = new PasswordField("Password, right-aligned");
    pwf.setInputPrompt("Secret words");
    pwf.addStyleName("inline-icon");
    pwf.addStyleName("align-right");
    pwf.setIcon(FontAwesome.LOCK);
    row.addComponent(pwf);

    pwf = new PasswordField("Password, centered");
    pwf.setInputPrompt("Secret words");
    pwf.addStyleName("inline-icon");
    pwf.addStyleName("align-center");
    pwf.setIcon(FontAwesome.LOCK);
    row.addComponent(pwf);

    tf = new TextField("Tiny");
    tf.setValue("Field value");
    tf.addStyleName("tiny");
    row.addComponent(tf);

    tf = new TextField("Huge");
    tf.setValue("Field value");
    tf.addStyleName("huge");
    row.addComponent(tf);

    h1 = new Label("Text Areas");
    h1.addStyleName("h1");
    addComponent(h1);

    row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    TextArea ta = new TextArea("Normal");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Inline icon");
    ta.setInputPrompt("Inline icon not really working");
    ta.addStyleName("inline-icon");
    ta.setIcon(testIcon.get());
    row.addComponent(ta);

    ta = new TextArea("Custom color");
    ta.addStyleName("color1");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Custom color, read-only");
    ta.addStyleName("color2");
    ta.setValue("Field value, spanning multiple lines of text");
    ta.setReadOnly(true);
    row.addComponent(ta);

    ta = new TextArea("Custom color");
    ta.addStyleName("color3");
    ta.setValue("Field value, spanning multiple lines of text");
    row.addComponent(ta);

    ta = new TextArea("Small");
    ta.addStyleName("small");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Large");
    ta.addStyleName("large");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Borderless");
    ta.addStyleName("borderless");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Right-aligned");
    ta.addStyleName("align-right");
    ta.setValue("Field value, spanning multiple lines of text");
    row.addComponent(ta);

    ta = new TextArea("Centered");
    ta.addStyleName("align-center");
    ta.setValue("Field value, spanning multiple lines of text");
    row.addComponent(ta);

    ta = new TextArea("Tiny");
    ta.addStyleName("tiny");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Huge");
    ta.addStyleName("huge");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    RichTextArea rta = new RichTextArea();
    rta.setValue("<b>Some</b> <i>rich</i> content");
    row.addComponent(rta);

    rta = new RichTextArea("Read-only");
    rta.setValue("<b>Some</b> <i>rich</i> content");
    rta.setReadOnly(true);
    row.addComponent(rta);
}

From source file:com.concur.ui.WebApp.java

License:Apache License

private Window createWindow() {
    FormLayout fl = new FormLayout();

    //        final SessionGuard sg = new SessionGuard();
    //        sg.setKeepalive(true);
    //        fl.addComponent(sg);

    fl.setSizeFull();//from  w w w  . j  a  v  a  2s . c  o m
    fl.setMargin(true);
    fl.addComponent(new Label("<h2>ATS Tuple Store -- Demo App<h2/>", Label.CONTENT_XML));

    actionField = new NativeSelect("Action:");
    actionField.addItem("Authenticate");
    actionField.addItem("GetTuple");
    actionField.addItem("PutTuple");
    actionField.addItem("GetConfigurations");
    actionField.select("Authenticate");
    fl.addComponent(actionField);

    tokenField = new TextField("Authentication Token:");
    tokenField.setColumns(40);
    fl.addComponent(tokenField);

    tupleKeyField = new TextField("TupleKey:");
    tupleKeyField.setColumns(40);
    fl.addComponent(tupleKeyField);

    tupleDataArea = new TextArea("TupleData:");
    tupleDataArea.setColumns(40);
    tupleDataArea.setRows(5);
    fl.addComponent(tupleDataArea);

    Button b = new Button("Send Request");
    b.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            submit();
        }
    });

    fl.addComponent(b);

    final Window w = new Window("ATS Tuple Store -- DEMO");
    w.setContent(fl);
    return w;
}

From source file:com.etest.valo.Forms.java

License:Apache License

public Forms() {
    setSpacing(true);//w ww  .j a  v  a  2 s  .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);
    StringGenerator sg = new StringGenerator();

    TextField name = new TextField("Name");
    name.setValue(sg.nextString(true) + " " + sg.nextString(true));
    name.setWidth("50%");
    form.addComponent(name);

    DateField birthday = new DateField("Birthday");
    birthday.setValue(new Date(80, 0, 31));
    form.addComponent(birthday);

    TextField username = new TextField("Username");
    username.setValue(sg.nextString(false) + sg.nextString(false));
    username.setRequired(true);
    form.addComponent(username);

    OptionGroup sex = new OptionGroup("Sex");
    sex.addItem("Female");
    sex.addItem("Male");
    sex.select("Male");
    sex.addStyleName("horizontal");
    form.addComponent(sex);

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

    TextField email = new TextField("Email");
    email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com");
    email.setWidth("50%");
    email.setRequired(true);
    form.addComponent(email);

    TextField location = new TextField("Location");
    location.setValue(sg.nextString(true) + ", " + sg.nextString(true));
    location.setWidth("50%");
    location.setComponentError(new UserError("This address doesn't exist"));
    form.addComponent(location);

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

    HorizontalLayout wrap = new HorizontalLayout();
    wrap.setSpacing(true);
    wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    wrap.setCaption("Newsletter");
    CheckBox newsletter = new CheckBox("Subscribe to newsletter", true);
    wrap.addComponent(newsletter);

    ComboBox period = new ComboBox();
    period.setTextInputAllowed(false);
    period.addItem("Daily");
    period.addItem("Weekly");
    period.addItem("Monthly");
    period.setNullSelectionAllowed(false);
    period.select("Weekly");
    period.addStyleName("small");
    period.setWidth("10em");
    wrap.addComponent(period);
    form.addComponent(wrap);

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

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

    TextArea shortbio = new TextArea("Short Bio");
    shortbio.setValue(
            "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum.");
    shortbio.setWidth("100%");
    shortbio.setRows(2);
    form.addComponent(shortbio);

    final RichTextArea bio = new RichTextArea("Bio");
    bio.setWidth("100%");
    bio.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(bio);

    form.setReadOnly(true);
    bio.setReadOnly(true);

    Button edit = new Button("Edit", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            boolean readOnly = form.isReadOnly();
            if (readOnly) {
                bio.setReadOnly(false);
                form.setReadOnly(false);
                form.removeStyleName("light");
                event.getButton().setCaption("Save");
                event.getButton().addStyleName("primary");
            } else {
                bio.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);
}