Search in sources :

Example 1 with IconType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.IconType in project midpoint by Evolveum.

the class CompositedIconBuilder method appendLayerIcon.

public CompositedIconBuilder appendLayerIcon(String icon, LayeredIconCssStyle style) {
    IconType iconType = new IconType();
    iconType.setCssClass(icon);
    return appendLayerIcon(iconType, style);
}
Also used : IconType(com.evolveum.midpoint.xml.ns._public.common.common_3.IconType)

Example 2 with IconType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.IconType in project midpoint by Evolveum.

the class SearchPanel method initLayout.

private <S extends SearchItem, T extends Serializable> void initLayout() {
    moreDialogModel = new LoadableModel<MoreDialogDto>(false) {

        private static final long serialVersionUID = 1L;

        @Override
        protected MoreDialogDto load() {
            MoreDialogDto dto = new MoreDialogDto();
            dto.setProperties(createPropertiesList());
            return dto;
        }

        @Override
        public MoreDialogDto getObject() {
            if (SearchPanel.this.getModelObject() != null && SearchPanel.this.getModelObject().isTypeChanged()) {
                reset();
            }
            return super.getObject();
        }
    };
    MidpointForm<?> form = new MidpointForm<>(ID_FORM);
    add(form);
    AjaxButton debug = new AjaxButton(ID_DEBUG, createStringResource("SearchPanel.debug")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            debugPerformed();
        }
    };
    debug.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return SearchBoxModeType.ADVANCED.equals(getModelObject().getSearchType()) && queryPlaygroundAccessible;
        }
    });
    form.add(debug);
    PropertyModel<ObjectCollectionSearchItem> collectionModel = new PropertyModel<>(getModel(), Search.F_COLLECTION);
    SearchObjectCollectionPanel collectionPanel = new SearchObjectCollectionPanel(ID_COLLECTION_REF_PANEL, collectionModel);
    form.add(collectionPanel);
    collectionPanel.add(new VisibleBehaviour(() -> collectionModel != null && collectionModel.getObject() != null && getModelObject().isCollectionItemVisible()));
    PropertyModel<ContainerTypeSearchItem> typeModel = new PropertyModel<>(getModel(), Search.F_TYPE);
    SearchTypePanel typePanel = new SearchTypePanel(ID_TYPE_PANEL, typeModel) {

        @Override
        protected void searchPerformed(AjaxRequestTarget target) {
            resetMoreDialogModel();
            SearchPanel.this.searchPerformed(target);
        }
    };
    form.add(typePanel);
    typePanel.add(new VisibleBehaviour(() -> typeModel != null && typeModel.getObject() != null && typeModel.getObject().isVisible() && !SearchBoxModeType.OID.equals(getModelObject().getSearchType())));
    ListView<SearchItem> specialItems = createSpecialItemsPanel(ID_SPECIAL_ITEMS, new PropertyModel<>(getModel(), Search.F_SPECIAL_ITEMS));
    form.add(specialItems);
    ListView<SearchItem> compositedItems = createSpecialItemsPanel(ID_COMPOSITED_SPECIAL_ITEMS, new PropertyModel(getModel(), Search.F_COMPOSITED_SPECIAL_ITEMS + "." + AbstractRoleCompositedSearchItem.F_SEARCH_ITEMS));
    form.add(compositedItems);
    ListView<S> items = new ListView<S>(ID_ITEMS, new PropertyModel<>(getModel(), Search.F_ITEMS)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<S> item) {
            AbstractSearchItemPanel searchItem;
            if (item.getModelObject() instanceof FilterSearchItem) {
                searchItem = new SearchFilterPanel(ID_ITEM, (IModel<FilterSearchItem>) item.getModel()) {

                    private static final long serialVersionUID = 1L;

                    @Override
                    protected boolean canRemoveSearchItem() {
                        return super.canRemoveSearchItem() && SearchPanel.this.getModelObject().isCanConfigure();
                    }

                    @Override
                    protected void searchPerformed(AjaxRequestTarget target) {
                        SearchPanel.this.searchPerformed(target);
                    }
                };
            } else {
                searchItem = new SearchPropertyPanel<T>(ID_ITEM, (IModel<PropertySearchItem<T>>) item.getModel()) {

                    private static final long serialVersionUID = 1L;

                    @Override
                    protected boolean canRemoveSearchItem() {
                        return super.canRemoveSearchItem() && SearchPanel.this.getModelObject().isCanConfigure();
                    }

                    @Override
                    protected void searchPerformed(AjaxRequestTarget target) {
                        SearchPanel.this.searchPerformed(target);
                    }
                };
            }
            item.add(searchItem);
        }
    };
    items.add(createVisibleBehaviour(SearchBoxModeType.BASIC));
    form.add(items);
    SearchSpecialItemPanel oidItem = new SearchSpecialItemPanel<String>(ID_OID_ITEM, new PropertyModel<String>(getModel(), Search.F_OID)) {

        @Override
        protected WebMarkupContainer initSearchItemField(String id) {
            TextPanel<String> inputPanel = new TextPanel<String>(id, getModelValue());
            inputPanel.getBaseFormComponent().add(AttributeAppender.append("style", "width: 220px; max-width: 400px !important;"));
            return inputPanel;
        }

        @Override
        protected IModel<String> createLabelModel() {
            return getPageBase().createStringResource("SearchPanel.oid");
        }

        @Override
        protected IModel<String> createHelpModel() {
            return getPageBase().createStringResource("SearchPanel.oid.help");
        }
    };
    oidItem.add(createVisibleBehaviour(SearchBoxModeType.OID));
    form.add(oidItem);
    WebMarkupContainer moreGroup = new WebMarkupContainer(ID_MORE_GROUP);
    moreGroup.add(new VisibleBehaviour(() -> createVisibleBehaviour(SearchBoxModeType.BASIC).isVisible()));
    form.add(moreGroup);
    AjaxLink<Void> more = new AjaxLink<Void>(ID_MORE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            resetMoreDialogModel();
            Component popover = SearchPanel.this.get(createComponentPath(ID_POPOVER));
            Component button = SearchPanel.this.get(createComponentPath(ID_FORM, ID_MORE_GROUP, ID_MORE));
            togglePopover(target, button, popover, 14);
        }
    };
    more.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            Search search = getModelObject();
            return !search.getAvailableDefinitions().isEmpty();
        }
    });
    more.setOutputMarkupId(true);
    moreGroup.add(more);
    WebMarkupContainer searchContainer = new WebMarkupContainer(ID_SEARCH_CONTAINER);
    searchContainer.setOutputMarkupId(true);
    form.add(searchContainer);
    final CompositedIconBuilder builder = new CompositedIconBuilder();
    builder.setBasicIcon(GuiStyleConstants.CLASS_ICON_SEARCH, IconCssStyle.IN_ROW_STYLE);
    IconType plusIcon = new IconType();
    plusIcon.setColor("white");
    builder.appendLayerIcon(getIconLabelByModeModel(), plusIcon, LayeredIconCssStyle.BOTTOM_RIGHT_STYLE);
    AjaxCompositedIconSubmitButton searchButtonBeforeDropdown = new AjaxCompositedIconSubmitButton(ID_SEARCH_BUTTON_BEFORE_DROPDOWN, builder.build(), getPageBase().createStringResource("SearchPanel.search")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(form);
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            searchPerformed(target);
        }
    };
    IModel<String> buttonRightPaddingModel = () -> {
        boolean isLongButton = SearchBoxModeType.BASIC.equals(getModelObject().getSearchType()) || SearchBoxModeType.AXIOM_QUERY.equals(getModelObject().getSearchType());
        String style = "padding-right: " + (isLongButton ? "23" : "16") + "px;";
        if (getModelObject().getAllowedSearchType().size() == 1) {
            style = style + "border-top-right-radius: 3px; border-bottom-right-radius: 3px;";
        }
        return style;
    };
    searchButtonBeforeDropdown.add(AttributeAppender.append("style", buttonRightPaddingModel));
    searchButtonBeforeDropdown.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            if (SearchBoxModeType.ADVANCED.equals(getModelObject().getSearchType()) || SearchBoxModeType.AXIOM_QUERY.equals(getModelObject().getSearchType())) {
                Search search = getModelObject();
                PrismContext ctx = getPageBase().getPrismContext();
                return search.isAdvancedQueryValid(ctx);
            }
            return true;
        }

        @Override
        public boolean isVisible() {
            Search search = getModelObject();
            if (search.getAllowedSearchType().size() == 1 && SearchBoxModeType.BASIC.equals(search.getAllowedSearchType().get(0))) {
                return !search.getItems().isEmpty() || !search.getAvailableDefinitions().isEmpty();
            }
            return true;
        }
    });
    searchButtonBeforeDropdown.setOutputMarkupId(true);
    searchContainer.add(searchButtonBeforeDropdown);
    form.setDefaultButton(searchButtonBeforeDropdown);
    WebMarkupContainer dropdownButton = new WebMarkupContainer(ID_SEARCH_BUTTON_DROPDOWN);
    dropdownButton.add(new VisibleBehaviour(() -> getModelObject().getAllowedSearchType().size() != 1));
    searchContainer.add(dropdownButton);
    List<InlineMenuItem> searchItems = new ArrayList<>();
    InlineMenuItem searchItem = new InlineMenuItem(createStringResource("SearchPanel.basic")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new InlineMenuItemAction() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    searchTypeUpdated(target, SearchBoxModeType.BASIC);
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(getModelObject().isAllowedSearchMode(SearchBoxModeType.BASIC));
        }
    };
    searchItems.add(searchItem);
    searchItem = new InlineMenuItem(createStringResource("SearchPanel.advanced")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new InlineMenuItemAction() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    searchTypeUpdated(target, SearchBoxModeType.ADVANCED);
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(getModelObject().isAllowedSearchMode(SearchBoxModeType.ADVANCED));
        }
    };
    searchItems.add(searchItem);
    searchItem = new InlineMenuItem(createStringResource("SearchPanel.fullText")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new InlineMenuItemAction() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    searchTypeUpdated(target, SearchBoxModeType.FULLTEXT);
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(isFullTextSearchEnabled() && getModelObject().isAllowedSearchMode(SearchBoxModeType.FULLTEXT));
        }
    };
    searchItems.add(searchItem);
    searchItem = new InlineMenuItem(createStringResource("SearchPanel.oid")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new InlineMenuItemAction() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    searchTypeUpdated(target, SearchBoxModeType.OID);
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(getModelObject().isOidSearchEnabled() && getModelObject().isAllowedSearchMode(SearchBoxModeType.OID));
        }
    };
    searchItems.add(searchItem);
    searchItem = new InlineMenuItem(createStringResource("SearchPanel.axiomQuery")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new InlineMenuItemAction() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    searchTypeUpdated(target, SearchBoxModeType.AXIOM_QUERY);
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(WebModelServiceUtils.isEnableExperimentalFeature(getPageBase()) && getModelObject().isAllowedSearchMode(SearchBoxModeType.AXIOM_QUERY));
        }
    };
    searchItems.add(searchItem);
    ListView<InlineMenuItem> li = new ListView<InlineMenuItem>(ID_MENU_ITEM, Model.ofList(searchItems)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<InlineMenuItem> item) {
            WebMarkupContainer menuItemBody = new MenuLinkPanel(ID_MENU_ITEM_BODY, item.getModel());
            menuItemBody.setRenderBodyOnly(true);
            item.add(menuItemBody);
            menuItemBody.add(new VisibleEnableBehaviour() {

                @Override
                public boolean isVisible() {
                    return Boolean.TRUE.equals(item.getModelObject().getVisible().getObject());
                }
            });
        }
    };
    searchContainer.add(li);
    initPopover();
    WebMarkupContainer fullTextContainer = new WebMarkupContainer(ID_FULL_TEXT_CONTAINER);
    fullTextContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isFullTextSearchEnabled() && getModelObject().getSearchType().equals(SearchBoxModeType.FULLTEXT);
        }
    });
    fullTextContainer.setOutputMarkupId(true);
    form.add(fullTextContainer);
    TextField<String> fullTextInput = new TextField<>(ID_FULL_TEXT_FIELD, new PropertyModel<>(getModel(), Search.F_FULL_TEXT));
    fullTextInput.add(new AjaxFormComponentUpdatingBehavior("blur") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    fullTextInput.add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
    fullTextInput.setOutputMarkupId(true);
    fullTextInput.add(new AttributeAppender("placeholder", createStringResource("SearchPanel.fullTextSearch")));
    fullTextInput.add(createVisibleBehaviour(SearchBoxModeType.FULLTEXT));
    fullTextContainer.add(fullTextInput);
    WebMarkupContainer advancedGroup = new WebMarkupContainer(ID_ADVANCED_GROUP);
    advancedGroup.add(createVisibleBehaviour(SearchBoxModeType.ADVANCED, SearchBoxModeType.AXIOM_QUERY));
    advancedGroup.add(AttributeAppender.append("class", createAdvancedGroupStyle()));
    advancedGroup.setOutputMarkupId(true);
    form.add(advancedGroup);
    Label advancedCheck = new Label(ID_ADVANCED_CHECK);
    advancedCheck.add(AttributeAppender.append("class", createAdvancedGroupLabelStyle()));
    advancedCheck.setOutputMarkupId(true);
    advancedGroup.add(advancedCheck);
    TextArea<?> advancedArea = new TextArea<>(ID_ADVANCED_AREA, new PropertyModel<>(getModel(), Search.F_ADVANCED_QUERY));
    advancedArea.add(new AjaxFormComponentUpdatingBehavior("keyup") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateAdvancedArea(advancedArea, target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.setThrottlingSettings(new ThrottlingSettings(ID_ADVANCED_AREA, Duration.ofMillis(500), true));
        }
    });
    advancedArea.add(AttributeAppender.append("placeholder", getPageBase().createStringResource("SearchPanel.insertFilterXml")));
    advancedArea.add(createVisibleBehaviour(SearchBoxModeType.ADVANCED));
    advancedGroup.add(advancedArea);
    TextField<String> queryDslField = new TextField<>(ID_AXIOM_QUERY_FIELD, new PropertyModel<>(getModel(), Search.F_DSL_QUERY));
    queryDslField.add(new AjaxFormComponentUpdatingBehavior("keyup") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateQueryDSLArea(advancedCheck, advancedGroup, target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.setThrottlingSettings(new ThrottlingSettings(ID_AXIOM_QUERY_FIELD, Duration.ofMillis(500), true));
            attributes.setChannel(new AjaxChannel("Drop", AjaxChannel.Type.DROP));
        }
    });
    queryDslField.add(AttributeAppender.append("placeholder", getPageBase().createStringResource("SearchPanel.insertAxiomQuery")));
    queryDslField.add(createVisibleBehaviour(SearchBoxModeType.AXIOM_QUERY));
    advancedGroup.add(queryDslField);
    WebMarkupContainer advancedErrorGroup = new WebMarkupContainer(ID_ADVANCED_ERROR_GROUP);
    advancedErrorGroup.setOutputMarkupId(true);
    advancedGroup.add(advancedErrorGroup);
    Label advancedError = new Label(ID_ADVANCED_ERROR, new PropertyModel<String>(getModel(), Search.F_ADVANCED_ERROR));
    advancedError.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            Search search = getModelObject();
            if (!search.isShowAdvanced()) {
                return false;
            }
            return StringUtils.isNotEmpty(search.getAdvancedError());
        }
    });
    advancedErrorGroup.add(advancedError);
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) TextArea(org.apache.wicket.markup.html.form.TextArea) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) TextPanel(com.evolveum.midpoint.web.component.input.TextPanel) AbstractRoleCompositedSearchItem(com.evolveum.midpoint.web.page.admin.roles.AbstractRoleCompositedSearchItem) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) TextField(org.apache.wicket.markup.html.form.TextField) AjaxChannel(org.apache.wicket.ajax.AjaxChannel) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) IconType(com.evolveum.midpoint.xml.ns._public.common.common_3.IconType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ThrottlingSettings(org.apache.wicket.ajax.attributes.ThrottlingSettings) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Component(org.apache.wicket.Component) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) IModel(org.apache.wicket.model.IModel) PropertyModel(org.apache.wicket.model.PropertyModel) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) MenuLinkPanel(com.evolveum.midpoint.web.component.menu.cog.MenuLinkPanel) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxCompositedIconSubmitButton(com.evolveum.midpoint.web.component.AjaxCompositedIconSubmitButton)

