Search in sources :

Example 36 with InlineMenuItem

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

the class AbstractRoleMemberPanel method createRemoveMemberInlineMenuItems.

protected List<InlineMenuItem> createRemoveMemberInlineMenuItems() {
    List<InlineMenuItem> removeMenuItems = new ArrayList<>();
    removeMenuItems.add(new InlineMenuItem(createStringResource("TreeTablePanel.menu.unassignMembersSelected"), false, new HeaderMenuAction(this) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeMembersPerformed(QueryScope.SELECTED, target);
        }
    }));
    removeMenuItems.add(new InlineMenuItem(createStringResource("TreeTablePanel.menu.unassignMembersAll"), false, new HeaderMenuAction(this) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeMembersPerformed(QueryScope.ALL, target);
        }
    }));
    return removeMenuItems;
}
Also used : HeaderMenuAction(com.evolveum.midpoint.web.page.admin.configuration.component.HeaderMenuAction) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ArrayList(java.util.ArrayList) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 37 with InlineMenuItem

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

the class TreeTablePanel method createTreeChildrenMenu.

private List<InlineMenuItem> createTreeChildrenMenu(OrgType org) {
    List<InlineMenuItem> items = new ArrayList<>();
    try {
        boolean allowModify = org == null || parentPage.getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_MODIFY_ACTION_URL, AuthorizationPhaseType.REQUEST, org.asPrismObject(), null, null, null);
        boolean allowRead = org == null || parentPage.getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_READ_ACTION_URL, AuthorizationPhaseType.REQUEST, org.asPrismObject(), null, null, null);
        InlineMenuItem item;
        if (allowModify) {
            item = new InlineMenuItem(createStringResource("TreeTablePanel.move"), new ColumnMenuAction<SelectableBean<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    moveRootPerformed(getRowModel().getObject(), target);
                }
            });
            items.add(item);
            item = new InlineMenuItem(createStringResource("TreeTablePanel.makeRoot"), new ColumnMenuAction<SelectableBean<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    makeRootPerformed(getRowModel().getObject(), target);
                }
            });
            items.add(item);
        }
        boolean allowDelete = org == null || parentPage.getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_DELETE_ACTION_URL, AuthorizationPhaseType.REQUEST, org.asPrismObject(), null, null, null);
        if (allowDelete) {
            item = new InlineMenuItem(createStringResource("TreeTablePanel.delete"), new ColumnMenuAction<SelectableBean<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteNodePerformed(getRowModel().getObject(), target);
                }
            });
            items.add(item);
        }
        if (allowModify) {
            item = new InlineMenuItem(createStringResource("TreeTablePanel.recompute"), new ColumnMenuAction<SelectableBean<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    recomputeRootPerformed(getRowModel().getObject(), target);
                }
            });
            items.add(item);
            item = new InlineMenuItem(createStringResource("TreeTablePanel.edit"), Model.of(allowModify), Model.of(allowModify), new ColumnMenuAction<SelectableBean<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    editRootPerformed(getRowModel().getObject(), target);
                }
            });
            items.add(item);
        } else if (allowRead) {
            item = new InlineMenuItem(createStringResource("TreeTablePanel.viewDetails"), Model.of(allowRead), Model.of(allowRead), new ColumnMenuAction<SelectableBean<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    editRootPerformed(getRowModel().getObject(), target);
                }
            });
            items.add(item);
        }
        boolean allowAddNew = parentPage.getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_ADD_ACTION_URL, AuthorizationPhaseType.REQUEST, (new OrgType(parentPage.getPrismContext())).asPrismObject(), null, null, null);
        if (allowModify && allowAddNew) {
            item = new InlineMenuItem(createStringResource("TreeTablePanel.createChild"), new ColumnMenuAction<SelectableBean<OrgType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    try {
                        initObjectForAdd(ObjectTypeUtil.createObjectRef(getRowModel().getObject().getValue()), OrgType.COMPLEX_TYPE, null, target);
                    } catch (SchemaException e) {
                        throw new SystemException(e.getMessage(), e);
                    }
                }
            });
            items.add(item);
        }
    } catch (SchemaException ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Failed to check menu items authorizations", ex);
    }
    return items;
}
Also used : ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)

Example 38 with InlineMenuItem

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

the class AbstractRoleMemberPanel method createMembersHeaderInlineMenu.

protected List<InlineMenuItem> createMembersHeaderInlineMenu() {
    List<InlineMenuItem> headerMenuItems = new ArrayList<>();
    headerMenuItems.addAll(createNewMemberInlineMenuItems());
    headerMenuItems.add(new InlineMenuItem());
    headerMenuItems.addAll(createRemoveMemberInlineMenuItems());
    headerMenuItems.addAll(createMemberRecomputeInlineMenuItems());
    return headerMenuItems;
}
Also used : ArrayList(java.util.ArrayList) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 39 with InlineMenuItem

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

the class PageResources method initLayout.

