Search in sources :

Example 1 with ButtonInlineMenuItem

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

the class MultivalueContainerListPanel method getDefaultMenuActions.

public List<InlineMenuItem> getDefaultMenuActions() {
    List<InlineMenuItem> menuItems = new ArrayList<>();
    menuItems.add(new ButtonInlineMenuItem(createStringResource("pageAdminFocus.button.delete")) {

        private static final long serialVersionUID = 1L;

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

        @Override
        public InlineMenuItemAction initAction() {
            return 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 createEditColumnAction();
        }
    });
    return menuItems;
}
Also used : ArrayList(java.util.ArrayList) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Example 2 with ButtonInlineMenuItem

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

the class InlineMenuButtonColumn method getPanel.

private Component getPanel(String componentId, IModel<T> rowModel, int numberOfButtons, boolean isHeaderPanel) {
    List<InlineMenuItem> filteredMenuItems = new ArrayList<>();
    for (InlineMenuItem menuItem : menuItems) {
        if (isHeaderPanel && !menuItem.isHeaderMenuItem()) {
            continue;
        }
        if (rowModel != null && menuItem.getAction() != null && menuItem.getAction() instanceof ColumnMenuAction) {
            ((ColumnMenuAction) menuItem.getAction()).setRowModel(rowModel);
        }
        if (menuItem.getVisibilityChecker() != null && !menuItem.getVisibilityChecker().isVisible(rowModel, isHeaderPanel)) {
            continue;
        }
        filteredMenuItems.add(menuItem);
    }
    List<ButtonInlineMenuItem> buttonMenuItems = new ArrayList<>();
    menuItems.forEach(menuItem -> {
        if (menuItem instanceof ButtonInlineMenuItem) {
            if (isHeaderPanel && !menuItem.isHeaderMenuItem() || !menuItem.getVisible().getObject()) {
                return;
            }
            if (menuItem.getVisibilityChecker() != null && !menuItem.getVisibilityChecker().isVisible(rowModel, isHeaderPanel)) {
                return;
            }
            buttonMenuItems.add((ButtonInlineMenuItem) menuItem);
        }
    });
    if (filteredMenuItems.isEmpty()) {
        // this is hack, TODO: cleanup and refactor soif there aren't any inline (row) actions, nothing is displayed
        return new Label(componentId);
    }
    return new MenuMultiButtonPanel<T>(componentId, rowModel, buttonMenuItems.size(), Model.ofList(filteredMenuItems)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Component createButton(int index, String componentId, IModel<T> model) {
            CompositedIconBuilder builder = getIconCompositedBuilder(index, buttonMenuItems);
            AjaxCompositedIconButton btn = new AjaxCompositedIconButton(componentId, builder.build(), Model.of(getButtonTitle(index, buttonMenuItems))) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    setRowModelToButtonAction(rowModel, buttonMenuItems);
                    buttonMenuItemClickPerformed(index, buttonMenuItems, target);
                }
            };
            btn.add(AttributeAppender.append("class", " btn btn-default btn-xs"));
            btn.add(new EnableBehaviour(() -> isButtonMenuItemEnabled(model)));
            return btn;
        }

        @Override
        protected void onBeforeClickMenuItem(AjaxRequestTarget target, InlineMenuItemAction action, IModel<InlineMenuItem> item) {
            if (action instanceof ColumnMenuAction) {
                if (!isHeaderPanel) {
                    ((ColumnMenuAction) action).setRowModel(rowModel);
                } else {
                    ((ColumnMenuAction) action).setRowModel(null);
                }
            }
        }
    };
}
Also used : AjaxCompositedIconButton(com.evolveum.midpoint.gui.impl.component.AjaxCompositedIconButton) IModel(org.apache.wicket.model.IModel) MenuMultiButtonPanel(com.evolveum.midpoint.web.component.data.MenuMultiButtonPanel) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour)

Example 3 with ButtonInlineMenuItem

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

the class PageCertDefinitions method createInlineMenu.

private List<InlineMenuItem> createInlineMenu() {
    List<InlineMenuItem> menu = new ArrayList<>();
    menu.add(new ButtonInlineMenuItem(createStringResource("PageCertDefinitions.button.createCampaign")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<SelectableBean<AccessCertificationDefinitionType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    AccessCertificationDefinitionType campaign = getRowModel().getObject().getValue();
                    createCampaignPerformed(target, campaign);
                }
            };
        }

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

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    menu.add(new ButtonInlineMenuItem(createStringResource("PageCertDefinitions.button.showCampaigns")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    AccessCertificationDefinitionType campaign = getRowModel().getObject().getValue();
                    showCampaignsPerformed(target, campaign);
                }
            };
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder("fa fa-files-o");
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    menu.add(new ButtonInlineMenuItem(createStringResource("PageCertDefinitions.button.deleteDefinition")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    AccessCertificationDefinitionType campaign = getRowModel().getObject().getValue();
                    deleteConfirmation(target, campaign);
                }
            };
        }

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

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    return menu;
}
Also used : AccessCertificationDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType) 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) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Example 4 with ButtonInlineMenuItem

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

