Search in sources :

Example 6 with LoadableModel

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();
        }
    };
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)

Example 7 with LoadableModel

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;
        }
    };
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CommonException(com.evolveum.midpoint.util.exception.CommonException) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 8 with LoadableModel

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();
        }
    };
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ObjectPolicyConfigurationTypeDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto)

Example 9 with LoadableModel

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();
        }
    };
}
Also used : LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ArrayList(java.util.ArrayList) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 10 with LoadableModel

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();
        }
    };
}
Also used : LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ArrayList(java.util.ArrayList) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Aggregations

LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)24 ArrayList (java.util.ArrayList)8 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)7 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)6 List (java.util.List)5 Model (org.apache.wicket.model.Model)5 PropertyModel (org.apache.wicket.model.PropertyModel)5 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)4 IModel (org.apache.wicket.model.IModel)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 Task (com.evolveum.midpoint.task.api.Task)3 CommonException (com.evolveum.midpoint.util.exception.CommonException)3 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)3 Label (org.apache.wicket.markup.html.basic.Label)3 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)2 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)2 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)2 TabbedPanel (com.evolveum.midpoint.web.component.TabbedPanel)2