Search in sources :

Example 41 with InlineMenuItem

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

the class ResourceContentPanel method createRowMenuItems.

@SuppressWarnings("serial")
private List<InlineMenuItem> createRowMenuItems() {
    List<InlineMenuItem> items = new ArrayList<InlineMenuItem>();
    items.add(new InlineMenuItem(createStringResource("pageContentAccounts.menu.enableAccount"), true, new ColumnMenuAction<SelectableBean<ShadowType>>() {

        @Override
        public void onSubmit(AjaxRequestTarget target, Form<?> form) {
            SelectableBean<ShadowType> shadow = getRowModel().getObject();
            updateResourceObjectStatusPerformed(shadow.getValue(), target, true);
        }
    }));
    items.add(new InlineMenuItem(createStringResource("pageContentAccounts.menu.disableAccount"), true, new ColumnMenuAction<SelectableBean<ShadowType>>() {

        @Override
        public void onSubmit(AjaxRequestTarget target, Form<?> form) {
            SelectableBean<ShadowType> shadow = getRowModel().getObject();
            updateResourceObjectStatusPerformed(shadow.getValue(), target, false);
        }
    }));
    items.add(new InlineMenuItem(createStringResource("pageContentAccounts.menu.deleteAccount"), true, new ColumnMenuAction<SelectableBean<ShadowType>>() {

        @Override
        public void onSubmit(AjaxRequestTarget target, Form<?> form) {
            SelectableBean<ShadowType> shadow = getRowModel().getObject();
            deleteResourceObjectPerformed(shadow.getValue(), target);
        }
    }));
    items.add(new InlineMenuItem());
    items.add(new InlineMenuItem(createStringResource("pageContentAccounts.menu.importAccount"), true, new ColumnMenuAction<SelectableBean<ShadowType>>() {

        @Override
        public void onSubmit(AjaxRequestTarget target, Form<?> form) {
            SelectableBean<ShadowType> shadow = getRowModel().getObject();
            importResourceObject(shadow.getValue(), target);
        }
    }));
    items.add(new InlineMenuItem());
    items.add(new InlineMenuItem(createStringResource("pageContentAccounts.menu.removeOwner"), true, new ColumnMenuAction<SelectableBean<ShadowType>>() {

        @Override
        public void onSubmit(AjaxRequestTarget target, Form<?> form) {
            SelectableBean<ShadowType> shadow = getRowModel().getObject();
            changeOwner(shadow.getValue(), target, null, Operation.REMOVE);
        }
    }));
    items.add(new InlineMenuItem(createStringResource("pageContentAccounts.menu.changeOwner"), true, new ColumnMenuAction<SelectableBean<ShadowType>>() {

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

                @Override
                protected void onSelectPerformed(AjaxRequestTarget target, FocusType focus) {
                    changeOwner(shadow.getValue(), target, focus, Operation.MODIFY);
                }
            };
            pageBase.showMainPopup(browser, target);
        }
    }));
    return items;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Form(org.apache.wicket.markup.html.form.Form) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) ArrayList(java.util.ArrayList) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)

Example 42 with InlineMenuItem

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

the class ObjectListPanel method initProvider.

protected BaseSortableDataProvider<SelectableBean<O>> initProvider() {
    Set<O> selectedObjectsSet = selectedObjects == null ? null : new HashSet<O>(selectedObjects);
    SelectableBeanObjectDataProvider<O> provider = new SelectableBeanObjectDataProvider<O>(parentPage, type, selectedObjectsSet) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
            String storageKey = getStorageKey();
            if (StringUtils.isNotEmpty(storageKey)) {
                PageStorage storage = getPageStorage(storageKey);
                if (storage != null) {
                    storage.setPaging(paging);
                }
            }
        }

        @Override
        public SelectableBean<O> createDataObjectWrapper(O obj) {
            SelectableBean<O> bean = super.createDataObjectWrapper(obj);
            List<InlineMenuItem> inlineMenu = createInlineMenu();
            if (inlineMenu != null) {
                bean.getMenuItems().addAll(inlineMenu);
            }
            return bean;
        }
    };
    if (options == null) {
        if (ResourceType.class.equals(type)) {
            options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
        }
    } else {
        if (ResourceType.class.equals(type)) {
            GetOperationOptions root = SelectorOptions.findRootOptions(options);
            root.setNoFetch(Boolean.TRUE);
        }
        provider.setOptions(options);
    }
    provider.setQuery(getQuery());
    return provider;
}
Also used : SelectableBeanObjectDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanObjectDataProvider) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) PageStorage(com.evolveum.midpoint.web.session.PageStorage)

Example 43 with InlineMenuItem

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

the class UserDelegationsTabPanel method initLayout.

