use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class PageAccount method createPageTitleModel.
@Override
protected IModel<String> createPageTitleModel() {
return new LoadableModel<String>(false) {
@Override
protected String load() {
PrismObject<ShadowType> account = accountModel.getObject().getObject();
String accName = WebComponentUtil.getName(account);
ResourceType resource = account.asObjectable().getResource();
String name = WebComponentUtil.getName(resource);
return createStringResourceStatic(PageAccount.this, "PageAccount.title", accName, name).getString();
}
};
}
use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class ResourceContentRepositoryPanel method createTotalsModel.
private LoadableModel<Integer> createTotalsModel(final SynchronizationSituationType situation) {
return new LoadableModel<Integer>(false) {
private static final long serialVersionUID = 1L;
@Override
protected Integer load() {
ObjectFilter resourceFilter = QueryBuilder.queryFor(ShadowType.class, getPageBase().getPrismContext()).item(ShadowType.F_RESOURCE_REF).ref(ResourceContentRepositoryPanel.this.getResourceModel().getObject().getOid()).buildFilter();
if (resourceFilter == null) {
return 0;
}
ObjectFilter filter = createQuery().getFilter();
if (filter == null) {
return 0;
}
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createRaw());
Task task = getPageBase().createSimpleTask(OPERATION_GET_TOTALS);
OperationResult result = new OperationResult(OPERATION_GET_TOTALS);
try {
ObjectFilter situationFilter = QueryBuilder.queryFor(ShadowType.class, getPageBase().getPrismContext()).item(ShadowType.F_SYNCHRONIZATION_SITUATION).eq(situation).buildFilter();
ObjectQuery query = ObjectQuery.createObjectQuery(AndFilter.createAnd(filter, situationFilter));
return getPageBase().getModelService().countObjects(ShadowType.class, query, options, task, result);
} catch (CommonException | RuntimeException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't count shadows", ex);
}
return 0;
}
};
}
use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class ObjectPolicyConfigurationEditor method createNameModel.
private IModel<String> createNameModel(final IModel<ObjectPolicyConfigurationTypeDto> model) {
return new LoadableModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String load() {
StringBuilder sb = new StringBuilder();
ObjectPolicyConfigurationTypeDto config = model.getObject();
if (config != null) {
ObjectReferenceType ref = config.getTemplateRef();
if (ref != null) {
sb.append(WebComponentUtil.getOrigStringFromPoly(ref.getTargetName())).append(": ");
}
if (config.getType() != null) {
sb.append(config.getType().getLocalPart());
}
if (config.getSubtype() != null) {
sb.append("(").append(config.getSubtype()).append(")");
}
}
return sb.toString();
}
};
}
use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class InlineMenuButtonColumn method createMenuModel.
private IModel<List<InlineMenuItem>> createMenuModel(final IModel<T> rowModel, List<InlineMenuItem> menuItems) {
return new LoadableModel<List<InlineMenuItem>>(false) {
@Override
public List<InlineMenuItem> load() {
if (rowModel == null) {
return menuItems;
}
if (rowModel.getObject() == null || !(rowModel.getObject() instanceof InlineMenuable)) {
return new ArrayList<InlineMenuItem>();
}
for (InlineMenuItem item : ((InlineMenuable) rowModel.getObject()).getMenuItems()) {
if (!(item.getAction() instanceof ColumnMenuAction)) {
continue;
}
ColumnMenuAction action = (ColumnMenuAction) item.getAction();
action.setRowModel(rowModel);
}
return ((InlineMenuable) rowModel.getObject()).getMenuItems();
}
};
}
use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class InlineMenuColumn method createMenuModel.
private IModel<List<InlineMenuItem>> createMenuModel(final IModel<T> rowModel) {
return new LoadableModel<List<InlineMenuItem>>(false) {
@Override
public List<InlineMenuItem> load() {
if (!(rowModel.getObject() instanceof InlineMenuable)) {
return new ArrayList<InlineMenuItem>();
}
T row = rowModel.getObject();
if (row.getMenuItems() == null) {
return new ArrayList<InlineMenuItem>();
}
for (InlineMenuItem item : row.getMenuItems()) {
if (!(item.getAction() instanceof ColumnMenuAction)) {
continue;
}
ColumnMenuAction action = (ColumnMenuAction) item.getAction();
action.setRowModel(rowModel);
}
return row.getMenuItems();
}
};
}
Aggregations