Search in sources :

Example 6 with ColumnMenuAction

use of com.evolveum.midpoint.web.component.data.column.ColumnMenuAction in project midpoint by Evolveum.

the class FocusProjectionsTabPanel method createShadowMenu.

private List<InlineMenuItem> createShadowMenu() {
    List<InlineMenuItem> items = new ArrayList<>();
    PrismObjectDefinition<F> def = getObjectWrapper().getObject().getDefinition();
    PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
    InlineMenuItem item;
    PrismPropertyDefinition<ActivationStatusType> administrativeStatus = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
    if (administrativeStatus.canRead() && administrativeStatus.canModify()) {
        item = new ButtonInlineMenuItem(createStringResource("pageAdminFocus.button.enable")) {

            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) {
                        updateShadowActivation(target, getMultivalueContainerListPanel().getPerformedSelectedItems(getRowModel()), true);
                    }
                };
            }

            @Override
            public CompositedIconBuilder getIconCompositedBuilder() {
                return getDefaultCompositedIconBuilder("fa fa-check");
            }
        };
        items.add(item);
        item = new InlineMenuItem(createStringResource("pageAdminFocus.button.disable")) {

            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) {
                        updateShadowActivation(target, getMultivalueContainerListPanel().getPerformedSelectedItems(getRowModel()), false);
                    }
                };
            }
        };
        items.add(item);
    }
    if (ref.canRead() && ref.canAdd()) {
        item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlink")) {

            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) {
                        unlinkProjectionPerformed(target, getMultivalueContainerListPanel().getPerformedSelectedItems(getRowModel()));
                    }
                };
            }
        };
        items.add(item);
    }
    PrismPropertyDefinition<LockoutStatusType> locakoutStatus = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS);
    if (locakoutStatus.canRead() && locakoutStatus.canModify()) {
        item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlock")) {

            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) {
                        unlockShadowPerformed(target, getMultivalueContainerListPanel().getPerformedSelectedItems(getRowModel()));
                    }
                };
            }
        };
        items.add(item);
    }
    if (administrativeStatus.canRead() && administrativeStatus.canModify()) {
        // items.add(new 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) {
                        deleteProjectionPerformed(target, getMultivalueContainerListPanel().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) {
                    getMultivalueContainerListPanel().editItemPerformed(target, getRowModel(), getMultivalueContainerListPanel().getSelectedItems());
                    target.add(getFeedbackPanel());
                }
            };
        }
    };
    items.add(item);
    return items;
}
Also used : 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) 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) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Example 7 with ColumnMenuAction

use of com.evolveum.midpoint.web.component.data.column.ColumnMenuAction in project midpoint by Evolveum.

the class PageRoles method initLayout.

protected void initLayout() {
    Form mainForm = new MidpointForm(ID_MAIN_FORM);
    add(mainForm);
    MainObjectListPanel<RoleType> table = new MainObjectListPanel<RoleType>(ID_TABLE, RoleType.class) {

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

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            FocusListInlineMenuHelper<RoleType> listInlineMenuHelper = new FocusListInlineMenuHelper<RoleType>(RoleType.class, PageRoles.this, this) {

                private static final long serialVersionUID = 1L;

                protected boolean isShowConfirmationDialog(ColumnMenuAction action) {
                    return PageRoles.this.isShowConfirmationDialog(action);
                }

                protected IModel<String> getConfirmationMessageModel(ColumnMenuAction action, String actionName) {
                    return PageRoles.this.getConfirmationMessageModel(action, actionName);
                }
            };
            return listInlineMenuHelper.createRowActions(getType());
        }

        // @Override
        // protected List<IColumn<SelectableBean<RoleType>, String>> createDefaultColumns() {
        // return ColumnUtils.getDefaultRoleColumns();
        // }
        @Override
        protected List<ItemPath> getFixedSearchItems() {
            List<ItemPath> fixedSearchItems = new ArrayList<>();
            fixedSearchItems.add(ObjectType.F_NAME);
            fixedSearchItems.add(AbstractRoleType.F_DISPLAY_NAME);
            fixedSearchItems.add(AbstractRoleType.F_IDENTIFIER);
            return fixedSearchItems;
        }
    };
    table.setOutputMarkupId(true);
    mainForm.add(table);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) ArrayList(java.util.ArrayList) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) FocusListInlineMenuHelper(com.evolveum.midpoint.web.component.util.FocusListInlineMenuHelper) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 8 with ColumnMenuAction

use of com.evolveum.midpoint.web.component.data.column.ColumnMenuAction in project midpoint by Evolveum.

the class TaskTablePanel method createTaskInlineMenuItem.

private InlineMenuItem createTaskInlineMenuItem(String menuNameKey, SerializableBiConsumer<AjaxRequestTarget, IModel<SelectableBean<TaskType>>> action, String confirmationMessageKey, SerializableFunction<TaskType, Boolean> visibilityHandler, boolean header) {
    InlineMenuItem menuItem = new InlineMenuItem(createStringResource(menuNameKey)) {

        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 IModel<String> getConfirmationMessageModel() {
            if (OPERATION_DELETE_ALL_CLOSED_TASKS.equals(confirmationMessageKey)) {
                return createStringResource("pageTasks.message.deleteAllClosedTasksConfirm");
            }
            String actionName = createStringResource(confirmationMessageKey).getString();
            return TaskTablePanel.this.getTaskConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }

        @Override
        public boolean isHeaderMenuItem() {
            return header;
        }
    };
    menuItem.setVisibilityChecker((rowModel, menuHeader) -> isMenuVisible(rowModel, menuHeader, visibilityHandler));
    return menuItem;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) 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)

Example 9 with ColumnMenuAction

use of com.evolveum.midpoint.web.component.data.column.ColumnMenuAction 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 10 with ColumnMenuAction

use of com.evolveum.midpoint.web.component.data.column.ColumnMenuAction 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)

Aggregations

ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)21 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)19 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)18 ArrayList (java.util.ArrayList)15 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)12 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)11 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)11 IModel (org.apache.wicket.model.IModel)11 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)6 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)5 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)4 SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)4 Form (org.apache.wicket.markup.html.form.Form)4 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)3 PrismContainerValueWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)3 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)3 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)3 Model (org.apache.wicket.model.Model)3 GuiStyleConstants (com.evolveum.midpoint.gui.api.GuiStyleConstants)2 BasePanel (com.evolveum.midpoint.gui.api.component.BasePanel)2