Search in sources :

Example 6 with CheckBox

use of org.apache.wicket.markup.html.form.CheckBox in project openmeetings by apache.

the class MessageDialog method onInitialize.

@Override
protected void onInitialize() {
    getTitle().setObject(getString("1209"));
    send = new DialogButton("send", getString("218"));
    cancel = new DialogButton("cancel", getString("lbl.cancel"));
    form.add(feedback.setOutputMarkupId(true));
    form.add(new UserMultiChoice("to", modelTo).setRequired(true));
    form.add(new TextField<String>("subject"));
    DefaultWysiwygToolbar toolbar = new DefaultWysiwygToolbar("toolbarContainer");
    form.add(toolbar);
    form.add(new WysiwygEditor("message", toolbar));
    form.add(roomParamsBlock.setOutputMarkupId(true));
    final CheckBox bookedRoom = new CheckBox("bookedRoom");
    form.add(bookedRoom.setOutputMarkupId(true).add(new AjaxEventBehavior(EVT_CLICK) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            PrivateMessage p = MessageDialog.this.getModelObject();
            p.setBookedRoom(!p.isBookedRoom());
            roomParams.setVisible(p.isBookedRoom());
            target.add(bookedRoom, roomParamsBlock);
        }
    }));
    bookedRoom.setVisible(cfgDao.getBool(CONFIG_MYROOMS_ENABLED, true));
    roomParamsBlock.add(roomParams);
    roomParams.add(new RoomTypeDropDown("room.type"));
    roomParams.add(start);
    roomParams.add(end);
    add(form.setOutputMarkupId(true));
    super.onInitialize();
}
Also used : WysiwygEditor(com.googlecode.wicket.jquery.ui.plugins.wysiwyg.WysiwygEditor) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DialogButton(com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton) DefaultWysiwygToolbar(com.googlecode.wicket.jquery.ui.plugins.wysiwyg.toolbar.DefaultWysiwygToolbar) UserMultiChoice(org.apache.openmeetings.web.util.UserMultiChoice) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) CheckBox(org.apache.wicket.markup.html.form.CheckBox) RoomTypeDropDown(org.apache.openmeetings.web.util.RoomTypeDropDown) PrivateMessage(org.apache.openmeetings.db.entity.user.PrivateMessage)

Example 7 with CheckBox

use of org.apache.wicket.markup.html.form.CheckBox in project openmeetings by apache.

