Search in sources :

Example 31 with ReadOnlyModel

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

the class PrismValueMetadataPanel method createMetadataNavigationPanel.

private void createMetadataNavigationPanel() {
    WebMarkupContainer metadataNavigation = new WebMarkupContainer(ID_METADATA_NAVIGATION);
    add(metadataNavigation);
    metadataNavigation.setOutputMarkupId(true);
    ListView<ContainersPopupDto> metadataList = new ListView<ContainersPopupDto>(ID_METADATA_LIST, createMetadataListModel()) {

        @Override
        protected void populateItem(ListItem<ContainersPopupDto> listItem) {
            AjaxButton showMetadataDetails = new AjaxButton(ID_METADATA_QNAME, createStringResource(listItem.getModelObject().getItemName())) {

                @Override
                public void onClick(AjaxRequestTarget ajaxRequestTarget) {
                    ContainersPopupDto ccontainerToShow = listItem.getModelObject();
                    ccontainerToShow.setSelected(true);
                    setContainersToShow(ccontainerToShow, ajaxRequestTarget);
                }
            };
            showMetadataDetails.add(AttributeAppender.replace("class", createButtonClassModel(listItem)));
            showMetadataDetails.setOutputMarkupId(true);
            showMetadataDetails.setOutputMarkupPlaceholderTag(true);
            listItem.setOutputMarkupId(true);
            listItem.add(showMetadataDetails);
        }
    };
    metadataNavigation.add(metadataList);
    ReadOnlyModel<String> activeTab = new ReadOnlyModel<>(() -> {
        if (getValueMetadata() != null && isAnyMetadataSelected()) {
            return "contains-active-tab";
        }
        return "";
    });
    metadataNavigation.add(AttributeAppender.replace("class", activeTab));
    metadataList.setOutputMarkupId(true);
    metadataList.setOutputMarkupPlaceholderTag(true);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) ContainersPopupDto(com.evolveum.midpoint.gui.impl.prism.panel.component.ContainersPopupDto) ListItem(org.apache.wicket.markup.html.list.ListItem) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 32 with ReadOnlyModel

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

the class StatisticsPanel method initLayout.

