Search in sources :

Example 31 with InlineMenuItemAction

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction in project midpoint by Evolveum.

the class AssignmentPanel method getAssignmentMenuActions.

private <AH extends FocusType> List<InlineMenuItem> getAssignmentMenuActions() {
    List<InlineMenuItem> menuItems = new ArrayList<>();
    PrismObject<AH> obj = getMultivalueContainerListPanel().getFocusObject();
    try {
        boolean isUnassignAuthorized = getParentPage().isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_UNASSIGN_ACTION_URI, AuthorizationPhaseType.REQUEST, obj, null, null, null);
        if (isUnassignAuthorized) {
            menuItems.add(new ButtonInlineMenuItem(getAssignmentsLimitReachedUnassignTitleModel()) {

                private static final long serialVersionUID = 1L;

                @Override
                public CompositedIconBuilder getIconCompositedBuilder() {
                    return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_DELETE_MENU_ITEM);
                }

                @Override
                public InlineMenuItemAction initAction() {
                    return getMultivalueContainerListPanel().createDeleteColumnAction();
                }
            });
        }
    } catch (Exception ex) {
        LOGGER.error("Couldn't check unassign authorization for the object: {}, {}", obj.getName(), ex.getLocalizedMessage());
        if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ASSIGN_ACTION_URI)) {
            menuItems.add(new ButtonInlineMenuItem(createStringResource("PageBase.button.unassign")) {

                private static final long serialVersionUID = 1L;

                @Override
                public CompositedIconBuilder getIconCompositedBuilder() {
                    return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_DELETE_MENU_ITEM);
                }

                @Override
                public InlineMenuItemAction initAction() {
                    return getMultivalueContainerListPanel().createDeleteColumnAction();
                }
            });
        }
    }
    menuItems.add(new ButtonInlineMenuItem(createStringResource("PageBase.button.edit")) {

        private static final long serialVersionUID = 1L;

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_EDIT_MENU_ITEM);
        }

        @Override
        public InlineMenuItemAction initAction() {
            return getMultivalueContainerListPanel().createEditColumnAction();
        }
    });
    ButtonInlineMenuItem menu = new ButtonInlineMenuItem(createStringResource("AssignmentPanel.viewTargetObject")) {

        private static final long serialVersionUID = 1L;

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_NAVIGATE_ARROW);
        }

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<PrismContainerValueWrapper<AssignmentType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    PrismContainerValueWrapper<AssignmentType> assignmentContainer = getRowModel().getObject();
                    PrismReferenceWrapper<ObjectReferenceType> targetRef;
                    try {
                        targetRef = assignmentContainer.findReference(ItemPath.create(AssignmentType.F_TARGET_REF));
                    } catch (SchemaException e) {
                        getSession().error("Couldn't show details page. More information provided in log.");
                        LOGGER.error("Couldn't show details page, no targetRef reference wrapper found: {}", e.getMessage(), e);
                        target.add(getPageBase().getFeedbackPanel());
                        return;
                    }
                    if (targetRef != null && targetRef.getValues() != null && targetRef.getValues().size() > 0) {
                        PrismReferenceValueWrapperImpl<ObjectReferenceType> refWrapper = targetRef.getValues().get(0);
                        if (!StringUtils.isEmpty(refWrapper.getNewValue().getOid())) {
                            Class<? extends ObjectType> targetClass = ObjectTypes.getObjectTypeFromTypeQName(refWrapper.getRealValue().getType()).getClassDefinition();
                            WebComponentUtil.dispatchToObjectDetailsPage(targetClass, refWrapper.getNewValue().getOid(), AssignmentPanel.this, false);
                        }
                    }
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    };
    menu.setVisibilityChecker((InlineMenuItem.VisibilityChecker) (rowModel, isHeader) -> {
        PrismContainerValueWrapper<AssignmentType> assignment = (PrismContainerValueWrapper<AssignmentType>) rowModel.getObject();
        if (assignment == null) {
            return false;
        }
        PrismReferenceWrapper<Referencable> target = null;
        try {
            target = assignment.findReference(AssignmentType.F_TARGET_REF);
        } catch (Exception e) {
            LOGGER.error("Couldn't find targetRef in assignment");
        }
        return target != null && !target.isEmpty();
    });
    menuItems.add(menu);
    return menuItems;
}
Also used : PrismContainerWrapperModel(com.evolveum.midpoint.web.model.PrismContainerWrapperModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) PrismContainerWrapperColumn(com.evolveum.midpoint.gui.impl.component.data.column.PrismContainerWrapperColumn) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) AuthorizationConstants(com.evolveum.midpoint.security.api.AuthorizationConstants) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AssignmentCandidatesSpecification(com.evolveum.midpoint.model.api.AssignmentCandidatesSpecification) StringUtils(org.apache.commons.lang3.StringUtils) AjaxLinkColumn(com.evolveum.midpoint.web.component.data.column.AjaxLinkColumn) QNameUtil(com.evolveum.midpoint.util.QNameUtil) AbstractColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn) WebModelServiceUtils(com.evolveum.midpoint.gui.api.util.WebModelServiceUtils) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) IModel(org.apache.wicket.model.IModel) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) Search(com.evolveum.midpoint.web.component.search.Search) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) Label(org.apache.wicket.markup.html.basic.Label) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) ValueStatus(com.evolveum.midpoint.web.component.prism.ValueStatus) ListItem(org.apache.wicket.markup.html.list.ListItem) Collection(java.util.Collection) CompositedIcon(com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon) SearchFactory(com.evolveum.midpoint.web.component.search.SearchFactory) Model(org.apache.wicket.model.Model) Component(org.apache.wicket.Component) WebComponentUtil(com.evolveum.midpoint.gui.api.util.WebComponentUtil) Task(com.evolveum.midpoint.task.api.Task) SessionStorage(com.evolveum.midpoint.web.session.SessionStorage) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) List(java.util.List) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) AssignmentListProvider(com.evolveum.midpoint.web.component.util.AssignmentListProvider) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) PropertyModel(org.apache.wicket.model.PropertyModel) Item(org.apache.wicket.markup.repeater.Item) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) MultivalueContainerDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel) AssignmentPopup(com.evolveum.midpoint.gui.api.component.AssignmentPopup) SearchItemDefinition(com.evolveum.midpoint.web.component.search.SearchItemDefinition) QName(javax.xml.namespace.QName) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) NotNull(org.jetbrains.annotations.NotNull) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) PrismReferenceValueWrapperImpl(com.evolveum.midpoint.gui.impl.prism.wrapper.PrismReferenceValueWrapperImpl) AssignmentPopupDto(com.evolveum.midpoint.gui.api.component.AssignmentPopupDto) GuiDisplayTypeUtil(com.evolveum.midpoint.gui.api.util.GuiDisplayTypeUtil) RefFilter(com.evolveum.midpoint.prism.query.RefFilter) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) IconCssStyle(com.evolveum.midpoint.gui.impl.component.icon.IconCssStyle) Trace(com.evolveum.midpoint.util.logging.Trace) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) GuiStyleConstants(com.evolveum.midpoint.gui.api.GuiStyleConstants) PageStorage(com.evolveum.midpoint.web.session.PageStorage) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) InlineMenuButtonColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn) PrismReferenceWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismReferenceWrapper) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) PrismObjectWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper) AssignmentsDetailsPanel(com.evolveum.midpoint.gui.impl.component.AssignmentsDetailsPanel) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) CompositedIconColumn(com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconColumn) Collections(java.util.Collections) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ArrayList(java.util.ArrayList) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismReferenceWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismReferenceWrapper) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Example 32 with InlineMenuItemAction

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction in project midpoint by Evolveum.

