Search in sources :

Example 16 with LoadableModel

use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.

the class CountToolbar method createModel.

private IModel<String> createModel() {
    return new LoadableModel<String>() {

        @Override
        protected String load() {
            long from = 0;
            long to = 0;
            long count = 0;
            IPageable pageable = getTable();
            if (pageable instanceof DataViewBase) {
                DataViewBase view = (DataViewBase) pageable;
                from = view.getFirstItemOffset() + 1;
                to = from + view.getItemsPerPage() - 1;
                long itemCount = view.getItemCount();
                if (to > itemCount) {
                    to = itemCount;
                }
                count = itemCount;
            } else if (pageable instanceof DataTable) {
                DataTable table = (DataTable) pageable;
                from = table.getCurrentPage() * table.getItemsPerPage() + 1;
                to = from + table.getItemsPerPage() - 1;
                long itemCount = table.getItemCount();
                if (to > itemCount) {
                    to = itemCount;
                }
                count = itemCount;
            }
            if (count > 0) {
                PageBase.createStringResourceStatic(CountToolbar.this, "CountToolbar.label", new Object[] { from, to, count });
            }
            return PageBase.createStringResourceStatic(CountToolbar.this, "CountToolbar.noFound").getString();
        }
    };
}
Also used : DataTable(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable) DataViewBase(org.apache.wicket.markup.repeater.data.DataViewBase) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) IPageable(org.apache.wicket.markup.html.navigation.paging.IPageable)

Example 17 with LoadableModel

use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.

the class PageResourceEdit method initLayout.

private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);
    final IModel<Boolean> editable = new LoadableModel<Boolean>(false) {

        @Override
        protected Boolean load() {
            return !isEditing();
        }
    };
    mainForm.add(new AjaxCheckBox(ID_EDIT, editable) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            editPerformed(target, editable.getObject());
        }
    });
    AceEditor editor = new AceEditor(ID_ACE_EDITOR, new PropertyModel<String>(model, ObjectViewDto.F_XML));
    editor.setReadonly(new LoadableModel<Boolean>(false) {

        @Override
        protected Boolean load() {
            return isEditing();
        }
    });
    mainForm.add(editor);
    initButtons(mainForm);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Form(org.apache.wicket.markup.html.form.Form) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) AceEditor(com.evolveum.midpoint.web.component.AceEditor)

Example 18 with LoadableModel

use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.

the class ObjectListPanel method initSearchModel.

private LoadableModel<Search> initSearchModel() {
    return new LoadableModel<Search>(false) {

        private static final long serialVersionUID = 1L;

        @Override
        public Search load() {
            String storageKey = getStorageKey();
            Search search = null;
            if (StringUtils.isNotEmpty(storageKey)) {
                PageStorage storage = getPageStorage(storageKey);
                if (storage != null) {
                    search = storage.getSearch();
                }
            }
            if (search == null) {
                search = createSearch();
            }
            return search;
        }
    };
}
Also used : Search(com.evolveum.midpoint.web.component.search.Search) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) PageStorage(com.evolveum.midpoint.web.session.PageStorage)

Example 19 with LoadableModel

use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.

the class PrismPropertyPanel method initLayout.