protected void initLayout() {
    contentsPanel = new WebMarkupContainer(ID_CONTENTS_PANEL);
    contentsPanel.setOutputMarkupId(true);
    add(contentsPanel);
    ListView<ProvisioningStatisticsLineDto> provisioningLines = new ListView<>(ID_PROVISIONING_STATISTICS_LINES, new PropertyModel<>(getModel(), StatisticsDto.F_PROVISIONING_LINES)) {

        protected void populateItem(final ListItem<ProvisioningStatisticsLineDto> item) {
            ListDataProvider<ProvisioningStatisticsOperationDto> provider = new ListDataProvider<>(StatisticsPanel.this, new PropertyModel<>(item.getModel(), ProvisioningStatisticsLineDto.F_OPERATIONS));
            BoxedTablePanel<ProvisioningStatisticsOperationDto> provisioningTable = new BoxedTablePanel<>(ID_PROVISIONING_OPERATIONS, provider, createProvisioningStatisticsColumns()) {

                private static final long serialVersionUID = 1L;

                @Override
                protected WebMarkupContainer createHeader(String headerId) {
                    return new ProvisioningStatisticsHeaderFragment(headerId, ID_PROVISIONING_TITLE, StatisticsPanel.this, item.getModel());
                }

                @Override
                protected Item<ProvisioningStatisticsOperationDto> customizeNewRowItem(Item<ProvisioningStatisticsOperationDto> item, IModel<ProvisioningStatisticsOperationDto> model) {
                    item.add(AttributeModifier.append("class", new ReadOnlyModel<>(() -> {
                        if (model.getObject() != null && OperationResultStatusType.FATAL_ERROR == model.getObject().getStatus()) {
                            return "bg-red disabled color-palette";
                        }
                        return null;
                    })));
                    return item;
                }

                @Override
                protected boolean hideFooterIfSinglePage() {
                    return true;
                }
            };
            provisioningTable.setOutputMarkupId(true);
            provisioningTable.add(new VisibleBehaviour(() -> hasAnyOperation(item.getModelObject())));
            item.add(provisioningTable);
        }
    };
    contentsPanel.add(provisioningLines);
    ListDataProvider<MappingsLineDto> mappingsProvider = new ListDataProvider<>(this, new PropertyModel<>(getModel(), StatisticsDto.F_MAPPINGS_LINES));
    BoxedTablePanel<MappingsLineDto> mappingsLines = new BoxedTablePanel<>(ID_MAPPINGS_STATISTICS_LINES, mappingsProvider, createMappingsColumn()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return new TableHeaderFragment(headerId, ID_MAPPINGS_TITLE, StatisticsPanel.this, createStringResource("Title.MappingsStatistics"));
        }

        @Override
        protected boolean hideFooterIfSinglePage() {
            return true;
        }
    };
    mappingsLines.setOutputMarkupId(true);
    contentsPanel.add(mappingsLines);
    ListDataProvider<NotificationsLineDto> notificationsProvider = new ListDataProvider<>(this, new PropertyModel<>(getModel(), StatisticsDto.F_NOTIFICATIONS_LINES));
    BoxedTablePanel<NotificationsLineDto> notificationsLines = new BoxedTablePanel<>(ID_NOTIFICATIONS_STATISTICS_LINES, notificationsProvider, createNotificationColumns()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return new TableHeaderFragment(headerId, ID_NOTIFICATIONS_TITLE, StatisticsPanel.this, createStringResource("Title.NotificationsStatistics"));
        }

        @Override
        protected boolean hideFooterIfSinglePage() {
            return true;
        }
    };
    notificationsLines.setOutputMarkupId(true);
    contentsPanel.add(notificationsLines);
    Label lastMessage = new Label(ID_LAST_MESSAGE, new PropertyModel<>(getModel(), StatisticsDto.F_LAST_MESSAGE));
    contentsPanel.add(lastMessage);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ListItem(org.apache.wicket.markup.html.list.ListItem) Item(org.apache.wicket.markup.repeater.Item) ListView(org.apache.wicket.markup.html.list.ListView) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) IModel(org.apache.wicket.model.IModel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 33 with ReadOnlyModel

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

the class SideBarMenuPanel method createHeader.

private Component createHeader(IModel<SideBarMenuItem> model) {
    WebMarkupContainer header = new WebMarkupContainer(ID_HEADER);
    header.add(new AjaxEventBehavior("click") {

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            onMenuClick(model);
        }
    });
    header.add(AttributeAppender.append("class", new ReadOnlyModel<>(() -> isMenuExpanded(model.getObject()) ? "" : "closed")));
    Label name = new Label(ID_NAME, new StringResourceModel("${name}", model));
    header.add(name);
    return header;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) StringResourceModel(org.apache.wicket.model.StringResourceModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 34 with ReadOnlyModel

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

the class RelationSearchItem method createSpecialSearchPanel.

@Override
public SearchSpecialItemPanel createSpecialSearchPanel(String id) {
    return new SearchSpecialItemPanel(id, new PropertyModel<>(searchBoxConfiguration, SearchBoxConfigurationHelper.F_RELATION_ITEM)) {

        @Override
        protected WebMarkupContainer initSearchItemField(String id) {
            ReadOnlyModel<List<QName>> availableRelations = new ReadOnlyModel<>(() -> {
                List<QName> choices = new ArrayList();
                IModel<RelationSearchItemConfigurationType> relationItem = getModelValue();
                List<QName> relations = relationItem.getObject().getSupportedRelations();
                if (relations != null && relations.size() > 1) {
                    choices.add(PrismConstants.Q_ANY);
                }
                choices.addAll(relations);
                return choices;
            });
            DropDownChoicePanel inputPanel = new DropDownChoicePanel(id, new PropertyModel(getModelValue(), RelationSearchItemConfigurationType.F_DEFAULT_VALUE.getLocalPart()), availableRelations, new QNameIChoiceRenderer() {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getDisplayValue(QName relation) {
                    RelationDefinitionType relationDef = WebComponentUtil.getRelationDefinition(relation);
                    if (relationDef != null) {
                        DisplayType display = relationDef.getDisplay();
                        if (display != null) {
                            PolyStringType label = display.getLabel();
                            if (PolyStringUtils.isNotEmpty(label)) {
                                return WebComponentUtil.getTranslatedPolyString(label);
                            }
                        }
                    }
                    if (QNameUtil.match(PrismConstants.Q_ANY, relation)) {
                        return new ResourceModel("RelationTypes.ANY", relation.getLocalPart()).getObject();
                    }
                    return super.getDisplayValue(relation);
                }
            }, false);
            inputPanel.getBaseFormComponent().add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
            inputPanel.getBaseFormComponent().add(AttributeAppender.append("style", "width: 100px; max-width: 400px !important;"));
            inputPanel.getBaseFormComponent().add(new EnableBehaviour(() -> availableRelations.getObject().size() > 1));
            inputPanel.setOutputMarkupId(true);
            return inputPanel;
        }

        @Override
        protected IModel<String> createLabelModel() {
            return Model.of(WebComponentUtil.getTranslatedPolyString(getReltaionConfig().getDisplay().getLabel()));
        }

        @Override
        protected IModel<String> createHelpModel() {
            return Model.of(WebComponentUtil.getTranslatedPolyString(getReltaionConfig().getDisplay().getHelp()));
        }
    };
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) QNameIChoiceRenderer(com.evolveum.midpoint.gui.impl.component.input.QNameIChoiceRenderer) DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) PropertyModel(org.apache.wicket.model.PropertyModel) RelationDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.RelationDefinitionType) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) ResourceModel(org.apache.wicket.model.ResourceModel) ArrayList(java.util.ArrayList) List(java.util.List) RelationSearchItemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.RelationSearchItemConfigurationType) SearchSpecialItemPanel(com.evolveum.midpoint.web.component.search.SearchSpecialItemPanel) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Example 35 with ReadOnlyModel

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

