Search in sources :

Example 11 with CheckBox

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

the class EditTeamPage method setupPage.

protected void setupPage(final TeamModel teamModel) {
    if (isCreate) {
        super.setupPage(getString("gb.newTeam"), "");
    } else {
        super.setupPage(getString("gb.edit"), teamModel.name);
    }
    CompoundPropertyModel<TeamModel> model = new CompoundPropertyModel<TeamModel>(teamModel);
    List<String> repos = getAccessRestrictedRepositoryList(true, null);
    List<String> teamUsers = new ArrayList<String>(teamModel.users);
    List<String> preReceiveScripts = new ArrayList<String>();
    List<String> postReceiveScripts = new ArrayList<String>();
    final String oldName = teamModel.name;
    final List<RegistrantAccessPermission> permissions = teamModel.getRepositoryPermissions();
    // users palette
    final Palette<UserChoice> users = new Palette<UserChoice>("users", new ListModel<UserChoice>(getTeamUsers(teamUsers)), new CollectionModel<UserChoice>(sortByDisplayName(getTeamUsers(app().users().getAllUsernames()))), new ChoiceRenderer<UserChoice>(null, "userId"), 10, false);
    // pre-receive palette
    if (teamModel.preReceiveScripts != null) {
        preReceiveScripts.addAll(teamModel.preReceiveScripts);
    }
    final Palette<String> preReceivePalette = new Palette<String>("preReceiveScripts", new ListModel<String>(preReceiveScripts), new CollectionModel<String>(app().repositories().getPreReceiveScriptsUnused(null)), new StringChoiceRenderer(), 12, true);
    // post-receive palette
    if (teamModel.postReceiveScripts != null) {
        postReceiveScripts.addAll(teamModel.postReceiveScripts);
    }
    final Palette<String> postReceivePalette = new Palette<String>("postReceiveScripts", new ListModel<String>(postReceiveScripts), new CollectionModel<String>(app().repositories().getPostReceiveScriptsUnused(null)), new StringChoiceRenderer(), 12, true);
    Form<TeamModel> form = new Form<TeamModel>("editForm", model) {

        private static final long serialVersionUID = 1L;

        /*
			 * (non-Javadoc)
			 *
			 * @see org.apache.wicket.markup.html.form.Form#onSubmit()
			 */
        @Override
        protected void onSubmit() {
            String teamname = teamModel.name;
            if (StringUtils.isEmpty(teamname)) {
                error(getString("gb.pleaseSetTeamName"));
                return;
            }
            if (isCreate) {
                TeamModel model = app().users().getTeamModel(teamname);
                if (model != null) {
                    error(MessageFormat.format(getString("gb.teamNameUnavailable"), teamname));
                    return;
                }
            }
            // update team permissions
            for (RegistrantAccessPermission repositoryPermission : permissions) {
                teamModel.setRepositoryPermission(repositoryPermission.registrant, repositoryPermission.permission);
            }
            Iterator<UserChoice> selectedUsers = users.getSelectedChoices();
            List<String> members = new ArrayList<String>();
            while (selectedUsers.hasNext()) {
                members.add(selectedUsers.next().getUserId().toLowerCase());
            }
            teamModel.users.clear();
            teamModel.users.addAll(members);
            // set mailing lists
            String ml = mailingLists.getObject();
            if (!StringUtils.isEmpty(ml)) {
                Set<String> list = new HashSet<String>();
                for (String address : ml.split("(,|\\s)")) {
                    if (StringUtils.isEmpty(address)) {
                        continue;
                    }
                    list.add(address.toLowerCase());
                }
                teamModel.mailingLists.clear();
                teamModel.mailingLists.addAll(list);
            }
            // pre-receive scripts
            List<String> preReceiveScripts = new ArrayList<String>();
            Iterator<String> pres = preReceivePalette.getSelectedChoices();
            while (pres.hasNext()) {
                preReceiveScripts.add(pres.next());
            }
            teamModel.preReceiveScripts.clear();
            teamModel.preReceiveScripts.addAll(preReceiveScripts);
            // post-receive scripts
            List<String> postReceiveScripts = new ArrayList<String>();
            Iterator<String> post = postReceivePalette.getSelectedChoices();
            while (post.hasNext()) {
                postReceiveScripts.add(post.next());
            }
            teamModel.postReceiveScripts.clear();
            teamModel.postReceiveScripts.addAll(postReceiveScripts);
            try {
                if (isCreate) {
                    app().gitblit().addTeam(teamModel);
                } else {
                    app().gitblit().reviseTeam(oldName, teamModel);
                }
            } catch (GitBlitException e) {
                error(e.getMessage());
                return;
            }
            setRedirect(false);
            if (isCreate) {
                // create another team
                info(MessageFormat.format(getString("gb.teamCreated"), teamModel.name));
            }
            // back to users page
            setResponsePage(TeamsPage.class);
        }
    };
    // do not let the browser pre-populate these fields
    form.add(new SimpleAttributeModifier("autocomplete", "off"));
    // not all user providers support manipulating team memberships
    boolean editMemberships = app().authentication().supportsTeamMembershipChanges(teamModel);
    // not all user providers support manipulating the admin role
    boolean changeAdminRole = app().authentication().supportsRoleChanges(teamModel, Role.ADMIN);
    // not all user providers support manipulating the create role
    boolean changeCreateRole = app().authentication().supportsRoleChanges(teamModel, Role.CREATE);
    // not all user providers support manipulating the fork role
    boolean changeForkRole = app().authentication().supportsRoleChanges(teamModel, Role.FORK);
    // field names reflective match TeamModel fields
    form.add(new TextField<String>("name"));
    form.add(new CheckBox("canAdmin").setEnabled(changeAdminRole));
    form.add(new CheckBox("canFork").setEnabled(app().settings().getBoolean(Keys.web.allowForking, true) && changeForkRole));
    form.add(new CheckBox("canCreate").setEnabled(changeCreateRole));
    form.add(users.setEnabled(editMemberships));
    mailingLists = new Model<String>(teamModel.mailingLists == null ? "" : StringUtils.flattenStrings(teamModel.mailingLists, " "));
    form.add(new TextField<String>("mailingLists", mailingLists));
    form.add(new RegistrantPermissionsPanel("repositories", RegistrantType.REPOSITORY, repos, permissions, getAccessPermissions()));
    form.add(preReceivePalette);
    form.add(new BulletListPanel("inheritedPreReceive", "inherited", app().repositories().getPreReceiveScriptsInherited(null)));
    form.add(postReceivePalette);
    form.add(new BulletListPanel("inheritedPostReceive", "inherited", app().repositories().getPostReceiveScriptsInherited(null)));
    form.add(new Button("save"));
    Button cancel = new Button("cancel") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {
            setResponsePage(TeamsPage.class);
        }
    };
    cancel.setDefaultFormProcessing(false);
    form.add(cancel);
    add(form);
}
Also used : Palette(org.apache.wicket.extensions.markup.html.form.palette.Palette) Form(org.apache.wicket.markup.html.form.Form) RegistrantPermissionsPanel(com.gitblit.wicket.panels.RegistrantPermissionsPanel) ArrayList(java.util.ArrayList) GitBlitException(com.gitblit.GitBlitException) SimpleAttributeModifier(org.apache.wicket.behavior.SimpleAttributeModifier) BulletListPanel(com.gitblit.wicket.panels.BulletListPanel) UserChoice(com.gitblit.models.UserChoice) TeamModel(com.gitblit.models.TeamModel) Button(org.apache.wicket.markup.html.form.Button) RegistrantAccessPermission(com.gitblit.models.RegistrantAccessPermission) HashSet(java.util.HashSet) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) StringChoiceRenderer(com.gitblit.wicket.StringChoiceRenderer) CheckBox(org.apache.wicket.markup.html.form.CheckBox)

