Example usage for com.vaadin.ui DateField DateField

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

Introduction

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

Prototype

public DateField(ValueChangeListener<LocalDate> valueChangeListener) 

Source Link

Document

Constructs a new DateField with a value change listener.

Usage

From source file:ch.bfh.ti.soed.hs16.srs.black.view.reservationView.ReservationMakeView.java

License:Open Source License

public ReservationMakeView() {
    fromField = new DateField("Start Date");
    fromField.setLocale(new Locale("de", "DE"));
    fromField.setResolution(Resolution.MINUTE);
    fromField.setDateFormat("dd.MM.yyyy HH:mm");
    fromField.setIcon(FontAwesome.CALENDAR);
    fromField.setWidth(12, Unit.EM);/*w ww  .  java2s  .  c o  m*/
    toField = new DateField("End Date");
    toField.setLocale(new Locale("de", "DE"));
    toField.setResolution(Resolution.MINUTE);
    toField.setDateFormat("dd.MM.yyyy HH:mm");
    toField.setIcon(FontAwesome.CALENDAR);
    toField.setWidth(12, Unit.EM);
    roomSelect = new NativeSelect("Room Number");
    roomSelect.setIcon(FontAwesome.BED);
    roomSelect.setNullSelectionAllowed(true);
    roomSelect.setImmediate(true);
    makeReservationButton = new Button("Make Reservation", FontAwesome.CHECK);
    makeReservationButton.setWidth(12, Unit.EM);
    logoutButton = new Button("Logout");

    Panel panel = new Panel("Create New Reservation");
    FormLayout content = new FormLayout();
    content.addComponents(fromField, toField, roomSelect, makeReservationButton);
    content.setSizeUndefined();
    content.setMargin(true);
    VerticalLayout formAndLogout = new VerticalLayout(content, logoutButton);
    formAndLogout.setMargin(true);
    panel.setContent(formAndLogout);
    makeViewLayout = new VerticalLayout(panel);
    makeViewLayout.setSizeUndefined();
    makeViewLayout.setMargin(true);
}

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!)
 */// w  w  w.  j a  v a2s.co  m
@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");
    }/*from w  ww  .ja v a2  s  . c o m*/
    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");
    }/* w w w  .j ava2s . c o  m*/
    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.calender.BeanItemContainerTestUI.java

License:Apache License

/**
 * Opens up a modal dialog window where an event can be modified
 * /*from w  w w. java2  s.  com*/
 * @param event
 *            The event to modify
 */
private void editEvent(final BasicEvent event) {
    Window modal = new Window("Add event");
    modal.setModal(true);
    modal.setResizable(false);
    modal.setDraggable(false);
    modal.setWidth("300px");
    final FieldGroup fieldGroup = new FieldGroup();

    FormLayout formLayout = new FormLayout();
    TextField captionField = new TextField("Caption");
    captionField.setImmediate(true);
    TextField descriptionField = new TextField("Description");
    descriptionField.setImmediate(true);
    DateField startField = new DateField("Start");
    startField.setResolution(Resolution.MINUTE);
    startField.setImmediate(true);
    DateField endField = new DateField("End");
    endField.setImmediate(true);
    endField.setResolution(Resolution.MINUTE);

    formLayout.addComponent(captionField);
    formLayout.addComponent(descriptionField);
    formLayout.addComponent(startField);
    formLayout.addComponent(endField);

    fieldGroup.bind(captionField, ContainerEventProvider.CAPTION_PROPERTY);
    fieldGroup.bind(descriptionField, ContainerEventProvider.DESCRIPTION_PROPERTY);
    fieldGroup.bind(startField, ContainerEventProvider.STARTDATE_PROPERTY);
    fieldGroup.bind(endField, ContainerEventProvider.ENDDATE_PROPERTY);

    fieldGroup.setItemDataSource(new BeanItem<BasicEvent>(event,
            Arrays.asList(ContainerEventProvider.CAPTION_PROPERTY, ContainerEventProvider.DESCRIPTION_PROPERTY,
                    ContainerEventProvider.STARTDATE_PROPERTY, ContainerEventProvider.ENDDATE_PROPERTY)));
    modal.setContent(formLayout);
    modal.addCloseListener(new Window.CloseListener() {
        @Override
        public void windowClose(CloseEvent e) {
            // Commit changes to bean
            try {
                fieldGroup.commit();
            } catch (CommitException e1) {
                e1.printStackTrace();
            }

            if (events.containsId(event)) {
                /*
                 * BeanItemContainer does not notify container listeners
                 * when the bean changes so we need to trigger a
                 * ItemSetChange event
                 */
                BasicEvent dummy = new BasicEvent();
                events.addBean(dummy);
                events.removeItem(dummy);

            } else {
                events.addBean(event);
            }
        }
    });
    getUI().addWindow(modal);
}

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

