use of com.evolveum.midpoint.web.component.util.VisibleBehaviour in project midpoint by Evolveum.
the class RoleMemberPanel method initSearch.
@Override
protected void initSearch(Form form) {
List<QName> allowedTypes = WebComponentUtil.createFocusTypeList();
allowedTypes.add(FocusType.COMPLEX_TYPE);
DropDownChoice<QName> typeSelect = createDropDown(ID_OBJECT_TYPE, Model.of(FocusType.COMPLEX_TYPE), allowedTypes, new QNameChoiceRenderer());
add(typeSelect);
DropDownChoice<OrgType> tenant = createDropDown(ID_TENANT, new Model(), createTenantList(), new ObjectTypeChoiceRenderer<OrgType>());
add(tenant);
tenant.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isRole();
}
});
DropDownChoice<OrgType> project = createDropDown(ID_PROJECT, new Model(), createProjectList(), new ObjectTypeChoiceRenderer<OrgType>());
add(project);
project.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isRole();
}
});
CheckBoxPanel includeIndirectMembers = new CheckBoxPanel(ID_INDIRECT_MEMBERS, new Model<Boolean>(false)) {
private static final long serialVersionUID = 1L;
public void onUpdate(AjaxRequestTarget target) {
refreshTable(target);
}
};
add(includeIndirectMembers);
// TODO shouldn't we hide also the label?
includeIndirectMembers.add(new VisibleBehaviour(this::isRole));
}
use of com.evolveum.midpoint.web.component.util.VisibleBehaviour in project midpoint by Evolveum.
the class PageAuditLogDetails method initEventPanel.
private void initEventPanel(WebMarkupContainer eventPanel) {
WebMarkupContainer eventDetailsPanel = new WebMarkupContainer(ID_EVENT_DETAILS_PANEL);
eventDetailsPanel.setOutputMarkupId(true);
eventPanel.addOrReplace(eventDetailsPanel);
final Label identifier = new Label(ID_PARAMETERS_EVENT_IDENTIFIER, new PropertyModel(recordModel, ID_PARAMETERS_EVENT_IDENTIFIER));
identifier.setOutputMarkupId(true);
eventDetailsPanel.add(identifier);
final Label timestamp = new Label(ID_PARAMETERS_TIMESTAMP, new PropertyModel(recordModel, ID_PARAMETERS_TIMESTAMP));
timestamp.setOutputMarkupId(true);
eventDetailsPanel.add(timestamp);
final Label sessionIdentifier = new Label(ID_PARAMETERS_SESSION_IDENTIFIER, new PropertyModel(recordModel, ID_PARAMETERS_SESSION_IDENTIFIER));
sessionIdentifier.setOutputMarkupId(true);
eventDetailsPanel.add(sessionIdentifier);
final Label taskIdentifier = new Label(ID_PARAMETERS_TASK_IDENTIFIER, new PropertyModel(recordModel, ID_PARAMETERS_TASK_IDENTIFIER));
taskIdentifier.setOutputMarkupId(true);
eventDetailsPanel.add(taskIdentifier);
final Label taskOID = new Label(ID_PARAMETERS_TASK_OID, new PropertyModel(recordModel, ID_PARAMETERS_TASK_OID));
taskOID.setOutputMarkupId(true);
eventDetailsPanel.add(taskOID);
final Label hostIdentifier = new Label(ID_PARAMETERS_HOST_IDENTIFIER, new PropertyModel(recordModel, ID_PARAMETERS_HOST_IDENTIFIER));
hostIdentifier.setOutputMarkupId(true);
eventDetailsPanel.add(hostIdentifier);
final Label nodeIdentifier = new Label(ID_PARAMETERS_NODE_IDENTIFIER, new PropertyModel(recordModel, ID_PARAMETERS_NODE_IDENTIFIER));
nodeIdentifier.setOutputMarkupId(true);
eventDetailsPanel.add(nodeIdentifier);
final Label remoteHostAddress = new Label(ID_PARAMETERS_REMOTE_HOST_ADDRESS, new PropertyModel(recordModel, ID_PARAMETERS_REMOTE_HOST_ADDRESS));
remoteHostAddress.setOutputMarkupId(true);
eventDetailsPanel.add(remoteHostAddress);
final Label initiatorRef = new Label(ID_PARAMETERS_EVENT_INITIATOR, new Model<>(WebModelServiceUtils.resolveReferenceName(recordModel.getObject().getInitiatorRef(), this, createSimpleTask(ID_PARAMETERS_EVENT_INITIATOR), new OperationResult(ID_PARAMETERS_EVENT_INITIATOR))));
initiatorRef.setOutputMarkupId(true);
eventDetailsPanel.add(initiatorRef);
final Label targetRef = new Label(ID_PARAMETERS_EVENT_TARGET, new Model<>(WebModelServiceUtils.resolveReferenceName(recordModel.getObject().getTargetRef(), this, createSimpleTask(ID_PARAMETERS_EVENT_TARGET), new OperationResult(ID_PARAMETERS_EVENT_TARGET))));
targetRef.setOutputMarkupId(true);
eventDetailsPanel.add(targetRef);
IModel<String> targetOwnerRefModel = new IModel<String>() {
@Override
public String getObject() {
return WebModelServiceUtils.resolveReferenceName(recordModel.getObject().getTargetOwnerRef(), PageAuditLogDetails.this, createSimpleTask(OPERATION_RESOLVE_REFERENCE_NAME), new OperationResult(OPERATION_RESOLVE_REFERENCE_NAME));
}
@Override
public void setObject(String s) {
}
@Override
public void detach() {
}
};
final Label targetOwnerRef = new Label(ID_PARAMETERS_EVENT_TARGET_OWNER, targetOwnerRefModel);
targetOwnerRef.setOutputMarkupId(true);
eventDetailsPanel.add(targetOwnerRef);
final Label eventType = new Label(ID_PARAMETERS_EVENT_TYPE, new PropertyModel(recordModel, ID_PARAMETERS_EVENT_TYPE));
eventType.setOutputMarkupId(true);
eventDetailsPanel.add(eventType);
final Label eventStage = new Label(ID_PARAMETERS_EVENT_STAGE, new PropertyModel(recordModel, ID_PARAMETERS_EVENT_STAGE));
eventStage.setOutputMarkupId(true);
eventDetailsPanel.add(eventStage);
final Label channel = new Label(ID_PARAMETERS_CHANNEL, new PropertyModel(recordModel, ID_PARAMETERS_CHANNEL));
channel.setOutputMarkupId(true);
eventDetailsPanel.add(channel);
final Label eventOutcome = new Label(ID_PARAMETERS_EVENT_OUTCOME, new PropertyModel(recordModel, ID_PARAMETERS_EVENT_OUTCOME));
eventOutcome.setOutputMarkupId(true);
eventDetailsPanel.add(eventOutcome);
final Label eventResult = new Label(ID_PARAMETERS_EVENT_RESULT, new PropertyModel(recordModel, ID_PARAMETERS_EVENT_RESULT));
eventResult.setOutputMarkupId(true);
eventDetailsPanel.add(eventResult);
final Label parameter = new Label(ID_PARAMETERS_PARAMETER, new PropertyModel(recordModel, ID_PARAMETERS_PARAMETER));
parameter.setOutputMarkupId(true);
eventDetailsPanel.add(parameter);
final Label message = new Label(ID_PARAMETERS_MESSAGE, new PropertyModel(recordModel, ID_PARAMETERS_MESSAGE));
message.setOutputMarkupId(true);
eventDetailsPanel.add(message);
ListView<AuditEventRecordItemValueDto> additionalItemsList = new ListView<AuditEventRecordItemValueDto>(ID_ADDITIONAL_ITEM_LINE, new AbstractReadOnlyModel<List<AuditEventRecordItemValueDto>>() {
@Override
public List<AuditEventRecordItemValueDto> getObject() {
List<AuditEventRecordItemValueDto> rv = new ArrayList<>();
for (AuditEventRecordItemType item : getSortedItems()) {
String currentName = getDisplayName(item.getName());
if (item instanceof AuditEventRecordPropertyType) {
for (String value : ((AuditEventRecordPropertyType) item).getValue()) {
rv.add(new AuditEventRecordItemValueDto(currentName, value));
currentName = null;
}
} else if (item instanceof AuditEventRecordReferenceType) {
for (AuditEventRecordReferenceValueType value : ((AuditEventRecordReferenceType) item).getValue()) {
rv.add(new AuditEventRecordItemValueDto(currentName, value.getTargetName() != null ? value.getTargetName().getOrig() : value.getOid()));
currentName = null;
}
} else {
// should not occur
}
}
return rv;
}
// TODO take locale into account when sorting
private List<AuditEventRecordItemType> getSortedItems() {
AuditEventRecordType record = recordModel.getObject();
List<AuditEventRecordItemType> rv = new ArrayList<>();
rv.addAll(record.getProperty());
rv.addAll(record.getReference());
rv.sort((a, b) -> {
// explicitly enumerated are shown first; others are sorted by display name
int index_a = EXTENSION_ITEMS_ORDER.indexOf(a.getName());
int index_b = EXTENSION_ITEMS_ORDER.indexOf(b.getName());
if (index_a != -1 && index_b != -1) {
return Integer.compare(index_a, index_b);
} else if (index_a != -1) {
return -1;
} else if (index_b != -1) {
return 1;
}
String name_a = getDisplayName(a.getName());
String name_b = getDisplayName(b.getName());
return String.CASE_INSENSITIVE_ORDER.compare(name_a, name_b);
});
return rv;
}
private String getDisplayName(String nameKey) {
// null should not occur so we don't try to be nice when displaying it
return nameKey != null ? createStringResource(nameKey).getString() : "(null)";
}
}) {
@Override
protected void populateItem(ListItem<AuditEventRecordItemValueDto> item) {
item.add(new Label(ID_ITEM_NAME, new PropertyModel<String>(item.getModel(), AuditEventRecordItemValueDto.F_NAME)));
item.add(new Label(ID_ITEM_VALUE, new PropertyModel<String>(item.getModel(), AuditEventRecordItemValueDto.F_VALUE)));
}
};
WebMarkupContainer additionalItemsContainer = new WebMarkupContainer(ID_ADDITIONAL_ITEMS);
additionalItemsContainer.add(additionalItemsList);
additionalItemsContainer.add(new VisibleBehaviour(() -> !additionalItemsList.getModelObject().isEmpty()));
eventDetailsPanel.add(additionalItemsContainer);
}
use of com.evolveum.midpoint.web.component.util.VisibleBehaviour in project midpoint by Evolveum.
the class WorkItemPanel method initLayout.
protected void initLayout(Form mainForm, PageBase pageBase) {
WebMarkupContainer additionalInfoColumn = new WebMarkupContainer(ID_ADDITIONAL_INFO_COLUMN);
WebMarkupContainer historyContainer = new WebMarkupContainer(ID_HISTORY_CONTAINER);
historyContainer.add(new ItemApprovalHistoryPanel(ID_HISTORY, new PropertyModel<>(getModel(), WorkItemDto.F_WORKFLOW_CONTEXT), UserProfileStorage.TableId.PAGE_WORK_ITEM_HISTORY_PANEL, (int) pageBase.getItemsPerPage(UserProfileStorage.TableId.PAGE_WORK_ITEM_HISTORY_PANEL)));
final VisibleEnableBehaviour historyContainerVisible = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject().hasHistory();
}
};
historyContainer.add(historyContainerVisible);
historyContainer.add(WebComponentUtil.createHelp(ID_HISTORY_HELP));
additionalInfoColumn.add(historyContainer);
WebMarkupContainer relatedWorkItemsContainer = new WebMarkupContainer(ID_RELATED_WORK_ITEMS_CONTAINER);
final IModel<List<WorkItemDto>> relatedWorkItemsModel = new PropertyModel<>(getModel(), WorkItemDto.F_OTHER_WORK_ITEMS);
final ISortableDataProvider<WorkItemDto, String> relatedWorkItemsProvider = new ListDataProvider<>(this, relatedWorkItemsModel);
relatedWorkItemsContainer.add(new WorkItemsPanel(ID_RELATED_WORK_ITEMS, relatedWorkItemsProvider, null, 10, WorkItemsPanel.View.ITEMS_FOR_PROCESS));
final VisibleEnableBehaviour relatedWorkItemsContainerVisible = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !relatedWorkItemsModel.getObject().isEmpty();
}
};
relatedWorkItemsContainer.add(relatedWorkItemsContainerVisible);
relatedWorkItemsContainer.add(WebComponentUtil.createHelp(ID_RELATED_WORK_ITEMS_HELP));
additionalInfoColumn.add(relatedWorkItemsContainer);
final WebMarkupContainer relatedWorkflowRequestsContainer = new WebMarkupContainer(ID_RELATED_REQUESTS_CONTAINER);
final IModel<List<ProcessInstanceDto>> relatedWorkflowRequestsModel = new PropertyModel<>(getModel(), WorkItemDto.F_RELATED_WORKFLOW_REQUESTS);
final ISortableDataProvider<ProcessInstanceDto, String> relatedWorkflowRequestsProvider = new ListDataProvider<>(this, relatedWorkflowRequestsModel);
relatedWorkflowRequestsContainer.add(new ProcessInstancesPanel(ID_RELATED_REQUESTS, relatedWorkflowRequestsProvider, null, 10, ProcessInstancesPanel.View.TASKS_FOR_PROCESS, new PropertyModel<>(getModel(), WorkItemDto.F_PROCESS_INSTANCE_ID)));
final VisibleEnableBehaviour relatedWorkflowRequestsContainerVisible = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !relatedWorkflowRequestsModel.getObject().isEmpty();
}
};
relatedWorkflowRequestsContainer.add(relatedWorkflowRequestsContainerVisible);
relatedWorkflowRequestsContainer.add(WebComponentUtil.createHelp(ID_RELATED_REQUESTS_HELP));
additionalInfoColumn.add(relatedWorkflowRequestsContainer);
final VisibleEnableBehaviour additionalInfoColumnVisible = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return historyContainerVisible.isVisible() || relatedWorkItemsContainerVisible.isVisible() || relatedWorkflowRequestsContainerVisible.isVisible();
}
};
additionalInfoColumn.add(additionalInfoColumnVisible);
add(additionalInfoColumn);
WebMarkupContainer primaryInfoColumn = new WebMarkupContainer(ID_PRIMARY_INFO_COLUMN);
// primaryInfoColumn.add(new Label(ID_REQUESTED_BY, new PropertyModel(getModel(), WorkItemDto.F_REQUESTER_NAME)));
// primaryInfoColumn.add(new Label(ID_REQUESTED_BY_FULL_NAME, new PropertyModel(getModel(), WorkItemDto.F_REQUESTER_FULL_NAME)));
// primaryInfoColumn.add(new Label(ID_REQUESTED_ON, new PropertyModel(getModel(), WorkItemDto.F_STARTED_FORMATTED_FULL)));
primaryInfoColumn.add(new Label(ID_WORK_ITEM_CREATED_ON, new PropertyModel(getModel(), WorkItemDto.F_CREATED_FORMATTED_FULL)));
primaryInfoColumn.add(new Label(ID_WORK_ITEM_DEADLINE, new PropertyModel(getModel(), WorkItemDto.F_DEADLINE_FORMATTED_FULL)));
primaryInfoColumn.add(new Label(ID_ORIGINALLY_ALLOCATED_TO, new PropertyModel(getModel(), WorkItemDto.F_ORIGINAL_ASSIGNEE_FULL)));
primaryInfoColumn.add(new Label(ID_CURRENTLY_ALLOCATED_TO, new PropertyModel(getModel(), WorkItemDto.F_CURRENT_ASSIGNEES_FULL)));
primaryInfoColumn.add(new Label(ID_CANDIDATES, new PropertyModel(getModel(), WorkItemDto.F_CANDIDATES)));
WebMarkupContainer stageInfoContainer = new WebMarkupContainer(ID_STAGE_INFO_CONTAINER);
primaryInfoColumn.add(stageInfoContainer);
stageInfoContainer.add(new Label(ID_STAGE_INFO, new PropertyModel<String>(getModel(), WorkItemDto.F_STAGE_INFO)));
stageInfoContainer.add(new VisibleBehaviour(() -> getModelObject().getStageInfo() != null));
WebMarkupContainer escalationLevelInfoContainer = new WebMarkupContainer(ID_ESCALATION_LEVEL_INFO_CONTAINER);
primaryInfoColumn.add(escalationLevelInfoContainer);
escalationLevelInfoContainer.add(new Label(ID_ESCALATION_LEVEL_INFO, new PropertyModel<String>(getModel(), WorkItemDto.F_ESCALATION_LEVEL_INFO)));
escalationLevelInfoContainer.add(new VisibleBehaviour(() -> getModelObject().getEscalationLevelInfo() != null));
WebMarkupContainer requesterCommentContainer = new WebMarkupContainer(ID_REQUESTER_COMMENT_CONTAINER);
requesterCommentContainer.setOutputMarkupId(true);
primaryInfoColumn.add(requesterCommentContainer);
requesterCommentContainer.add(new Label(ID_REQUESTER_COMMENT_MESSAGE, new PropertyModel<String>(getModel(), WorkItemDto.F_REQUESTER_COMMENT)));
//primaryInfoColumn.add(new ScenePanel(ID_DELTAS_TO_BE_APPROVED, new PropertyModel<SceneDto>(getModel(), WorkItemDto.F_DELTAS)));
primaryInfoColumn.add(new TaskChangesPanel(ID_DELTAS_TO_BE_APPROVED, new PropertyModel<>(getModel(), WorkItemDto.F_CHANGES)));
primaryInfoColumn.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return additionalInfoColumnVisible.isVisible() ? "col-md-5" : "col-md-12";
}
}));
add(primaryInfoColumn);
add(new AjaxFallbackLink(ID_SHOW_REQUEST) {
public void onClick(AjaxRequestTarget target) {
String oid = WorkItemPanel.this.getModelObject().getTaskOid();
if (oid != null) {
PageParameters parameters = new PageParameters();
parameters.add(OnePageParameterEncoder.PARAMETER, oid);
getPageBase().navigateToNext(PageTaskEdit.class, parameters);
}
}
});
add(WebComponentUtil.createHelp(ID_SHOW_REQUEST_HELP));
WebMarkupContainer additionalInformation = new InformationListPanel(ID_ADDITIONAL_INFORMATION, new PropertyModel<>(getModel(), WorkItemDto.F_ADDITIONAL_INFORMATION));
add(additionalInformation);
WorkItemDto dto = getModelObject();
ApprovalStageDefinitionType level = WfContextUtil.getCurrentStageDefinition(dto.getWorkflowContext());
WebMarkupContainer additionalAttribues = new WebMarkupContainer(ID_ADDITIONAL_ATTRIBUTES);
add(additionalAttribues);
additionalAttribues.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
public boolean isVisible() {
return (level != null && level.getFormRef() != null && level.getFormRef().getOid() != null);
}
;
});
if (level != null && level.getFormRef() != null && level.getFormRef().getOid() != null) {
String formOid = level.getFormRef().getOid();
ObjectType focus = dto.getFocus(pageBase);
if (focus == null) {
// TODO FIXME (this should not occur anyway)
focus = new UserType(pageBase.getPrismContext());
}
Task task = pageBase.createSimpleTask(OPERATION_LOAD_CUSTOM_FORM);
DynamicFormPanel<?> customForm = new DynamicFormPanel<>(ID_CUSTOM_FORM, focus.asPrismObject(), formOid, mainForm, task, pageBase);
additionalAttribues.add(customForm);
} else {
additionalAttribues.add(new Label(ID_CUSTOM_FORM));
}
add(new TextArea<>(ID_APPROVER_COMMENT, new PropertyModel<String>(getModel(), WorkItemDto.F_APPROVER_COMMENT)));
}
use of com.evolveum.midpoint.web.component.util.VisibleBehaviour in project midpoint by Evolveum.
the class InformationPanel method initLayout.
private void initLayout() {
Label titleLabel = new Label(ID_TITLE, new PropertyModel<>(getModel(), InformationType.F_TITLE.getLocalPart()));
titleLabel.add(new VisibleBehaviour(() -> getModelObject().getTitle() != null));
add(titleLabel);
ListView<InformationPartType> list = new ListView<InformationPartType>(ID_PARTS, new PropertyModel<>(getModel(), InformationType.F_PART.getLocalPart())) {
@Override
protected void populateItem(ListItem<InformationPartType> item) {
InformationPartType part = item.getModelObject();
Label label = new Label(ID_PART, part.getText());
if (Boolean.TRUE.equals(part.isHasMarkup())) {
label.setEscapeModelStrings(false);
}
item.add(label);
}
};
add(list);
}
use of com.evolveum.midpoint.web.component.util.VisibleBehaviour 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);
}
Aggregations