Search in sources :

Example 21 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters 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 22 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters in project midpoint by Evolveum.

the class PageCertDecisions method initColumns.

//	private void addVisibleOnWarningBehavior(Component c) {
//		c.add(new VisibleEnableBehaviour() {
//			@Override
//			public boolean isVisible() {
//				return PageCertDecisions.this.getFeedbackMessages().hasMessage(FeedbackMessage.WARNING);
//			}
//		});
//	}
private List<IColumn<CertWorkItemDto, String>> initColumns() {
    List<IColumn<CertWorkItemDto, String>> columns = new ArrayList<>();
    IColumn<CertWorkItemDto, String> column;
    column = new CheckBoxHeaderColumn<>();
    columns.add(column);
    column = helper.createTypeColumn(OBJECT, this);
    columns.add(column);
    column = helper.createObjectNameColumn(this, "PageCertDecisions.table.objectName");
    columns.add(column);
    column = helper.createTypeColumn(TARGET, this);
    columns.add(column);
    column = helper.createTargetNameColumn(this, "PageCertDecisions.table.targetName");
    columns.add(column);
    column = helper.createDetailedInfoColumn(this);
    columns.add(column);
    column = helper.createConflictingNameColumn(this, "PageCertDecisions.table.conflictingTargetName");
    columns.add(column);
    if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_CERTIFICATION_ALL_URL, AuthorizationConstants.AUTZ_UI_CERTIFICATION_CAMPAIGN_URL)) {
        column = new LinkColumn<CertWorkItemDto>(createStringResource("PageCertDecisions.table.campaignName"), SearchingUtils.CAMPAIGN_NAME, CertWorkItemDto.F_CAMPAIGN_NAME) {

            @Override
            public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, IModel<CertWorkItemDto> rowModel) {
                super.populateItem(item, componentId, rowModel);
                AccessCertificationCampaignType campaign = rowModel.getObject().getCampaign();
                if (campaign != null && campaign.getDescription() != null) {
                    item.add(AttributeModifier.replace("title", campaign.getDescription()));
                    item.add(new TooltipBehavior());
                }
            }

            @Override
            public void onClick(AjaxRequestTarget target, IModel<CertWorkItemDto> rowModel) {
                CertWorkItemDto dto = rowModel.getObject();
                PageParameters parameters = new PageParameters();
                parameters.add(OnePageParameterEncoder.PARAMETER, dto.getCampaignRef().getOid());
                navigateToNext(PageCertCampaign.class, parameters);
            }
        };
    } else {
        column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.campaignName"), SearchingUtils.CAMPAIGN_NAME) {

            @Override
            public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
                item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {

                    @Override
                    public Object getObject() {
                        return rowModel.getObject().getCampaignName();
                    }
                }));
            }
        };
    }
    columns.add(column);
    column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.campaignStage")) {

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
            item.add(new Label(componentId, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    CertWorkItemDto dto = rowModel.getObject();
                    return dto.getCampaignStageNumber() + "/" + dto.getCampaignStageCount();
                }
            }));
            String stageName = rowModel.getObject().getCurrentStageName();
            if (stageName != null) {
                item.add(AttributeModifier.replace("title", stageName));
                item.add(new TooltipBehavior());
            }
        }
    };
    columns.add(column);
    column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.escalation")) {

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
            item.add(new Label(componentId, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    CertWorkItemDto dto = rowModel.getObject();
                    Integer n = dto.getEscalationLevelNumber();
                    return n != null ? String.valueOf(n) : null;
                }
            }));
            String info = rowModel.getObject().getEscalationLevelInfo();
            if (info != null) {
                item.add(AttributeModifier.replace("title", info));
                item.add(new TooltipBehavior());
            }
        }
    };
    columns.add(column);
    column = new PropertyColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.requested"), SearchingUtils.CURRENT_REVIEW_REQUESTED_TIMESTAMP, CertWorkItemDto.F_REVIEW_REQUESTED) {

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, IModel<CertWorkItemDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            CertWorkItemDto dto = rowModel.getObject();
            Date started = dto.getStageStarted();
            if (started != null) {
                item.add(AttributeModifier.replace("title", WebComponentUtil.getLocalizedDate(started, DateLabelComponent.LONG_MEDIUM_STYLE)));
                item.add(new TooltipBehavior());
            }
        }
    };
    columns.add(column);
    column = new PropertyColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.deadline"), SearchingUtils.CURRENT_REVIEW_DEADLINE, CertWorkItemDto.F_DEADLINE_AS_STRING) {

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            XMLGregorianCalendar deadline = rowModel.getObject().getCertCase().getCurrentStageDeadline();
            if (deadline != null) {
                item.add(AttributeModifier.replace("title", WebComponentUtil.formatDate(deadline)));
                item.add(new TooltipBehavior());
            }
        }
    };
    columns.add(column);
    final AvailableResponses availableResponses = new AvailableResponses(getPage());
    final int responses = availableResponses.getResponseKeys().size();
    column = new MultiButtonColumn<CertWorkItemDto>(new Model(), responses + 1) {

        @Override
        public String getCaption(int id) {
            return availableResponses.getCaption(id);
        }

        @Override
        public boolean isButtonEnabled(int id, IModel<CertWorkItemDto> model) {
            if (id < responses) {
                return !decisionEquals(model, availableResponses.getResponseValues().get(id));
            } else {
                return false;
            }
        }

        @Override
        public boolean isButtonVisible(int id, IModel<CertWorkItemDto> model) {
            if (id < responses) {
                return true;
            } else {
                return !availableResponses.isAvailable(model.getObject().getResponse());
            }
        }

        @Override
        public String getButtonColorCssClass(int id) {
            if (id < responses) {
                return getDecisionButtonColor(getRowModel(), availableResponses.getResponseValues().get(id));
            } else {
                return BUTTON_COLOR_CLASS.DANGER.toString();
            }
        }

        @Override
        public void clickPerformed(int id, AjaxRequestTarget target, IModel<CertWorkItemDto> model) {
            if (id < responses) {
                // should be always the case
                recordActionPerformed(target, model.getObject(), availableResponses.getResponseValues().get(id));
            }
        }
    };
    columns.add(column);
    column = new DirectlyEditablePropertyColumn<CertWorkItemDto>(createStringResource("PageCertDecisions.table.comment"), CertWorkItemDto.F_COMMENT) {

        @Override
        public void onBlur(AjaxRequestTarget target, IModel model) {
            // TODO determine somehow if the model.comment was really changed
            recordActionPerformed(target, (CertWorkItemDto) model.getObject(), null);
        }
    };
    columns.add(column);
    columns.add(new InlineMenuHeaderColumn(createInlineMenu(availableResponses)));
    return columns;
}
Also used : ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AvailableResponses(com.evolveum.midpoint.web.page.admin.certification.helpers.AvailableResponses) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) CertWorkItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertWorkItemDto) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType) IModel(org.apache.wicket.model.IModel) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Date(java.util.Date) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model)