the class TaskResultTabPanel method initLayout.

private void initLayout() {
    IModel<List<OperationResult>> resultModel = new ReadOnlyModel<>(() -> createOperationResultList());
    SelectableListDataProvider<SelectableBean<OperationResult>, OperationResult> provider = new SelectableListDataProvider<>(this, resultModel);
    BoxedTablePanel<SelectableBean<OperationResult>> resultTablePanel = new BoxedTablePanel<>(ID_OPERATION_RESULT, provider, initResultColumns());
    resultTablePanel.setOutputMarkupId(true);
    add(resultTablePanel);
    AjaxFallbackLink<Void> showResult = new AjaxFallbackLink<Void>(ID_SHOW_RESULT) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(Optional<AjaxRequestTarget> optionalTarget) {
            if (!optionalTarget.isPresent()) {
                LOGGER.warn("Cannot show result in interactive way, request target not present.");
                return;
            }
            AjaxRequestTarget target = optionalTarget.get();
            PrismObjectWrapper<TaskType> taskWrapper = TaskResultTabPanel.this.getModelObject();
            TaskType taskType = taskWrapper.getObject().asObjectable();
            OperationResult opResult = OperationResult.createOperationResult(taskType.getResult());
            OpResult result = opResult != null ? OpResult.getOpResult(getPageBase(), opResult) : null;
            OperationResultPanel body = new OperationResultPanel(getPageBase().getMainPopupBodyId(), new Model<>(result));
            body.add(new VisibleBehaviour(() -> opResult != null));
            body.setOutputMarkupId(true);
            getPageBase().showMainPopup(body, target);
        }
    };
    showResult.setOutputMarkupId(true);
    add(showResult);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) OperationResultPanel(com.evolveum.midpoint.gui.api.component.result.OperationResultPanel) AjaxFallbackLink(org.apache.wicket.ajax.markup.html.AjaxFallbackLink) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) SelectableListDataProvider(com.evolveum.midpoint.web.component.util.SelectableListDataProvider) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OpResult(com.evolveum.midpoint.gui.api.component.result.OpResult) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel)

Aggregations

ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)35 Label (org.apache.wicket.markup.html.basic.Label)14 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)13 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)10 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)9 IModel (org.apache.wicket.model.IModel)9 ListItem (org.apache.wicket.markup.html.list.ListItem)8 PropertyModel (org.apache.wicket.model.PropertyModel)8 ListView (org.apache.wicket.markup.html.list.ListView)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)5 ArrayList (java.util.ArrayList)5 QName (javax.xml.namespace.QName)5 List (java.util.List)4 StringResourceModel (org.apache.wicket.model.StringResourceModel)4 ItemWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)3 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)3 DisplayType (com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType)3 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)3