Search in sources :

Example 11 with ButtonInlineMenuItem

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

the class TaskTablePanel method createTaskButtonAction.

private ButtonInlineMenuItem createTaskButtonAction(String buttonNameKey, SerializableBiConsumer<AjaxRequestTarget, IModel<SelectableBean<TaskType>>> action, String icon, String confirmationMessageKey, SerializableFunction<TaskType, Boolean> visibilityHandler) {
    ButtonInlineMenuItem buttonInlineMenuItem = new ButtonInlineMenuItem(createStringResource(buttonNameKey)) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    action.accept(target, getRowModel());
                }
            };
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            CompositedIconBuilder builder = getDefaultCompositedIconBuilder(icon);
            if (GuiStyleConstants.CLASS_SUSPEND_MENU_ITEM.equals(icon) || GuiStyleConstants.CLASS_START_MENU_ITEM.equals(icon)) {
                builder.appendLayerIcon(GuiStyleConstants.CLASS_OBJECT_TASK_ICON, CompositedIconCssStyle.BOTTOM_RIGHT_STYLE);
            }
            return builder;
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource(confirmationMessageKey).getString();
            return TaskTablePanel.this.getTaskConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    };
    buttonInlineMenuItem.setVisibilityChecker((rowModel, header) -> checkVisibility(rowModel, header, visibilityHandler));
    return buttonInlineMenuItem;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Example 12 with ButtonInlineMenuItem

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

the class ListMappingPanel method initLayout.

private void initLayout() {
    MultivalueContainerListPanelWithDetailsPanel<MappingType> table = new MultivalueContainerListPanelWithDetailsPanel<MappingType>(ID_TABLE, MappingType.class) {

        @Override
        protected MultivalueContainerDetailsPanel<MappingType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<MappingType>> item) {
            return new MultivalueContainerDetailsPanel<>(MultivalueContainerListPanelWithDetailsPanel.ID_ITEM_DETAILS, item.getModel(), true) {

                @Override
                protected DisplayNamePanel<MappingType> createDisplayNamePanel(String displayNamePanelId) {
                    ItemRealValueModel<MappingType> displayNameModel = new ItemRealValueModel<>(item.getModel());
                    return new DisplayNamePanel<>(displayNamePanelId, displayNameModel) {

                        @Override
                        protected IModel<String> createHeaderModel() {
                            IModel<String> headerModel = super.createHeaderModel();
                            if (StringUtils.isEmpty(headerModel.getObject())) {
                                return getPageBase().createStringResource("feedbackMessagePanel.message.undefined");
                            }
                            return headerModel;
                        }
                    };
                }

                @Override
                protected ItemVisibility getBasicTabVisibity(ItemWrapper<?, ?> itemWrapper) {
                    if (itemWrapper.getPath().isSubPathOrEquivalent(ItemPath.create(ItemPath.EMPTY_PATH, MappingType.F_METADATA_MAPPING))) {
                        return ItemVisibility.HIDDEN;
                    }
                    return ItemVisibility.AUTO;
                }
            };
        }

        @Override
        protected boolean isCreateNewObjectVisible() {
            return true;
        }

        @Override
        protected IModel<PrismContainerWrapper<MappingType>> getContainerModel() {
            return ListMappingPanel.this.getModel();
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return null;
        }

        @Override
        protected List<IColumn<PrismContainerValueWrapper<MappingType>, String>> createDefaultColumns() {
            List<IColumn<PrismContainerValueWrapper<MappingType>, String>> columns = new ArrayList<>();
            columns.add(new PrismPropertyWrapperColumn<>(ListMappingPanel.this.getModel(), MappingType.F_DESCRIPTION, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
            columns.add(new PrismPropertyWrapperColumn<>(ListMappingPanel.this.getModel(), MappingType.F_ENABLED, AbstractItemWrapperColumn.ColumnType.VALUE, getPageBase()));
            columns.add(new AbstractColumn<>(createStringResource("ListMappingPanel.mappingDescription")) {

                @Override
                public void populateItem(Item<ICellPopulator<PrismContainerValueWrapper<MappingType>>> cellItem, String componentId, IModel<PrismContainerValueWrapper<MappingType>> rowModel) {
                    cellItem.add(new Label(componentId, WebComponentUtil.createMappingDescription(rowModel)));
                }
            });
            List<InlineMenuItem> items = new ArrayList<>();
            InlineMenuItem item = new InlineMenuItem(createStringResource("pageAdminFocus.button.delete")) {

                private static final long serialVersionUID = 1L;

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

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClick(AjaxRequestTarget target) {
                            deleteItemPerformed(target, getPerformedSelectedItems(getRowModel()));
                        }
                    };
                }
            };
            items.add(item);
            item = 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 new ColumnMenuAction() {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClick(AjaxRequestTarget target) {
                            editItemPerformed(target, getRowModel(), getSelectedItems());
                            target.add(getFeedbackPanel());
                        }
                    };
                }
            };
            items.add(item);
            columns.add(new InlineMenuButtonColumn(items, getPageBase()) {

                @Override
                public String getCssClass() {
                    return "col-xs-1";
                }
            });
            return columns;
        }

        @Override
        protected IColumn<PrismContainerValueWrapper<MappingType>, String> createNameColumn(IModel<String> displayModel, GuiObjectColumnType customColumn, ItemPath itemPath, ExpressionType expression) {
            return new PrismPropertyWrapperColumn<>(ListMappingPanel.this.getModel(), MappingType.F_NAME, AbstractItemWrapperColumn.ColumnType.LINK, getPageBase()) {

                @Override
                protected void onClick(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<MappingType>> model) {
                    itemDetailsPerformed(target, model);
                }
            };
        }

        @Override
        protected IColumn<PrismContainerValueWrapper<MappingType>, String> createCheckboxColumn() {
            return new CheckBoxHeaderColumn<>();
        }

        @Override
        protected PrismContainerDefinition<MappingType> getTypeDefinitionForSearch() {
            return getPrismContext().getSchemaRegistry().findContainerDefinitionByType(MappingType.COMPLEX_TYPE);
        }
    };
    add(table);
}
Also used : MultivalueContainerDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) DisplayNamePanel(com.evolveum.midpoint.gui.api.component.DisplayNamePanel) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) 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) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) IModel(org.apache.wicket.model.IModel) PrismPropertyWrapperColumn(com.evolveum.midpoint.gui.impl.component.data.column.PrismPropertyWrapperColumn) InlineMenuButtonColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn) ItemRealValueModel(com.evolveum.midpoint.gui.impl.factory.panel.ItemRealValueModel) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) ListItem(org.apache.wicket.markup.html.list.ListItem) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 13 with ButtonInlineMenuItem

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

