Search in sources :

Example 56 with CompositedIconBuilder

use of com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder in project midpoint by Evolveum.

the class PageNodes method createNodesInlineMenu.

private List<InlineMenuItem> createNodesInlineMenu() {
    List<InlineMenuItem> items = new ArrayList<>();
    items.add(new ButtonInlineMenuItem(createStringResource("pageTasks.button.startScheduler")) {

        private static final long serialVersionUID = 1L;

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

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

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

        @SuppressWarnings("unchecked")
        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageTasks.message.startSchedulerAction").getString();
            return PageNodes.this.getNodeConfirmationMessageModel((ColumnMenuAction<SelectableBean<NodeType>>) getAction(), actionName);
        }
    });
    items.add(new ButtonInlineMenuItem(createStringResource("pageTasks.button.stopScheduler")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

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

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

        @SuppressWarnings({ "unchecked" })
        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageTasks.message.stopSchedulerAction").getString();
            return PageNodes.this.getNodeConfirmationMessageModel((ColumnMenuAction<SelectableBean<NodeType>>) getAction(), actionName);
        }
    });
    items.add(new InlineMenuItem(createStringResource("pageTasks.button.stopSchedulerAndTasks")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

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

        @SuppressWarnings("unchecked")
        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageTasks.message.stopSchedulerTasksAction").getString();
            return PageNodes.this.getNodeConfirmationMessageModel((ColumnMenuAction<SelectableBean<NodeType>>) getAction(), actionName);
        }
    });
    items.add(new InlineMenuItem(createStringResource("pageTasks.button.deleteNode")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

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

        @SuppressWarnings("unchecked")
        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageTasks.message.deleteAction").getString();
            return PageNodes.this.getNodeConfirmationMessageModel((ColumnMenuAction<SelectableBean<NodeType>>) getAction(), actionName);
        }
    });
    return items;
}
Also used : IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) 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 57 with CompositedIconBuilder

use of com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder in project midpoint by Evolveum.

the class PageUsers method createRowActions.

private List<InlineMenuItem> createRowActions() {
    List<InlineMenuItem> menu = new ArrayList<>();
    ButtonInlineMenuItem enableItem = new ButtonInlineMenuItem(createStringResource("pageUsers.menu.enable")) {

        private static final long serialVersionUID = 1L;

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

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

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

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

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

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

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            CompositedIconBuilder builder = getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_OBJECT_USER_ICON);
            builder.appendLayerIcon(WebComponentUtil.createIconType(GuiStyleConstants.CLASS_BAN), IconCssStyle.BOTTOM_RIGHT_STYLE);
            return builder;
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageUsers.message.disableAction").getString();
            return getTable().getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    };
    disableItem.setVisibilityChecker(FocusListInlineMenuHelper::isObjectEnabled);
    menu.add(disableItem);
    menu.add(new ButtonInlineMenuItem(createStringResource("pageUsers.menu.reconcile")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        reconcilePerformed(target, null);
                    } else {
                        SelectableBean<UserType> 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 = createStringResource("pageUsers.message.reconcileAction").getString();
            return getTable().getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    menu.add(new InlineMenuItem(createStringResource("pageUsers.menu.unlock")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

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

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageUsers.message.unlockAction").getString();
            return getTable().getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    menu.add(getTable().createDeleteInlineMenu());
    menu.add(new InlineMenuItem(createStringResource("pageUsers.menu.merge")) {

        private static final long serialVersionUID = 1L;

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

                @Override
                public void onClick(AjaxRequestTarget target) {
                    OperationResult result = new OperationResult(OPERATION_LOAD_MERGE_CONFIGURATION);
                    List<MergeConfigurationType> mergeConfiguration;
                    try {
                        mergeConfiguration = getModelInteractionService().getMergeConfiguration(result);
                    } catch (ObjectNotFoundException | SchemaException ex) {
                        LOGGER.error("Couldn't load merge configuration: {}", ex.getLocalizedMessage());
                        result.recomputeStatus();
                        getFeedbackMessages().error(PageUsers.this, ex.getLocalizedMessage());
                        target.add(getFeedbackPanel());
                        return;
                    }
                    if (mergeConfiguration == null || mergeConfiguration.size() == 0) {
                        getFeedbackMessages().warn(PageUsers.this, createStringResource("PageUsers.noMergeConfigurationMessage").getString());
                        target.add(getFeedbackPanel());
                        return;
                    }
                    if (getRowModel() == null) {
                        mergePerformed(target, null);
                    } else {
                        SelectableBean<UserType> rowDto = getRowModel().getObject();
                        mergePerformed(target, rowDto.getValue());
                    }
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    return menu;
}
Also used : IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) 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) ArrayList(java.util.ArrayList) List(java.util.List) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) FocusListInlineMenuHelper(com.evolveum.midpoint.web.component.util.FocusListInlineMenuHelper)

Aggregations

CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)57 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)32 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)26 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)26 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)26 ArrayList (java.util.ArrayList)26 IModel (org.apache.wicket.model.IModel)17 ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)11 CompositedIconButtonDto (com.evolveum.midpoint.web.component.CompositedIconButtonDto)9 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)9 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)7 SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)7 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)6 CompositedIcon (com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon)6 PrismContainerValueWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)5 CompositedIconColumn (com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconColumn)4 InlineMenuButtonColumn (com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn)4 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)4