Search in sources :

Example 1 with PageSelfProfile

use of com.evolveum.midpoint.web.page.self.PageSelfProfile in project midpoint by Evolveum.

the class PasswordPanel method initLayout.

private void initLayout(final IModel<ProtectedStringType> model, final boolean isReadOnly) {
    setOutputMarkupId(true);
    final WebMarkupContainer inputContainer = new WebMarkupContainer(ID_INPUT_CONTAINER) {

        @Override
        public boolean isVisible() {
            return passwordInputVisble;
        }
    };
    inputContainer.setOutputMarkupId(true);
    add(inputContainer);
    final PasswordTextField password1 = new PasswordTextField(ID_PASSWORD_ONE, new PasswordModel(model));
    password1.setRequired(false);
    password1.setResetPassword(false);
    password1.setOutputMarkupId(true);
    password1.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    inputContainer.add(password1);
    final PasswordTextField password2 = new PasswordTextField(ID_PASSWORD_TWO, new Model<String>());
    password2.setRequired(false);
    password2.setResetPassword(false);
    password2.setOutputMarkupId(true);
    password2.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    inputContainer.add(password2);
    password1.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            boolean required = !StringUtils.isEmpty(password1.getModel().getObject());
            password2.setRequired(required);
        //fix of MID-2463
        //				target.add(password2);
        //				target.appendJavaScript("$(\"#"+ password2.getMarkupId() +"\").focus()");
        }
    });
    password2.add(new PasswordValidator(password1, password2));
    final WebMarkupContainer linkContainer = new WebMarkupContainer(ID_LINK_CONTAINER) {

        @Override
        public boolean isVisible() {
            return !passwordInputVisble;
        }
    };
    inputContainer.setOutputMarkupId(true);
    linkContainer.setOutputMarkupId(true);
    add(linkContainer);
    final Label passwordSetLabel = new Label(ID_PASSWORD_SET, new ResourceModel("passwordPanel.passwordSet"));
    linkContainer.add(passwordSetLabel);
    final Label passwordRemoveLabel = new Label(ID_PASSWORD_REMOVE, new ResourceModel("passwordPanel.passwordRemoveLabel"));
    passwordRemoveLabel.setVisible(false);
    linkContainer.add(passwordRemoveLabel);
    AjaxLink link = new AjaxLink(ID_CHANGE_PASSWORD_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onLinkClick(target);
        }

        @Override
        public boolean isVisible() {
            return !passwordInputVisble;
        }
    };
    link.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !isReadOnly;
        }
    });
    link.setBody(new ResourceModel("passwordPanel.passwordChange"));
    link.setOutputMarkupId(true);
    linkContainer.add(link);
    final WebMarkupContainer removeButtonContainer = new WebMarkupContainer(ID_REMOVE_BUTTON_CONTAINER);
    AjaxLink removePassword = new AjaxLink(ID_REMOVE_PASSWORD_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onRemovePassword(model, target);
        }
    };
    removePassword.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            PageBase pageBase = (PageBase) getPage();
            if (pageBase == null) {
                return false;
            }
            if (pageBase instanceof PageSelfProfile) {
                return false;
            }
            if (pageBase instanceof PageUser && model.getObject() != null && !model.getObject().isEmpty()) {
                return true;
            }
            return false;
        }
    });
    removePassword.setBody(new ResourceModel("passwordPanel.passwordRemove"));
    removePassword.setOutputMarkupId(true);
    removeButtonContainer.add(removePassword);
    add(removeButtonContainer);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) Label(org.apache.wicket.markup.html.basic.Label) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) PageSelfProfile(com.evolveum.midpoint.web.page.self.PageSelfProfile) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PageUser(com.evolveum.midpoint.web.page.admin.users.PageUser) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ResourceModel(org.apache.wicket.model.ResourceModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 2 with PageSelfProfile

use of com.evolveum.midpoint.web.page.self.PageSelfProfile in project midpoint by Evolveum.

the class FocusMainPanel method addDefaultTabs.

protected void addDefaultTabs(final PageAdminObjectDetails<F> parentPage, List<ITab> tabs) {
    FocusTabVisibleBehavior authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_BASIC_URL);
    tabs.add(new PanelTab(parentPage.createStringResource("pageAdminFocus.basic"), authorization) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return createFocusDetailsTabPanel(panelId, parentPage);
        }
    });
    authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_PROJECTIONS_URL);
    tabs.add(new CountablePanelTab(parentPage.createStringResource("pageAdminFocus.projections"), authorization) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return createFocusProjectionsTabPanel(panelId, parentPage);
        }

        @Override
        public String getCount() {
            return Integer.toString(projectionModel.getObject() == null ? 0 : projectionModel.getObject().size());
        }
    });
    authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_PERSONAS_URL);
    tabs.add(new PanelTab(parentPage.createStringResource("pageAdminFocus.personas"), authorization) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return new FocusPersonasTabPanel<F>(panelId, getMainForm(), getObjectModel(), parentPage);
        }
    });
    authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_ASSIGNMENTS_URL);
    tabs.add(new CountablePanelTab(parentPage.createStringResource("pageAdminFocus.assignments"), authorization) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return createFocusAssignmentsTabPanel(panelId, parentPage);
        }

        @Override
        public String getCount() {
            return Integer.toString(assignmentsModel.count());
        }
    });
    authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_TASKS_URL);
    tabs.add(new CountablePanelTab(parentPage.createStringResource("pageAdminFocus.tasks"), authorization) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return new FocusTasksTabPanel<F>(panelId, getMainForm(), getObjectModel(), taskDtoProvider, parentPage);
        }

        @Override
        public String getCount() {
            return Long.toString(taskDtoProvider == null ? 0L : taskDtoProvider.size());
        }
    });
    if (!(parentPage instanceof PageSelfProfile)) {
        authorization = new FocusTabVisibleBehavior(unwrapModel(), ComponentConstants.UI_FOCUS_TAB_REQUEST_ROLE_URL);
        tabs.add(new PanelTab(parentPage.createStringResource("pageAdminFocus.request"), authorization) {

            private static final long serialVersionUID = 1L;

            @Override
            public WebMarkupContainer createPanel(String panelId) {
                return createRequestAssignmentTabPanel(panelId, parentPage);
            }
        });
    }
}
Also used : PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) CountablePanelTab(com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab) FocusTabVisibleBehavior(com.evolveum.midpoint.gui.api.util.FocusTabVisibleBehavior) CountablePanelTab(com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab) PageSelfProfile(com.evolveum.midpoint.web.page.self.PageSelfProfile) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Aggregations

PageSelfProfile (com.evolveum.midpoint.web.page.self.PageSelfProfile)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 CountablePanelTab (com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab)1 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)1 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)1 FocusTabVisibleBehavior (com.evolveum.midpoint.gui.api.util.FocusTabVisibleBehavior)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 PageUser (com.evolveum.midpoint.web.page.admin.users.PageUser)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)1 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)1 Label (org.apache.wicket.markup.html.basic.Label)1 PasswordTextField (org.apache.wicket.markup.html.form.PasswordTextField)1 ResourceModel (org.apache.wicket.model.ResourceModel)1