License:Apache License

public DateFields() {
    setMargin(true);/*  ww w.jav  a2s  .c  om*/

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

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

    DateField date = new DateField("Default resolution");
    setDate(date);
    row.addComponent(date);

    date = new DateField("Error");
    setDate(date);
    date.setComponentError(new UserError("Fix it, now!"));
    row.addComponent(date);

    date = new DateField("Error, borderless");
    setDate(date);
    date.setComponentError(new UserError("Fix it, now!"));
    date.addStyleName("borderless");
    row.addComponent(date);

    CssLayout group = new CssLayout();
    group.setCaption("Grouped with a Button");
    group.addStyleName("v-component-group");
    row.addComponent(group);

    final DateField date2 = new DateField();
    group.addComponent(date2);

    Button today = new Button("Today", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            date2.setValue(new Date());
        }
    });
    group.addComponent(today);

    date = new DateField("Default resolution, explicit size");
    setDate(date);
    row.addComponent(date);
    date.setWidth("260px");
    date.setHeight("60px");

    date = new DateField("Second resolution");
    setDate(date);
    date.setResolution(Resolution.SECOND);
    row.addComponent(date);

    date = new DateField("Minute resolution");
    setDate(date);
    date.setResolution(Resolution.MINUTE);
    row.addComponent(date);

    date = new DateField("Hour resolution");
    setDate(date);
    date.setResolution(Resolution.HOUR);
    row.addComponent(date);

    date = new DateField("Disabled");
    setDate(date);
    date.setResolution(Resolution.HOUR);
    date.setEnabled(false);
    row.addComponent(date);

    date = new DateField("Day resolution");
    setDate(date);
    date.setResolution(Resolution.DAY);
    row.addComponent(date);

    date = new DateField("Month resolution");
    setDate(date);
    date.setResolution(Resolution.MONTH);
    row.addComponent(date);

    date = new DateField("Year resolution");
    setDate(date);
    date.setResolution(Resolution.YEAR);
    row.addComponent(date);

    date = new DateField("Custom color");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("color1");
    row.addComponent(date);

    date = new DateField("Custom color");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("color2");
    row.addComponent(date);

    date = new DateField("Custom color");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("color3");
    row.addComponent(date);

    date = new DateField("Small");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("small");
    row.addComponent(date);

    date = new DateField("Large");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("large");
    row.addComponent(date);

    date = new DateField("Borderless");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("borderless");
    row.addComponent(date);

    date = new DateField("Week numbers");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.setLocale(new Locale("fi", "fi"));
    date.setShowISOWeekNumbers(true);
    row.addComponent(date);

    date = new DateField("US locale");
    setDate(date);
    date.setResolution(Resolution.SECOND);
    date.setLocale(new Locale("en", "US"));
    row.addComponent(date);

    date = new DateField("Custom format");
    setDate(date);
    date.setDateFormat("E dd/MM/yyyy");
    row.addComponent(date);

    date = new DateField("Tiny");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("tiny");
    row.addComponent(date);

    date = new DateField("Huge");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("huge");
    row.addComponent(date);

    date = new InlineDateField("Date picker");
    setDate(date);
    row.addComponent(date);

    date = new InlineDateField("Date picker with week numbers");
    setDate(date);
    date.setLocale(new Locale("fi", "fi"));
    date.setShowISOWeekNumbers(true);
    row.addComponent(date);
}

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

License:Apache License

