use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class MultipleAssignmentSelector method createRowLink.
private Component createRowLink(String id, final IModel<SelectableBean<AssignmentEditorDto>> rowModel) {
AjaxLink<SelectableBean<AssignmentEditorDto>> button = new AjaxLink<SelectableBean<AssignmentEditorDto>>(id, rowModel) {
@Override
public IModel<?> getBody() {
AssignmentEditorDto dto = (AssignmentEditorDto) rowModel.getObject();
String name = StringUtils.isNotEmpty(dto.getNameForTargetObject()) ? dto.getNameForTargetObject() : dto.getName();
return new Model<>(name);
}
@Override
public void onClick(AjaxRequestTarget target) {
LOGGER.trace("{} CLICK: {}", this, rowModel.getObject());
toggleRow(rowModel);
target.add(this);
}
@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
if (rowModel.getObject().isSelected()) {
tag.put("class", "list-group-item active");
tag.put("style", "background-color: #eee; border-color: #d6d6d6; color: #000;");
} else {
tag.put("class", "list-group-item");
}
String description = ((AssignmentEditorDto) rowModel.getObject()).getDescription();
if (description != null) {
tag.put("title", description);
}
}
};
button.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return ((AssignmentEditorDto) rowModel.getObject()).getStatus() != UserDtoStatus.DELETE;
}
});
button.setOutputMarkupId(true);
return button;
}
use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class ObjectDataProvider method getSelectedData.
public List<T> getSelectedData() {
for (Serializable s : super.getAvailableData()) {
if (s instanceof SelectableBean) {
SelectableBean<T> selectable = (SelectableBean<T>) s;
if (selectable.isSelected() && selectable.getValue() != null) {
selected.add(selectable.getValue());
}
}
}
List<T> allSelected = new ArrayList<>();
allSelected.addAll(selected);
return allSelected;
}
use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class ObjectNameColumn method populateItem.
@Override
public void populateItem(final Item<ICellPopulator<SelectableBean<O>>> cellItem, String componentId, final IModel<SelectableBean<O>> rowModel) {
IModel<String> labelModel = new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
SelectableBean<O> selectableBean = rowModel.getObject();
O value = selectableBean.getValue();
if (value == null) {
OperationResult result = selectableBean.getResult();
OperationResultStatusPresentationProperties props = OperationResultStatusPresentationProperties.parseOperationalResultStatus(result.getStatus());
return cellItem.getString(props.getStatusLabelKey());
} else {
String name = WebComponentUtil.getName(value);
if (selectableBean.getResult() != null) {
StringBuilder complexName = new StringBuilder();
complexName.append(name);
complexName.append(" (");
complexName.append(selectableBean.getResult().getStatus());
complexName.append(")");
return complexName.toString();
}
return name;
}
}
};
if (isClickable(rowModel)) {
// beware: rowModel is very probably resolved at this moment; but it seems to cause no problems
cellItem.add(new LinkPanel(componentId, labelModel) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
SelectableBean<O> selectableBean = rowModel.getObject();
O value = selectableBean.getValue();
if (value == null) {
OperationResult result = selectableBean.getResult();
throw new RestartResponseException(new PageOperationResult(result));
} else {
if (selectableBean.getResult() != null) {
throw new RestartResponseException(new PageOperationResult(selectableBean.getResult()));
} else {
ObjectNameColumn.this.onClick(target, rowModel);
}
}
}
});
} else {
cellItem.add(new Label(componentId, labelModel));
}
}
use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class SelectableBeanObjectDataProvider method internalIterator.
@Override
public Iterator<SelectableBean<O>> internalIterator(long offset, long pageSize) {
LOGGER.trace("begin::iterator() offset {} pageSize {}.", new Object[] { offset, pageSize });
// if (pageSize > 1000000) {
// // Failsafe. Do not even try this. This can have huge impact on the resource. (MID-3336)
// throw new IllegalArgumentException("Requested huge page size: "+pageSize);
// }
preprocessSelectedData();
OperationResult result = new OperationResult(OPERATION_SEARCH_OBJECTS);
try {
ObjectPaging paging = createPaging(offset, pageSize);
Task task = getPage().createSimpleTask(OPERATION_SEARCH_OBJECTS);
ObjectQuery query = getQuery();
if (query == null) {
if (emptyListOnNullQuery) {
return new ArrayList<SelectableBean<O>>().iterator();
}
query = new ObjectQuery();
}
query.setPaging(paging);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Query {} with {}", type.getSimpleName(), query.debugDump());
}
if (ResourceType.class.equals(type) && (options == null || options.isEmpty())) {
options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
}
List<PrismObject<? extends O>> list = (List) getModel().searchObjects(type, query, options, task, result);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Query {} resulted in {} objects", type.getSimpleName(), list.size());
}
for (PrismObject<? extends O> object : list) {
getAvailableData().add(createDataObjectWrapper(object.asObjectable()));
}
// result.recordSuccess();
} catch (Exception ex) {
result.recordFatalError("Couldn't list objects.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list objects", ex);
return handleNotSuccessOrHandledErrorInIterator(result);
} finally {
result.computeStatusIfUnknown();
}
LOGGER.trace("end::iterator() {}", result);
return getAvailableData().iterator();
}
use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class ColumnUtils method getDefaultTaskColumns.
public static <T extends ObjectType> List<IColumn<SelectableBean<T>, String>> getDefaultTaskColumns() {
List<IColumn<SelectableBean<T>, String>> columns = new ArrayList<IColumn<SelectableBean<T>, String>>();
columns.add(new AbstractColumn<SelectableBean<T>, String>(createStringResource("TaskType.kind")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<T>>> cellItem, String componentId, IModel<SelectableBean<T>> rowModel) {
SelectableBean<TaskType> object = (SelectableBean<TaskType>) rowModel.getObject();
PrismProperty<ShadowKindType> pKind = object.getValue() != null ? object.getValue().asPrismObject().findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_KIND)) : null;
if (pKind != null) {
cellItem.add(new Label(componentId, WebComponentUtil.createLocalizedModelForEnum(pKind.getRealValue(), cellItem)));
} else {
cellItem.add(new Label(componentId));
}
}
});
columns.add(new AbstractColumn<SelectableBean<T>, String>(createStringResource("TaskType.intent")) {
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<T>>> cellItem, String componentId, IModel<SelectableBean<T>> rowModel) {
SelectableBean<TaskType> object = (SelectableBean<TaskType>) rowModel.getObject();
PrismProperty<String> pIntent = object.getValue() != null ? object.getValue().asPrismObject().findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_INTENT)) : null;
if (pIntent != null) {
cellItem.add(new Label(componentId, pIntent.getRealValue()));
} else {
cellItem.add(new Label(componentId));
}
}
});
columns.add(new AbstractColumn<SelectableBean<T>, String>(createStringResource("TaskType.objectClass")) {
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<T>>> cellItem, String componentId, IModel<SelectableBean<T>> rowModel) {
SelectableBean<TaskType> object = (SelectableBean<TaskType>) rowModel.getObject();
PrismProperty<QName> pObjectClass = object.getValue() != null ? object.getValue().asPrismObject().findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.OBJECTCLASS_PROPERTY_NAME)) : null;
if (pObjectClass != null) {
cellItem.add(new Label(componentId, pObjectClass.getRealValue().getLocalPart()));
} else {
cellItem.add(new Label(componentId, ""));
}
}
});
List<ColumnTypeDto<String>> columnsDefs = Arrays.asList(new ColumnTypeDto<String>("TaskType.executionStatus", TaskType.F_EXECUTION_STATUS.getLocalPart(), SelectableBean.F_VALUE + ".executionStatus", false));
columns.addAll(ColumnUtils.<SelectableBean<T>>createColumns(columnsDefs));
return columns;
}
Aggregations