Search in sources :

Example 1 with DefaultAjaxButton

use of com.evolveum.midpoint.web.component.DefaultAjaxButton in project midpoint by Evolveum.

the class PageWorkItem method initButtons.

private void initButtons(Form mainForm) {
    VisibleBehaviour isAllowedToSubmit = new VisibleBehaviour(() -> getWorkflowManager().isCurrentUserAuthorizedToSubmit(workItemDtoModel.getObject().getWorkItem()));
    VisibleBehaviour isAllowedToDelegate = new VisibleBehaviour(() -> getWorkflowManager().isCurrentUserAuthorizedToDelegate(workItemDtoModel.getObject().getWorkItem()));
    VisibleBehaviour isAllowedToClaim = new VisibleBehaviour(() -> workItemDtoModel.getObject().getWorkItem().getAssigneeRef() == null && getWorkflowManager().isCurrentUserAuthorizedToClaim(workItemDtoModel.getObject().getWorkItem()));
    VisibleBehaviour isAllowedToRelease = new VisibleBehaviour(() -> {
        WorkItemType workItem = workItemDtoModel.getObject().getWorkItem();
        MidPointPrincipal principal;
        try {
            principal = (MidPointPrincipal) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        } catch (ClassCastException e) {
            return false;
        }
        String principalOid = principal.getOid();
        return workItem.getAssigneeRef() != null && workItem.getAssigneeRef().stream().anyMatch(ref -> ref.getOid().equals(principalOid)) && (!workItem.getCandidateRef().isEmpty());
    });
    AjaxSubmitButton claim = new DefaultAjaxSubmitButton(ID_CLAIM, createStringResource("pageWorkItem.button.claim"), this, (target, form) -> claimPerformed(target));
    claim.add(isAllowedToClaim);
    mainForm.add(claim);
    AjaxSubmitButton release = new DefaultAjaxSubmitButton(ID_RELEASE, createStringResource("pageWorkItem.button.release"), this, (target, form) -> releasePerformed(target));
    release.add(isAllowedToRelease);
    mainForm.add(release);
    AjaxSubmitButton approve = new DefaultAjaxSubmitButton(ID_APPROVE, createStringResource("pageWorkItem.button.approve"), this, (target, form) -> savePerformed(target, true));
    approve.add(isAllowedToSubmit);
    mainForm.add(approve);
    AjaxSubmitButton reject = new DefaultAjaxSubmitButton(ID_REJECT, createStringResource("pageWorkItem.button.reject"), this, (target, form) -> savePerformed(target, false));
    reject.add(isAllowedToSubmit);
    mainForm.add(reject);
    AjaxSubmitButton delegate = new DefaultAjaxSubmitButton(ID_DELEGATE, createStringResource("pageWorkItem.button.delegate"), this, (target, form) -> delegatePerformed(target));
    delegate.add(isAllowedToDelegate);
    mainForm.add(delegate);
    AjaxButton cancel = new DefaultAjaxButton(ID_CANCEL, createStringResource("pageWorkItem.button.cancel"), this::cancelPerformed);
    mainForm.add(cancel);
}
Also used : DefaultAjaxSubmitButton(com.evolveum.midpoint.web.component.DefaultAjaxSubmitButton) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) DefaultAjaxButton(com.evolveum.midpoint.web.component.DefaultAjaxButton) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) DefaultAjaxButton(com.evolveum.midpoint.web.component.DefaultAjaxButton) DefaultAjaxSubmitButton(com.evolveum.midpoint.web.component.DefaultAjaxSubmitButton) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal)

Aggregations

MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)1 DefaultAjaxButton (com.evolveum.midpoint.web.component.DefaultAjaxButton)1 DefaultAjaxSubmitButton (com.evolveum.midpoint.web.component.DefaultAjaxSubmitButton)1 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)1