use of com.evolveum.midpoint.web.component.DateLabelComponent in project midpoint by Evolveum.
the class PageCreatedReports method initColumns.
//TODO - consider adding Author name, File Type and ReportType to columns
private List<IColumn<SelectableBean<ReportOutputType>, String>> initColumns(final AjaxDownloadBehaviorFromStream ajaxDownloadBehavior) {
List<IColumn<SelectableBean<ReportOutputType>, String>> columns = new ArrayList<>();
IColumn column;
column = new CheckBoxHeaderColumn();
columns.add(column);
column = new PropertyColumn(createStringResource("pageCreatedReports.table.name"), "name", "value.name");
columns.add(column);
column = new PropertyColumn(createStringResource("pageCreatedReports.table.description"), "value.description");
columns.add(column);
column = new AbstractColumn<SelectableBean<ReportOutputType>, String>(createStringResource("pageCreatedReports.table.time"), "createTimestamp") {
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ReportOutputType>>> cellItem, String componentId, final IModel<SelectableBean<ReportOutputType>> rowModel) {
cellItem.add(new DateLabelComponent(componentId, new AbstractReadOnlyModel<Date>() {
@Override
public Date getObject() {
ReportOutputType object = rowModel.getObject().getValue();
MetadataType metadata = object != null ? object.getMetadata() : null;
if (metadata == null) {
return null;
}
return XmlTypeConverter.toDate(metadata.getCreateTimestamp());
}
}, DateLabelComponent.LONG_MEDIUM_STYLE));
}
};
columns.add(column);
column = new AbstractColumn<SelectableBean<ReportOutputType>, String>(new Model(), null) {
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ReportOutputType>>> cellItem, String componentId, final IModel<SelectableBean<ReportOutputType>> model) {
DownloadButtonPanel panel = new DownloadButtonPanel(componentId) {
@Override
protected void deletePerformed(AjaxRequestTarget target) {
deleteSelectedPerformed(target, ReportDeleteDialogDto.Operation.DELETE_SINGLE, model.getObject().getValue());
}
@Override
protected void downloadPerformed(AjaxRequestTarget target) {
currentReport = model.getObject().getValue();
PageCreatedReports.this.downloadPerformed(target, model.getObject().getValue(), ajaxDownloadBehavior);
}
};
cellItem.add(panel);
}
};
columns.add(column);
column = new InlineMenuHeaderColumn<InlineMenuable>(initInlineMenu()) {
@Override
public void populateItem(Item<ICellPopulator<InlineMenuable>> cellItem, String componentId, IModel<InlineMenuable> rowModel) {
cellItem.add(new Label(componentId));
}
};
columns.add(column);
return columns;
}
use of com.evolveum.midpoint.web.component.DateLabelComponent in project midpoint by Evolveum.
the class PageTasks method addCustomColumns.
private void addCustomColumns(List<IColumn<SelectableBean<TaskType>, String>> columns) {
columns.add(2, new ObjectReferenceColumn<>(createStringResource("pageTasks.task.objectRef"), SelectableBeanImpl.F_VALUE + "." + TaskType.F_OBJECT_REF.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public IModel<ObjectReferenceType> extractDataModel(IModel<SelectableBean<TaskType>> rowModel) {
SelectableBean<TaskType> bean = rowModel.getObject();
return Model.of(bean.getValue().getObjectRef());
}
});
columns.add(4, new AbstractExportableColumn<>(createStringResource("pageTasks.task.currentRunTime"), TaskType.F_COMPLETION_TIMESTAMP.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(final Item<ICellPopulator<SelectableBean<TaskType>>> item, final String componentId, final IModel<SelectableBean<TaskType>> rowModel) {
DateLabelComponent dateLabel = new DateLabelComponent(componentId, new IModel<>() {
private static final long serialVersionUID = 1L;
@Override
public Date getObject() {
Date date = getCurrentRuntime(rowModel);
SelectableBean<TaskType> task = rowModel.getObject();
if (task.getValue().getExecutionState() == TaskExecutionStateType.CLOSED && date != null) {
((DateLabelComponent) item.get(componentId)).setBefore(createStringResource("pageTasks.task.closedAt").getString() + " ");
} else if (date != null) {
((DateLabelComponent) item.get(componentId)).setBefore(WebComponentUtil.formatDurationWordsForLocal(date.getTime(), true, true, PageTasks.this));
}
return date;
}
}, WebComponentUtil.getShortDateTimeFormat(PageTasks.this));
item.add(dateLabel);
}
@Override
public IModel<String> getDataModel(IModel<SelectableBean<TaskType>> rowModel) {
SelectableBean<TaskType> task = rowModel.getObject();
Date date = getCurrentRuntime(rowModel);
String displayValue = "";
if (date != null) {
if (task.getValue().getExecutionState() == TaskExecutionStateType.CLOSED) {
displayValue = createStringResource("pageTasks.task.closedAt").getString() + WebComponentUtil.getShortDateTimeFormattedValue(date, PageTasks.this);
} else {
displayValue = WebComponentUtil.formatDurationWordsForLocal(date.getTime(), true, true, PageTasks.this);
}
}
return Model.of(displayValue);
}
});
columns.add(5, new AbstractExportableColumn<>(createStringResource("pageTasks.task.scheduledToRunAgain")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<TaskType>>> item, String componentId, final IModel<SelectableBean<TaskType>> rowModel) {
item.add(new Label(componentId, () -> createScheduledToRunAgain(rowModel)));
}
@Override
public IModel<String> getDataModel(IModel<SelectableBean<TaskType>> rowModel) {
return Model.of(createScheduledToRunAgain(rowModel));
}
});
}
use of com.evolveum.midpoint.web.component.DateLabelComponent in project midpoint by Evolveum.
the class PageTasks method initTaskColumns.
private List<IColumn<TaskDto, String>> initTaskColumns() {
List<IColumn<TaskDto, String>> columns = new ArrayList<IColumn<TaskDto, String>>();
IColumn column = new CheckBoxHeaderColumn<>();
columns.add(column);
column = createTaskNameColumn(this, "pageTasks.task.name");
columns.add(column);
columns.add(createTaskCategoryColumn(this, "pageTasks.task.category"));
columns.add(new IconColumn<TaskDto>(createStringResource("")) {
@Override
protected IModel<String> createIconModel(IModel<TaskDto> rowModel) {
ObjectReferenceType ref = rowModel.getObject().getObjectRef();
if (ref == null || ref.getType() == null) {
return Model.of("");
}
ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(ref.getType());
String icon = guiDescriptor != null ? guiDescriptor.getBlackIcon() : ObjectTypeGuiDescriptor.ERROR_ICON;
return new Model<>(icon);
}
private ObjectTypeGuiDescriptor getObjectTypeDescriptor(QName type) {
return ObjectTypeGuiDescriptor.getDescriptor(ObjectTypes.getObjectTypeFromTypeQName(type));
}
@Override
public void populateItem(Item<ICellPopulator<TaskDto>> item, String componentId, IModel<TaskDto> rowModel) {
super.populateItem(item, componentId, rowModel);
ObjectReferenceType ref = rowModel.getObject().getObjectRef();
if (ref != null && ref.getType() != null) {
ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(ref.getType());
if (guiDescriptor != null) {
item.add(AttributeModifier.replace("title", createStringResource(guiDescriptor.getLocalizationKey())));
item.add(new TooltipBehavior());
}
}
}
});
columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.objectRef")) {
@Override
public void populateItem(Item<ICellPopulator<TaskDto>> item, String componentId, final IModel<TaskDto> rowModel) {
item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {
@Override
public Object getObject() {
return createObjectRef(rowModel);
}
}));
}
@Override
public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
return Model.of(createObjectRef(rowModel));
}
});
columns.add(createTaskExecutionStatusColumn(this, "pageTasks.task.execution"));
columns.add(new PropertyColumn<TaskDto, String>(createStringResource("pageTasks.task.executingAt"), "executingAt"));
columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.progress")) {
@Override
public void populateItem(Item<ICellPopulator<TaskDto>> cellItem, String componentId, final IModel<TaskDto> rowModel) {
cellItem.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {
@Override
public Object getObject() {
return createProgress(rowModel);
}
}));
}
@Override
public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
return Model.of(createProgress(rowModel));
}
});
columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.currentRunTime")) {
@Override
public void populateItem(final Item<ICellPopulator<TaskDto>> item, final String componentId, final IModel<TaskDto> rowModel) {
DateLabelComponent dateLabel = new DateLabelComponent(componentId, new AbstractReadOnlyModel<Date>() {
@Override
public Date getObject() {
Date date = createCurrentRuntime(rowModel);
TaskDto task = rowModel.getObject();
if (task.getRawExecutionStatus() == TaskExecutionStatus.CLOSED) {
((DateLabelComponent) item.get(componentId)).setBefore("closed at ");
} else if (date != null) {
((DateLabelComponent) item.get(componentId)).setBefore(DurationFormatUtils.formatDurationWords(date.getTime(), true, true));
}
return date;
}
}, DateLabelComponent.MEDIUM_MEDIUM_STYLE);
item.add(dateLabel);
}
@Override
public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
TaskDto task = rowModel.getObject();
Date date = createCurrentRuntime(rowModel);
String displayValue = "";
if (date != null) {
if (task.getRawExecutionStatus() == TaskExecutionStatus.CLOSED) {
displayValue = "closed at " + WebComponentUtil.getLocalizedDate(date, DateLabelComponent.LONG_MEDIUM_STYLE);
} else {
displayValue = DurationFormatUtils.formatDurationWords(date.getTime(), true, true);
}
}
return Model.of(displayValue);
}
});
columns.add(new AbstractExportableColumn<TaskDto, String>(createStringResource("pageTasks.task.scheduledToRunAgain")) {
@Override
public void populateItem(Item<ICellPopulator<TaskDto>> item, String componentId, final IModel<TaskDto> rowModel) {
item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {
@Override
public Object getObject() {
return createScheduledToRunAgain(rowModel);
}
}));
}
@Override
public IModel<String> getDataModel(IModel<TaskDto> rowModel) {
return Model.of(createScheduledToRunAgain(rowModel));
}
});
columns.add(new IconColumn<TaskDto>(createStringResource("pageTasks.task.status")) {
@Override
protected IModel<String> createTitleModel(final IModel<TaskDto> rowModel) {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
TaskDto dto = rowModel.getObject();
if (dto != null && dto.getStatus() != null) {
return createStringResourceStatic(PageTasks.this, dto.getStatus()).getString();
} else {
return createStringResourceStatic(PageTasks.this, OperationResultStatus.UNKNOWN).getString();
}
}
};
}
@Override
protected IModel<String> createIconModel(final IModel<TaskDto> rowModel) {
return new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (rowModel != null && rowModel.getObject() != null && rowModel.getObject().getStatus() != null) {
return OperationResultStatusPresentationProperties.parseOperationalResultStatus(rowModel.getObject().getStatus().createStatusType()).getIcon() + " fa-lg";
} else
return OperationResultStatusPresentationProperties.UNKNOWN.getIcon() + " fa-lg";
}
};
}
});
IColumn<TaskDto, String> menuColumn = new InlineMenuButtonColumn<TaskDto>(createTasksInlineMenu(false), 2, PageTasks.this) {
@Override
protected int getHeaderNumberOfButtons() {
return 2;
}
@Override
protected List<InlineMenuItem> getHeaderMenuItems() {
return createTasksInlineMenu(true);
}
};
columns.add(menuColumn);
return columns;
}
use of com.evolveum.midpoint.web.component.DateLabelComponent in project midpoint by Evolveum.
the class PersonalInfoPanel method initLayout.
protected void initLayout(PageBase parentPage) {
DateLabelComponent lastLoginDate = new DateLabelComponent(ID_LAST_LOGIN_DATE, new AbstractReadOnlyModel<Date>() {
@Override
public Date getObject() {
PersonalInfoDto dto = getModel().getObject();
return dto == null ? null : dto.getLastLoginDate();
}
}, DateLabelComponent.LONG_MEDIUM_STYLE);
lastLoginDate.setBeforeTextOnDateNull(parentPage.getString("PersonalInfoPanel.never"));
add(lastLoginDate);
Label lastLoginFrom = new Label(ID_LAST_LOGIN_FROM, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
PersonalInfoDto dto = getModel().getObject();
return StringUtils.isNotEmpty(dto.getLastLoginFrom()) ? dto.getLastLoginFrom() : PersonalInfoPanel.this.getString("PersonalInfoPanel.undefined");
}
});
add(lastLoginFrom);
DateLabelComponent lastFailDate = new DateLabelComponent(ID_LAST_FAIL_DATE, new AbstractReadOnlyModel<Date>() {
@Override
public Date getObject() {
PersonalInfoDto dto = getModel().getObject();
return dto == null ? null : dto.getLastFailDate();
}
}, DateLabelComponent.LONG_MEDIUM_STYLE);
lastFailDate.setBeforeTextOnDateNull(parentPage.getString("PersonalInfoPanel.never"));
add(lastFailDate);
Label lastFailFrom = new Label(ID_LAST_FAIL_FROM, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
PersonalInfoDto dto = getModel().getObject();
return StringUtils.isNotEmpty(dto.getLastFailFrom()) ? dto.getLastFailFrom() : PersonalInfoPanel.this.getString("PersonalInfoPanel.undefined");
}
});
add(lastFailFrom);
Label passwordExp = new Label(ID_PASSWORD_EXP, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
PersonalInfoDto dto = getModel().getObject();
return dto.getPasswordExp() != null ? WebComponentUtil.formatDate(dto.getPasswordExp()) : PersonalInfoPanel.this.getString("PersonalInfoPanel.undefined");
}
});
add(passwordExp);
}
use of com.evolveum.midpoint.web.component.DateLabelComponent in project midpoint by Evolveum.
the class PageCreatedReports method initColumns.
private List<IColumn<SelectableBean<ReportDataType>, String>> initColumns() {
List<IColumn<SelectableBean<ReportDataType>, String>> columns = new ArrayList<>();
IColumn<SelectableBean<ReportDataType>, String> column = new AbstractColumn<SelectableBean<ReportDataType>, String>(createStringResource("pageCreatedReports.table.time"), "createTimestamp") {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ReportDataType>>> cellItem, String componentId, final IModel<SelectableBean<ReportDataType>> rowModel) {
cellItem.add(new DateLabelComponent(componentId, new IModel<Date>() {
private static final long serialVersionUID = 1L;
@Override
public Date getObject() {
ReportDataType object = rowModel.getObject().getValue();
MetadataType metadata = object != null ? object.getMetadata() : null;
if (metadata == null) {
return null;
}
return XmlTypeConverter.toDate(metadata.getCreateTimestamp());
}
}, WebComponentUtil.getShortDateTimeFormat(PageCreatedReports.this)));
}
};
columns.add(column);
column = new PropertyColumn<>(createStringResource("pageCreatedReports.table.description"), SelectableBeanImpl.F_VALUE + "." + ReportDataType.F_DESCRIPTION.getLocalPart());
columns.add(column);
column = new EnumPropertyColumn(createStringResource("pageCreatedReports.table.fileFormat"), SelectableBeanImpl.F_VALUE + "." + ReportDataType.F_FILE_FORMAT.getLocalPart()) {
@Override
protected String translate(Enum en) {
return createStringResource(en).getString();
}
};
columns.add(column);
column = new ObjectReferenceColumn<SelectableBean<ReportDataType>>(createStringResource("pageCreatedReports.table.type"), SelectableBeanImpl.F_VALUE + "." + ReportDataType.F_REPORT_REF.getLocalPart()) {
@Override
public IModel<ObjectReferenceType> extractDataModel(IModel<SelectableBean<ReportDataType>> rowModel) {
SelectableBean<ReportDataType> bean = rowModel.getObject();
return Model.of(bean.getValue().getReportRef());
}
};
columns.add(column);
return columns;
}
Aggregations