private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);
    Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
    options.add(SelectorOptions.create(ResourceType.F_CONNECTOR_REF, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)));
    MainObjectListPanel<ResourceType> resourceListPanel = new MainObjectListPanel<ResourceType>(ID_TABLE, ResourceType.class, TableId.TABLE_RESOURCES, options, this) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return PageResources.this.createRowMenuItems(false);
        }

        @Override
        protected List<IColumn<SelectableBean<ResourceType>, String>> createColumns() {
            return PageResources.this.initResourceColumns();
        }

        @Override
        protected IColumn<SelectableBean<ResourceType>, String> createActionsColumn() {
            return PageResources.this.createResourceActionsColumn();
        }

        @Override
        protected void objectDetailsPerformed(AjaxRequestTarget target, ResourceType object) {
            PageResources.this.resourceDetailsPerformed(target, object.getOid());
        }

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

Example 40 with InlineMenuItem

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

the class ResourceContentPanel method initLayout.

private void initLayout() {
    WebMarkupContainer totals = new WebMarkupContainer(ID_TOTALS);
    totals.setOutputMarkupId(true);
    add(totals);
    initShadowStatistics(totals);
    MainObjectListPanel<ShadowType> shadowListPanel = new MainObjectListPanel<ShadowType>(ID_TABLE, ShadowType.class, getTableId(), null, pageBase) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return ResourceContentPanel.this.createRowMenuItems();
        }

        @Override
        protected List<IColumn<SelectableBean<ShadowType>, String>> createColumns() {
            return ResourceContentPanel.this.initColumns();
        }

        @Override
        protected IColumn<SelectableBean<ShadowType>, String> createActionsColumn() {
            return new InlineMenuHeaderColumn(createHeaderMenuItems());
        }

        @Override
        protected void objectDetailsPerformed(AjaxRequestTarget target, ShadowType object) {
            shadowDetailsPerformed(target, WebComponentUtil.getName(object), object.getOid());
        }

        @Override
        protected void newObjectPerformed(AjaxRequestTarget target) {
        // TODO Auto-generated method stub
        }

        @Override
        protected BaseSortableDataProvider<SelectableBean<ShadowType>> initProvider() {
            provider = (SelectableBeanObjectDataProvider<ShadowType>) super.initProvider();
            provider.setEmptyListOnNullQuery(true);
            provider.setSort(null);
            createSearchOptions(provider);
            return provider;
        }

        @Override
        protected ObjectQuery createContentQuery() {
            ObjectQuery parentQuery = super.createContentQuery();
            List<ObjectFilter> filters = new ArrayList<>();
            if (parentQuery != null) {
                filters.add(parentQuery.getFilter());
            }
            ObjectQuery customQuery = ResourceContentPanel.this.createQuery();
            if (customQuery != null && customQuery.getFilter() != null) {
                filters.add(customQuery.getFilter());
            }
            ObjectQuery query = new ObjectQuery();
            if (filters.size() == 1) {
                query = ObjectQuery.createObjectQuery(filters.iterator().next());
                //					setProviderAvailableDataSize(query);
                return query;
            }
            if (filters.size() == 0) {
                //					setProviderAvailableDataSize(query);
                return null;
            }
            query = ObjectQuery.createObjectQuery(AndFilter.createAnd(filters));
            //				setProviderAvailableDataSize(query);
            return query;
        }

        @Override
        protected Search createSearch() {
            return ResourceContentPanel.this.createSearch();
        }
    };
    shadowListPanel.setOutputMarkupId(true);
    shadowListPanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return createQuery() != null;
        }
    });
    shadowListPanel.setAdditionalBoxCssClasses(GuiStyleConstants.CLASS_OBJECT_SHADOW_BOX_CSS_CLASSES);
    add(shadowListPanel);
    Label label = new Label(ID_LABEL, "Nothing to show. Select intent to search");
    add(label);
    label.setOutputMarkupId(true);
    label.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return createQuery() == null;
        }
    });
    OperationResult result = new OperationResult(OPERATION_SEARCH_TASKS_FOR_RESOURCE);
    List<PrismObject<TaskType>> tasks = WebModelServiceUtils.searchObjects(TaskType.class, QueryBuilder.queryFor(TaskType.class, getPageBase().getPrismContext()).item(TaskType.F_OBJECT_REF).ref(getResourceModel().getObject().getOid()).build(), result, getPageBase());
    List<TaskType> tasksForKind = getTasksForKind(tasks);
    List<TaskType> importTasks = new ArrayList<>();
    List<TaskType> syncTasks = new ArrayList<>();
    List<TaskType> reconTasks = new ArrayList<>();
    for (TaskType task : tasksForKind) {
        if (TaskCategory.RECONCILIATION.equals(task.getCategory())) {
            reconTasks.add(task);
        } else if (TaskCategory.LIVE_SYNCHRONIZATION.equals(task.getCategory())) {
            syncTasks.add(task);
        } else if (TaskCategory.IMPORTING_ACCOUNTS.equals(task.getCategory())) {
            importTasks.add(task);
        }
    }
    initButton(ID_IMPORT, "Import", " fa-download", TaskCategory.IMPORTING_ACCOUNTS, importTasks);
    initButton(ID_RECONCILIATION, "Reconciliation", " fa-link", TaskCategory.RECONCILIATION, reconTasks);
    initButton(ID_LIVE_SYNC, "Live Sync", " fa-refresh", TaskCategory.LIVE_SYNCHRONIZATION, syncTasks);
    initCustomLayout();
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) InlineMenuHeaderColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismObject(com.evolveum.midpoint.prism.PrismObject) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

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