Example 12 with CheckBox

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

the class EditUserPage method setupPage.

protected void setupPage(final UserModel userModel) {
    if (isCreate) {
        super.setupPage(getString("gb.newUser"), "");
    } else {
        super.setupPage(getString("gb.edit"), userModel.username);
    }
    final Model<String> confirmPassword = new Model<String>(StringUtils.isEmpty(userModel.password) ? "" : userModel.password);
    CompoundPropertyModel<UserModel> model = new CompoundPropertyModel<UserModel>(userModel);
    // build list of projects including all repositories wildcards
    List<String> repos = getAccessRestrictedRepositoryList(true, userModel);
    List<String> userTeams = new ArrayList<String>();
    for (TeamModel team : userModel.teams) {
        userTeams.add(team.name);
    }
    Collections.sort(userTeams);
    final String oldName = userModel.username;
    final List<RegistrantAccessPermission> permissions = app().repositories().getUserAccessPermissions(userModel);
    final Palette<String> teams = new Palette<String>("teams", new ListModel<String>(new ArrayList<String>(userTeams)), new CollectionModel<String>(app().users().getAllTeamNames()), new StringChoiceRenderer(), 10, false);
    Locale locale = userModel.getPreferences().getLocale();
    List<Language> languages = UserPage.getLanguages();
    Language preferredLanguage = UserPage.getPreferredLanguage(locale, languages);
    final IModel<Language> language = Model.of(preferredLanguage);
    Form<UserModel> form = new Form<UserModel>("editForm", model) {

        private static final long serialVersionUID = 1L;

        /*
			 * (non-Javadoc)
			 *
			 * @see org.apache.wicket.markup.html.form.Form#onSubmit()
			 */
        @Override
        protected void onSubmit() {
            if (StringUtils.isEmpty(userModel.username)) {
                error(getString("gb.pleaseSetUsername"));
                return;
            }
            Language lang = language.getObject();
            if (lang != null) {
                userModel.getPreferences().setLocale(lang.code);
            }
            // force username to lower-case
            userModel.username = userModel.username.toLowerCase();
            String username = userModel.username;
            if (isCreate) {
                UserModel model = app().users().getUserModel(username);
                if (model != null) {
                    error(MessageFormat.format(getString("gb.usernameUnavailable"), username));
                    return;
                }
            }
            boolean rename = !StringUtils.isEmpty(oldName) && !oldName.equalsIgnoreCase(username);
            if (app().authentication().supportsCredentialChanges(userModel)) {
                if (!userModel.password.equals(confirmPassword.getObject())) {
                    error(getString("gb.passwordsDoNotMatch"));
                    return;
                }
                String password = userModel.password;
                if (!PasswordHash.isHashedEntry(password)) {
                    // This is a plain text password.
                    // Check length.
                    int minLength = app().settings().getInteger(Keys.realm.minPasswordLength, 5);
                    if (minLength < 4) {
                        minLength = 4;
                    }
                    if (password.trim().length() < minLength) {
                        // TODO: Why do we trim here, but not in EditUserDialog and ChangePasswordPage?
                        error(MessageFormat.format(getString("gb.passwordTooShort"), minLength));
                        return;
                    }
                    // change the cookie
                    userModel.cookie = userModel.createCookie();
                    // Optionally store the password MD5 digest.
                    String type = app().settings().getString(Keys.realm.passwordStorage, PasswordHash.getDefaultType().name());
                    PasswordHash pwdh = PasswordHash.instanceOf(type);
                    if (pwdh != null) {
                        // Hash the password
                        userModel.password = pwdh.toHashedEntry(password, username);
                    }
                } else if (rename && password.toUpperCase().startsWith(PasswordHash.Type.CMD5.name())) {
                    error(getString("gb.combinedMd5Rename"));
                    return;
                }
            }
            // update user permissions
            for (RegistrantAccessPermission repositoryPermission : permissions) {
                if (repositoryPermission.mutable) {
                    userModel.setRepositoryPermission(repositoryPermission.registrant, repositoryPermission.permission);
                }
            }
            Iterator<String> selectedTeams = teams.getSelectedChoices();
            userModel.teams.clear();
            while (selectedTeams.hasNext()) {
                TeamModel team = app().users().getTeamModel(selectedTeams.next());
                if (team == null) {
                    continue;
                }
                userModel.teams.add(team);
            }
            try {
                if (isCreate) {
                    app().gitblit().addUser(userModel);
                } else {
                    app().gitblit().reviseUser(oldName, userModel);
                }
            } catch (GitBlitException e) {
                error(e.getMessage());
                return;
            }
            setRedirect(false);
            if (isCreate) {
                // create another user
                info(MessageFormat.format(getString("gb.userCreated"), userModel.username));
                setResponsePage(EditUserPage.class);
            } else {
                // back to users page
                setResponsePage(UsersPage.class);
            }
        }
    };
    // do not let the browser pre-populate these fields
    form.add(new SimpleAttributeModifier("autocomplete", "off"));
    // not all user providers support manipulating username and password
    boolean editCredentials = app().authentication().supportsCredentialChanges(userModel);
    // not all user providers support manipulating display name
    boolean editDisplayName = app().authentication().supportsDisplayNameChanges(userModel);
    // not all user providers support manipulating email address
    boolean editEmailAddress = app().authentication().supportsEmailAddressChanges(userModel);
    // not all user providers support manipulating team memberships
    boolean editTeams = app().authentication().supportsTeamMembershipChanges(userModel);
    // not all user providers support manipulating the admin role
    boolean changeAdminRole = app().authentication().supportsRoleChanges(userModel, Role.ADMIN);
    // not all user providers support manipulating the create role
    boolean changeCreateRole = app().authentication().supportsRoleChanges(userModel, Role.CREATE);
    // not all user providers support manipulating the fork role
    boolean changeForkRole = app().authentication().supportsRoleChanges(userModel, Role.FORK);
    // field names reflective match UserModel fields
    form.add(new TextField<String>("username").setEnabled(editCredentials));
    NonTrimmedPasswordTextField passwordField = new NonTrimmedPasswordTextField("password");
    passwordField.setResetPassword(false);
    form.add(passwordField.setEnabled(editCredentials));
    NonTrimmedPasswordTextField confirmPasswordField = new NonTrimmedPasswordTextField("confirmPassword", confirmPassword);
    confirmPasswordField.setResetPassword(false);
    form.add(confirmPasswordField.setEnabled(editCredentials));
    form.add(new TextField<String>("displayName").setEnabled(editDisplayName));
    form.add(new TextField<String>("emailAddress").setEnabled(editEmailAddress));
    DropDownChoice<Language> choice = new DropDownChoice<Language>("language", language, languages);
    form.add(choice.setEnabled(languages.size() > 0));
    if (userModel.canAdmin() && !userModel.canAdmin) {
        // user inherits Admin permission
        // display a disabled-yet-checked checkbox
        form.add(new CheckBox("canAdmin", Model.of(true)).setEnabled(false));
    } else {
        form.add(new CheckBox("canAdmin").setEnabled(changeAdminRole));
    }
    if (userModel.canFork() && !userModel.canFork) {
        // user inherits Fork permission
        // display a disabled-yet-checked checkbox
        form.add(new CheckBox("canFork", Model.of(true)).setEnabled(false));
    } else {
        final boolean forkingAllowed = app().settings().getBoolean(Keys.web.allowForking, true);
        form.add(new CheckBox("canFork").setEnabled(forkingAllowed && changeForkRole));
    }
    if (userModel.canCreate() && !userModel.canCreate) {
        // user inherits Create permission
        // display a disabled-yet-checked checkbox
        form.add(new CheckBox("canCreate", Model.of(true)).setEnabled(false));
    } else {
        form.add(new CheckBox("canCreate").setEnabled(changeCreateRole));
    }
    form.add(new CheckBox("excludeFromFederation"));
    form.add(new CheckBox("disabled"));
    form.add(new RegistrantPermissionsPanel("repositories", RegistrantType.REPOSITORY, repos, permissions, getAccessPermissions()));
    form.add(teams.setEnabled(editTeams));
    form.add(new TextField<String>("organizationalUnit").setEnabled(editDisplayName));
    form.add(new TextField<String>("organization").setEnabled(editDisplayName));
    form.add(new TextField<String>("locality").setEnabled(editDisplayName));
    form.add(new TextField<String>("stateProvince").setEnabled(editDisplayName));
    form.add(new TextField<String>("countryCode").setEnabled(editDisplayName));
    form.add(new Button("save"));
    Button cancel = new Button("cancel") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {
            setResponsePage(UsersPage.class);
        }
    };
    cancel.setDefaultFormProcessing(false);
    form.add(cancel);
    add(form);
}
Also used : Locale(java.util.Locale) Palette(org.apache.wicket.extensions.markup.html.form.palette.Palette) Form(org.apache.wicket.markup.html.form.Form) RegistrantPermissionsPanel(com.gitblit.wicket.panels.RegistrantPermissionsPanel) ArrayList(java.util.ArrayList) GitBlitException(com.gitblit.GitBlitException) SimpleAttributeModifier(org.apache.wicket.behavior.SimpleAttributeModifier) UserModel(com.gitblit.models.UserModel) TeamModel(com.gitblit.models.TeamModel) Button(org.apache.wicket.markup.html.form.Button) RegistrantAccessPermission(com.gitblit.models.RegistrantAccessPermission) TextField(org.apache.wicket.markup.html.form.TextField) NonTrimmedPasswordTextField(com.gitblit.wicket.NonTrimmedPasswordTextField) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) NonTrimmedPasswordTextField(com.gitblit.wicket.NonTrimmedPasswordTextField) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) StringChoiceRenderer(com.gitblit.wicket.StringChoiceRenderer) CheckBox(org.apache.wicket.markup.html.form.CheckBox) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) IModel(org.apache.wicket.model.IModel) CollectionModel(org.apache.wicket.model.util.CollectionModel) ListModel(org.apache.wicket.model.util.ListModel) Model(org.apache.wicket.model.Model) UserModel(com.gitblit.models.UserModel) TeamModel(com.gitblit.models.TeamModel) PasswordHash(com.gitblit.utils.PasswordHash)

