Search in sources :

Example 16 with ButtonInlineMenuItem

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

the class InternalsLoggedInUsersPanel method initInlineMenu.

private List<InlineMenuItem> initInlineMenu() {
    List<InlineMenuItem> menuItems = new ArrayList<>();
    menuItems.add(new ButtonInlineMenuItem(createStringResource("InternalsLoggedInUsers.refresh")) {

        private static final long serialVersionUID = 1L;

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

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

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

        @Override
        public boolean isHeaderMenuItem() {
            return true;
        }
    });
    return menuItems;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ArrayList(java.util.ArrayList) 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 17 with ButtonInlineMenuItem

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

the class PageCases method createActions.

private List<InlineMenuItem> createActions() {
    List<InlineMenuItem> menu = new ArrayList<>();
    menu.add(new ButtonInlineMenuItem(createStringResource("pageCases.button.stopProcess")) {

        private static final long serialVersionUID = 1L;

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

                @Override
                public void onClick(AjaxRequestTarget target) {
                    if (getRowModel() == null && warnIfNoCaseSelected(target)) {
                        return;
                    }
                    if (getRowModel() == null) {
                        stopCaseProcessConfirmed(target);
                    } else {
                        stopCaseProcessConfirmed(target, Collections.singletonList(getRowModel().getObject().getValue()));
                    }
                }
            };
        }

        @Override
        public IModel<Boolean> getEnabled() {
            IModel<SelectableBeanImpl<CaseType>> rowModel = ((ColumnMenuAction<SelectableBeanImpl<CaseType>>) getAction()).getRowModel();
            if (rowModel != null && rowModel.getObject() != null && rowModel.getObject().getValue() != null) {
                return Model.of(!CaseTypeUtil.isClosed(rowModel.getObject().getValue()));
            } else {
                return super.getEnabled();
            }
        }

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

        @Override
        public IModel<String> getConfirmationMessageModel() {
            return getTablePanel().getSelectedObjectsCount() > 0 ? createStringResource("pageCases.button.stopProcess.multiple.confirmationMessage", getTablePanel().getSelectedObjectsCount()) : createStringResource("pageCases.button.stopProcess.confirmationMessage");
        }
    });
    menu.add(new ButtonInlineMenuItem(createStringResource("pageCases.button.delete")) {

        private static final long serialVersionUID = 1L;

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

                @Override
                public void onClick(AjaxRequestTarget target) {
                    if (getRowModel() == null && warnIfNoCaseSelected(target)) {
                        return;
                    }
                    if (getRowModel() == null) {
                        deleteCaseObjectsConfirmed(target);
                    } else {
                        deleteCaseObjectsConfirmed(target, Collections.singletonList(getRowModel().getObject().getValue()));
                    }
                }
            };
        }

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

        @Override
        public IModel<Boolean> getEnabled() {
            IModel<SelectableBeanImpl<CaseType>> rowModel = ((ColumnMenuAction<SelectableBeanImpl<CaseType>>) getAction()).getRowModel();
            if (rowModel != null && rowModel.getObject() != null && rowModel.getObject().getValue() != null) {
                return Model.of(!CaseTypeUtil.isClosed(rowModel.getObject().getValue()));
            } else {
                return super.getEnabled();
            }
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            return getTablePanel().getSelectedObjectsCount() > 0 ? createStringResource("pageCases.button.delete.multiple.confirmationMessage", getTablePanel().getSelectedObjectsCount()) : createStringResource("pageCases.button.delete.confirmationMessage");
        }
    });
    return menu;
}
Also used : IModel(org.apache.wicket.model.IModel) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) 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)

Example 18 with ButtonInlineMenuItem

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

the class FocusProjectionsPanel method createShadowMenu.