the class RoomForm method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    RequiredTextField<String> name = new RequiredTextField<>("name");
    name.setLabel(new Model<>(getString("165")));
    add(name);
    add(new // 
    DropDownChoice<>(// 
    "capacity", // 
    DROPDOWN_NUMBER_OF_PARTICIPANTS, new ChoiceRenderer<Long>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Object getDisplayValue(Long id) {
            return id;
        }

        @Override
        public String getIdValue(Long id, int index) {
            return "" + id;
        }
    }));
    add(new RoomTypeDropDown("type").setRequired(true).setLabel(Model.of(getString("45"))));
    add(new TextArea<String>("comment"));
    boolean isGroupAdmin = hasGroupAdminLevel(getRights());
    add(new CheckBox("appointment").setEnabled(false));
    add(new CheckBox("ispublic").setEnabled(!isGroupAdmin));
    List<Group> orgList = isGroupAdmin ? groupDao.get(null, getUserId(), 0, Integer.MAX_VALUE, null) : groupDao.get(0, Integer.MAX_VALUE);
    final List<RoomGroup> orgRooms = new ArrayList<>(orgList.size());
    for (Group org : orgList) {
        orgRooms.add(new RoomGroup(org, getModelObject()));
    }
    add(new Select2MultiChoice<>("groups", null, new RestrictiveChoiceProvider<RoomGroup>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getDisplayValue(RoomGroup choice) {
            String name = choice.getGroup().getName();
            return name == null ? "" : name;
        }

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

        @Override
        public void query(String term, int page, Response<RoomGroup> response) {
            response.addAll(orgRooms.stream().filter(rg -> Strings.isEmpty(term) || rg.getGroup().getName().contains(term)).collect(Collectors.toList()));
        }

        @Override
        public RoomGroup fromId(String _id) {
            Long id = Long.valueOf(_id);
            if (!orgList.stream().filter(g -> g.getId().equals(id)).findFirst().isPresent()) {
                // seems to be hacked
                return null;
            }
            Group g = groupDao.get(id);
            return new RoomGroup(g, RoomForm.this.getModelObject());
        }
    }).setLabel(Model.of(getString("828"))).setRequired(isGroupAdmin));
    add(new CheckBox("isDemoRoom"));
    TextField<Integer> demoTime = new TextField<>("demoTime");
    demoTime.setLabel(new Model<>(getString("637")));
    add(demoTime);
    add(new CheckBox("allowUserQuestions"));
    add(new CheckBox("audioOnly"));
    add(new CheckBox("closed"));
    add(new TextField<String>("redirectURL"));
    add(new CheckBox("waitForRecording"));
    add(new CheckBox("allowRecording"));
    add(new CheckBox("chatModerated"));
    add(new Select2MultiChoice<>("hiddenElements", null, new ChoiceProvider<RoomElement>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getDisplayValue(RoomElement choice) {
            return choice.name();
        }

        @Override
        public String getIdValue(RoomElement choice) {
            return choice.name();
        }

        @Override
        public void query(String term, int page, Response<RoomElement> response) {
            for (RoomElement r : RoomElement.values()) {
                if (Strings.isEmpty(term) || r.name().contains(term)) {
                    response.add(r);
                }
            }
        }

        @Override
        public Collection<RoomElement> toChoices(Collection<String> ids) {
            Collection<RoomElement> rights = new ArrayList<>(ids.size());
            for (String id : ids) {
                rights.add(RoomElement.valueOf(id));
            }
            return rights;
        }
    }));
    add(new CheckBox("chatOpened"));
    add(new CheckBox("filesOpened"));
    add(new CheckBox("autoVideoSelect"));
    // Moderators
    final Select2Choice<User> moderatorChoice = new Select2Choice<>("moderator2add", moderator2add, new AdminUserChoiceProvider() {

        private static final long serialVersionUID = 1L;

        @Override
        public void query(String term, int page, Response<User> response) {
            response.addAll(userDao.get(term, false, page * PAGE_SIZE, PAGE_SIZE));
            response.setHasMore(PAGE_SIZE == response.getResults().size());
        }

        @Override
        public String getDisplayValue(User choice) {
            Address a = choice.getAddress();
            return String.format("\"%s %s\" <%s>", choice.getFirstname(), choice.getLastname(), a == null ? "" : a.getEmail());
        }
    });
    moderatorChoice.getSettings().setCloseOnSelect(true);
    add(moderatorChoice.add(new AjaxFormComponentUpdatingBehavior("change") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            Room r = RoomForm.this.getModelObject();
            User u = moderator2add.getObject();
            boolean found = false;
            if (u != null) {
                if (r.getModerators() == null) {
                    r.setModerators(new ArrayList<RoomModerator>());
                }
                for (RoomModerator rm : r.getModerators()) {
                    if (rm.getUser().getId().equals(u.getId())) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    RoomModerator rm = new RoomModerator();
                    rm.setRoomId(r.getId());
                    rm.setUser(u);
                    r.getModerators().add(0, rm);
                    moderator2add.setObject(null);
                    target.add(moderatorContainer, moderatorChoice);
                }
            }
        }
    }).setOutputMarkupId(true));
    add(moderatorContainer.add(new ListView<RoomModerator>("moderators") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<RoomModerator> item) {
            RoomModerator moderator = item.getModelObject();
            Label name = new Label("uName", moderator.getUser().getFirstname() + " " + moderator.getUser().getLastname());
            if (moderator.getId() == null) {
                name.add(AttributeModifier.append(ATTR_CLASS, "newItem"));
            }
            item.add(new CheckBox("superModerator", new PropertyModel<Boolean>(moderator, "superModerator"))).add(new Label("userId", "" + moderator.getUser().getId())).add(name).add(new Label("email", moderator.getUser().getAddress().getEmail())).add(new ConfirmableAjaxBorder("delete", getString("80"), getString("833")) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onSubmit(AjaxRequestTarget target) {
                    RoomForm.this.getModelObject().getModerators().remove(item.getIndex());
                    target.add(moderatorContainer);
                }
            });
        }
    }).setOutputMarkupId(true));
    add(new CheckBox("moderated"));
    // Files
    Form<Void> filesForm = new Form<>("filesForm");
    add(filesForm.add(new Select2MultiChoice<>("files2add", files2add, new ChoiceProvider<BaseFileItem>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getDisplayValue(BaseFileItem f) {
            return f.getName();
        }

        @Override
        public String getIdValue(BaseFileItem f) {
            return "" + f.getId();
        }

        @Override
        public void query(String term, int page, Response<BaseFileItem> response) {
            response.addAll(fileDao.getAllRoomFiles(term, page * PAGE_SIZE, PAGE_SIZE, RoomForm.this.getModelObject().getId(), orgList));
            response.setHasMore(PAGE_SIZE == response.getResults().size());
        }

        @Override
        public Collection<BaseFileItem> toChoices(Collection<String> ids) {
            return fileDao.get(ids);
        }
    }).setLabel(Model.of(getString("245")))).add(new TextField<Long>("wbidx", wbIdx) {

        private static final long serialVersionUID = 1L;

        @Override
        protected String[] getInputTypes() {
            return new String[] { "number" };
        }
    }).add(new AjaxButton("addFiles") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            Room r = RoomForm.this.getModelObject();
            if (r.getFiles() == null) {
                r.setFiles(new ArrayList<>());
            }
            for (BaseFileItem f : files2add.getObject()) {
                r.getFiles().add(new RoomFile(r.getId(), f, wbIdx.getObject()));
            }
            target.add(filesContainer, filesForm);
        }

        @Override
        protected String getIcon() {
            return JQueryIcon.PLUSTHICK;
        }
    }).setOutputMarkupId(true));
    add(filesContainer.add(new ListView<RoomFile>("files") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<RoomFile> item) {
            final RoomFile rf = item.getModelObject();
            item.add(new Label("name", new PropertyModel<>(rf.getFile(), "name"))).add(new Label("wbIdx", new PropertyModel<>(rf, "wbIdx"))).add(new ConfirmableAjaxBorder("delete", getString("80"), getString("833")) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onSubmit(AjaxRequestTarget target) {
                    Room r = RoomForm.this.getModelObject();
                    for (Iterator<RoomFile> iter = r.getFiles().iterator(); iter.hasNext(); ) {
                        RoomFile _rf = iter.next();
                        if (_rf.getFile().getId().equals(rf.getFile().getId())) {
                            iter.remove();
                            break;
                        }
                    }
                    target.add(filesContainer);
                }
            });
        }
    }).setOutputMarkupId(true));
    // Users in this Room
    add(clientsContainer.add(clients.setOutputMarkupId(true)).setOutputMarkupId(true));
    add(new TextField<String>("confno").setEnabled(false));
    add(pin);
    pin.setEnabled(getModelObject().isSipEnabled());
    add(new TextField<String>("ownerId").setEnabled(false));
    add(new AjaxCheckBox("sipEnabled") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateView(target);
        }
    }.setOutputMarkupId(true));
    // attach an ajax validation behavior to all form component's keydown
    // event and throttle it down to once per second
    add(new AjaxFormValidatingBehavior("keydown", Duration.ONE_SECOND));
}
Also used : Arrays(java.util.Arrays) SpringBean(org.apache.wicket.spring.injection.annot.SpringBean) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) WebSession.getUserId(org.apache.openmeetings.web.app.WebSession.getUserId) FileItemDao(org.apache.openmeetings.db.dao.file.FileItemDao) AdminBaseForm(org.apache.openmeetings.web.admin.AdminBaseForm) RoomElement(org.apache.openmeetings.db.entity.room.Room.RoomElement) TextField(org.apache.wicket.markup.html.form.TextField) User(org.apache.openmeetings.db.entity.user.User) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Strings(org.apache.wicket.util.string.Strings) IModel(org.apache.wicket.model.IModel) ChoiceProvider(org.wicketstuff.select2.ChoiceProvider) ListView(org.apache.wicket.markup.html.list.ListView) Label(org.apache.wicket.markup.html.basic.Label) Duration(org.apache.wicket.util.time.Duration) ListItem(org.apache.wicket.markup.html.list.ListItem) Collection(java.util.Collection) Model(org.apache.wicket.model.Model) AdminUserChoiceProvider(org.apache.openmeetings.web.admin.AdminUserChoiceProvider) AttributeModifier(org.apache.wicket.AttributeModifier) Collectors(java.util.stream.Collectors) RoomDao(org.apache.openmeetings.db.dao.room.RoomDao) Room(org.apache.openmeetings.db.entity.room.Room) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) Response(org.wicketstuff.select2.Response) PAGE_SIZE(org.apache.openmeetings.web.admin.AdminUserChoiceProvider.PAGE_SIZE) RoomTypeDropDown(org.apache.openmeetings.web.util.RoomTypeDropDown) List(java.util.List) Group(org.apache.openmeetings.db.entity.user.Group) PropertyModel(org.apache.wicket.model.PropertyModel) GroupDao(org.apache.openmeetings.db.dao.user.GroupDao) Form(org.apache.wicket.markup.html.form.Form) AjaxButton(com.googlecode.wicket.jquery.ui.form.button.AjaxButton) UserDao(org.apache.openmeetings.db.dao.user.UserDao) ConfirmableAjaxBorder(org.apache.openmeetings.web.common.ConfirmableAjaxBorder) CheckBox(org.apache.wicket.markup.html.form.CheckBox) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) ArrayList(java.util.ArrayList) RequiredTextField(org.apache.wicket.markup.html.form.RequiredTextField) AuthLevelUtil.hasGroupAdminLevel(org.apache.openmeetings.db.util.AuthLevelUtil.hasGroupAdminLevel) ChoiceRenderer(org.apache.wicket.markup.html.form.ChoiceRenderer) Address(org.apache.openmeetings.db.entity.user.Address) CollectionModel(org.apache.wicket.model.util.CollectionModel) RoomFile(org.apache.openmeetings.db.entity.room.RoomFile) AjaxFormValidatingBehavior(org.apache.wicket.ajax.form.AjaxFormValidatingBehavior) RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup) TextArea(org.apache.wicket.markup.html.form.TextArea) JQueryIcon(com.googlecode.wicket.jquery.ui.JQueryIcon) ATTR_CLASS(org.apache.openmeetings.util.OpenmeetingsVariables.ATTR_CLASS) Application.kickUser(org.apache.openmeetings.web.app.Application.kickUser) Iterator(java.util.Iterator) Select2Choice(org.wicketstuff.select2.Select2Choice) RestrictiveChoiceProvider(org.apache.openmeetings.web.util.RestrictiveChoiceProvider) Client(org.apache.openmeetings.db.entity.basic.Client) Select2MultiChoice(org.wicketstuff.select2.Select2MultiChoice) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ClientManager(org.apache.openmeetings.web.app.ClientManager) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) WebSession.getRights(org.apache.openmeetings.web.app.WebSession.getRights) RoomModerator(org.apache.openmeetings.db.entity.room.RoomModerator) Address(org.apache.openmeetings.db.entity.user.Address) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AjaxFormValidatingBehavior(org.apache.wicket.ajax.form.AjaxFormValidatingBehavior) AjaxButton(com.googlecode.wicket.jquery.ui.form.button.AjaxButton) TextField(org.apache.wicket.markup.html.form.TextField) RequiredTextField(org.apache.wicket.markup.html.form.RequiredTextField) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) RestrictiveChoiceProvider(org.apache.openmeetings.web.util.RestrictiveChoiceProvider) ConfirmableAjaxBorder(org.apache.openmeetings.web.common.ConfirmableAjaxBorder) RoomModerator(org.apache.openmeetings.db.entity.room.RoomModerator) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) ChoiceProvider(org.wicketstuff.select2.ChoiceProvider) AdminUserChoiceProvider(org.apache.openmeetings.web.admin.AdminUserChoiceProvider) RestrictiveChoiceProvider(org.apache.openmeetings.web.util.RestrictiveChoiceProvider) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) CheckBox(org.apache.wicket.markup.html.form.CheckBox) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) Collection(java.util.Collection) RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup) RoomElement(org.apache.openmeetings.db.entity.room.Room.RoomElement) Group(org.apache.openmeetings.db.entity.user.Group) RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup) User(org.apache.openmeetings.db.entity.user.User) Application.kickUser(org.apache.openmeetings.web.app.Application.kickUser) AdminBaseForm(org.apache.openmeetings.web.admin.AdminBaseForm) Form(org.apache.wicket.markup.html.form.Form) Room(org.apache.openmeetings.db.entity.room.Room) AdminUserChoiceProvider(org.apache.openmeetings.web.admin.AdminUserChoiceProvider) Select2Choice(org.wicketstuff.select2.Select2Choice) RoomFile(org.apache.openmeetings.db.entity.room.RoomFile) PropertyModel(org.apache.wicket.model.PropertyModel) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) RequiredTextField(org.apache.wicket.markup.html.form.RequiredTextField) Response(org.wicketstuff.select2.Response) Select2MultiChoice(org.wicketstuff.select2.Select2MultiChoice) ChoiceRenderer(org.apache.wicket.markup.html.form.ChoiceRenderer) RoomTypeDropDown(org.apache.openmeetings.web.util.RoomTypeDropDown)