Example 13 with CheckBox

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

the class CheckFormGroup method initLayout.

private void initLayout(IModel<String> label, final String tooltipKey, String labelSize, String textSize) {
    WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
    labelContainer.setOutputMarkupId(true);
    add(labelContainer);
    Label l = new Label(ID_LABEL, label);
    l.setOutputMarkupId(true);
    if (StringUtils.isNotEmpty(labelSize)) {
        labelContainer.add(AttributeAppender.prepend("class", labelSize));
    }
    labelContainer.add(l);
    Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
    tooltipLabel.add(new AttributeAppender("data-original-title", (IModel<String>) () -> getString(tooltipKey)));
    tooltipLabel.add(new InfoTooltipBehavior());
    tooltipLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return tooltipKey != null;
        }
    });
    tooltipLabel.setOutputMarkupId(true);
    tooltipLabel.setOutputMarkupPlaceholderTag(true);
    labelContainer.add(tooltipLabel);
    labelContainer.add(new VisibleBehaviour(() -> getLabelVisible()) {
    });
    WebMarkupContainer checkWrapper = new WebMarkupContainer(ID_CHECK_WRAPPER);
    if (StringUtils.isNotEmpty(textSize)) {
        checkWrapper.add(AttributeAppender.prepend("class", textSize));
    }
    add(checkWrapper);
    checkWrapper.setOutputMarkupId(true);
    CheckBox check = new CheckBox(ID_CHECK, getModel());
    check.setOutputMarkupId(true);
    check.setLabel(label);
    checkWrapper.add(check);
    setOutputMarkupId(true);
}
Also used : InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) IModel(org.apache.wicket.model.IModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) CheckBox(org.apache.wicket.markup.html.form.CheckBox) Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 14 with CheckBox

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

