Search in sources :

Example 11 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase 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 12 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class FocusMainPanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    StringValue oidValue = getPage().getPageParameters().get(OnePageParameterEncoder.PARAMETER);
    taskDtoProvider.setQuery(createTaskQuery(oidValue != null ? oidValue.toString() : null, (PageBase) getPage()));
}
Also used : StringValue(org.apache.wicket.util.string.StringValue) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Example 13 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class FocusMainPanel method createTabPanel.

protected WebMarkupContainer createTabPanel(String panelId, FormSpecificationType formSpecificationType, PageAdminObjectDetails<F> parentPage) {
    String panelClassName = formSpecificationType.getPanelClass();
    Class<?> panelClass;
    try {
        panelClass = Class.forName(panelClassName);
    } catch (ClassNotFoundException e) {
        throw new SystemException("Panel class '" + panelClassName + "' as specified in admin GUI configuration was not found", e);
    }
    if (AbstractFocusTabPanel.class.isAssignableFrom(panelClass)) {
        Constructor<?> constructor;
        try {
            constructor = panelClass.getConstructor(String.class, Form.class, LoadableModel.class, LoadableModel.class, LoadableModel.class, PageBase.class);
        } catch (NoSuchMethodException | SecurityException e) {
            throw new SystemException("Unable to locate constructor (String,Form,LoadableModel,LoadableModel,LoadableModel,PageBase) in " + panelClass + ": " + e.getMessage(), e);
        }
        AbstractFocusTabPanel<F> tabPanel;
        try {
            tabPanel = (AbstractFocusTabPanel<F>) constructor.newInstance(panelId, getMainForm(), getObjectModel(), assignmentsModel, projectionModel, parentPage);
        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            throw new SystemException("Error instantiating " + panelClass + ": " + e.getMessage(), e);
        }
        return tabPanel;
    } else if (AbstractObjectTabPanel.class.isAssignableFrom(panelClass)) {
        Constructor<?> constructor;
        try {
            constructor = panelClass.getConstructor(String.class, Form.class, LoadableModel.class, PageBase.class);
        } catch (NoSuchMethodException | SecurityException e) {
            throw new SystemException("Unable to locate constructor (String,Form,LoadableModel,PageBase) in " + panelClass + ": " + e.getMessage(), e);
        }
        AbstractObjectTabPanel<F> tabPanel;
        try {
            tabPanel = (AbstractObjectTabPanel<F>) constructor.newInstance(panelId, getMainForm(), getObjectModel(), parentPage);
        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            throw new SystemException("Error instantiating " + panelClass + ": " + e.getMessage(), e);
        }
        return tabPanel;
    } else {
        throw new UnsupportedOperationException("Tab panels that are not subclasses of AbstractObjectTabPanel or AbstractFocusTabPanel are not supported yet (got " + panelClass + ")");
    }
}
Also used : Form(com.evolveum.midpoint.web.component.form.Form) Constructor(java.lang.reflect.Constructor) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) InvocationTargetException(java.lang.reflect.InvocationTargetException) SystemException(com.evolveum.midpoint.util.exception.SystemException) CountableLoadableModel(com.evolveum.midpoint.gui.api.model.CountableLoadableModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Example 14 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class UserMenuPanel method loadModel.

private PasswordQuestionsDto loadModel(PageBase parentPage) {
    LOGGER.trace("Loading user for Security Question Page.");
    PasswordQuestionsDto dto = new PasswordQuestionsDto();
    OperationResult result = new OperationResult(OPERATION_LOAD_USER);
    if (parentPage == null) {
        parentPage = ((PageBase) getPage());
    }
    try {
        MidPointPrincipal principal = SecurityUtils.getPrincipalUser();
        if (principal == null) {
            result.recordNotApplicableIfUnknown();
            return null;
        }
        String userOid = principal.getOid();
        Task task = parentPage.createSimpleTask(OPERATION_LOAD_USER);
        OperationResult subResult = result.createSubresult(OPERATION_LOAD_USER);
        Collection options = SelectorOptions.createCollection(UserType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
        PrismObject<UserType> user = parentPage.getModelService().getObject(UserType.class, userOid, options, task, subResult);
        userModel.setObject(user);
        jpegPhoto = user == null ? null : (user.asObjectable() == null ? null : user.asObjectable().getJpegPhoto());
        dto.setSecurityAnswers(createUsersSecurityQuestionsList(user));
        subResult.recordSuccessIfUnknown();
    } catch (Exception ex) {
        LoggingUtils.logExceptionOnDebugLevel(LOGGER, "Couldn't get user Questions, Probably not set yet", ex);
    } finally {
        result.recomputeStatus();
        isUserModelLoaded = true;
    }
    return dto;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) PasswordQuestionsDto(com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal)

Example 15 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class PageConnectorHosts method deleteHostPerformed.

private void deleteHostPerformed(AjaxRequestTarget target) {
    List<SelectableBean<ConnectorHostType>> selected = WebComponentUtil.getSelectedData(getConnectorHostTable());
    if (selected.isEmpty()) {
        warn(getString("pageResources.message.noHostSelected"));
        target.add(getFeedbackPanel());
        return;
    }
    ConfirmationPanel dialog = new ConfirmationPanel(((PageBase) getPage()).getMainPopupBodyId(), createDeleteConfirmString("pageResources.message.deleteHostConfirm", "pageResources.message.deleteHostsConfirm", false)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void yesPerformed(AjaxRequestTarget target) {
            ((PageBase) getPage()).hideMainPopup(target);
            deleteHostConfirmedPerformed(target);
        }
    };
    ((PageBase) getPage()).showMainPopup(dialog, target);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Aggregations

PageBase (com.evolveum.midpoint.gui.api.page.PageBase)44 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)16 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)13 Task (com.evolveum.midpoint.task.api.Task)9 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 SystemException (com.evolveum.midpoint.util.exception.SystemException)6 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)5 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)5 ModelService (com.evolveum.midpoint.model.api.ModelService)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)4 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)4 ConfirmationPanel (com.evolveum.midpoint.web.component.dialog.ConfirmationPanel)4 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)4 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 RestartResponseException (org.apache.wicket.RestartResponseException)3