Example 23 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters in project midpoint by Evolveum.

the class PageAccounts method ownerDetailsPerformed.

private <F extends FocusType> void ownerDetailsPerformed(AjaxRequestTarget target, IModel<SelectableBean> model) {
    F focus = loadShadowOwner(model);
    if (focus == null) {
        error(getString("PageAccounts.message.cantShowOwner"));
        target.add(getFeedbackPanel());
        return;
    }
    PageParameters parameters = new PageParameters();
    parameters.add(OnePageParameterEncoder.PARAMETER, focus.getOid());
    if (focus instanceof UserType) {
        navigateToNext(PageUser.class, parameters);
    } else if (focus instanceof RoleType) {
        navigateToNext(PageRole.class, parameters);
    } else if (focus instanceof OrgType) {
        navigateToNext(PageOrgUnit.class, parameters);
    } else {
        error(getString("PageAccounts.message.unsupportedOwnerType"));
        target.add(getFeedbackPanel());
        return;
    }
}
Also used : RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) PageRole(com.evolveum.midpoint.web.page.admin.roles.PageRole) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 24 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters in project midpoint by Evolveum.

the class PageCertDefinitions method detailsPerformed.

protected void detailsPerformed(AjaxRequestTarget target, AccessCertificationDefinitionType service) {
    PageParameters parameters = new PageParameters();
    parameters.add(OnePageParameterEncoder.PARAMETER, service.getOid());
    navigateToNext(PageCertDefinition.class, parameters);
}
Also used : PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters)

Example 25 with PageParameters

use of org.apache.wicket.request.mapper.parameter.PageParameters in project midpoint by Evolveum.

the class PageDebugList method deleteAllTypeConfirmed.

private void deleteAllTypeConfirmed(AjaxRequestTarget target) {
    DebugSearchDto dto = searchModel.getObject();
    LOGGER.debug("Deleting all of type {}", dto.getType());
    OperationResult result = new OperationResult(OPERATION_DELETE_OBJECTS);
    String taskOid = null;
    try {
        ObjectQuery query = null;
        if (ObjectTypes.USER.equals(dto.getType())) {
            query = createDeleteAllUsersQuery();
        }
        QName type = dto.getType().getTypeQName();
        taskOid = deleteObjectsAsync(type, query, true, "Delete all of type " + type.getLocalPart(), result);
        info(getString("pageDebugList.messsage.deleteAllOfType", dto.getType()));
    } catch (Exception ex) {
        result.recomputeStatus();
        result.recordFatalError("Couldn't delete objects of type " + dto.getType(), ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete objects of type " + dto.getType(), ex);
    }
    showResult(result);
    if (taskOid != null) {
        PageParameters parameters = new PageParameters();
        parameters.add(OnePageParameterEncoder.PARAMETER, taskOid);
        navigateToNext(PageTaskEdit.class, parameters);
    } else {
        navigateToNext(PageTasks.class);
    }
    target.add(getFeedbackPanel());
}
Also used : QName(javax.xml.namespace.QName) DebugSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.DebugSearchDto) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Aggregations

PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)52 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)7 ArrayList (java.util.ArrayList)5 StringValue (org.apache.wicket.util.string.StringValue)5 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)4 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)4 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)3 Label (org.apache.wicket.markup.html.basic.Label)3 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)3 PropertyModel (org.apache.wicket.model.PropertyModel)3 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)2 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 WorkItemsPanel (com.evolveum.midpoint.web.component.wf.WorkItemsPanel)2