Search in sources :

Example 16 with PageBase

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

the class PageResources method deleteResourcePerformed.

private void deleteResourcePerformed(AjaxRequestTarget target, ResourceType single) {
    List<ResourceType> selected = isAnyResourceSelected(target, single);
    singleDelete = single;
    if (selected.isEmpty()) {
        return;
    }
    ConfirmationPanel dialog = new ConfirmationPanel(((PageBase) getPage()).getMainPopupBodyId(), createDeleteConfirmString("pageResources.message.deleteResourceConfirm", "pageResources.message.deleteResourcesConfirm", true)) {

        @Override
        public void yesPerformed(AjaxRequestTarget target) {
            ((PageBase) getPage()).hideMainPopup(target);
            deleteResourceConfirmedPerformed(target);
        }
    };
    ((PageBase) getPage()).showMainPopup(dialog, target);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Example 17 with PageBase

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

the class LockoutStatusPanel method initLayout.

private void initLayout(final IModel<LockoutStatusType> model) {
    WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
    add(container);
    Label label = new Label(ID_LABEL, new IModel<String>() {

        @Override
        public String getObject() {
            LockoutStatusType object = model != null ? model.getObject() : null;
            String labelValue = object == null ? ((PageBase) getPage()).createStringResource("LockoutStatusType.UNDEFINED").getString() : WebComponentUtil.createLocalizedModelForEnum(object, getLabel()).getObject();
            if (!isInitialState) {
                labelValue += " " + ((PageBase) getPage()).createStringResource("LockoutStatusPanel.changesSaving").getString();
            }
            return labelValue;
        }

        @Override
        public void setObject(String s) {
        }

        @Override
        public void detach() {
        }
    });
    label.setOutputMarkupId(true);
    container.add(label);
    AjaxButton button = new AjaxButton(ID_BUTTON, getButtonModel()) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            PrismPropertyValue oldValue = (PrismPropertyValue) valueWrapper.getOldValue();
            if (!isInitialState) {
                model.setObject(initialValue);
                oldValue.setValue(initialValue);
                valueWrapper.setStatus(ValueStatus.NOT_CHANGED);
            } else {
                model.setObject(LockoutStatusType.NORMAL);
                if (oldValue.getValue() != null) {
                    oldValue.setValue(null);
                }
            }
            isInitialState = !isInitialState;
            ajaxRequestTarget.add(getButton());
            ajaxRequestTarget.add(getLabel());
        }
    };
    button.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return true;
        }
    });
    button.setOutputMarkupId(true);
    container.add(button);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) LockoutStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 18 with PageBase

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

the class WebComponentUtil method dispatchToObjectDetailsPage.

public static void dispatchToObjectDetailsPage(Class<? extends ObjectType> objectClass, String oid, Component component, boolean failIfUnsupported) {
    PageParameters parameters = new PageParameters();
    parameters.add(OnePageParameterEncoder.PARAMETER, oid);
    Class<? extends PageBase> page = getObjectDetailsPage(objectClass);
    if (page != null) {
        ((PageBase) component.getPage()).navigateToNext(page, parameters);
    } else if (failIfUnsupported) {
        throw new SystemException("Cannot determine details page for " + objectClass);
    }
}
Also used : SystemException(com.evolveum.midpoint.util.exception.SystemException) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Example 19 with PageBase

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

the class PageRequestRole method loadUser.

private void loadUser() {
    LOGGER.debug("Loading user and accounts.");
    OperationResult result = new OperationResult(OPERATION_LOAD_USER);
    try {
        String userOid = SecurityUtils.getPrincipalUser().getOid();
        Task task = createSimpleTask(OPERATION_LOAD_USER);
        user = WebModelServiceUtils.loadObject(UserType.class, userOid, null, (PageBase) getPage(), task, result);
        result.recordSuccessIfUnknown();
        result.recordSuccessIfUnknown();
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load accounts", ex);
        result.recordFatalError("Couldn't load accounts", ex);
    } finally {
        result.recomputeStatus();
    }
    if (!result.isSuccess() && !result.isHandledError()) {
        showResult(result);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) SchemaException(com.evolveum.midpoint.util.exception.SchemaException)

Example 20 with PageBase

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

the class PageSelfDashboard method initMyAccounts.

private void initMyAccounts() {
    AsyncDashboardPanel<Object, List<SimpleAccountDto>> accounts = new AsyncDashboardPanel<Object, List<SimpleAccountDto>>(ID_ACCOUNTS, createStringResource("PageDashboard.accounts"), GuiStyleConstants.CLASS_SHADOW_ICON_ACCOUNT, GuiStyleConstants.CLASS_OBJECT_SHADOW_BOX_CSS_CLASSES, true) {

        private static final long serialVersionUID = 1L;

        @Override
        protected SecurityContextAwareCallable<CallableResult<List<SimpleAccountDto>>> createCallable(Authentication auth, IModel<Object> callableParameterModel) {
            return new SecurityContextAwareCallable<CallableResult<List<SimpleAccountDto>>>(getSecurityEnforcer(), auth) {

                @Override
                public AccountCallableResult<List<SimpleAccountDto>> callWithContextPrepared() throws Exception {
                    return loadAccounts();
                }
            };
        }

        @Override
        protected Component getMainComponent(String markupId) {
            return new MyAccountsPanel(markupId, new PropertyModel<List<SimpleAccountDto>>(getModel(), CallableResult.F_VALUE));
        }

        @Override
        protected void onPostSuccess(AjaxRequestTarget target) {
            showFetchResult();
            super.onPostSuccess(target);
        }

        @Override
        protected void onUpdateError(AjaxRequestTarget target, Exception ex) {
            showFetchResult();
            super.onUpdateError(target, ex);
        }

        private void showFetchResult() {
            AccountCallableResult<List<SimpleAccountDto>> result = (AccountCallableResult<List<SimpleAccountDto>>) getModel().getObject();
            PageBase page = (PageBase) getPage();
            for (OperationResult res : result.getFetchResults()) {
                if (!WebComponentUtil.isSuccessOrHandledError(res)) {
                    page.showResult(res);
                }
            }
        }
    };
    accounts.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            UserInterfaceElementVisibilityType visibilityType = getComponentVisibility(PredefinedDashboardWidgetId.MY_ACCOUNTS);
            return WebComponentUtil.getElementVisibility(visibilityType);
        }
    });
    add(accounts);
}
Also used : IModel(org.apache.wicket.model.IModel) SimpleAccountDto(com.evolveum.midpoint.web.page.admin.home.dto.SimpleAccountDto) SecurityContextAwareCallable(com.evolveum.midpoint.web.component.SecurityContextAwareCallable) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AsyncDashboardPanel(com.evolveum.midpoint.web.page.admin.home.component.AsyncDashboardPanel) MyAccountsPanel(com.evolveum.midpoint.web.page.admin.home.component.MyAccountsPanel) Authentication(org.springframework.security.core.Authentication) AccountCallableResult(com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult) PrismObject(com.evolveum.midpoint.prism.PrismObject) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) CallableResult(com.evolveum.midpoint.web.component.util.CallableResult) AccountCallableResult(com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult)

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