the class DefinitionStagePanel method initLayout.

protected void initLayout(PageBase pageBase) {
    TextField nameField = new TextField<>(ID_NAME, new PropertyModel<>(getModel(), StageDefinitionDto.F_NAME));
    add(nameField);
    TextArea descriptionField = new TextArea<>(ID_DESCRIPTION, new PropertyModel<>(getModel(), StageDefinitionDto.F_DESCRIPTION));
    add(descriptionField);
    TextField durationField = new TextField<>(ID_DURATION, new PropertyModel<>(getModel(), StageDefinitionDto.F_DURATION));
    add(durationField);
    add(WebComponentUtil.createHelp(ID_STAGE_DURATION_HELP));
    TextField notifyBeforeDeadlineField = new TextField<>(ID_NOTIFY_BEFORE_DEADLINE, new PropertyModel<>(getModel(), StageDefinitionDto.F_NOTIFY_BEFORE_DEADLINE));
    add(notifyBeforeDeadlineField);
    add(WebComponentUtil.createHelp(ID_NOTIFY_BEFORE_DEADLINE_HELP));
    add(new CheckBox(ID_NOTIFY_ONLY_WHEN_NO_DECISION, new PropertyModel<>(getModel(), StageDefinitionDto.F_NOTIFY_ONLY_WHEN_NO_DECISION)));
    add(WebComponentUtil.createHelp(ID_NOTIFY_WHEN_NO_DECISION_HELP));
    TextField reviewerNameField = new TextField<>(ID_REVIEWER_NAME, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_NAME));
    add(reviewerNameField);
    TextArea reviewerDescriptionField = new TextArea<>(ID_REVIEWER_DESCRIPTION, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_DESCRIPTION));
    add(reviewerDescriptionField);
    add(new CheckBox(ID_USE_TARGET_OWNER, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_USE_TARGET_OWNER)));
    add(new CheckBox(ID_USE_TARGET_APPROVER, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_USE_TARGET_APPROVER)));
    add(WebComponentUtil.createHelp(ID_TARGET_HELP));
    add(new CheckBox(ID_USE_OBJECT_OWNER, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_USE_OBJECT_OWNER)));
    add(new CheckBox(ID_USE_OBJECT_APPROVER, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_USE_OBJECT_APPROVER)));
    add(WebComponentUtil.createHelp(ID_OBJECT_HELP));
    AjaxCheckBox useObjectManagerCheckbox = new AjaxCheckBox(ID_USE_OBJECT_MANAGER, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_USE_OBJECT_MANAGER_PRESENT)) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(DefinitionStagePanel.this.get(ID_USE_OBJECT_MANAGER_DETAILS));
        }
    };
    add(useObjectManagerCheckbox);
    WebMarkupContainer useObjectManagerDetails = new WebMarkupContainer(ID_USE_OBJECT_MANAGER_DETAILS);
    useObjectManagerDetails.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return useObjectManagerCheckbox.getModelObject();
        }
    });
    useObjectManagerDetails.setOutputMarkupId(true);
    add(useObjectManagerDetails);
    add(WebComponentUtil.createHelp(ID_USE_OBJECT_MANAGER_HELP));
    TextField orgTypeField = new TextField<>(ID_USE_OBJECT_MANAGER_ORG_TYPE, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_USE_OBJECT_MANAGER + "." + ManagerSearchDto.F_ORG_TYPE));
    orgTypeField.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    useObjectManagerDetails.add(orgTypeField);
    useObjectManagerDetails.add(WebComponentUtil.createHelp(ID_USE_OBJECT_MANAGER_ORG_TYPE_HELP));
    CheckBox allowSelf = new CheckBox(ID_USE_OBJECT_MANAGER_ALLOW_SELF, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_USE_OBJECT_MANAGER + "." + ManagerSearchDto.F_ALLOW_SELF));
    allowSelf.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    useObjectManagerDetails.add(allowSelf);
    useObjectManagerDetails.add(WebComponentUtil.createHelp(ID_USE_OBJECT_MANAGER_ALLOW_SELF_HELP));
    try {
        ItemPanelSettingsBuilder builder = new ItemPanelSettingsBuilder().visibilityHandler(iw -> ItemVisibility.AUTO);
        Panel defaultOwnerRefPanel = pageBase.initItemPanel(ID_DEFAULT_REVIEWER_REF, ObjectReferenceType.COMPLEX_TYPE, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_DEFAULT_REVIEWERS), builder.build());
        add(defaultOwnerRefPanel);
        add(WebComponentUtil.createHelp(ID_DEFAULT_REVIEWER_REF_HELP));
        Panel additionalOwnerRefPanel = pageBase.initItemPanel(ID_ADDITIONAL_REVIEWER_REF, ObjectReferenceType.COMPLEX_TYPE, new PropertyModel<>(getModel(), StageDefinitionDto.F_REVIEWER_DTO + "." + AccessCertificationReviewerDto.F_ADDITIONAL_REVIEWERS), builder.build());
        add(additionalOwnerRefPanel);
        add(WebComponentUtil.createHelp(ID_ADDITIONAL_REVIEWER_REF_HELP));
    } catch (SchemaException e) {
    }
    DropDownChoice outcomeStrategy1 = new DropDownChoice<>(ID_OUTCOME_STRATEGY, new PropertyModel<>(getModel(), StageDefinitionDto.F_OUTCOME_STRATEGY), WebComponentUtil.createReadonlyModelFromEnum(AccessCertificationCaseOutcomeStrategyType.class), new EnumChoiceRenderer<>(this));
    add(outcomeStrategy1);
    add(WebComponentUtil.createHelp(ID_OUTCOME_STRATEGY_HELP));
    DropDownChoice<AccessCertificationResponseType> outcomeIfNoReviewers = new DropDownChoice<>(ID_OUTCOME_IF_NO_REVIEWERS, new PropertyModel<>(getModel(), StageDefinitionDto.F_OUTCOME_IF_NO_REVIEWERS), WebComponentUtil.createReadonlyModelFromEnum(AccessCertificationResponseType.class), new EnumChoiceRenderer<>(this));
    add(outcomeIfNoReviewers);
    add(WebComponentUtil.createHelp(ID_OUTCOME_IF_NO_REVIEWERS_HELP));
    Label stopReviewOn = new Label(ID_STOP_REVIEW_ON, new IModel<String>() {

        @Override
        public String getObject() {
            List<AccessCertificationResponseType> stopOn = getModelObject().getStopReviewOn();
            return CertMiscUtil.getStopReviewOnText(stopOn, getPageBase());
        }
    });
    add(stopReviewOn);
    add(WebComponentUtil.createHelp(ID_STOP_REVIEW_ON_HELP));
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) TextArea(org.apache.wicket.markup.html.form.TextArea) PropertyModel(org.apache.wicket.model.PropertyModel) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) Label(org.apache.wicket.markup.html.basic.Label) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AccessCertificationResponseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ItemPanelSettingsBuilder(com.evolveum.midpoint.gui.impl.prism.panel.ItemPanelSettingsBuilder) ItemHeaderPanel(com.evolveum.midpoint.gui.impl.prism.panel.ItemHeaderPanel) Panel(org.apache.wicket.markup.html.panel.Panel) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) AccessCertificationCaseOutcomeStrategyType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseOutcomeStrategyType) CheckBox(org.apache.wicket.markup.html.form.CheckBox) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) TextField(org.apache.wicket.markup.html.form.TextField) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 15 with CheckBox

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