the class FocusListInlineMenuHelper method createRowActions.

public List<InlineMenuItem> createRowActions(Class<F> objectType) {
    List<InlineMenuItem> menu = new ArrayList<>();
    ButtonInlineMenuItem enableItem = new ButtonInlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.enable")) {

        private static final long serialVersionUID = 1L;

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

                @Override
                public void onClick(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        updateActivationPerformed(target, true, null);
                    } else {
                        SelectableBeanImpl<F> rowDto = getRowModel().getObject();
                        updateActivationPerformed(target, true, rowDto.getValue());
                    }
                }
            };
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(getEnableActionDefaultIcon(objectType));
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = parentPage.createStringResource("pageUsers.message.enableAction").getString();
            return FocusListInlineMenuHelper.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    };
    enableItem.setVisibilityChecker(FocusListInlineMenuHelper::isObjectDisabled);
    menu.add(enableItem);
    ButtonInlineMenuItem disableItem = new ButtonInlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.disable")) {

        private static final long serialVersionUID = 1L;

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

                @Override
                public void onClick(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        updateActivationPerformed(target, false, null);
                    } else {
                        SelectableBeanImpl<F> rowDto = getRowModel().getObject();
                        updateActivationPerformed(target, false, rowDto.getValue());
                    }
                }
            };
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = parentPage.createStringResource("pageUsers.message.disableAction").getString();
            return FocusListInlineMenuHelper.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            CompositedIconBuilder builder = getDefaultCompositedIconBuilder(getEnableActionDefaultIcon(objectType));
            builder.appendLayerIcon(WebComponentUtil.createIconType(GuiStyleConstants.CLASS_BAN), IconCssStyle.BOTTOM_RIGHT_STYLE);
            return builder;
        }
    };
    disableItem.setVisibilityChecker(FocusListInlineMenuHelper::isObjectEnabled);
    menu.add(disableItem);
    menu.add(new ButtonInlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.reconcile")) {

        private static final long serialVersionUID = 1L;

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

                @Override
                public void onClick(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        reconcilePerformed(target, null);
                    } else {
                        SelectableBeanImpl<F> rowDto = getRowModel().getObject();
                        reconcilePerformed(target, rowDto.getValue());
                    }
                }
            };
        }

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

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = parentPage.createStringResource("pageUsers.message.reconcileAction").getString();
            return FocusListInlineMenuHelper.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    menu.add(new InlineMenuItem(parentPage.createStringResource("FocusListInlineMenuHelper.menu.delete")) {

        private static final long serialVersionUID = 1L;

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

                @Override
                public void onClick(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        deleteConfirmedPerformed(target, null);
                    } else {
                        SelectableBeanImpl<F> rowDto = getRowModel().getObject();
                        deleteConfirmedPerformed(target, rowDto.getValue());
                    }
                }
            };
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = parentPage.createStringResource("pageUsers.message.deleteAction").getString();
            return FocusListInlineMenuHelper.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    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) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Example 14 with ButtonInlineMenuItem

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

the class PageResources method createRowMenuItems.

