Search in sources :

Example 36 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.

the class PageBase method initTitleLayout.

private void initTitleLayout(WebMarkupContainer mainHeader) {
    WebMarkupContainer pageTitleContainer = new WebMarkupContainer(ID_PAGE_TITLE_CONTAINER);
    pageTitleContainer.add(createUserStatusBehaviour());
    pageTitleContainer.setOutputMarkupId(true);
    mainHeader.add(pageTitleContainer);
    WebMarkupContainer pageTitle = new WebMarkupContainer(ID_PAGE_TITLE);
    pageTitleContainer.add(pageTitle);
    IModel<String> deploymentNameModel = new IModel<>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            DeploymentInformationType info = MidPointApplication.get().getDeploymentInfo();
            if (info == null) {
                return "";
            }
            return StringUtils.isEmpty(info.getName()) ? "" : info.getName() + ": ";
        }
    };
    Label deploymentName = new Label(ID_DEPLOYMENT_NAME, deploymentNameModel);
    deploymentName.add(new VisibleBehaviour(() -> StringUtils.isNotEmpty(deploymentNameModel.getObject())));
    deploymentName.setRenderBodyOnly(true);
    pageTitle.add(deploymentName);
    Label pageTitleReal = new Label(ID_PAGE_TITLE_REAL, createPageTitleModel());
    pageTitleReal.setRenderBodyOnly(true);
    pageTitle.add(pageTitleReal);
    IModel<List<Breadcrumb>> breadcrumbsModel = new IModel<>() {

        private static final long serialVersionUID = 1L;

        @Override
        public List<Breadcrumb> getObject() {
            return getBreadcrumbs();
        }
    };
    ListView<Breadcrumb> breadcrumbs = new ListView<>(ID_BREADCRUMB, breadcrumbsModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<Breadcrumb> item) {
            final Breadcrumb dto = item.getModelObject();
            AjaxLink<String> bcLink = new AjaxLink<>(ID_BC_LINK) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    redirectBackToBreadcrumb(dto);
                }
            };
            item.add(bcLink);
            bcLink.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isEnabled() {
                    return dto.isUseLink();
                }
            });
            WebMarkupContainer bcIcon = new WebMarkupContainer(ID_BC_ICON);
            bcIcon.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    return dto.getIcon() != null && dto.getIcon().getObject() != null;
                }
            });
            bcIcon.add(AttributeModifier.replace("class", dto.getIcon()));
            bcLink.add(bcIcon);
            Label bcName = new Label(ID_BC_NAME, dto.getLabel());
            bcLink.add(bcName);
            item.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    return dto.isVisible();
                }
            });
        }
    };
    breadcrumbs.add(new VisibleBehaviour(() -> !isErrorPage()));
    mainHeader.add(breadcrumbs);
    initCartButton(mainHeader);
}
Also used : IModel(org.apache.wicket.model.IModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) Breadcrumb(com.evolveum.midpoint.web.component.breadcrumbs.Breadcrumb) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) TransparentWebMarkupContainer(org.apache.wicket.markup.html.TransparentWebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) PageAssignmentsList(com.evolveum.midpoint.web.page.self.PageAssignmentsList) ListItem(org.apache.wicket.markup.html.list.ListItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 37 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.

the class OperationResultPanel method initContexts.

private void initContexts(WebMarkupContainer operationContent, final IModel<OpResult> model) {
    Label contextsLabel = new Label("contextsLabel", createStringResource("FeedbackAlertMessageDetails.contexts"));
    contextsLabel.setOutputMarkupId(true);
    contextsLabel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return CollectionUtils.isNotEmpty(model.getObject().getContexts());
        }
    });
    operationContent.add(contextsLabel);
    ListView<Context> contexts = new ListView<Context>("contexts", createContextsModel(model)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<Context> item) {
            item.add(new Label("contextName", new PropertyModel<>(item.getModel(), "name")));
            item.add(new Label("contextValue", new PropertyModel<>(item.getModel(), "value")));
        }
    };
    contexts.setOutputMarkupId(true);
    contexts.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return CollectionUtils.isNotEmpty(model.getObject().getContexts());
        }
    });
    operationContent.add(contexts);
}
Also used : ListView(org.apache.wicket.markup.html.list.ListView) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 38 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.

the class OperationResultPanel method initParams.