the class SearchPanel method getSavedSearchList.

private List<InlineMenuItem> getSavedSearchList() {
    ContainerableListPanel listPanel = findParent(ContainerableListPanel.class);
    List<InlineMenuItem> savedSearchItems = new ArrayList<>();
    List<AvailableFilterType> availableFilterList = null;
    if (listPanel != null) {
        CompiledObjectCollectionView view = listPanel.getObjectCollectionView();
        availableFilterList = view != null ? getAvailableFilterList(view.getSearchBoxConfiguration()) : null;
    } else {
        FocusType principalFocus = getPageBase().getPrincipalFocus();
        GuiObjectListViewType view = WebComponentUtil.getPrincipalUserObjectListView(getPageBase(), principalFocus, getModelObject().getTypeClass(), false);
        availableFilterList = view != null ? getAvailableFilterList(view.getSearchBoxConfiguration()) : null;
    }
    if (availableFilterList != null) {
        availableFilterList.stream().filter(filter -> getModelObject().getSearchMode().equals(filter.getSearchMode())).forEach(filter -> {
            PolyStringType filterLabel = filter.getDisplay() != null ? filter.getDisplay().getLabel() : null;
            InlineMenuItem searchItem = new InlineMenuItem(Model.of(WebComponentUtil.getTranslatedPolyString(filterLabel))) {

                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) {
                            if (filter == null) {
                                return;
                            }
                            if (SearchBoxModeType.BASIC.equals(filter.getSearchMode())) {
                                applyFilterToBasicMode(filter.getSearchItem());
                            } else if (SearchBoxModeType.AXIOM_QUERY.equals(filter.getSearchMode())) {
                                applyFilterToAxiomMode(filter.getSearchItem());
                            } else if (SearchBoxModeType.FULLTEXT.equals(filter.getSearchMode())) {
                                applyFilterToFulltextMode(filter.getSearchItem());
                            }
                            searchPerformed(target);
                        }
                    };
                }
            };
            savedSearchItems.add(searchItem);
        });
    }
    return savedSearchItems;
}
Also used : PrismValue(com.evolveum.midpoint.prism.PrismValue) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) com.evolveum.midpoint.prism.query(com.evolveum.midpoint.prism.query) AjaxCompositedIconSubmitButton(com.evolveum.midpoint.web.component.AjaxCompositedIconSubmitButton) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) TextField(org.apache.wicket.markup.html.form.TextField) AjaxChannel(org.apache.wicket.ajax.AjaxChannel) StringUtils(org.apache.commons.lang3.StringUtils) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) WebModelServiceUtils(com.evolveum.midpoint.gui.api.util.WebModelServiceUtils) SecurityUtils(com.evolveum.midpoint.web.security.util.SecurityUtils) Duration(java.time.Duration) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) ListView(org.apache.wicket.markup.html.list.ListView) Label(org.apache.wicket.markup.html.basic.Label) MenuLinkPanel(com.evolveum.midpoint.web.component.menu.cog.MenuLinkPanel) ListItem(org.apache.wicket.markup.html.list.ListItem) CompositedIcon(com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) Model(org.apache.wicket.model.Model) Component(org.apache.wicket.Component) WebComponentUtil(com.evolveum.midpoint.gui.api.util.WebComponentUtil) AttributeModifier(org.apache.wicket.AttributeModifier) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) InvocationTargetException(java.lang.reflect.InvocationTargetException) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) PropertyModel(org.apache.wicket.model.PropertyModel) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) SystemException(com.evolveum.midpoint.util.exception.SystemException) QName(javax.xml.namespace.QName) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) java.util(java.util) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) IconCssStyle(com.evolveum.midpoint.gui.impl.component.icon.IconCssStyle) LayeredIconCssStyle(com.evolveum.midpoint.gui.impl.component.icon.LayeredIconCssStyle) Trace(com.evolveum.midpoint.util.logging.Trace) Constructor(java.lang.reflect.Constructor) PageRepositoryQuery(com.evolveum.midpoint.web.page.admin.configuration.PageRepositoryQuery) CollectionUtils(org.apache.commons.collections4.CollectionUtils) CheckBox(org.apache.wicket.markup.html.form.CheckBox) GuiStyleConstants(com.evolveum.midpoint.gui.api.GuiStyleConstants) Fragment(org.apache.wicket.markup.html.panel.Fragment) PrismContext(com.evolveum.midpoint.prism.PrismContext) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) Containerable(com.evolveum.midpoint.prism.Containerable) Popupable(com.evolveum.midpoint.web.component.dialog.Popupable) SearchItem(com.evolveum.midpoint.web.component.search.SearchItem) TextArea(org.apache.wicket.markup.html.form.TextArea) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ContainerableListPanel(com.evolveum.midpoint.gui.impl.component.ContainerableListPanel) ThrottlingSettings(org.apache.wicket.ajax.attributes.ThrottlingSettings) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) SearchValue(com.evolveum.midpoint.web.component.search.SearchValue) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) CollectionInstance(com.evolveum.midpoint.web.application.CollectionInstance) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) ContainerableListPanel(com.evolveum.midpoint.gui.impl.component.ContainerableListPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 33 with InlineMenuItemAction

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction in project midpoint by Evolveum.

the class SearchPanel method getSearchBoxTypesList.

private List<InlineMenuItem> getSearchBoxTypesList() {
    List<InlineMenuItem> searchItems = new ArrayList<>();
    List<SearchBoxModeType> modeList = getSearchConfigurationWrapper().getAllowedModeList();
    for (SearchBoxModeType searchBoxModeType : modeList) {
        InlineMenuItem searchItem = new InlineMenuItem(createStringResource(searchBoxModeType)) {

            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) {
                        searchBoxTypeUpdated(target, searchBoxModeType);
                    }
                };
            }

            @Override
            public IModel<Boolean> getVisible() {
                if (SearchBoxModeType.AXIOM_QUERY.equals(searchBoxModeType)) {
                    return Model.of(WebModelServiceUtils.isEnableExperimentalFeature(getPageBase()) && getSearchConfigurationWrapper().getAllowedModeList().contains(searchBoxModeType));
                }
                return Model.of(getSearchConfigurationWrapper().getAllowedModeList().contains(searchBoxModeType));
            }
        };
        searchItems.add(searchItem);
    }
    return searchItems;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 34 with InlineMenuItemAction

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction in project midpoint by Evolveum.

