Search in sources :

Example 1 with ReadOnlyModel

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

the class DetailsNavigationPanel method getMenuItemIconClass.

private IModel<String> getMenuItemIconClass(IModel<ContainerPanelConfigurationType> item) {
    return new ReadOnlyModel<>(() -> {
        ContainerPanelConfigurationType config = item.getObject();
        if (config == null || config.getDisplay() == null) {
            return GuiStyleConstants.CLASS_CIRCLE_FULL;
        }
        String iconCss = WebComponentUtil.getIconCssClass(config.getDisplay());
        return StringUtils.isNoneEmpty(iconCss) ? iconCss : GuiStyleConstants.CLASS_CIRCLE_FULL;
    });
}
Also used : ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) ContainerPanelConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType)

Example 2 with ReadOnlyModel

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

the class DetailsNavigationPanel method createNavigationDetailsStyleModel.

private IModel<String> createNavigationDetailsStyleModel(ListItem<ContainerPanelConfigurationType> item) {
    return new ReadOnlyModel<>(() -> {
        ContainerPanelConfigurationType storageConfig = getConfigurationFromStorage();
        ContainerPanelConfigurationType itemModelObject = item.getModelObject();
        if (isMenuActive(storageConfig, itemModelObject)) {
            return "active open";
        }
        if (hasActiveSubmenu(storageConfig, itemModelObject)) {
            return "open";
        }
        return "";
    });
}
Also used : ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) ContainerPanelConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ContainerPanelConfigurationType)

Example 3 with ReadOnlyModel

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

the class PrismPropertyWrapperColumnPanel method createLink.

@Override
protected Panel createLink(String id, IModel<PrismPropertyValueWrapper<T>> object) {
    String humanReadableLinkName = getHumanReadableLinkName(object);
    IModel labelModel;
    if (StringUtils.isEmpty(humanReadableLinkName)) {
        labelModel = getPageBase().createStringResource("feedbackMessagePanel.message.undefined");
    } else {
        labelModel = new ReadOnlyModel(() -> humanReadableLinkName);
    }
    AjaxLinkPanel ajaxLinkPanel = new AjaxLinkPanel(id, labelModel) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            PrismPropertyWrapperColumnPanel.this.onClick(target, getModelObject().getParent());
        }
    };
    return ajaxLinkPanel;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) AjaxLinkPanel(com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel)

Example 4 with ReadOnlyModel

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

the class ResourceDetailsTabPanel method createAvailabilityStatusInfoBoxModel.

private ReadOnlyModel<InfoBoxType> createAvailabilityStatusInfoBoxModel() {
    return new ReadOnlyModel<>(() -> {
        String messageKey = "PageResource.resource.availabilityUnknown";
        String backgroundColor = "bg-gray";
        String icon = "fa fa-question";
        ResourceType resource = getObjectDetailsModels().getObjectType();
        OperationalStateType operationalState = resource.getOperationalState();
        AdministrativeOperationalStateType administrativeOperationalState = resource.getAdministrativeOperationalState();
        boolean inMaintenance = false;
        if (administrativeOperationalState != null) {
            AdministrativeAvailabilityStatusType administrativeAvailabilityStatus = administrativeOperationalState.getAdministrativeAvailabilityStatus();
            if (administrativeAvailabilityStatus == AdministrativeAvailabilityStatusType.MAINTENANCE) {
                messageKey = "PageResource.resource.maintenance";
                backgroundColor = "bg-gray";
                icon = "fa fa-wrench";
                inMaintenance = true;
            }
        }
        if (operationalState != null && !inMaintenance) {
            AvailabilityStatusType lastAvailabilityStatus = operationalState.getLastAvailabilityStatus();
            if (lastAvailabilityStatus != null) {
                if (lastAvailabilityStatus == AvailabilityStatusType.UP) {
                    messageKey = "PageResource.resource.up";
                    backgroundColor = "bg-green";
                    icon = "fa fa-power-off";
                } else if (lastAvailabilityStatus == AvailabilityStatusType.DOWN) {
                    backgroundColor = "bg-red";
                    messageKey = "PageResource.resource.down";
                    icon = "fa fa-ban";
                } else if (lastAvailabilityStatus == AvailabilityStatusType.BROKEN) {
                    backgroundColor = "bg-yellow";
                    messageKey = "PageResource.resource.broken";
                    icon = "fa fa-warning";
                }
            }
        }
        InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, icon, getPageBase().getString(messageKey));
        ConnectorType connectorType = getConnectorType(resource);
        if (connectorType == null) {
            // Connector not found. Probably bad connectorRef reference.
            infoBoxType.setNumber("--");
            infoBoxType.setDescription("--");
        } else {
            String connectorName = StringUtils.substringAfterLast(WebComponentUtil.getEffectiveName(connectorType, ConnectorType.F_CONNECTOR_TYPE), ".");
            String connectorVersion = connectorType.getConnectorVersion();
            infoBoxType.setNumber(connectorName);
            infoBoxType.setDescription(connectorVersion);
        }
        return infoBoxType;
    });
}
Also used : InfoBoxType(com.evolveum.midpoint.web.component.box.InfoBoxType) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel)

Example 5 with ReadOnlyModel

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

the class ResourceSchemaHandlingPanel method createMultivalueContainerDetailsPanel.

private MultivalueContainerDetailsPanel<ResourceObjectTypeDefinitionType> createMultivalueContainerDetailsPanel(String panelId, IModel<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> model) {
    return new MultivalueContainerDetailsPanel<>(panelId, model, true) {

        @Override
        protected ItemVisibility getBasicTabVisibity(ItemWrapper<?, ?> itemWrapper) {
            if (itemWrapper instanceof PrismContainerWrapper) {
                return ItemVisibility.HIDDEN;
            }
            return ItemVisibility.AUTO;
        }

        @Override
        @NotNull
        protected List<ITab> createTabs() {
            List<ITab> tabs = new ArrayList<>();
            tabs.add(new PanelTab(createStringResource("ResourceSchemaHandlingPanel.tab.attributes")) {

                @Override
                public WebMarkupContainer createPanel(String panelId) {
                    return new ResourceAttributePanel(panelId, PrismContainerWrapperModel.fromContainerValueWrapper(getModel(), ResourceObjectTypeDefinitionType.F_ATTRIBUTE), getPanelConfiguration());
                }
            });
            return tabs;
        }

        @Override
        protected DisplayNamePanel<ResourceObjectTypeDefinitionType> createDisplayNamePanel(String displayNamePanelId) {
            return new DisplayNamePanel<>(displayNamePanelId, new ItemRealValueModel<>(getModel())) {

                @Override
                protected IModel<String> createHeaderModel() {
                    return new ReadOnlyModel<>(() -> loadHeaderModel(getModelObject()));
                }

                @Override
                protected IModel<List<String>> getDescriptionLabelsModel() {
                    return new ReadOnlyModel<>(() -> loadDescriptionModel(getModelObject()));
                }
            };
        }
    };
}
Also used : PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) MultivalueContainerDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) ArrayList(java.util.ArrayList) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) DisplayNamePanel(com.evolveum.midpoint.gui.api.component.DisplayNamePanel) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) ResourceAttributePanel(com.evolveum.midpoint.gui.impl.prism.panel.ResourceAttributePanel) ArrayList(java.util.ArrayList) List(java.util.List)

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