private void initParams(WebMarkupContainer operationContent, final IModel<OpResult> model) {
    Label paramsLabel = new Label("paramsLabel", createStringResource("FeedbackAlertMessageDetails.params"));
    paramsLabel.setOutputMarkupId(true);
    paramsLabel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return CollectionUtils.isNotEmpty(model.getObject().getParams());
        }
    });
    operationContent.add(paramsLabel);
    ListView<Param> params = new ListView<Param>(ID_PARAMS, createParamsModel(model)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<Param> item) {
            item.add(new Label("paramName", new PropertyModel<>(item.getModel(), "name")));
            item.add(new Label("paramValue", new PropertyModel<>(item.getModel(), "value")));
        }
    };
    params.setOutputMarkupId(true);
    params.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return CollectionUtils.isNotEmpty(model.getObject().getParams());
        }
    });
    operationContent.add(params);
    ListView<OpResult> subresults = new ListView<OpResult>("subresults", createSubresultsModel(model)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<OpResult> item) {
            Panel subresult = new OperationResultPanel("subresult", item.getModel());
            subresult.add(new VisibleBehaviour(() -> item.getModel() != null && item.getModelObject() != null));
            subresult.setOutputMarkupId(true);
            item.add(subresult);
        }
    };
    subresults.setOutputMarkupId(true);
    subresults.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return CollectionUtils.isNotEmpty(model.getObject().getSubresults());
        }
    });
    operationContent.add(subresults);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) Panel(org.apache.wicket.markup.html.panel.Panel) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) ListView(org.apache.wicket.markup.html.list.ListView) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 39 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.

the class PasswordLimitationsPanel method initLayout.

private void initLayout() {
    final WebMarkupContainer validationContainer = new WebMarkupContainer(ID_VALIDATION_CONTAINER) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !getModelObject().isEmpty();
        }
    };
    validationContainer.setOutputMarkupId(true);
    add(validationContainer);
    final WebMarkupContainer validationParentContainer = new WebMarkupContainer(ID_VALIDATION_PARENT_ITEMS) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !getModelObject().isEmpty();
        }
    };
    validationParentContainer.setOutputMarkupId(true);
    validationContainer.add(validationParentContainer);
    ListView<StringLimitationResult> validationItems = new ListView<>(ID_VALIDATION_ITEMS, getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<StringLimitationResult> item) {
            StringLimitationPanel limitationPanel = new StringLimitationPanel(ID_VALIDATION_ITEM, item.getModel());
            limitationPanel.setOutputMarkupId(true);
            item.add(limitationPanel);
            item.add(AttributeModifier.append("class", new IModel<String>() {

                @Override
                public String getObject() {
                    return Boolean.TRUE.equals(item.getModelObject().isSuccess()) ? " text-success" : " text-danger";
                }
            }));
        }
    };
    validationItems.setOutputMarkupId(true);
    validationParentContainer.add(validationItems);
}
Also used : IModel(org.apache.wicket.model.IModel) ListView(org.apache.wicket.markup.html.list.ListView) StringLimitationResult(com.evolveum.midpoint.model.api.validator.StringLimitationResult) ListItem(org.apache.wicket.markup.html.list.ListItem) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 40 with ListItem

use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.

the class FocusProjectionsTabPanel method initLayout.