the class TreeTablePanel method createTreeChildrenMenu.

private List<InlineMenuItem> createTreeChildrenMenu(TreeSelectableBean<OrgType> org) {
    List<InlineMenuItem> items = new ArrayList<>();
    boolean isAllowModify = isAllowModify(org.getValue());
    boolean isAllowRead = isAllowRead(org.getValue());
    InlineMenuItem item;
    if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ORG_MOVE_ACTION_URI)) {
        item = new InlineMenuItem(createStringResource("TreeTablePanel.move")) {

            private static final long serialVersionUID = 1L;

            @Override
            public InlineMenuItemAction initAction() {
                return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        moveRootPerformed(org, target);
                    }
                };
            }
        };
        items.add(item);
    }
    if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ORG_MAKE_ROOT_ACTION_URI)) {
        item = new InlineMenuItem(createStringResource("TreeTablePanel.makeRoot")) {

            private static final long serialVersionUID = 1L;

            @Override
            public InlineMenuItemAction initAction() {
                return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        makeRootPerformed(org, target);
                    }
                };
            }
        };
        items.add(item);
    }
    item = new InlineMenuItem(createStringResource("TreeTablePanel.delete")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteNodePerformed(org, target);
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(isAllowDelete(org.getValue()));
        }
    };
    items.add(item);
    item = new InlineMenuItem(createStringResource("TreeTablePanel.recompute")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    recomputeRootPerformed(org, target);
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(isAllowModify);
        }
    };
    items.add(item);
    InlineMenuItem editMenuItem = new InlineMenuItem(createStringResource("TreeTablePanel.edit")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    editRootPerformed(org);
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(isAllowModify);
        }
    };
    items.add(editMenuItem);
    item = new InlineMenuItem(createStringResource("TreeTablePanel.viewDetails")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    editRootPerformed(org);
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(!editMenuItem.getVisible().getObject() && isAllowRead);
        }
    };
    items.add(item);
    item = new InlineMenuItem(createStringResource("TreeTablePanel.createChild")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<SelectableBeanImpl<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    try {
                        initObjectForAdd(ObjectTypeUtil.createObjectRef(org.getValue(), getPageBase().getPrismContext()), target);
                    } catch (SchemaException e) {
                        throw new SystemException(e.getMessage(), e);
                    }
                }
            };
        }

        @Override
        public IModel<Boolean> getVisible() {
            return Model.of(isAllowRead && isAllowAddNew());
        }
    };
    items.add(item);
    return items;
}
Also used : IModel(org.apache.wicket.model.IModel) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)

