use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.
the class PageRoles method initColumns.
private List<IColumn<SelectableBean<RoleType>, String>> initColumns() {
List<IColumn<SelectableBean<RoleType>, String>> columns = new ArrayList<>();
IColumn column = new PropertyColumn(createStringResource("OrgType.displayName"), "value.displayName");
columns.add(column);
column = new PropertyColumn(createStringResource("OrgType.identifier"), "value.identifier");
columns.add(column);
column = new PropertyColumn(createStringResource("ObjectType.description"), "value.description");
columns.add(column);
return columns;
}
use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.
the class PageAuditLogDetails method initColumns.
private List<IColumn<AuditEventRecordType, String>> initColumns() {
List<IColumn<AuditEventRecordType, String>> columns = new ArrayList<>();
PropertyColumn<AuditEventRecordType, String> timeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.timestamp"), AuditEventRecordType.F_TIMESTAMP.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
XMLGregorianCalendar time = rowModel.getObject().getTimestamp();
item.add(new Label(componentId, WebComponentUtil.getLocalizedDate(time, DateLabelComponent.SHORT_SHORT_STYLE)));
}
};
columns.add(timeColumn);
PropertyColumn<AuditEventRecordType, String> stageColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventStageShortLabel"), AuditEventRecordType.F_EVENT_STAGE.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
AuditEventStageType stage = rowModel.getObject().getEventStage();
String shortStage = "";
if (AuditEventStageType.EXECUTION.equals(stage)) {
shortStage = AuditEventStageType.EXECUTION.value().substring(0, 4);
} else if (AuditEventStageType.REQUEST.equals(stage)) {
shortStage = AuditEventStageType.REQUEST.value().substring(0, 3);
}
item.add(new Label(componentId, shortStage));
}
};
columns.add(stageColumn);
PropertyColumn<AuditEventRecordType, String> typeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventTypeShortLabel"), AuditEventRecordType.F_EVENT_TYPE.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
//TODO create some proper short values
AuditEventTypeType type = rowModel.getObject().getEventType();
String typeVal = type.value().substring(0, 4);
item.add(new Label(componentId, typeVal));
}
};
columns.add(typeColumn);
return columns;
}
use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.
the class AssignmentPreviewDialog method initLayout.
public void initLayout() {
List<IColumn<AssignmentsPreviewDto, String>> columns = initColumns();
ListDataProvider provider = new ListDataProvider(pageBase, data);
WebMarkupContainer content = new WebMarkupContainer(ID_CONTENT);
content.setOutputMarkupId(true);
add(content);
TablePanel table = new TablePanel<>(ID_TABLE, provider, columns);
table.setOutputMarkupId(true);
content.add(table);
AjaxButton addButton = new AjaxButton(ID_BUTTON_ADD, createStringResource("userBrowserDialog.button.selectButton")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<AssignmentsPreviewDto> previewDtos = data.getObject();
List<AssignmentsPreviewDto> selectedDtos = new ArrayList<>();
for (AssignmentsPreviewDto dto : previewDtos) {
if (dto.isSelected()) {
selectedDtos.add(dto);
}
}
AssignmentPreviewDialog.this.addButtonClicked(target, selectedDtos);
}
};
addButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return multiselect;
}
});
content.add(addButton);
AjaxButton cancelButton = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("AssignmentPreviewDialog.button.cancel")) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
((PageBase) getPage()).hideMainPopup(ajaxRequestTarget);
}
};
content.add(cancelButton);
}
use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.
the class AuditLogViewerPanel method initColumns.
protected List<IColumn<AuditEventRecordType, String>> initColumns() {
List<IColumn<AuditEventRecordType, String>> columns = new ArrayList<IColumn<AuditEventRecordType, String>>();
IColumn<AuditEventRecordType, String> linkColumn = new LinkColumn<AuditEventRecordType>(createStringResource("AuditEventRecordType.timestamp"), "timestamp") {
private static final long serialVersionUID = 1L;
@Override
protected IModel<String> createLinkModel(final IModel<AuditEventRecordType> rowModel) {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
XMLGregorianCalendar time = rowModel.getObject().getTimestamp();
return WebComponentUtil.formatDate(time);
}
};
}
@Override
public void onClick(AjaxRequestTarget target, IModel<AuditEventRecordType> rowModel) {
AuditEventRecordType record = rowModel.getObject();
try {
AuditEventRecord.adopt(record, pageBase.getPrismContext());
} catch (SchemaException e) {
throw new SystemException("Couldn't adopt event record: " + e, e);
}
pageBase.navigateToNext(new PageAuditLogDetails(record));
}
};
columns.add(linkColumn);
PropertyColumn<AuditEventRecordType, String> initiatorRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.initiatorRef"), AuditEventRecordType.F_INITIATOR_REF.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
AuditEventRecordType auditEventRecordType = rowModel.getObject();
createReferenceColumn(auditEventRecordType.getInitiatorRef(), item, componentId);
}
};
columns.add(initiatorRefColumn);
if (visibilityMap == null || visibilityMap.get(EVENT_STAGE_COLUMN_VISIBILITY) == null || visibilityMap.get(EVENT_STAGE_COLUMN_VISIBILITY)) {
IColumn<AuditEventRecordType, String> eventStageColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventStageLabel"), "eventStage");
columns.add(eventStageColumn);
}
IColumn<AuditEventRecordType, String> eventTypeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.eventTypeLabel"), "eventType");
columns.add(eventTypeColumn);
if (visibilityMap == null || visibilityMap.get(TARGET_COLUMN_VISIBILITY) == null || visibilityMap.get(TARGET_COLUMN_VISIBILITY)) {
PropertyColumn<AuditEventRecordType, String> targetRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.targetRef"), AuditEventRecordType.F_TARGET_REF.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
createReferenceColumn(auditEventRecordType.getTargetRef(), item, componentId);
}
};
columns.add(targetRefColumn);
}
if (visibilityMap == null || visibilityMap.get(TARGET_OWNER_COLUMN_VISIBILITY) == null || visibilityMap.get(TARGET_OWNER_COLUMN_VISIBILITY)) {
PropertyColumn<AuditEventRecordType, String> targetOwnerRefColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.targetOwnerRef"), AuditEventRecordType.F_TARGET_OWNER_REF.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
createReferenceColumn(auditEventRecordType.getTargetOwnerRef(), item, componentId);
}
};
columns.add(targetOwnerRefColumn);
}
IColumn<AuditEventRecordType, String> channelColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("AuditEventRecordType.channel"), "channel") {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<AuditEventRecordType>> item, String componentId, IModel<AuditEventRecordType> rowModel) {
AuditEventRecordType auditEventRecordType = (AuditEventRecordType) rowModel.getObject();
String channel = auditEventRecordType.getChannel();
if (channel != null) {
QName channelQName = QNameUtil.uriToQName(channel);
String return_ = channelQName.getLocalPart();
item.add(new Label(componentId, return_));
} else {
item.add(new Label(componentId, ""));
}
item.add(new AttributeModifier("style", new Model<String>("width: 10%;")));
}
};
columns.add(channelColumn);
IColumn<AuditEventRecordType, String> outcomeColumn = new PropertyColumn<AuditEventRecordType, String>(createStringResource("PageAuditLogViewer.outcomeLabel"), "outcome");
columns.add(outcomeColumn);
return columns;
}
use of org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn in project midpoint by Evolveum.
the class AuditLogViewerPanel method addOrReplaceTable.
private void addOrReplaceTable(Form mainForm) {
AuditEventRecordProvider provider = new AuditEventRecordProvider(AuditLogViewerPanel.this) {
private static final long serialVersionUID = 1L;
public Map<String, Object> getParameters() {
Map<String, Object> parameters = new HashMap<String, Object>();
AuditSearchDto search = auditSearchDto.getObject();
parameters.put("from", search.getFrom());
parameters.put("to", search.getTo());
if (search.getChannel() != null) {
parameters.put("channel", QNameUtil.qNameToUri(search.getChannel()));
}
parameters.put("hostIdentifier", search.getHostIdentifier());
if (search.getInitiatorName() != null) {
parameters.put("initiatorName", search.getInitiatorName().getOid());
}
if (search.getTargetOwnerName() != null) {
parameters.put("targetOwnerName", search.getTargetOwnerName().getOid());
}
List<String> targetOids = new ArrayList<>();
if (isNotEmpty(search.getTargetNamesObjects())) {
targetOids.addAll(search.getTargetNamesObjects().stream().map(ObjectType::getOid).collect(toList()));
}
if (isNotEmpty(search.getTargetNames())) {
targetOids.addAll(search.getTargetNames().stream().map(ObjectReferenceType::getOid).collect(toList()));
}
if (!targetOids.isEmpty()) {
parameters.put("targetNames", targetOids);
}
if (search.getChangedItem().toItemPath() != null) {
ItemPath itemPath = search.getChangedItem().toItemPath();
parameters.put("changedItem", CanonicalItemPath.create(itemPath).asString());
}
parameters.put("eventType", search.getEventType());
parameters.put("eventStage", search.getEventStage());
parameters.put("outcome", search.getOutcome());
if (isNotEmpty(search.getvalueRefTargetNames())) {
parameters.put(AuditEventRecordProvider.VALUE_REF_TARGET_NAMES_KEY, search.getvalueRefTargetNames().stream().map(ObjectType::getName).map(PolyStringType::getOrig).collect(toList()));
}
return parameters;
}
@Override
protected void saveCurrentPage(long from, long count) {
if (count != 0) {
auditLogStorage.setPageNumber(from / count);
}
}
};
UserProfileStorage userProfile = pageBase.getSessionStorage().getUserProfile();
int pageSize = DEFAULT_PAGE_SIZE;
if (userProfile.getTables().containsKey(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER)) {
pageSize = userProfile.getPagingSize(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER);
}
List<IColumn<AuditEventRecordType, String>> columns = initColumns();
BoxedTablePanel<AuditEventRecordType> table = new BoxedTablePanel<AuditEventRecordType>(ID_TABLE, provider, columns, UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER, pageSize) {
private static final long serialVersionUID = 1L;
@Override
protected WebMarkupContainer createButtonToolbar(String id) {
String fileName = "AuditLogViewer_" + createStringResource("MainObjectListPanel.exportFileName").getString();
CSVDataExporter csvDataExporter = new CSVDataExporter() {
@Override
public <T> void exportData(IDataProvider<T> dataProvider, List<IExportableColumn<T, ?>> columns, OutputStream outputStream) throws IOException {
((AuditEventRecordProvider) dataProvider).setExportSize(true);
super.exportData(dataProvider, columns, outputStream);
((AuditEventRecordProvider) dataProvider).setExportSize(false);
}
};
ResourceStreamResource resource = (new ResourceStreamResource() {
protected IResourceStream getResourceStream() {
return new ExportToolbar.DataExportResourceStreamWriter(csvDataExporter, getAuditLogViewerTable().getDataTable());
}
}).setFileName(fileName + "." + csvDataExporter.getFileNameExtension());
AbstractLink exportDataLink = (new ResourceLink(id, resource)).setBody(csvDataExporter.getDataFormatNameModel());
exportDataLink.add(new AttributeAppender("class", " btn btn-primary btn-sm"));
return exportDataLink;
}
@Override
public void setShowPaging(boolean show) {
//we don't need to do anything here
}
};
table.setShowPaging(true);
table.setCurrentPage(auditLogStorage.getPageNumber());
table.setOutputMarkupId(true);
mainForm.addOrReplace(table);
}
Aggregations