the class SchemaListPanel method initDetailsPanel.

private void initDetailsPanel(WebMarkupContainer parent) {
    WebMarkupContainer detailsContainer = new WebMarkupContainer(ID_DETAILS_PANEL);
    detailsContainer.setOutputMarkupId(true);
    detailsContainer.setOutputMarkupPlaceholderTag(true);
    parent.add(detailsContainer);
    Label displayName = new Label(ID_DETAILS_DISPLAY_NAME, new PropertyModel<String>(detailsModel, ObjectClassDetailsDto.F_DISPLAY_NAME));
    detailsContainer.add(displayName);
    Label description = new Label(ID_DETAILS_DESCRIPTION, new PropertyModel<String>(detailsModel, ObjectClassDetailsDto.F_DESCRIPTION));
    detailsContainer.add(description);
    Label kind = new Label(ID_DETAILS_KIND, new PropertyModel<String>(detailsModel, ObjectClassDetailsDto.F_KIND));
    detailsContainer.add(kind);
    Label intent = new Label(ID_DETAILS_INTENT, new PropertyModel<String>(detailsModel, ObjectClassDetailsDto.F_INTENT));
    detailsContainer.add(intent);
    Label nativeObjectClass = new Label(ID_DETAILS_NATIVE_OBJECT_CLASS, new PropertyModel<String>(detailsModel, ObjectClassDetailsDto.F_NATIVE_OBJECT_CLASS));
    detailsContainer.add(nativeObjectClass);
    CheckBox isDefault = new CheckBox(ID_DETAILS_DEFAULT, new PropertyModel<>(detailsModel, ObjectClassDetailsDto.F_IS_DEFAULT));
    isDefault.setEnabled(false);
    detailsContainer.add(isDefault);
    Label kindTooltip = new Label(ID_T_KIND);
    kindTooltip.add(new InfoTooltipBehavior());
    detailsContainer.add(kindTooltip);
    Label intentTooltip = new Label(ID_T_INTENT);
    intentTooltip.add(new InfoTooltipBehavior());
    detailsContainer.add(intentTooltip);
    Label nativeObjClassTooltip = new Label(ID_T_NATIVE_OBJECT_CLASS);
    nativeObjClassTooltip.add(new InfoTooltipBehavior());
    detailsContainer.add(nativeObjClassTooltip);
    Label defaultTooltip = new Label(ID_T_DEFAULT);
    defaultTooltip.add(new InfoTooltipBehavior());
    detailsContainer.add(defaultTooltip);
}
Also used : InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) CheckBox(org.apache.wicket.markup.html.form.CheckBox) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

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