Search in sources :

Example 1 with InlineMenuItemAction

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

the class ResourceContentPanel method initButton.

private void initButton(String id, String label, String icon, final String category, final List<TaskType> tasks) {
    List<InlineMenuItem> items = new ArrayList<>();
    InlineMenuItem item = new InlineMenuItem(getPageBase().createStringResource("ResourceContentResourcePanel.showExisting"), new InlineMenuItemAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            runTask(tasks, target);
        }
    });
    items.add(item);
    item = new InlineMenuItem(getPageBase().createStringResource("ResourceContentResourcePanel.newTask"), new InlineMenuItemAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            newTaskPerformed(category, target);
        }
    });
    items.add(item);
    DropdownButtonPanel button = new DropdownButtonPanel(id, new DropdownButtonDto(String.valueOf(tasks.size()), icon, label, items));
    add(button);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) 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) DropdownButtonPanel(com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel)

Example 2 with InlineMenuItemAction

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction 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 3 with InlineMenuItemAction

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction 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 4 with InlineMenuItemAction

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

the class PageCertCampaigns method createInlineMenuForItem.

private List<InlineMenuItem> createInlineMenuForItem() {
    List<InlineMenuItem> menuItems = new ArrayList<>();
    InlineMenuItem item = new InlineMenuItem(createStringResource("PageCertCampaigns.menu.close")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    closeCampaignConfirmation(target, getRowModel().getObject());
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    };
    item.setVisibilityChecker((rowModel, header) -> isNotClosed(rowModel));
    menuItems.add(item);
    item = new InlineMenuItem(createStringResource("PageCertCampaigns.menu.reiterate")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    reiterateCampaignConfirmation(target, getRowModel().getObject());
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    };
    item.setVisibilityChecker((rowModel, header) -> isReiterable(rowModel));
    menuItems.add(item);
    menuItems.add(new InlineMenuItem(createStringResource("PageCertCampaigns.menu.delete")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteCampaignConfirmation(target, getRowModel().getObject());
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    return menuItems;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ArrayList(java.util.ArrayList) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) CertCampaignListItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto)

Example 5 with InlineMenuItemAction

use of com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction 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)

Aggregations

InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)44 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)43 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)39 ArrayList (java.util.ArrayList)32 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)28 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)26 IModel (org.apache.wicket.model.IModel)19 ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)11 SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)10 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)8 List (java.util.List)6 ListItem (org.apache.wicket.markup.html.list.ListItem)6 PrismContainerValueWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)5 HeaderMenuAction (com.evolveum.midpoint.web.page.admin.configuration.component.HeaderMenuAction)5 QName (javax.xml.namespace.QName)5 DropdownButtonDto (com.evolveum.midpoint.gui.api.component.button.DropdownButtonDto)4 DropdownButtonPanel (com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel)4 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)4 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)4 Label (org.apache.wicket.markup.html.basic.Label)4