private List<InlineMenuItem> createRowMenuItems() {
    List<InlineMenuItem> menuItems = new ArrayList<>();
    menuItems.add(new ButtonInlineMenuItem(createStringResource("PageResources.inlineMenuItem.test")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    SelectableBeanImpl<ResourceType> rowDto = getRowModel().getObject();
                    testResourcePerformed(target, rowDto.getValue());
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_TEST_CONNECTION_MENU_ITEM);
        }
    });
    menuItems.add(new ButtonInlineMenuItem(createStringResource("pageResources.button.editAsXml")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    SelectableBeanImpl<ResourceType> rowDto = getRowModel().getObject();
                    editAsXmlPerformed(rowDto.getValue());
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_EDIT_MENU_ITEM);
        }
    });
    menuItems.add(new InlineMenuItem(createStringResource("pageResources.inlineMenuItem.editResource")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    SelectableBeanImpl<ResourceType> rowDto = getRowModel().getObject();
                    editResourcePerformed(rowDto.getValue());
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    menuItems.add(new InlineMenuItem(createStringResource("pageResource.button.refreshSchema")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    SelectableBeanImpl<ResourceType> rowDto = getRowModel().getObject();
                    refreshSchemaPerformed(rowDto.getValue(), target);
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    menuItems.add(new ButtonInlineMenuItem(createStringResource("PageBase.button.delete")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        deleteResourcePerformed(target, null);
                    } else {
                        SelectableBeanImpl<ResourceType> rowDto = getRowModel().getObject();
                        deleteResourcePerformed(target, rowDto.getValue());
                    }
                }
            };
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_DELETE_MENU_ITEM);
        }
    });
    menuItems.add(new InlineMenuItem(createStringResource("pageResources.inlineMenuItem.deleteSyncToken")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    SelectableBeanImpl<ResourceType> rowDto = getRowModel().getObject();
                    deleteResourceSyncTokenPerformed(target, rowDto.getValue());
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    menuItems.add(new InlineMenuItem(createStringResource("pageResources.inlineMenuItem.toggleMaintenance")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    SelectableBeanImpl<ResourceType> rowDto = getRowModel().getObject();
                    WebComponentUtil.toggleResourceMaintenance(rowDto.getValue().asPrismContainer(), OPERATION_SET_MAINTENANCE, target, PageResources.this);
                    target.add(getResourceTable());
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    return menuItems;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) 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 15 with ButtonInlineMenuItem

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

the class ResourceContentPanel method createRowMenuItems.

private List<InlineMenuItem> createRowMenuItems() {
    List<InlineMenuItem> items = new ArrayList<>();
    items.add(new InlineMenuItem(createStringResource("pageContentAccounts.menu.enableAccount"), true) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onSubmit(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        updateResourceObjectStatusPerformed(null, target, true);
                    } else {
                        SelectableBeanImpl<ShadowType> shadow = getRowModel().getObject();
                        updateResourceObjectStatusPerformed(shadow.getValue(), target, true);
                    }
                }
            };
        }
    });
    items.add(new InlineMenuItem(createStringResource("pageContentAccounts.menu.disableAccount"), true) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onSubmit(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        updateResourceObjectStatusPerformed(null, target, false);
                    } else {
                        SelectableBeanImpl<ShadowType> shadow = getRowModel().getObject();
                        updateResourceObjectStatusPerformed(shadow.getValue(), target, false);
                    }
                }
            };
        }
    });
    items.add(new InlineMenuItem(createStringResource("pageContentAccounts.menu.deleteAccount"), true) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onSubmit(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        deleteResourceObjectPerformed(null, target);
                    } else {
                        SelectableBeanImpl<ShadowType> shadow = getRowModel().getObject();
                        deleteResourceObjectPerformed(shadow.getValue(), target);
                    }
                }
            };
        }
    });
    items.add(new ButtonInlineMenuItem(createStringResource("pageContentAccounts.menu.importAccount"), true) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onSubmit(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        importResourceObject(null, target);
                    } else {
                        SelectableBeanImpl<ShadowType> shadow = getRowModel().getObject();
                        importResourceObject(shadow.getValue(), target);
                    }
                }
            };
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_IMPORT_MENU_ITEM);
        }
    });
    // items.add(new InlineMenuItem());
    items.add(new InlineMenuItem(createStringResource("pageContentAccounts.menu.removeOwner"), true) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onSubmit(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        changeOwner(null, target, null, Operation.REMOVE);
                    } else {
                        SelectableBeanImpl<ShadowType> shadow = getRowModel().getObject();
                        changeOwner(shadow.getValue(), target, null, Operation.REMOVE);
                    }
                }
            };
        }
    });
    items.add(new ButtonInlineMenuItem(createStringResource("pageContentAccounts.menu.changeOwner"), true) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onSubmit(AjaxRequestTarget target) {
                    final SelectableBeanImpl<ShadowType> shadow = getRowModel().getObject();
                    ObjectBrowserPanel<FocusType> browser = new ObjectBrowserPanel<>(getPageBase().getMainPopupBodyId(), UserType.class, WebComponentUtil.createFocusTypeList(), false, getPageBase()) {

                        @Override
                        protected void onSelectPerformed(AjaxRequestTarget target, FocusType focus) {
                            changeOwner(shadow.getValue(), target, focus, Operation.MODIFY);
                        }
                    };
                    getPageBase().showMainPopup(browser, target);
                }
            };
        }

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

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    return items;
}
Also used : SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) 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