Search in sources :

Example 1 with CountryDropDown

use of org.apache.openmeetings.web.util.CountryDropDown in project openmeetings by apache.

the class GeneralUserForm method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    add(email);
    email.setLabel(Model.of(getString("119")));
    email.add(RfcCompliantEmailAddressValidator.getInstance());
    add(new DropDownChoice<>("salutation", Arrays.asList(Salutation.values()), new ChoiceRenderer<Salutation>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Object getDisplayValue(Salutation object) {
            return getString("user.salutation." + object.name());
        }

        @Override
        public String getIdValue(Salutation object, int index) {
            return object.name();
        }
    }));
    add(new TextField<String>("firstname"));
    add(new TextField<String>("lastname"));
    add(new DropDownChoice<>("timeZoneId", AVAILABLE_TIMEZONES));
    add(new LanguageDropDown("languageId"));
    add(new TextField<String>("address.phone"));
    add(new CheckBox("sendSMS"));
    add(new AjaxDatePicker("age", new PropertyModel<LocalDate>(this, "age"), WebSession.get().getLocale()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onValueChanged(IPartialPageRequestHandler target) {
            User u = GeneralUserForm.this.getModelObject();
            u.setAge(CalendarHelper.getDate(age, u.getTimeZoneId()));
        }
    });
    add(new TextField<String>("address.street"));
    add(new TextField<String>("address.additionalname"));
    add(new TextField<String>("address.zip"));
    add(new TextField<String>("address.town"));
    add(new CountryDropDown("address.country"));
    add(new TextArea<String>("address.comment"));
    add(new Select2MultiChoice<>("groupUsers", null, new RestrictiveChoiceProvider<GroupUser>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getDisplayValue(GroupUser choice) {
            return choice.getGroup().getName();
        }

        @Override
        public String toId(GroupUser choice) {
            Long id = choice.getGroup().getId();
            return id == null ? null : "" + id;
        }

        @Override
        public void query(String term, int page, Response<GroupUser> response) {
            for (GroupUser ou : grpUsers) {
                if (Strings.isEmpty(term) || ou.getGroup().getName().contains(term)) {
                    response.add(ou);
                }
            }
        }

        @Override
        public GroupUser fromId(String _id) {
            Long id = Long.parseLong(_id);
            User u = GeneralUserForm.this.getModelObject();
            Group g = groupDao.get(id);
            GroupUser gu = new GroupUser(g, u);
            int idx = grpUsers.indexOf(gu);
            return idx < 0 ? gu : grpUsers.get(idx);
        }
    }).setLabel(Model.of(getString("161"))).setRequired(isAdminForm && hasGroupAdminLevel(getRights())).setEnabled(isAdminForm));
}
Also used : AjaxDatePicker(com.googlecode.wicket.kendo.ui.form.datetime.local.AjaxDatePicker) CountryDropDown(org.apache.openmeetings.web.util.CountryDropDown) Group(org.apache.openmeetings.db.entity.user.Group) User(org.apache.openmeetings.db.entity.user.User) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) PropertyModel(org.apache.wicket.model.PropertyModel) IPartialPageRequestHandler(org.apache.wicket.core.request.handler.IPartialPageRequestHandler) Salutation(org.apache.openmeetings.db.entity.user.User.Salutation) CheckBox(org.apache.wicket.markup.html.form.CheckBox) Select2MultiChoice(org.wicketstuff.select2.Select2MultiChoice) ChoiceRenderer(org.apache.wicket.markup.html.form.ChoiceRenderer)

Aggregations

AjaxDatePicker (com.googlecode.wicket.kendo.ui.form.datetime.local.AjaxDatePicker)1 Group (org.apache.openmeetings.db.entity.user.Group)1 GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)1 User (org.apache.openmeetings.db.entity.user.User)1 Salutation (org.apache.openmeetings.db.entity.user.User.Salutation)1 CountryDropDown (org.apache.openmeetings.web.util.CountryDropDown)1 IPartialPageRequestHandler (org.apache.wicket.core.request.handler.IPartialPageRequestHandler)1 CheckBox (org.apache.wicket.markup.html.form.CheckBox)1 ChoiceRenderer (org.apache.wicket.markup.html.form.ChoiceRenderer)1 PropertyModel (org.apache.wicket.model.PropertyModel)1 Select2MultiChoice (org.wicketstuff.select2.Select2MultiChoice)1