Example 3 with IconType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.IconType in project midpoint by Evolveum.

the class DashboardWidgetDto method createIconCssClass.

private String createIconCssClass(DashboardWidget dashboardWidget) {
    if (dashboardWidget == null) {
        return DEFAULT_ICON;
    }
    DisplayType displayType = dashboardWidget.getDisplay();
    if (displayType == null) {
        return DEFAULT_ICON;
    }
    IconType icon = displayType.getIcon();
    if (icon == null) {
        return DEFAULT_ICON;
    }
    String cssClass = icon.getCssClass();
    if (StringUtils.isNoneBlank(cssClass)) {
        return cssClass;
    }
    return DEFAULT_ICON;
}
Also used : DisplayType(com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType) IconType(com.evolveum.midpoint.xml.ns._public.common.common_3.IconType)

Example 4 with IconType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.IconType in project midpoint by Evolveum.

the class OperationResultPanel method initHeader.

private void initHeader(WebMarkupContainer box) {
    WebMarkupContainer iconType = new WebMarkupContainer(ID_ICON_TYPE);
    iconType.setOutputMarkupId(true);
    iconType.add(new AttributeAppender("class", new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            StringBuilder sb = new StringBuilder();
            OpResult message = getModelObject();
            switch(message.getStatus()) {
                case IN_PROGRESS:
                case NOT_APPLICABLE:
                    sb.append(" fa-info");
                    break;
                case SUCCESS:
                    sb.append(" fa-check");
                    break;
                case FATAL_ERROR:
                    sb.append(" fa-ban");
                    break;
                case PARTIAL_ERROR:
                case UNKNOWN:
                case WARNING:
                case HANDLED_ERROR:
                default:
                    sb.append(" fa-warning");
            }
            return sb.toString();
        }
    }));
    box.add(iconType);
    Label message = createMessage();
    AjaxLink<String> showMore = new AjaxLink<String>(ID_MESSAGE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            OpResult result = OperationResultPanel.this.getModelObject();
            result.setShowMore(!result.isShowMore());
            // hack to be able to expand/collapse OpResult after rendered.
            result.setAlreadyShown(false);
            target.add(OperationResultPanel.this);
        }
    };
    showMore.add(message);
    box.add(showMore);
    AjaxLink<String> backgroundTask = new AjaxLink<String>(ID_BACKGROUND_TASK) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            final OpResult opResult = OperationResultPanel.this.getModelObject();
            String oid = opResult.getBackgroundTaskOid();
            if (oid == null || !opResult.isBackgroundTaskVisible()) {
                // just for safety
                return;
            }
            ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(oid, ObjectTypes.TASK);
            WebComponentUtil.dispatchToObjectDetailsPage(ref, getPageBase(), false);
        }
    };
    backgroundTask.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getBackgroundTaskOid() != null && getModelObject().isBackgroundTaskVisible();
        }
    });
    box.add(backgroundTask);
    AjaxLink<String> aCase = new AjaxLink<String>(ID_CASE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            final OpResult opResult = OperationResultPanel.this.getModelObject();
            String oid = opResult.getCaseOid();
            if (oid == null || !opResult.isCaseVisible()) {
                // just for safety
                return;
            }
            ObjectReferenceType ref = ObjectTypeUtil.createObjectRef(oid, ObjectTypes.CASE);
            WebComponentUtil.dispatchToObjectDetailsPage(ref, getPageBase(), false);
        }
    };
    aCase.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getCaseOid() != null && getModelObject().isCaseVisible();
        }
    });
    box.add(aCase);
    AjaxLink<String> showAll = new AjaxLink<String>(ID_SHOW_ALL) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showHideAll(true, target);
        }
    };
    showAll.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !OperationResultPanel.this.getModelObject().isShowMore();
        }
    });
    box.add(showAll);
    AjaxLink<String> hideAll = new AjaxLink<String>(ID_HIDE_ALL) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showHideAll(false, target);
        }
    };
    hideAll.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return OperationResultPanel.this.getModelObject().isShowMore();
        }
    });
    box.add(hideAll);
    AjaxLink<String> close = new AjaxLink<String>("close") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            close(target);
        }
    };
    box.add(close);
    DownloadLink downloadXml = new DownloadLink("downloadXml", new IModel<File>() {

        private static final long serialVersionUID = 1L;

        @Override
        public File getObject() {
            String home = getPageBase().getMidpointConfiguration().getMidpointHome();
            File f = new File(home, "result");
            try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(f))) {
                dos.writeBytes(OperationResultPanel.this.getModel().getObject().getXml());
            } catch (IOException e) {
                LOGGER.error("Could not download result: {}", e.getMessage(), e);
            }
            return f;
        }
    });
    downloadXml.add(new VisibleBehaviour(() -> getModelObject().isParent()));
    downloadXml.setDeleteAfterDownload(true);
    box.add(downloadXml);
}
Also used : DownloadLink(org.apache.wicket.markup.html.link.DownloadLink) IModel(org.apache.wicket.model.IModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) DataOutputStream(java.io.DataOutputStream) Label(org.apache.wicket.markup.html.basic.Label) IOException(java.io.IOException) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) FileOutputStream(java.io.FileOutputStream) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) File(java.io.File) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 5 with IconType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.IconType 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

IconType (com.evolveum.midpoint.xml.ns._public.common.common_3.IconType)4 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)2 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)2 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)2 DisplayType (com.evolveum.midpoint.xml.ns._public.common.common_3.DisplayType)2 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)2 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 Label (org.apache.wicket.markup.html.basic.Label)2 IModel (org.apache.wicket.model.IModel)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 CompositedIconPanel (com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconPanel)1 CompositedIcon (com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)1 AjaxCompositedIconSubmitButton (com.evolveum.midpoint.web.component.AjaxCompositedIconSubmitButton)1 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)1 TextPanel (com.evolveum.midpoint.web.component.input.TextPanel)1