the class CaseWorkItemsPanel method createRowActions.

protected List<InlineMenuItem> createRowActions() {
    List<InlineMenuItem> menu = new ArrayList<>();
    menu.add(new ButtonInlineMenuItem(createStringResource("pageWorkItem.button.reject")) {

        private static final long serialVersionUID = 1L;

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

                @Override
                public void onClick(AjaxRequestTarget target) {
                    workItemActionPerformed(getRowModel(), false, target);
                }
            };
        }

        @Override
        public IModel<Boolean> getEnabled() {
            IModel<PrismContainerValueWrapper<CaseWorkItemType>> rowModel = ((ColumnMenuAction<PrismContainerValueWrapper<CaseWorkItemType>>) getAction()).getRowModel();
            if (rowModel != null && rowModel.getObject() != null && rowModel.getObject().getRealValue() != null) {
                CaseWorkItemType workItem = rowModel.getObject().getRealValue();
                return Model.of(!CaseTypeUtil.isClosed(CaseTypeUtil.getCase(workItem)));
            } else {
                return super.getEnabled();
            }
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            return createStringResource("CaseWorkItemsPanel.confirmWorkItemsRejectAction");
        }

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

        @Override
        public IModel<Boolean> getVisible() {
            IModel<PrismContainerValueWrapper<CaseWorkItemType>> rowModel = ((ColumnMenuAction<PrismContainerValueWrapper<CaseWorkItemType>>) getAction()).getRowModel();
            if (rowModel != null && rowModel.getObject() != null && rowModel.getObject().getRealValue() != null) {
                CaseWorkItemType workItem = rowModel.getObject().getRealValue();
                return Model.of(!CaseTypeUtil.isCorrelationCase(CaseTypeUtil.getCase(workItem)));
            } else {
                return super.getVisible();
            }
        }
    });
    menu.add(new ButtonInlineMenuItem(createStringResource("pageWorkItem.button.approve")) {

        private static final long serialVersionUID = 1L;

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

                @Override
                public void onClick(AjaxRequestTarget target) {
                    workItemActionPerformed(getRowModel(), true, target);
                }
            };
        }

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

        @Override
        public IModel<Boolean> getEnabled() {
            IModel<PrismContainerValueWrapper<CaseWorkItemType>> rowModel = ((ColumnMenuAction<PrismContainerValueWrapper<CaseWorkItemType>>) getAction()).getRowModel();
            if (rowModel != null && rowModel.getObject() != null && rowModel.getObject().getRealValue() != null) {
                CaseWorkItemType workItem = rowModel.getObject().getRealValue();
                return Model.of(!CaseTypeUtil.isClosed(CaseTypeUtil.getCase(workItem)));
            } else {
                return super.getEnabled();
            }
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            return createStringResource("CaseWorkItemsPanel.confirmWorkItemsApproveAction");
        }

        @Override
        public IModel<Boolean> getVisible() {
            IModel<PrismContainerValueWrapper<CaseWorkItemType>> rowModel = ((ColumnMenuAction<PrismContainerValueWrapper<CaseWorkItemType>>) getAction()).getRowModel();
            if (rowModel != null && rowModel.getObject() != null && rowModel.getObject().getRealValue() != null) {
                CaseWorkItemType workItem = rowModel.getObject().getRealValue();
                return Model.of(!CaseTypeUtil.isCorrelationCase(CaseTypeUtil.getCase(workItem)));
            } else {
                return super.getVisible();
            }
        }
    });
    return menu;
}
Also used : IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Example 5 with ButtonInlineMenuItem

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

the class NotificationConfigTabPanel method getMenuActions.

private List<InlineMenuItem> getMenuActions() {
    List<InlineMenuItem> menuItems = new ArrayList<>();
    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 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 createEditColumnAction();
        }
    });
    return menuItems;
}
Also used : ArrayList(java.util.ArrayList) 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) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Aggregations

ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)27 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)25 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)25 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)25 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)23 ArrayList (java.util.ArrayList)21 IModel (org.apache.wicket.model.IModel)14 ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)11 SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)8 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)7 PrismContainerValueWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)5 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)4 InlineMenuButtonColumn (com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn)3 List (java.util.List)3 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)3 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)3 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)2 PrismContainerWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper)2 MultivalueContainerDetailsPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel)2 MultivalueContainerListPanelWithDetailsPanel (com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel)2