Example 35 with InlineMenuItemAction

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction in project midpoint by Evolveum.

the class ExecuteChangeOptionsPanel method createTracingDropdownButton.

// todo rework, this now creates only one item in dropdown with multiple input[option], therefore dropdown is not correctly rendered (each item should be created separately, like for options)
private void createTracingDropdownButton() {
    List<InlineMenuItem> items = new ArrayList<>();
    items.add(new InlineMenuItem(createStringResource("ExecuteChangeOptionsPanel.tracing")) {

        @Override
        public InlineMenuItemAction initAction() {
            return null;
        }
    });
    DropdownButtonDto model = new DropdownButtonDto(null, GuiStyleConstants.CLASS_TRACING_BUTTON_ICON, getString("ExecuteChangeOptionsPanel.tracing"), items);
    DropdownButtonPanel dropdownButtonPanel = new DropdownButtonPanel(ID_TRACING, model) {

        @Override
        protected void populateMenuItem(String componentId, ListItem<InlineMenuItem> menuItem) {
            menuItem.add(createTracingRadioChoicesFragment(componentId));
        }

        @Override
        protected String getSpecialButtonClass() {
            return "mr-2 btn-sm btn-default";
        }
    };
    add(dropdownButtonPanel);
    dropdownButtonPanel.setOutputMarkupId(true);
    dropdownButtonPanel.add(new VisibleBehaviour(this::isTracingEnabled));
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) ArrayList(java.util.ArrayList) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) DropdownButtonDto(com.evolveum.midpoint.gui.api.component.button.DropdownButtonDto) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ListItem(org.apache.wicket.markup.html.list.ListItem) DropdownButtonPanel(com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel)

Aggregations

InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)50 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)49 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)44 ArrayList (java.util.ArrayList)34 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)29 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)29 IModel (org.apache.wicket.model.IModel)21 ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)14 SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)12 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)9 ListItem (org.apache.wicket.markup.html.list.ListItem)8 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)7 List (java.util.List)6 QName (javax.xml.namespace.QName)6 DropdownButtonDto (com.evolveum.midpoint.gui.api.component.button.DropdownButtonDto)5 DropdownButtonPanel (com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel)5 PrismContainerValueWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)5 HeaderMenuAction (com.evolveum.midpoint.web.page.admin.configuration.component.HeaderMenuAction)5 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)5 ObjectBrowserPanel (com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel)4