public Forms() {
    setSpacing(true);/* ww  w  . j a  v  a  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);
    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.esofthead.mycollab.module.project.view.task.GanttChartTaskContainer.java

License:Open Source License

private Panel createControls() {

    Panel panel = new Panel();
    panel.setWidth(100, Unit.PERCENTAGE);

    HorizontalLayout controls = new HorizontalLayout();
    controls.setSpacing(true);//from w  w  w  .  ja  va 2s  .  com
    controls.setMargin(true);
    panel.setContent(controls);

    start = new DateField(AppContext.getMessage(TaskI18nEnum.FORM_START_DATE));
    start.setValue(gantt.getStartDate());
    start.setResolution(Resolution.DAY);
    start.setImmediate(true);
    start.addValueChangeListener(startDateValueChangeListener);

    end = new DateField(AppContext.getMessage(TaskI18nEnum.FORM_END_DATE));
    end.setValue(gantt.getEndDate());
    end.setResolution(Resolution.DAY);
    end.setImmediate(true);
    end.addValueChangeListener(endDateValueChangeListener);

    reso = new NativeSelect("Resolution");
    reso.setNullSelectionAllowed(false);
    reso.addItem(org.tltv.gantt.client.shared.Resolution.Hour);
    reso.addItem(org.tltv.gantt.client.shared.Resolution.Day);
    reso.addItem(org.tltv.gantt.client.shared.Resolution.Week);
    reso.setValue(gantt.getResolution());
    reso.setImmediate(true);
    reso.addValueChangeListener(resolutionValueChangeListener);

    controls.addComponent(start);
    controls.addComponent(end);
    controls.addComponent(reso);
    panel.setStyleName(UIConstants.THEME_NO_BORDER);

    return panel;
}

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

License:Apache License

public Forms() {
    setSpacing(true);//  w w w  . 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);
}

From source file:com.example.testzbox.vista.TabCarga.java

private void iniciarElementos() {

    //layout.setSpacing(true);
    layout.setWidth(200.0f, Unit.PERCENTAGE);
    //layout.setSizeFull();

    cmbArea = new ComboBox("Area");
    cmbArea.setWidth(30.0f, Unit.PERCENTAGE);
    cmbArea.setNullSelectionAllowed(false);
    cmbArea.setTextInputAllowed(false);//  w ww .  jav a2  s. c  o m
    cmbArea.setInputPrompt("Seleccione");
    cmbArea.addItem("adjustment");
    //        cmbArea.addItem("theft");
    //        cmbArea.addItem("siu");
    //        cmbArea.addItem("glasses");
    //        cmbArea.addItem("payments");
    //        cmbArea.addItem("valuation");
    //                
    cmbOperacion = new ComboBox("Operacin");
    cmbOperacion.setWidth(30.0f, Unit.PERCENTAGE);
    cmbOperacion.setNullSelectionAllowed(false);
    cmbOperacion.setTextInputAllowed(false);
    cmbOperacion.setInputPrompt("Seleccione");
    cmbOperacion.addItem("Asegurado");
    cmbOperacion.addItem("Tercero");

    txtNombreDoc = new TextField("Nombre Documento");
    txtNombreDoc.setWidth(30.0f, Unit.PERCENTAGE);

    //SINIESTRO
    txtNumSiniestro = new TextField("Nmero Siniestro");
    txtNumSiniestro.setWidth(30.0f, Unit.PERCENTAGE);
    txtNumPoliza = new TextField("Nmero de Pliza");
    txtNumPoliza.setWidth(30.0f, Unit.PERCENTAGE);
    txtNombAsegurado = new TextField("Nombre Asegurado");
    txtNombAsegurado.setWidth(30.0f, Unit.PERCENTAGE);
    dateFechaDocumento = new DateField("Fecha Creacin");
    dateFechaDocumento.setWidth(30.0f, Unit.PERCENTAGE);
    txtIdUsuarioCmp = new TextField("Id Usuario");
    txtIdUsuarioCmp.setWidth(30.0f, Unit.PERCENTAGE);

    //TIPO DOCUMENTAL
    cmbTipoDoc = new ComboBox("Tipo Documental");
    cmbTipoDoc.setWidth(30.0f, Unit.PERCENTAGE);
    cmbTipoDoc.setNullSelectionAllowed(false);
    cmbTipoDoc.setTextInputAllowed(false);
    cmbTipoDoc.setInputPrompt("Seleccione");
    cmbTipoDoc.addItem("averiguacionPrevia");
    cmbTipoDoc.addItem("declaracionUniversalAccidente");
    cmbTipoDoc.addItem("declaracionUniversalAccidenteSIPAC");
    cmbTipoDoc.addItem("demanda");
    cmbTipoDoc.addItem("poderNotarial");
    cmbTipoDoc.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            dateFechaExpedicion.setVisible(true);
            txtFolioActa.setVisible(true);
            cmbTipoEvento.setVisible(true);
        }
    });

    dateFechaExpedicion = new DateField("Fecha Expedicin");
    dateFechaExpedicion.setWidth(30.0f, Unit.PERCENTAGE);
    dateFechaExpedicion.setVisible(false);
    txtFolioActa = new TextField("Folio Acta");
    txtFolioActa.setWidth(30.0f, Unit.PERCENTAGE);
    txtFolioActa.setVisible(false);
    cmbTipoEvento = new ComboBox("Tipo Evento");
    cmbTipoEvento.setWidth(30.0f, Unit.PERCENTAGE);
    cmbTipoEvento.setVisible(false);
    cmbTipoEvento.setNullSelectionAllowed(false);
    cmbTipoEvento.setTextInputAllowed(false);
    cmbTipoEvento.setInputPrompt("Seleccione");
    cmbTipoEvento.addItem("Averiguacin Previa");
    cmbTipoEvento.addItem("DUA");
    cmbTipoEvento.addItem("DUA SIPAC");
    cmbTipoEvento.addItem("DUA Cristaleras");
    cmbTipoEvento.addItem("Demanda");
    cmbTipoEvento.addItem("Poder Notarial");

    lblPathArchivo = new Label();
    lblPathArchivo.setVisible(false);
    lblExtensionArchivo = new Label();
    lblExtensionArchivo.setVisible(false);

    //  form.setSpacing(true);
    form.addComponents(cmbArea, cmbOperacion, txtNombreDoc, txtNumSiniestro, txtNumPoliza, txtNombAsegurado,
            dateFechaDocumento, txtIdUsuarioCmp, cmbTipoDoc, dateFechaExpedicion, txtFolioActa, cmbTipoEvento);

    uploader = uploadContents();
    btnEnviar = new Button("Enviar");
    btnEnviar.addStyleName(ValoTheme.BUTTON_PRIMARY);
    btnEnviar.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            //Path pathFile = Paths.get("C:\\Documento Prueba.pdf");
            Path pathFile = Paths.get(lblPathArchivo.getCaption());

            DocumentoVO documentoVO = new DocumentoVO();

            documentoVO.setNombreDocumento(txtNombreDoc.getValue() + "." + lblExtensionArchivo.getCaption());
            documentoVO.setSubTipoDocumental(cmbTipoDoc.getValue().toString());
            documentoVO.setInputStream(pathFile.toFile());

            Map<String, String> metadatos = new HashMap<>();
            metadatos.put("folioActa", txtFolioActa.getValue());
            metadatos.put("tipoEvento", cmbTipoEvento.getValue().toString());
            metadatos.put("fechaExpedicion", convertDate(dateFechaExpedicion));
            metadatos.put("numeroSiniestro", txtNumSiniestro.getValue());
            metadatos.put("numeroPoliza", txtNumPoliza.getValue());
            metadatos.put("nombreAsegurado", txtNombAsegurado.getValue());
            metadatos.put("fechaCreacionDocumento", convertDate(dateFechaDocumento));
            metadatos.put("idUsuarioCmp", txtIdUsuarioCmp.getValue());
            metadatos.put("area", cmbArea.getValue().toString());
            metadatos.put("operacion", cmbOperacion.getValue().toString());

            documentoVO.setMetadatos(metadatos);

            cargarDocumento(documentoVO);

        }

    });

    footer.setSpacing(true);
    footer.setWidth(38.0f, Unit.PERCENTAGE);
    footer.addComponents(uploader, btnEnviar);
    footer.setComponentAlignment(btnEnviar, Alignment.BOTTOM_RIGHT);

    layout.addComponents(form, lblPathArchivo, footer);

    setCaption("Carga");
    setMargin(true);
    //setSpacing(true);
    addComponents(layout, panel);

}