use of com.evolveum.midpoint.web.util.TooltipBehavior in project midpoint by Evolveum.
the class ProcessInstancesPanel method createTypeIconColumn.
public IColumn<ProcessInstanceDto, String> createTypeIconColumn(final boolean object) {
// true = object, false = target
return new IconColumn<ProcessInstanceDto>(createStringResource("")) {
@Override
protected DisplayType getIconDisplayType(IModel<ProcessInstanceDto> rowModel) {
if (getObjectType(rowModel) == null) {
return GuiDisplayTypeUtil.createDisplayType("");
}
ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(rowModel);
String icon = guiDescriptor != null ? guiDescriptor.getBlackIcon() : ObjectTypeGuiDescriptor.ERROR_ICON;
return GuiDisplayTypeUtil.createDisplayType(icon);
}
private ObjectTypeGuiDescriptor getObjectTypeDescriptor(IModel<ProcessInstanceDto> rowModel) {
QName type = getObjectType(rowModel);
return ObjectTypeGuiDescriptor.getDescriptor(ObjectTypes.getObjectTypeFromTypeQName(type));
}
private QName getObjectType(IModel<ProcessInstanceDto> rowModel) {
return object ? rowModel.getObject().getObjectType() : rowModel.getObject().getTargetType();
}
@Override
public void populateItem(Item<ICellPopulator<ProcessInstanceDto>> item, String componentId, IModel<ProcessInstanceDto> rowModel) {
super.populateItem(item, componentId, rowModel);
ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(rowModel);
if (guiDescriptor != null) {
item.add(AttributeModifier.replace("title", createStringResource(guiDescriptor.getLocalizationKey())));
item.add(new TooltipBehavior());
}
}
};
}
use of com.evolveum.midpoint.web.util.TooltipBehavior in project midpoint by Evolveum.
the class CompositedButtonPanel method initLayout.
private void initLayout() {
WebMarkupContainer buttonContainer = new WebMarkupContainer(ID_COMPOSITED_BUTTON);
add(buttonContainer);
CompositedIconPanel compositedIconPanel = new CompositedIconPanel(ID_COMPOSITED_ICON, new PropertyModel<>(getModel(), CompositedIconButtonDto.F_COMPOSITED_ICON));
buttonContainer.add(compositedIconPanel);
Label label = new Label(ID_LABEL, new ReadOnlyModel<>(() -> {
DisplayType displayType = getModelObject().getAdditionalButtonDisplayType();
return WebComponentUtil.getTranslatedPolyString(displayType.getLabel());
}));
buttonContainer.add(label);
buttonContainer.add(AttributeAppender.append("title", new ReadOnlyModel<>(() -> {
DisplayType displayType = getModelObject().getAdditionalButtonDisplayType();
return WebComponentUtil.getTranslatedPolyString(displayType.getTooltip());
})));
buttonContainer.add(new TooltipBehavior());
buttonContainer.add(new AjaxEventBehavior("click") {
@Override
protected void onEvent(AjaxRequestTarget target) {
onButtonClicked(target, getModelObject());
}
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
attributes.setPreventDefault(true);
super.updateAjaxAttributes(attributes);
}
});
// Label description = new Label(ID_DESCRIPTION, new ReadOnlyModel<>(() -> {
// DisplayType displayType = getModelObject().getAdditionalButtonDisplayType();
// return WebComponentUtil.getTranslatedPolyString(displayType.getTooltip());
// }));
// buttonContainer.add(description);
}
use of com.evolveum.midpoint.web.util.TooltipBehavior in project midpoint by Evolveum.
the class TaskInfoBoxPanel method customInitLayout.
@Override
protected void customInitLayout(WebMarkupContainer parentInfoBox, IModel<ActivityInfoBoxDto> model, Class<? extends IRequestablePage> linkPage) {
Label duration = new Label(ID_DURATION, new ReadOnlyModel<>(() -> model != null && model.getObject() != null ? WebComponentUtil.formatDurationWordsForLocal(model.getObject().getDuration(), true, true, getPageBase()) : ""));
parentInfoBox.add(duration);
Label errorMessage = new Label(ID_ERROR_MESSAGE, new PropertyModel<>(model, ActivityInfoBoxDto.F_ERROR_MESSAGE));
parentInfoBox.add(errorMessage);
errorMessage.add(AttributeAppender.append("title", new PropertyModel<>(model, ActivityInfoBoxDto.F_ERROR_MESSAGE)));
errorMessage.add(new TooltipBehavior() {
@Override
public String getDataPlacement() {
return "bottom";
}
});
if (linkPage != null) {
add(new AjaxEventBehavior("click") {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget target) {
setResponsePage(linkPage);
}
});
}
}
use of com.evolveum.midpoint.web.util.TooltipBehavior 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.util.TooltipBehavior in project midpoint by Evolveum.
the class ColumnUtils method getDefaultCaseColumns.
public static List<IColumn<SelectableBean<CaseType>, String>> getDefaultCaseColumns(PageBase pageBase, boolean isDashboard) {
List<IColumn<SelectableBean<CaseType>, String>> columns = new ArrayList<>();
IColumn column = new PropertyColumn(createStringResource("pageCases.table.description"), "value.description");
columns.add(column);
column = new AbstractColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.objectRef")) {
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<CaseType>>> item, String componentId, IModel<SelectableBean<CaseType>> rowModel) {
item.add(new Label(componentId, new IModel<String>() {
@Override
public String getObject() {
CaseType caseModelObject = rowModel.getObject().getValue();
if (caseModelObject == null) {
return "";
}
AssignmentHolderType objectRef = WebComponentUtil.getObjectFromAddDeltyForCase(caseModelObject);
if (objectRef != null) {
return WebComponentUtil.getEffectiveName(objectRef, AbstractRoleType.F_DISPLAY_NAME);
} else if (caseModelObject.getObjectRef() != null && StringUtils.isNotEmpty(caseModelObject.getObjectRef().getOid())) {
if (caseModelObject.getObjectRef().getObject() != null) {
return WebComponentUtil.getEffectiveName(caseModelObject.getObjectRef().getObject(), AbstractRoleType.F_DISPLAY_NAME);
} else {
try {
return WebComponentUtil.getEffectiveName(caseModelObject.getObjectRef(), AbstractRoleType.F_DISPLAY_NAME, pageBase, pageBase.getClass().getSimpleName() + "." + "loadCaseObjectRefName");
} catch (Exception ex) {
LOGGER.error("Unable find the object for reference: {}", caseModelObject.getObjectRef());
}
}
}
return "";
}
}));
}
};
columns.add(column);
if (!isDashboard) {
columns.add(createCaseActorsColumn(pageBase));
}
column = new AbstractColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.openTimestamp"), MetadataType.F_CREATE_TIMESTAMP.getLocalPart()) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<CaseType>>> cellItem, String componentId, final IModel<SelectableBean<CaseType>> rowModel) {
CaseType object = rowModel.getObject().getValue();
MetadataType metadata = object != null ? object.getMetadata() : null;
XMLGregorianCalendar createdCal = metadata != null ? metadata.getCreateTimestamp() : null;
final Date created;
if (createdCal != null) {
created = createdCal.toGregorianCalendar().getTime();
// cellItem.add(AttributeModifier.replace("title", WebComponentUtil.getLocalizedDate(created, DateLabelComponent.LONG_MEDIUM_STYLE)));
// cellItem.add(new TooltipBehavior());
} else {
created = null;
}
cellItem.add(new Label(componentId, new IModel<String>() {
@Override
public String getObject() {
return WebComponentUtil.getShortDateTimeFormattedValue(created, pageBase);
}
}));
}
@Override
public String getCssClass() {
return isDashboard ? "col-sm-2 col-lg-1" : super.getCssClass();
}
};
columns.add(column);
if (!isDashboard) {
column = new PropertyColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.closeTimestamp"), CaseType.F_CLOSE_TIMESTAMP.getLocalPart(), "value.closeTimestamp") {
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<CaseType>>> cellItem, String componentId, final IModel<SelectableBean<CaseType>> rowModel) {
CaseType object = rowModel.getObject().getValue();
XMLGregorianCalendar closedCal = object != null ? object.getCloseTimestamp() : null;
final Date closed;
if (closedCal != null) {
closed = closedCal.toGregorianCalendar().getTime();
cellItem.add(AttributeModifier.replace("title", WebComponentUtil.getLocalizedDate(closed, DateLabelComponent.LONG_MEDIUM_STYLE)));
cellItem.add(new TooltipBehavior());
} else {
closed = null;
}
cellItem.add(new Label(componentId, new IModel<String>() {
@Override
public String getObject() {
return WebComponentUtil.getShortDateTimeFormattedValue(closed, pageBase);
}
}));
}
@Override
public String getCssClass() {
return isDashboard ? "col-sm-2 col-lg-1" : super.getCssClass();
}
};
columns.add(column);
}
column = new CountIconColumn<SelectableBean<CaseType>>(createStringResource("CaseType.outcome")) {
@Override
protected Map<DisplayType, Integer> getIconDisplayType(IModel<SelectableBean<CaseType>> rowModel) {
Map<DisplayType, Integer> map = new HashMap<>();
CaseType caseType = rowModel.getObject().getValue();
if (ObjectTypeUtil.hasArchetype(caseType, SystemObjectsType.ARCHETYPE_OPERATION_REQUEST.value())) {
ObjectQuery queryFilter = pageBase.getPrismContext().queryFor(CaseType.class).item(CaseType.F_PARENT_REF).ref(caseType.getOid()).build();
List<PrismObject<CaseType>> childs = WebModelServiceUtils.searchObjects(CaseType.class, queryFilter, new OperationResult("search_case_child"), pageBase);
for (PrismObject<CaseType> child : childs) {
processCaseOutcome(child.asObjectable(), map, false);
}
} else {
processCaseOutcome(caseType, map, true);
}
return map;
}
@Override
public String getCssClass() {
return "col-lg-1";
}
};
columns.add(column);
column = new PropertyColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.state"), CaseType.F_STATE.getLocalPart(), "value.state") {
@Override
public String getCssClass() {
return "col-lg-1";
}
@Override
public IModel<?> getDataModel(IModel<SelectableBean<CaseType>> rowModel) {
IModel<String> dataModel = (IModel<String>) super.getDataModel(rowModel);
if (StringUtils.isNotBlank(dataModel.getObject())) {
String key = CaseType.COMPLEX_TYPE.getLocalPart() + "." + CaseType.F_STATE.getLocalPart() + "." + dataModel.getObject();
return new StringResourceModel(key, pageBase).setModel(new Model<String>()).setDefaultValue(dataModel.getObject());
}
return dataModel;
}
};
columns.add(column);
if (!isDashboard) {
column = new AbstractExportableColumn<SelectableBean<CaseType>, String>(createStringResource("pageCases.table.workitems")) {
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<CaseType>>> cellItem, String componentId, IModel<SelectableBean<CaseType>> model) {
cellItem.add(new Label(componentId, model.getObject().getValue() != null && model.getObject().getValue().getWorkItem() != null ? model.getObject().getValue().getWorkItem().size() : null));
}
@Override
public IModel<String> getDataModel(IModel<SelectableBean<CaseType>> rowModel) {
return Model.of(rowModel.getObject().getValue() != null && rowModel.getObject().getValue().getWorkItem() != null ? Integer.toString(rowModel.getObject().getValue().getWorkItem().size()) : "");
}
@Override
public String getCssClass() {
return "col-lg-1";
}
};
columns.add(column);
}
return columns;
}
Aggregations