Example 8 with CheckBox

use of org.apache.wicket.markup.html.form.CheckBox in project openmeetings by apache.

the class UserForm method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    add(password.setResetPassword(false).setLabel(Model.of(getString("110"))).setRequired(false).add(passValidator = new StrongPasswordValidator(getMinPasswdLength(cfgDao), getModelObject())));
    login.setLabel(Model.of(getString("108")));
    add(login.add(minimumLength(getMinLoginLength(cfgDao))));
    add(new DropDownChoice<>("type", Arrays.asList(Type.values())).add(new OnChangeAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateDomain(target);
        }
    }));
    update(null);
    add(domain.add(domainId).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
    add(new Label("ownerId"));
    add(new DateLabel("inserted"));
    add(new DateLabel("updated"));
    add(new CheckBox("forceTimeZoneCheck"));
    add(new Select2MultiChoice<>("rights", null, new RestrictiveChoiceProvider<Right>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getDisplayValue(Right choice) {
            return choice.name();
        }

        @Override
        public String toId(Right choice) {
            return choice.name();
        }

        @Override
        public void query(String term, int page, Response<Right> response) {
            boolean isGroupAdmin = hasGroupAdminLevel(getRights());
            for (Right r : Right.values()) {
                if (Right.GroupAdmin == r) {
                    continue;
                }
                if (isGroupAdmin && (Right.Admin == r || Right.Soap == r)) {
                    continue;
                }
                if (Strings.isEmpty(term) || r.name().contains(term)) {
                    response.add(r);
                }
            }
        }

        @Override
        public Right fromId(String id) {
            return Right.valueOf(id);
        }
    }));
    add(new ComunityUserForm("comunity", getModel()));
    // attach an ajax validation behavior to all form component's keydown
    // event and throttle it down to once per second
    add(new AjaxFormValidatingBehavior("keydown", Duration.ONE_SECOND));
    add(adminPass);
}
Also used : RestrictiveChoiceProvider(org.apache.openmeetings.web.util.RestrictiveChoiceProvider) Label(org.apache.wicket.markup.html.basic.Label) DateLabel(org.apache.openmeetings.web.util.DateLabel) Right(org.apache.openmeetings.db.entity.user.User.Right) AjaxFormValidatingBehavior(org.apache.wicket.ajax.form.AjaxFormValidatingBehavior) StrongPasswordValidator(org.apache.openmeetings.core.util.StrongPasswordValidator) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) DateLabel(org.apache.openmeetings.web.util.DateLabel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Response(org.wicketstuff.select2.Response) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) CheckBox(org.apache.wicket.markup.html.form.CheckBox) ComunityUserForm(org.apache.openmeetings.web.common.ComunityUserForm)