private void initLayout() {
    IModel<Integer> deadShadows = new ReadOnlyModel<>(() -> countDeadShadows());
    Label label = new Label(ID_DEAD_SHADOWS, deadShadows);
    label.add(new VisibleBehaviour(() -> deadShadows.getObject() > 0));
    add(label);
    MultivalueContainerListPanelWithDetailsPanel<ShadowType> multivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<ShadowType>(ID_SHADOW_TABLE, ShadowType.class) {

        private static final long serialVersionUID = 1L;

        @Override
        protected ISelectableDataProvider<ShadowType, PrismContainerValueWrapper<ShadowType>> createProvider() {
            return new ProjectionsListProvider(FocusProjectionsTabPanel.this, getSearchModel(), loadShadowModel()) {

                @Override
                protected PageStorage getPageStorage() {
                    PageStorage storage = getSession().getSessionStorage().getPageStorageMap().get(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
                    if (storage == null) {
                        storage = getSession().getSessionStorage().initPageStorage(SessionStorage.KEY_FOCUS_PROJECTION_TABLE);
                    }
                    return storage;
                }
            };
        }

        @Override
        protected void newItemPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation) {
            List<QName> supportedTypes = new ArrayList<>(1);
            supportedTypes.add(ResourceType.COMPLEX_TYPE);
            PageBase pageBase = FocusProjectionsTabPanel.this.getPageBase();
            ObjectBrowserPanel<ResourceType> resourceSelectionPanel = new ObjectBrowserPanel<ResourceType>(pageBase.getMainPopupBodyId(), ResourceType.class, supportedTypes, true, pageBase) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void addPerformed(AjaxRequestTarget target, QName type, List<ResourceType> selected) {
                    FocusProjectionsTabPanel.this.addSelectedAccountPerformed(target, selected);
                }
            };
            resourceSelectionPanel.setOutputMarkupId(true);
            pageBase.showMainPopup(resourceSelectionPanel, target);
        }

        @Override
        protected boolean isCreateNewObjectVisible() {
            PrismObjectDefinition<F> def = getObjectWrapper().getObject().getDefinition();
            PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
            return (ref.canRead() && ref.canAdd());
        }

        @Override
        protected IModel<PrismContainerWrapper<ShadowType>> getContainerModel() {
            return null;
        }

        @Override
        protected TableId getTableId() {
            return UserProfileStorage.TableId.FOCUS_PROJECTION_TABLE;
        }

        @Override
        protected List<IColumn<PrismContainerValueWrapper<ShadowType>, String>> createDefaultColumns() {
            return initBasicColumns();
        }

        @Override
        public void editItemPerformed(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ShadowType>> rowModel, List<PrismContainerValueWrapper<ShadowType>> listItems) {
            loadShadowIfNeeded(rowModel, target);
            if (listItems != null) {
                listItems.forEach(value -> {
                    if (((ShadowWrapper) value.getParent()).isLoadWithNoFetch()) {
                        ((PageAdminFocus) getPage()).loadFullShadow((PrismObjectValueWrapper) value, target);
                    }
                });
            }
            super.editItemPerformed(target, rowModel, listItems);
        }

        @Override
        protected Search createSearch(Class<ShadowType> type) {
            Search search = super.createSearch(type);
            PropertySearchItem<Boolean> defaultDeadItem = search.findPropertySearchItem(ShadowType.F_DEAD);
            if (defaultDeadItem != null) {
                defaultDeadItem.setVisible(false);
            }
            addDeadSearchItem(search);
            return search;
        }

        @Override
        protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<ShadowType> containerDef) {
            List<SearchItemDefinition> defs = new ArrayList<>();
            SearchFactory.addSearchRefDef(containerDef, ShadowType.F_RESOURCE_REF, defs, AreaCategoryType.ADMINISTRATION, getPageBase());
            SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_NAME, defs);
            SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_INTENT, defs);
            SearchFactory.addSearchPropertyDef(containerDef, ShadowType.F_KIND, defs);
            return defs;
        }

        @Override
        protected MultivalueContainerDetailsPanel<ShadowType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<ShadowType>> item) {
            return FocusProjectionsTabPanel.this.getMultivalueContainerDetailsPanel(item);
        }
    };
    add(multivalueContainerListPanel);
    setOutputMarkupId(true);
}
Also used : PageAdminFocus(com.evolveum.midpoint.web.page.admin.PageAdminFocus) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) ArrayList(java.util.ArrayList) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) ProjectionsListProvider(com.evolveum.midpoint.web.component.util.ProjectionsListProvider) List(java.util.List) ArrayList(java.util.ArrayList) PageStorage(com.evolveum.midpoint.web.session.PageStorage) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Aggregations

ListItem (org.apache.wicket.markup.html.list.ListItem)127 ListView (org.apache.wicket.markup.html.list.ListView)103 Label (org.apache.wicket.markup.html.basic.Label)79 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)70 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)69 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)40 IModel (org.apache.wicket.model.IModel)40 List (java.util.List)38 ArrayList (java.util.ArrayList)37 PropertyModel (org.apache.wicket.model.PropertyModel)28 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)23 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)23 TextField (org.apache.wicket.markup.html.form.TextField)15 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)14 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)14 QName (javax.xml.namespace.QName)13 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)13 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)11 AttributeModifier (org.apache.wicket.AttributeModifier)11 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)10