private void initLayout() {
    WebMarkupContainer delegations = new WebMarkupContainer(ID_DELEGATIONS_CONTAINER);
    delegations.setOutputMarkupId(true);
    add(delegations);
    AssignmentTablePanel panel = new AssignmentTablePanel<UserType>(ID_DELEGATIONS_PANEL, createStringResource("FocusType.delegations"), delegationsModel) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateAssignmentDetailsPanel(ListItem<AssignmentEditorDto> item) {
            DelegationEditorPanel editor = new DelegationEditorPanel(ID_ROW, item.getModel(), false, privilegesListModel, pageBase);
            item.add(editor);
        }

        @Override
        public String getExcludeOid() {
            return getObjectWrapper().getOid();
        }

        @Override
        protected List<InlineMenuItem> createAssignmentMenu() {
            List<InlineMenuItem> items = new ArrayList<>();
            InlineMenuItem item;
            if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_DELEGATE_ACTION_URL)) {
                item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.addDelegation"), new InlineMenuItemAction() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        List<QName> supportedTypes = new ArrayList<>();
                        supportedTypes.add(UserType.COMPLEX_TYPE);
                        ObjectFilter filter = InOidFilter.createInOid(getObjectWrapper().getOid());
                        ObjectFilter notFilter = NotFilter.createNot(filter);
                        ObjectBrowserPanel<UserType> panel = new ObjectBrowserPanel<UserType>(pageBase.getMainPopupBodyId(), UserType.class, supportedTypes, false, pageBase, notFilter) {

                            private static final long serialVersionUID = 1L;

                            @Override
                            protected void onSelectPerformed(AjaxRequestTarget target, UserType user) {
                                pageBase.hideMainPopup(target);
                                List<ObjectType> newAssignmentsList = new ArrayList<>();
                                newAssignmentsList.add(user);
                                addSelectedAssignablePerformed(target, newAssignmentsList, getPageBase().getMainPopup().getId());
                            }
                        };
                        panel.setOutputMarkupId(true);
                        pageBase.showMainPopup(panel, target);
                    }
                });
                items.add(item);
            }
            if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_UNASSIGN_ACTION_URL)) {
                item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.deleteDelegation"), new InlineMenuItemAction() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        deleteAssignmentPerformed(target);
                    }
                });
                items.add(item);
            }
            return items;
        }

        @Override
        protected String getNoAssignmentsSelectedMessage() {
            return getString("AssignmentTablePanel.message.noDelegationsSelected");
        }

        @Override
        protected String getAssignmentsDeleteMessage(int size) {
            return createStringResource("AssignmentTablePanel.modal.message.deleteDelegation", size).getString();
        }

        @Override
        protected void addSelectedAssignablePerformed(AjaxRequestTarget target, List<ObjectType> newAssignments, String popupId) {
            ModalWindow window = (ModalWindow) get(popupId);
            if (window != null) {
                window.close(target);
            }
            getPageBase().hideMainPopup(target);
            if (newAssignments.isEmpty()) {
                warn(getString("AssignmentTablePanel.message.noAssignmentSelected"));
                target.add(getPageBase().getFeedbackPanel());
                return;
            }
            for (ObjectType object : newAssignments) {
                try {
                    AssignmentEditorDto dto = AssignmentEditorDto.createDtoAddFromSelectedObject(((PrismObject<UserType>) getObjectWrapper().getObject()).asObjectable(), SchemaConstants.ORG_DEPUTY, getPageBase(), (UserType) object);
                    dto.setPrivilegeLimitationList(privilegesListModel.getObject());
                    delegationsModel.getObject().add(dto);
                } catch (Exception e) {
                    error(getString("AssignmentTablePanel.message.couldntAssignObject", object.getName(), e.getMessage()));
                    LoggingUtils.logUnexpectedException(LOGGER, "Couldn't assign object", e);
                }
            }
            reloadAssignmentsPanel(target);
            reloadMainFormButtons(target);
        }
    };
    delegations.add(panel);
}
Also used : DelegationEditorPanel(com.evolveum.midpoint.web.component.assignment.DelegationEditorPanel) AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) AssignmentTablePanel(com.evolveum.midpoint.web.component.assignment.AssignmentTablePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ModalWindow(org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow)

Example 44 with InlineMenuItem

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

the class PageUsers method createRowActions.

private List<InlineMenuItem> createRowActions(boolean isHeader) {
    List<InlineMenuItem> menu = new ArrayList<InlineMenuItem>();
    menu.add(new InlineMenuItem(createStringResource("pageUsers.menu.enable"), new Model<Boolean>(false), new Model<Boolean>(false), false, new ColumnMenuAction<SelectableBean<UserType>>() {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                updateActivationPerformed(target, true, null);
            } else {
                SelectableBean<UserType> rowDto = getRowModel().getObject();
                updateActivationPerformed(target, true, rowDto.getValue());
            }
        }
    }, isHeader ? InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.HEADER_ENABLE.getMenuItemId() : InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.ENABLE.getMenuItemId(), GuiStyleConstants.CLASS_OBJECT_USER_ICON, DoubleButtonColumn.BUTTON_COLOR_CLASS.SUCCESS.toString()) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return PageUsers.this.isShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageUsers.message.enableAction").getString();
            return PageUsers.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    menu.add(new InlineMenuItem(createStringResource("pageUsers.menu.disable"), isHeader ? new Model<Boolean>(true) : new Model<Boolean>(false), isHeader ? new Model<Boolean>(true) : new Model<Boolean>(false), false, new ColumnMenuAction<SelectableBean<UserType>>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                updateActivationPerformed(target, false, null);
            } else {
                SelectableBean<UserType> rowDto = getRowModel().getObject();
                updateActivationPerformed(target, false, rowDto.getValue());
            }
        }
    }, isHeader ? InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.HEADER_DISABLE.getMenuItemId() : InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.DISABLE.getMenuItemId(), GuiStyleConstants.CLASS_OBJECT_USER_ICON, DoubleButtonColumn.BUTTON_COLOR_CLASS.DANGER.toString()) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return PageUsers.this.isShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageUsers.message.disableAction").getString();
            return PageUsers.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    menu.add(new InlineMenuItem(createStringResource("pageUsers.menu.reconcile"), new Model<Boolean>(false), new Model<Boolean>(false), false, new ColumnMenuAction<SelectableBean<UserType>>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                reconcilePerformed(target, null);
            } else {
                SelectableBean<UserType> rowDto = getRowModel().getObject();
                reconcilePerformed(target, rowDto.getValue());
            }
        }
    }, isHeader ? InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.HEADER_RECONCILE.getMenuItemId() : InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.RECONCILE.getMenuItemId(), GuiStyleConstants.CLASS_RECONCILE_MENU_ITEM, DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO.toString()) {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return PageUsers.this.isShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageUsers.message.reconcileAction").getString();
            return PageUsers.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    menu.add(new InlineMenuItem(createStringResource("pageUsers.menu.unlock"), false, new ColumnMenuAction<SelectableBean<UserType>>() {

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

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return PageUsers.this.isShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageUsers.message.unlockAction").getString();
            return PageUsers.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    menu.add(new InlineMenuItem(createStringResource("pageUsers.menu.delete"), false, new ColumnMenuAction<SelectableBean<UserType>>() {

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

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isShowConfirmationDialog() {
            return PageUsers.this.isShowConfirmationDialog((ColumnMenuAction) getAction());
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageUsers.message.deleteAction").getString();
            return PageUsers.this.getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    menu.add(new InlineMenuItem(createStringResource("pageUsers.menu.merge"), isHeader ? new Model<Boolean>(false) : new Model<Boolean>(true), isHeader ? new Model<Boolean>(false) : new Model<Boolean>(true), false, new ColumnMenuAction<SelectableBean<UserType>>() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (getRowModel() == null) {
                mergePerformed(target, null);
            } else {
                SelectableBean<UserType> rowDto = getRowModel().getObject();
                mergePerformed(target, rowDto.getValue());
            }
        }
    }, InlineMenuItem.FOCUS_LIST_INLINE_MENU_ITEM_ID.MERGE.getMenuItemId(), "", ""));
    return menu;
}
Also used : IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 45 with InlineMenuItem

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

the class PageServices method initLayout.

private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);
    MainObjectListPanel<ServiceType> servicePanel = new MainObjectListPanel<ServiceType>(ID_TABLE, ServiceType.class, TableId.TABLE_SERVICES, null, this) {

        private static final long serialVersionUID = 1L;

        @Override
        public void objectDetailsPerformed(AjaxRequestTarget target, ServiceType service) {
            PageServices.this.serviceDetailsPerformed(target, service);
        }

        @Override
        protected List<IColumn<SelectableBean<ServiceType>, String>> createColumns() {
            return ColumnUtils.getDefaultServiceColumns();
        }

        @Override
        protected IColumn<SelectableBean<ServiceType>, String> createActionsColumn() {
            return new InlineMenuButtonColumn<SelectableBean<ServiceType>>(listInlineMenuHelper.createRowActions(false), 3, PageServices.this) {

                @Override
                protected int getHeaderNumberOfButtons() {
                    return 2;
                }

                @Override
                protected List<InlineMenuItem> getHeaderMenuItems() {
                    return listInlineMenuHelper.createRowActions(true);
                }
            };
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return listInlineMenuHelper.createRowActions(false);
        }

        @Override
        protected void newObjectPerformed(AjaxRequestTarget target) {
            navigateToNext(PageService.class);
        }
    };
    servicePanel.setAdditionalBoxCssClasses(GuiStyleConstants.CLASS_OBJECT_SERVICE_BOX_CSS_CLASSES);
    servicePanel.setOutputMarkupId(true);
    mainForm.add(servicePanel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) Form(org.apache.wicket.markup.html.form.Form) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ServiceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ServiceType) InlineMenuButtonColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Aggregations

InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)45 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)36 ArrayList (java.util.ArrayList)24 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)11 HeaderMenuAction (com.evolveum.midpoint.web.page.admin.configuration.component.HeaderMenuAction)11 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)10 IModel (org.apache.wicket.model.IModel)10 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)9 Form (org.apache.wicket.markup.html.form.Form)9 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)8 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)7 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)7 Label (org.apache.wicket.markup.html.basic.Label)7 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)7 Model (org.apache.wicket.model.Model)7 ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)5 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)4 ObjectBrowserPanel (com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)3