private List<InlineMenuItem> createShadowMenu() {
    List<InlineMenuItem> items = new ArrayList<>();
    PrismObjectDefinition<F> def = getObjectWrapperModel().getObject().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(getPageBase().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 19 with ButtonInlineMenuItem

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

the class PageCreatedReports method initInlineMenu.

private List<InlineMenuItem> initInlineMenu() {
    List<InlineMenuItem> menuItems = new ArrayList<>();
    // menuItems.add(new InlineMenuItem(createStringResource("pageCreatedReports.inlineMenu.deleteAll")) {
    // private static final long serialVersionUID = 1L;
    // 
    // @Override
    // public InlineMenuItemAction initAction() {
    // return new HeaderMenuAction(PageCreatedReports.this) {
    // private static final long serialVersionUID = 1L;
    // 
    // @Override
    // public void onClick(AjaxRequestTarget target) {
    // deleteAllPerformed(target, ReportDeleteDialogDto.Operation.DELETE_ALL);
    // }
    // };
    // }
    // });
    menuItems.add(new ButtonInlineMenuItem(createStringResource("pageCreatedReports.button.delete")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    ReportDataType report = null;
                    if (getRowModel() != null) {
                        SelectableBeanImpl<ReportDataType> rowDto = getRowModel().getObject();
                        report = rowDto.getValue();
                    }
                    deleteSelectedPerformed(target, ReportDeleteDialogDto.Operation.DELETE_SELECTED, report);
                }
            };
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder("fa fa-minus");
        }
    });
    boolean canViewTraces;
    boolean canReadTraces;
    try {
        canReadTraces = isAuthorized(ModelAuthorizationAction.READ_TRACE.getUrl());
    } catch (Throwable t) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't authorize reading traces", t);
        canReadTraces = false;
    }
    canViewTraces = canReadTraces && WebModelServiceUtils.isEnableExperimentalFeature(this);
    ButtonInlineMenuItem item = new ButtonInlineMenuItem(createStringResource("DownloadButtonPanel.download")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    SelectableBeanImpl<ReportDataType> rowDto = getRowModel().getObject();
                    currentReport = rowDto.getValue();
                    downloadPerformed(target, ajaxDownloadBehavior);
                }
            };
        }

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

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    };
    if (!canReadTraces) {
        item.setVisibilityChecker((rowModel, isHeader) -> !isTrace(rowModel));
    }
    menuItems.add(item);
    ButtonInlineMenuItem viewTraceItem = new ButtonInlineMenuItem(createStringResource("DownloadButtonPanel.viewTrace")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    SelectableBeanImpl<ReportDataType> rowDto = getRowModel().getObject();
                    currentReport = rowDto.getValue();
                    PageParameters parameters = new PageParameters();
                    parameters.add(PageTraceView.PARAM_OBJECT_ID, currentReport.getOid());
                    navigateToNext(PageTraceView.class, parameters);
                }
            };
        }

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

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    };
    menuItems.add(viewTraceItem);
    viewTraceItem.setVisibilityChecker((rowModel, isHeader) -> canViewTraces && isTrace(rowModel));
    return menuItems;
}
Also used : SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) 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 20 with ButtonInlineMenuItem

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

the class PageReports method createInlineMenu.

private List<InlineMenuItem> createInlineMenu() {
    List<InlineMenuItem> menu = new ArrayList<>();
    ButtonInlineMenuItem runButton = new ButtonInlineMenuItem(createStringResource("PageReports.button.run")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    ReportType report = getRowModel().getObject().getValue();
                    com.evolveum.midpoint.web.page.admin.reports.PageReport.runReportPerformed(target, report.asPrismObject(), PageReports.this);
                }
            };
        }

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

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    };
    runButton.setVisibilityChecker((rowModel, isHeader) -> !isImportReport((IModel<SelectableBean<ReportType>>) rowModel));
    menu.add(runButton);
    ButtonInlineMenuItem importButton = new ButtonInlineMenuItem(createStringResource("PageReports.button.import")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    ReportType report = getRowModel().getObject().getValue();
                    com.evolveum.midpoint.web.page.admin.reports.PageReport.importReportPerformed(target, report.asPrismObject(), PageReports.this);
                }
            };
        }

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

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    };
    importButton.setVisibilityChecker((rowModel, isHeader) -> isImportReport((IModel<SelectableBean<ReportType>>) rowModel));
    menu.add(importButton);
    menu.add(new ButtonInlineMenuItem(createStringResource("PageReports.button.configure")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    ReportType reportObject = getRowModel().getObject().getValue();
                    configurePerformed(target, reportObject);
                }
            };
        }

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

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

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    ReportType reportObject = getRowModel().getObject().getValue();
                    PageParameters pageParameters = new PageParameters();
                    pageParameters.add(OnePageParameterEncoder.PARAMETER, reportObject.getOid());
                    navigateToNext(PageCreatedReports.class, pageParameters);
                }
            };
        }

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

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    return menu;
}
Also used : IModel(org.apache.wicket.model.IModel) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) ArrayList(java.util.ArrayList) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) 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)

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