Search in sources :

Example 11 with SelectableBeanImpl

use of com.evolveum.midpoint.web.component.util.SelectableBeanImpl 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 12 with SelectableBeanImpl

use of com.evolveum.midpoint.web.component.util.SelectableBeanImpl 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)

Example 13 with SelectableBeanImpl

use of com.evolveum.midpoint.web.component.util.SelectableBeanImpl in project midpoint by Evolveum.

the class ObjectDataProvider method internalIterator.

@Override
public Iterator<W> internalIterator(long first, long count) {
    LOGGER.trace("begin::iterator() from {} count {}.", first, count);
    for (W available : getAvailableData()) {
        if (available instanceof SelectableBeanImpl) {
            SelectableBeanImpl<O> selectableBean = (SelectableBeanImpl<O>) available;
            if (selectableBean.isSelected() && selectableBean.getValue() != null) {
                selected.add(selectableBean.getValue());
            }
        }
    }
    for (W available : getAvailableData()) {
        if (available instanceof SelectableBeanImpl) {
            SelectableBeanImpl<O> selectableBean = (SelectableBeanImpl<O>) available;
            if (!selectableBean.isSelected()) {
                selected.remove(selectableBean.getValue());
            }
        }
    }
    getAvailableData().clear();
    OperationResult result = new OperationResult(OPERATION_SEARCH_OBJECTS);
    try {
        ObjectPaging paging = createPaging(first, count);
        Task task = getPageBase().createSimpleTask(OPERATION_SEARCH_OBJECTS);
        ObjectQuery query = getQuery();
        if (query == null) {
            query = getPrismContext().queryFactory().createQuery();
        }
        query.setPaging(paging);
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Query {} with {}", getType().getSimpleName(), query.debugDump());
        }
        List<PrismObject<O>> list = getModel().searchObjects(getType(), query, getOptionsToUse(), task, result);
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Query {} resulted in {} objects", getType().getSimpleName(), list.size());
        }
        for (PrismObject<O> object : list) {
            getAvailableData().add(createDataObjectWrapper(object));
        }
    } catch (Exception ex) {
        result.recordFatalError(getPageBase().createStringResource("ObjectDataProvider.message.listObjects.fatalError").getString(), ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list objects", ex);
    } finally {
        result.computeStatusIfUnknown();
    }
    if (!WebComponentUtil.isSuccessOrHandledError(result)) {
        handleNotSuccessOrHandledErrorInIterator(result);
    }
    LOGGER.trace("end::iterator()");
    return getAvailableData().iterator();
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) Task(com.evolveum.midpoint.task.api.Task) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 14 with SelectableBeanImpl

use of com.evolveum.midpoint.web.component.util.SelectableBeanImpl in project midpoint by Evolveum.

the class TreeTablePanel method moveRootPerformed.

private void moveRootPerformed(final TreeSelectableBean<OrgType> root, AjaxRequestTarget target) {
    OrgTreeAssignablePanel orgAssignablePanel = new OrgTreeAssignablePanel(parentPage.getMainPopupBodyId(), false) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onItemSelect(SelectableBeanImpl<OrgType> selected, AjaxRequestTarget target) {
            moveConfirmPerformed(root, selected, target);
        }

        @SuppressWarnings("unchecked")
        @Override
        protected OrgType getAssignmentOwnerObject() {
            return root.getValue();
        }
    };
    orgAssignablePanel.setOutputMarkupId(true);
    parentPage.showMainPopup(orgAssignablePanel, target);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) OrgTreeAssignablePanel(com.evolveum.midpoint.web.page.admin.orgs.OrgTreeAssignablePanel)

Example 15 with SelectableBeanImpl

use of com.evolveum.midpoint.web.component.util.SelectableBeanImpl in project midpoint by Evolveum.

the class ResourceDetailsTabPanel method initLayout.

protected void initLayout() {
    // PrismObject<ResourceType> resourceObject = getObjectWrapper().getObject();
    // ResourceType resource = resourceObject.asObjectable();
    add(createLastAvailabilityStatusInfo());
    add(createSourceTargetInfo());
    add(createSchemaStatusInfo());
    CapabilitiesPanel capabilities = new CapabilitiesPanel(PANEL_CAPABILITIES, capabilitiesModel);
    add(capabilities);
    ListDataProvider<ResourceConfigurationDto> resourceConfigProvider = new ListDataProvider<>(ResourceDetailsTabPanel.this, createResourceConfigListModel());
    List<IColumn<SelectableBeanImpl<ResourceType>, String>> tableColumns = new ArrayList<>();
    tableColumns.add(ColumnUtils.createPropertyColumn(new ColumnTypeDto<>("ShadowType.kind", "objectTypeDefinition.kind", ShadowType.F_KIND.getLocalPart())));
    tableColumns.add(new PropertyColumn<>(createStringResource("ShadowType.objectClass"), "objectTypeDefinition.objectClass") {

        @Override
        public IModel<?> getDataModel(IModel<SelectableBeanImpl<ResourceType>> rowModel) {
            IModel<QName> model = (IModel<QName>) super.getDataModel(rowModel);
            if (model.getObject() != null) {
                return () -> model.getObject().getLocalPart();
            }
            return model;
        }
    });
    List<ColumnTypeDto<String>> columns = Arrays.asList(new ColumnTypeDto<>("ShadowType.intent", "objectTypeDefinition.intent", ShadowType.F_INTENT.getLocalPart()), new ColumnTypeDto<>("ResourceType.isSync", "sync", null));
    tableColumns.addAll(ColumnUtils.createColumns(columns));
    PropertyColumn tasksColumn = new PropertyColumn(PageBase.createStringResourceStatic(this, "ResourceType.tasks"), "definedTasks") {

        @Override
        public void populateItem(Item item, String componentId, final IModel rowModel) {
            ResourceConfigurationDto conf = (ResourceConfigurationDto) rowModel.getObject();
            RepeatingView repeater = new RepeatingView(componentId);
            for (final TaskType task : conf.getDefinedTasks()) {
                repeater.add(new AjaxLinkPanel(repeater.newChildId(), new Model<>(task.getName().getOrig())) {

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        ResourceDetailsTabPanel.this.taskDetailsPerformed(target, task.getOid());
                    }
                });
            }
            item.add(repeater);
        }
    };
    tableColumns.add(tasksColumn);
    BoxedTablePanel<ResourceConfigurationDto> resourceConfig = new BoxedTablePanel("resourceConfig", resourceConfigProvider, tableColumns);
    resourceConfig.setAdditionalBoxCssClasses("box-success");
    add(resourceConfig);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) ResourceConfigurationDto(com.evolveum.midpoint.web.page.admin.resources.dto.ResourceConfigurationDto) ColumnTypeDto(com.evolveum.midpoint.web.component.data.column.ColumnTypeDto) Item(org.apache.wicket.markup.repeater.Item) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) AjaxLinkPanel(com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel) CapabilitiesPanel(com.evolveum.midpoint.web.page.admin.resources.CapabilitiesPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) Model(org.apache.wicket.model.Model) ResourceDetailsModel(com.evolveum.midpoint.gui.impl.page.admin.resource.ResourceDetailsModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Aggregations

SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)18 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)14 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)12 ArrayList (java.util.ArrayList)12 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)9 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)9 IModel (org.apache.wicket.model.IModel)9 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)8 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)7 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)6 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)5 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)5 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)4 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)3 ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)3 List (java.util.List)3 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)2 AjaxLinkPanel (com.evolveum.midpoint.web.component.data.column.AjaxLinkPanel)2