private void initLayout(final IModel<IW> model, final Form form) {
    WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
    labelContainer.setOutputMarkupId(true);
    labelContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return labelContainerVisible;
        }
    });
    add(labelContainer);
    final IModel<String> label = createDisplayName(model);
    labelContainer.add(new Label(ID_LABEL, label));
    final IModel<String> helpText = new LoadableModel<String>(false) {

        private static final long serialVersionUID = 1L;

        @Override
        protected String load() {
            return loadHelpText(model);
        }
    };
    Label help = new Label(ID_HELP);
    help.add(AttributeModifier.replace("title", helpText));
    help.add(new InfoTooltipBehavior());
    help.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return StringUtils.isNotEmpty(helpText.getObject());
        }
    });
    labelContainer.add(help);
    WebMarkupContainer required = new WebMarkupContainer("required");
    required.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            IW wrapper = model.getObject();
            ItemDefinition def = wrapper.getItemDefinition();
            if (ObjectType.F_NAME.equals(def.getName())) {
                //fix for "name as required" MID-789
                return true;
            }
            return def.isMandatory();
        }
    });
    labelContainer.add(required);
    WebMarkupContainer hasOutbound = new WebMarkupContainer("hasOutbound");
    hasOutbound.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return hasOutbound(model);
        }
    });
    labelContainer.add(hasOutbound);
    WebMarkupContainer hasPendingModification = new WebMarkupContainer(ID_HAS_PENDING_MODIFICATION);
    hasPendingModification.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return hasPendingModification(model);
        }
    });
    labelContainer.add(hasPendingModification);
    ListView<ValueWrapper> values = new ListView<ValueWrapper>("values", new PropertyModel<List<ValueWrapper>>(model, "values")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<ValueWrapper> item) {
            PrismValuePanel panel = new PrismValuePanel("value", item.getModel(), label, form, getValueCssClass(), getInputCssClass(), pageBase);
            item.add(panel);
            item.add(AttributeModifier.append("class", createStyleClassModel(item.getModel())));
            item.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    return isVisibleValue(item.getModel());
                }
            });
        }
    };
    values.add(new AttributeModifier("class", getValuesClass()));
    values.setReuseItems(true);
    add(values);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) ListView(org.apache.wicket.markup.html.list.ListView) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 20 with LoadableModel

use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.

the class FocusPersonasTabPanel method initLayout.

private void initLayout() {
    WebMarkupContainer container = new WebMarkupContainer(ID_PERSONAS_CONTAINER);
    container.setOutputMarkupId(true);
    add(container);
    RepeatingView view = new RepeatingView(ID_PERSONAS_TABLE);
    view.setOutputMarkupId(true);
    container.add(view);
    LoadableModel<List<PrismObject<FocusType>>> personasListModel = loadModel();
    if (personasListModel.getObject() == null || personasListModel.getObject().size() == 0) {
        WebMarkupContainer viewChild = new WebMarkupContainer(view.newChildId());
        viewChild.setOutputMarkupId(true);
        view.add(viewChild);
        WebMarkupContainer emptyContainer = new WebMarkupContainer(ID_PERSONAS_SUMMARY);
        emptyContainer.setOutputMarkupId(true);
        viewChild.add(emptyContainer);
        return;
    }
    Task task = pageBase.createSimpleTask(OPERATION_LOAD_PERSONAS);
    for (PrismObject<FocusType> personaObject : personasListModel.getObject()) {
        ObjectWrapper<FocusType> personaWrapper = ObjectWrapperUtil.createObjectWrapper(WebComponentUtil.getEffectiveName(personaObject, RoleType.F_DISPLAY_NAME), "", personaObject, ContainerStatus.MODIFYING, task, getPageBase());
        WebMarkupContainer personaPanel = new WebMarkupContainer(view.newChildId());
        personaPanel.setOutputMarkupId(true);
        view.add(personaPanel);
        if (personaObject.getCompileTimeClass().equals(UserType.class)) {
            personaPanel.add(new UserSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<UserType>>((ObjectWrapper) personaWrapper)));
        } else if (personaObject.getCompileTimeClass().equals(RoleType.class)) {
            personaPanel.add(new RoleSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<RoleType>>((ObjectWrapper) personaWrapper)));
        } else if (personaObject.getCompileTimeClass().equals(OrgType.class)) {
            personaPanel.add(new OrgSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<OrgType>>((ObjectWrapper) personaWrapper)));
        } else if (personaObject.getCompileTimeClass().equals(ServiceType.class)) {
            personaPanel.add(new ServiceSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<ServiceType>>((ObjectWrapper) personaWrapper)));
        }
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ServiceSummaryPanel(com.evolveum.midpoint.web.page.admin.users.component.ServiceSummaryPanel) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) UserSummaryPanel(com.evolveum.midpoint.web.page.admin.users.component.UserSummaryPanel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) RoleSummaryPanel(com.evolveum.midpoint.web.page.admin.roles.component.RoleSummaryPanel) ObjectWrapper(com.evolveum.midpoint.web.component.prism.ObjectWrapper) ArrayList(java.util.ArrayList) List(java.util.List) OrgSummaryPanel(com.evolveum.midpoint.web.page.admin.users.component.OrgSummaryPanel)

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