Example 9 with CheckBox

use of org.apache.wicket.markup.html.form.CheckBox 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)

Example 10 with CheckBox

use of org.apache.wicket.markup.html.form.CheckBox in project wicket by apache.

the class EnhancedPageView method addTreeControls.

private void addTreeControls() {
    Form<Void> form = new Form<>("form");
    add(form);
    form.add(new CheckBox("showStateless", new PropertyModel<Boolean>(this, "showStatefulAndParentsOnly")));
    form.add(new CheckBox("showBehaviors", new PropertyModel<Boolean>(this, "showBehaviors")));
    form.add(new CheckBoxMultipleChoice<>("visibleColumns", new PropertyModel<List<IColumn<TreeNode, Void>>>(this, "visibleColumns"), allColumns).setSuffix(" "));
    form.add(new AjaxFallbackButton("submit", form) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onAfterSubmit(Optional<AjaxRequestTarget> target) {
            target.ifPresent(t -> t.add(componentTree));
        }
    });
    add(new AjaxFallbackLink<Void>("expandAll") {

        private static final long serialVersionUID = 1L;

        public void onClick(Optional<AjaxRequestTarget> targetOptional) {
            expandState.expandAll();
            targetOptional.ifPresent(target -> target.add(componentTree));
        }
    });
    add(new AjaxFallbackLink<Void>("collapseAll") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(Optional<AjaxRequestTarget> targetOptional) {
            expandState.collapseAll();
            targetOptional.ifPresent(target -> target.add(componentTree));
        }
    });
}
Also used : Form(org.apache.wicket.markup.html.form.Form) Arrays(java.util.Arrays) Behavior(org.apache.wicket.behavior.Behavior) WicketObjects(org.apache.wicket.core.util.lang.WicketObjects) Page(org.apache.wicket.Page) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) PageView(org.apache.wicket.markup.html.debug.PageView) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) OddEvenItem(org.apache.wicket.markup.repeater.OddEvenItem) CheckBox(org.apache.wicket.markup.html.form.CheckBox) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) AjaxFallbackButton(org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton) AbstractColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CheckBoxMultipleChoice(org.apache.wicket.markup.html.form.CheckBoxMultipleChoice) Strings(org.apache.wicket.util.string.Strings) IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) AbstractTree(org.apache.wicket.extensions.markup.html.repeater.tree.AbstractTree) Iterator(java.util.Iterator) SortableTreeProvider(org.apache.wicket.extensions.markup.html.repeater.util.SortableTreeProvider) Collection(java.util.Collection) IClusterable(org.apache.wicket.util.io.IClusterable) GenericPanel(org.apache.wicket.markup.html.panel.GenericPanel) Model(org.apache.wicket.model.Model) Set(java.util.Set) Component(org.apache.wicket.Component) MarkupContainer(org.apache.wicket.MarkupContainer) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) PageReference(org.apache.wicket.PageReference) DefaultTableTree(org.apache.wicket.extensions.markup.html.repeater.tree.DefaultTableTree) List(java.util.List) TreeColumn(org.apache.wicket.extensions.markup.html.repeater.tree.table.TreeColumn) PropertyModel(org.apache.wicket.model.PropertyModel) Bytes(org.apache.wicket.util.lang.Bytes) Item(org.apache.wicket.markup.repeater.Item) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) Optional(java.util.Optional) AjaxFallbackLink(org.apache.wicket.ajax.markup.html.AjaxFallbackLink) Comparator(java.util.Comparator) Collections(java.util.Collections) Form(org.apache.wicket.markup.html.form.Form) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxFallbackButton(org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CheckBox(org.apache.wicket.markup.html.form.CheckBox) ArrayList(java.util.ArrayList) List(java.util.List) CheckBoxMultipleChoice(org.apache.wicket.markup.html.form.CheckBoxMultipleChoice)

Aggregations

CheckBox (org.apache.wicket.markup.html.form.CheckBox)39 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)24 Label (org.apache.wicket.markup.html.basic.Label)20 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)16 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)14 ArrayList (java.util.ArrayList)12 List (java.util.List)12 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)11 PropertyModel (org.apache.wicket.model.PropertyModel)11 Form (org.apache.wicket.markup.html.form.Form)10 TextField (org.apache.wicket.markup.html.form.TextField)10 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)9 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)8 IModel (org.apache.wicket.model.IModel)7 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)5 Model (org.apache.wicket.model.Model)5 EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)4 StringChoiceRenderer (com.gitblit.wicket.StringChoiceRenderer)4 AjaxCheckBox (org.apache.wicket.ajax.markup.html.form.AjaxCheckBox)4 ListItem (org.apache.wicket.markup.html.list.ListItem)4