use of org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.
the class ActionsExecutedInformationPanel method initLayout.
protected void initLayout() {
WebMarkupContainer tableLinesContainer = new WebMarkupContainer(ID_OBJECTS_TABLE_LINES_CONTAINER);
ListView tableLines = new ListView<ActionsExecutedObjectsTableLineDto>(ID_OBJECTS_TABLE_LINES, new AbstractReadOnlyModel<List<ActionsExecutedObjectsTableLineDto>>() {
@Override
public List<ActionsExecutedObjectsTableLineDto> getObject() {
final ActionsExecutedInformationDto modelObject = getModelObject();
if (modelObject == null) {
return new ArrayList<>();
}
if (showResultingActionsOnly) {
return modelObject.getUniqueObjectsTableLines();
} else {
return modelObject.getObjectsTableLines();
}
}
}) {
protected void populateItem(final ListItem<ActionsExecutedObjectsTableLineDto> item) {
item.add(new Label(ID_OBJECT_TYPE, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
String key = item.getModelObject().getObjectTypeLocalizationKey();
if (key != null) {
return createStringResource(key).getString();
} else {
return item.getModelObject().getObjectType().getLocalPart();
}
}
}));
item.add(new Label(ID_OPERATION, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return createStringResource(item.getModelObject().getOperation()).getString();
}
}));
item.add(new Label(ID_CHANNEL, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
String channel = item.getModelObject().getChannel();
if (channel != null && !channel.isEmpty()) {
String key = "Channel." + channel;
return createStringResource(key).getString();
} else {
return "";
}
}
}));
item.add(new Label(ID_SUCCESS_COUNT, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_SUCCESS_COUNT)));
item.add(new Label(ID_LAST_SUCCESS_OBJECT, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_LAST_SUCCESS_OBJECT)));
item.add(new Label(ID_LAST_SUCCESS_TIMESTAMP, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_LAST_SUCCESS_TIMESTAMP)));
item.add(new Label(ID_FAILURE_COUNT, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_FAILURE_COUNT)));
}
};
tableLinesContainer.add(tableLines);
tableLinesContainer.setOutputMarkupId(true);
add(tableLinesContainer);
final Label showResultingActionsOnlyLabel = new Label(ID_SHOW_RESULTING_ACTIONS_ONLY_LABEL, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return showResultingActionsOnly ? createStringResource("ActionsExecutedInformationPanel.showingResultingActionsOnly").getString() : createStringResource("ActionsExecutedInformationPanel.showingAllActions").getString();
}
});
showResultingActionsOnlyLabel.setOutputMarkupId(true);
add(showResultingActionsOnlyLabel);
add(new AjaxFallbackLink<String>(ID_SHOW_RESULTING_ACTIONS_ONLY_LINK) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
showResultingActionsOnly = !showResultingActionsOnly;
ajaxRequestTarget.add(ActionsExecutedInformationPanel.this);
}
});
add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject() != null;
}
});
}
use of org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.
the class TaskBasicTabPanel method initLayoutBasic.
private void initLayoutBasic() {
// Name
WebMarkupContainer nameContainer = new WebMarkupContainer(ID_NAME_CONTAINER);
RequiredTextField<String> name = new RequiredTextField<>(ID_NAME, new PropertyModel<String>(taskDtoModel, TaskDto.F_NAME));
name.add(parentPage.createEnabledIfEdit(new ItemPath(TaskType.F_NAME)));
name.add(new AttributeModifier("style", "width: 100%"));
name.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
nameContainer.add(name);
nameContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_NAME)));
add(nameContainer);
// Description
WebMarkupContainer descriptionContainer = new WebMarkupContainer(ID_DESCRIPTION_CONTAINER);
TextArea<String> description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(taskDtoModel, TaskDto.F_DESCRIPTION));
description.add(parentPage.createEnabledIfEdit(new ItemPath(TaskType.F_DESCRIPTION)));
// description.add(new AttributeModifier("style", "width: 100%"));
// description.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
descriptionContainer.add(description);
descriptionContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_DESCRIPTION)));
add(descriptionContainer);
// OID
Label oid = new Label(ID_OID, new PropertyModel(getObjectWrapperModel(), ID_OID));
add(oid);
// Identifier
WebMarkupContainer identifierContainer = new WebMarkupContainer(ID_IDENTIFIER_CONTAINER);
identifierContainer.add(new Label(ID_IDENTIFIER, new PropertyModel(taskDtoModel, TaskDto.F_IDENTIFIER)));
identifierContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_TASK_IDENTIFIER)));
add(identifierContainer);
// Category
WebMarkupContainer categoryContainer = new WebMarkupContainer(ID_CATEGORY_CONTAINER);
categoryContainer.add(new Label(ID_CATEGORY, WebComponentUtil.createCategoryNameModel(this, new PropertyModel(taskDtoModel, TaskDto.F_CATEGORY))));
categoryContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_CATEGORY)));
add(categoryContainer);
// Parent
WebMarkupContainer parentContainer = new WebMarkupContainer(ID_PARENT_CONTAINER);
final LinkPanel parent = new LinkPanel(ID_PARENT, new PropertyModel<String>(taskDtoModel, TaskDto.F_PARENT_TASK_NAME)) {
@Override
public void onClick(AjaxRequestTarget target) {
String oid = taskDtoModel.getObject().getParentTaskOid();
if (oid != null) {
PageParameters parameters = new PageParameters();
parameters.add(OnePageParameterEncoder.PARAMETER, oid);
getPageBase().navigateToNext(PageTaskEdit.class, parameters);
}
}
};
parentContainer.add(parent);
parentContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_PARENT)));
add(parentContainer);
// Owner
WebMarkupContainer ownerContainer = new WebMarkupContainer(ID_OWNER_CONTAINER);
final LinkPanel owner = new LinkPanel(ID_OWNER, new PropertyModel<String>(taskDtoModel, TaskDto.F_OWNER_NAME)) {
@Override
public void onClick(AjaxRequestTarget target) {
String oid = taskDtoModel.getObject().getOwnerOid();
if (oid != null) {
PageParameters parameters = new PageParameters();
parameters.add(OnePageParameterEncoder.PARAMETER, oid);
getPageBase().navigateToNext(PageUser.class, parameters);
}
}
};
ownerContainer.add(owner);
ownerContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_OWNER_REF)));
add(ownerContainer);
// Handler URI
ListView<String> handlerUriContainer = new ListView<String>(ID_HANDLER_URI_CONTAINER, new PropertyModel(taskDtoModel, TaskDto.F_HANDLER_URI_LIST)) {
@Override
protected void populateItem(ListItem<String> item) {
item.add(new Label(ID_HANDLER_URI, item.getModelObject()));
}
};
handlerUriContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_HANDLER_URI), new ItemPath(TaskType.F_OTHER_HANDLERS_URI_STACK)));
add(handlerUriContainer);
// Execution
WebMarkupContainer executionContainer = new WebMarkupContainer(ID_EXECUTION_CONTAINER);
Label execution = new Label(ID_EXECUTION, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
TaskDtoExecutionStatus executionStatus = taskDtoModel.getObject().getExecution();
if (executionStatus != TaskDtoExecutionStatus.CLOSED) {
return getString(TaskDtoExecutionStatus.class.getSimpleName() + "." + executionStatus.name());
} else {
return getString(TaskDtoExecutionStatus.class.getSimpleName() + "." + executionStatus.name() + ".withTimestamp", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (taskDtoModel.getObject().getCompletionTimestamp() != null) {
// todo correct formatting
return new Date(taskDtoModel.getObject().getCompletionTimestamp()).toLocaleString();
} else {
return "?";
}
}
});
}
}
});
executionContainer.add(execution);
Label node = new Label(ID_NODE, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
TaskDto dto = taskDtoModel.getObject();
if (!TaskDtoExecutionStatus.RUNNING.equals(dto.getExecution())) {
return null;
}
return parentPage.getString("pageTaskEdit.message.node", dto.getExecutingAt());
}
});
executionContainer.add(node);
executionContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_EXECUTION_STATUS), new ItemPath(TaskType.F_NODE_AS_OBSERVED)));
add(executionContainer);
}
use of org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.
the class DelegationEditorPanel method addPrivilegesPanel.
private void addPrivilegesPanel(WebMarkupContainer body) {
privilegesNames = getPrivilegesNamesList();
ListView<String> privilegesListComponent = new ListView<String>(ID_PRIVILEGES_LIST, privilegesNames) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<String> item) {
Label privilageNameLabel = new Label(ID_PRIVILEGE, item.getModel());
item.add(privilageNameLabel);
}
};
privilegesListComponent.setOutputMarkupId(true);
privilegesListComponent.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
if (!UserDtoStatus.ADD.equals(getModelObject().getStatus())) {
return true;
}
return false;
}
});
body.addOrReplace(privilegesListComponent);
}
use of org.apache.wicket.markup.html.list.ListView 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 org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.
the class PageBase method initTitleLayout.
private void initTitleLayout(WebMarkupContainer mainHeader) {
WebMarkupContainer pageTitleContainer = new WebMarkupContainer(ID_PAGE_TITLE_CONTAINER);
pageTitleContainer.add(createUserStatusBehaviour(true));
mainHeader.add(pageTitleContainer);
WebMarkupContainer pageTitle = new WebMarkupContainer(ID_PAGE_TITLE);
pageTitleContainer.add(pageTitle);
String environmentName = "";
if (deploymentInfoModel != null && deploymentInfoModel.getObject() != null && StringUtils.isNotEmpty(deploymentInfoModel.getObject().getName())) {
environmentName = deploymentInfoModel.getObject().getName();
}
Model<String> deploymentNameModel = new Model<String>(StringUtils.isNotEmpty(environmentName) ? environmentName + ": " : "");
Label deploymentName = new Label(ID_DEPLOYMENT_NAME, deploymentNameModel);
deploymentName.add(new VisibleEnableBehaviour() {
public boolean isVisible() {
return StringUtils.isNotEmpty(deploymentNameModel.getObject());
}
});
deploymentName.setRenderBodyOnly(true);
pageTitle.add(deploymentName);
Label pageTitleReal = new Label(ID_PAGE_TITLE_REAL, createPageTitleModel());
pageTitleReal.setRenderBodyOnly(true);
pageTitle.add(pageTitleReal);
ListView breadcrumbs = new ListView<Breadcrumb>(ID_BREADCRUMB, new AbstractReadOnlyModel<List<Breadcrumb>>() {
private static final long serialVersionUID = 1L;
@Override
public List<Breadcrumb> getObject() {
return getBreadcrumbs();
}
}) {
@Override
protected void populateItem(ListItem<Breadcrumb> item) {
final Breadcrumb dto = item.getModelObject();
AjaxLink bcLink = new AjaxLink(ID_BC_LINK) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
redirectBackToBreadcrumb(dto);
}
};
item.add(bcLink);
bcLink.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return dto.isUseLink();
}
});
WebMarkupContainer bcIcon = new WebMarkupContainer(ID_BC_ICON);
bcIcon.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return dto.getIcon() != null && dto.getIcon().getObject() != null;
}
});
bcIcon.add(AttributeModifier.replace("class", dto.getIcon()));
bcLink.add(bcIcon);
Label bcName = new Label(ID_BC_NAME, dto.getLabel());
bcLink.add(bcName);
item.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return dto.isVisible();
}
});
}
};
mainHeader.add(breadcrumbs);
}
Aggregations