Search in sources :

Example 1 with CompositedIconPanel

use of com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconPanel in project midpoint by Evolveum.

the class CompositedButtonPanel method initLayout.

private void initLayout() {
    WebMarkupContainer buttonContainer = new WebMarkupContainer(ID_COMPOSITED_BUTTON);
    add(buttonContainer);
    CompositedIconPanel compositedIconPanel = new CompositedIconPanel(ID_COMPOSITED_ICON, new PropertyModel<>(getModel(), CompositedIconButtonDto.F_COMPOSITED_ICON));
    buttonContainer.add(compositedIconPanel);
    Label label = new Label(ID_LABEL, new ReadOnlyModel<>(() -> {
        DisplayType displayType = getModelObject().getAdditionalButtonDisplayType();
        return WebComponentUtil.getTranslatedPolyString(displayType.getLabel());
    }));
    buttonContainer.add(label);
    buttonContainer.add(AttributeAppender.append("title", new ReadOnlyModel<>(() -> {
        DisplayType displayType = getModelObject().getAdditionalButtonDisplayType();
        return WebComponentUtil.getTranslatedPolyString(displayType.getTooltip());
    })));
    buttonContainer.add(new TooltipBehavior());
    buttonContainer.add(new AjaxEventBehavior("click") {

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            onButtonClicked(target, getModelObject());
        }

        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.setPreventDefault(true);
            super.updateAjaxAttributes(attributes);
        }
    });
// Label description = new Label(ID_DESCRIPTION, new ReadOnlyModel<>(() -> {
// DisplayType displayType = getModelObject().getAdditionalButtonDisplayType();
// return WebComponentUtil.getTranslatedPolyString(displayType.getTooltip());
// }));
// buttonContainer.add(description);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) CompositedIconPanel(com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconPanel) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 2 with CompositedIconPanel

use of com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconPanel in project midpoint by Evolveum.

the class ColumnResultPanel method initLayout.

private void initLayout() {
    LoadableModel<CompositedIcon> compositedIcon = new LoadableModel<CompositedIcon>() {

        @Override
        protected CompositedIcon load() {
            OperationResult result = getModelObject();
            if (result == null) {
                return null;
            }
            String basicIconCssClass;
            String title;
            if (result.isEmpty()) {
                DisplayType displayType = getDisplayForEmptyResult();
                if (displayType == null || displayType.getIcon() == null || displayType.getIcon().getCssClass() == null) {
                    return null;
                }
                basicIconCssClass = displayType.getIcon().getCssClass();
                title = WebComponentUtil.getTranslatedPolyString(displayType.getTooltip());
            } else {
                OperationResultStatusPresentationProperties statusProperties = OperationResultStatusPresentationProperties.parseOperationalResultStatus(result.getStatus());
                basicIconCssClass = statusProperties.getIcon() + " fa-lg";
                title = getPageBase().createStringResource(statusProperties.getStatusLabelKey()).getString();
            }
            CompositedIconBuilder builder = new CompositedIconBuilder();
            String additionalCssClass = "";
            Throwable cause = RepoCommonUtils.getResultExceptionIfExists(getModelObject());
            if (OperationResultStatus.IN_PROGRESS.equals(result.getStatus()) && (cause instanceof CommunicationException) && isProjectionResult()) {
                IconType icon = new IconType();
                icon.setCssClass("fa fa-info-circle " + GuiStyleConstants.BLUE_COLOR);
                builder.appendLayerIcon(icon, LayeredIconCssStyle.BOTTOM_RIGHT_STYLE);
                builder.setTitle(getPageBase().createStringResource("ColumnResultPanel.message.communicationFail").getString());
                additionalCssClass = "change-password-icon-result-center";
            } else {
                builder.setTitle(title);
            }
            builder.setBasicIcon(basicIconCssClass, IconCssStyle.IN_ROW_STYLE, additionalCssClass);
            return builder.build();
        }
    };
    CompositedIconPanel iconPanel = new CompositedIconPanel(ID_RESULT_ICON, compositedIcon);
    iconPanel.setOutputMarkupId(true);
    add(iconPanel);
    AjaxButton showErrorDetailsButton = new AjaxButton(ID_DETAILS_BUTTON) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            getPageBase().showResult(ColumnResultPanel.this.getModelObject());
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    showErrorDetailsButton.setOutputMarkupId(true);
    showErrorDetailsButton.add(AttributeAppender.append("title", getPageBase().createStringResource("ColumnResultPanel.showDetails")));
    showErrorDetailsButton.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject() != null && RepoCommonUtils.getResultExceptionIfExists(getModelObject()) != null;
        }
    });
    add(showErrorDetailsButton);
}
Also used : DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) OperationResultStatusPresentationProperties(com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties) IconType(com.evolveum.midpoint.xml.ns._public.common.common_3.IconType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CompositedIconPanel(com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconPanel) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) CompositedIcon(com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Aggregations

CompositedIconPanel (com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconPanel)2 DisplayType (com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)1 CompositedIcon (com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon)1 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 OperationResultStatusPresentationProperties (com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties)1 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)1 TooltipBehavior (com.evolveum.midpoint.web.util.TooltipBehavior)1 IconType (com.evolveum.midpoint.xml.ns._public.common.common_3.IconType)1 AjaxEventBehavior (org.apache.wicket.ajax.AjaxEventBehavior)1 AjaxRequestAttributes (org.apache.wicket.ajax.attributes.AjaxRequestAttributes)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1