Search in sources :

Example 51 with SelectableBean

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

the class PageAccounts method createAccountsColumns.

private List<IColumn> createAccountsColumns() {
    List<IColumn> columns = new ArrayList<>();
    columns.add(new PropertyColumn(createStringResource("PageAccounts.accounts.oid"), SelectableBean.F_VALUE + ".oid"));
    columns.add(new PropertyColumn<>(createStringResource("PageAccounts.accounts.name"), ShadowType.F_NAME.getLocalPart(), SelectableBean.F_VALUE + ".name"));
    columns.add(new PropertyColumn<>(createStringResource("PageAccounts.accounts.kind"), ShadowType.F_KIND.getLocalPart(), SelectableBean.F_VALUE + ".kind"));
    columns.add(new PropertyColumn<>(createStringResource("PageAccounts.accounts.intent"), ShadowType.F_INTENT.getLocalPart(), SelectableBean.F_VALUE + ".intent"));
    columns.add(new PropertyColumn<QName, String>(createStringResource("PageAccounts.accounts.objectClass"), ShadowType.F_OBJECT_CLASS.getLocalPart(), SelectableBean.F_VALUE + ".objectClass.localPart"));
    columns.add(new PropertyColumn<>(createStringResource("PageAccounts.accounts.synchronizationSituation"), ShadowType.F_SYNCHRONIZATION_SITUATION.getLocalPart(), SelectableBean.F_VALUE + ".synchronizationSituation"));
    columns.add(new PropertyColumn<>(createStringResource("PageAccounts.accounts.synchronizationTimestamp"), ShadowType.F_SYNCHRONIZATION_TIMESTAMP.getLocalPart(), SelectableBean.F_VALUE + ".synchronizationTimestamp"));
    //        columns.add(new PropertyColumn<>(createStringResource("PageAccounts.accounts.result"),
    //                ShadowType.F_RESULT.getLocalPart(), SelectableBean.F_VALUE + ".result.status"));
    columns.add(new LinkColumn<SelectableBean>(createStringResource("PageAccounts.accounts.result")) {

        @Override
        protected IModel<String> createLinkModel(final IModel<SelectableBean> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    OperationResultType result = getResult(rowModel);
                    if (result == null) {
                        return "";
                    }
                    return createStringResource("OperationResultStatusType." + result.getStatus()).getObject();
                }
            };
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<SelectableBean> rowModel) {
            showShadowResult(target, rowModel);
        }
    });
    columns.add(new LinkColumn<SelectableBean>(createStringResource("PageAccounts.accounts.owner")) {

        @Override
        protected IModel<String> createLinkModel(final IModel<SelectableBean> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    FocusType focus = loadShadowOwner(rowModel);
                    return WebComponentUtil.getName(focus);
                }
            };
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<SelectableBean> rowModel) {
            ownerDetailsPerformed(target, rowModel);
        }
    });
    return columns;
}
Also used : IModel(org.apache.wicket.model.IModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean)

Example 52 with SelectableBean

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

the class ExportingPanel method createTable.

private BoxedTablePanel<SelectableBean<Integer>> createTable(String id, DataTable<?, ?> dataTable) {
    List<? extends IColumn<?, ?>> allColumns = dataTable.getColumns();
    List<Integer> exportableColumnIndex = getExportableColumns(dataTable);
    if (exportableColumnIndex.isEmpty()) {
        throw new IllegalArgumentException("List of exportable columns is empty");
    }
    List<IColumn<SelectableBean<Integer>, String>> columns = new ArrayList<>();
    CheckBoxHeaderColumn<SelectableBean<Integer>> checkboxColumn = new CheckBoxHeaderColumn<>();
    columns.add(checkboxColumn);
    StringResourceModel nameString = getPageBase().createStringResource("ExportingPopupPanel.nameColumn");
    IColumn<SelectableBean<Integer>, String> nameColumn = new AbstractColumn<SelectableBean<Integer>, String>(nameString) {

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<Integer>>> cellItem, String componentId, IModel<SelectableBean<Integer>> rowModel) {
            IModel stringModel = ((IExportableColumn) allColumns.get(rowModel.getObject().getValue())).getDisplayModel();
            cellItem.add(new Label(componentId, stringModel));
        }
    };
    columns.add(nameColumn);
    SelectableListDataProvider<SelectableBean<Integer>, Integer> provider = new SelectableListDataProvider<SelectableBean<Integer>, Integer>(getPageBase(), Model.ofList(exportableColumnIndex)) {

        @Override
        public Iterator<SelectableBean<Integer>> internalIterator(long first, long count) {
            if (getAvailableData().isEmpty()) {
                return super.internalIterator(first, count);
            } else {
                return getAvailableData().iterator();
            }
        }
    };
    BoxedTablePanel<SelectableBean<Integer>> table = new BoxedTablePanel<SelectableBean<Integer>>(id, provider, columns) {

        private static final long serialVersionUID = 1L;

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return new WebMarkupContainer(headerId);
        }

        @Override
        public String getAdditionalBoxCssClasses() {
            return null;
        }

        @Override
        protected WebMarkupContainer createButtonToolbar(String id) {
            return new WebMarkupContainer(id);
        }

        @Override
        protected boolean hideFooterIfSinglePage() {
            return true;
        }

        @Override
        public int getAutoRefreshInterval() {
            return 0;
        }

        @Override
        public boolean isAutoRefreshEnabled() {
            return false;
        }
    };
    table.setOutputMarkupId(true);
    return table;
}
Also used : IExportableColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.export.IExportableColumn) IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AbstractColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Item(org.apache.wicket.markup.repeater.Item) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) SelectableListDataProvider(com.evolveum.midpoint.web.component.util.SelectableListDataProvider) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 53 with SelectableBean

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

the class ExportingPanel method initLayout.

private void initLayout() {
    MidpointForm form = new MidpointForm<>(ID_MAIN_FORM, true);
    MessagePanel warningMessage = new MessagePanel(ID_WARNING_MESSAGE, MessagePanel.MessagePanelType.WARN, getWarningMessageModel());
    warningMessage.setOutputMarkupId(true);
    warningMessage.add(new VisibleBehaviour(() -> getWarningMessageModel() != null));
    form.add(warningMessage);
    FeedbackAlerts feedbackList = new FeedbackAlerts(ID_FEEDBACK);
    feedbackList.setOutputMarkupId(true);
    feedbackList.setOutputMarkupPlaceholderTag(true);
    form.add(feedbackList);
    TextPanel<String> nameField = new TextPanel<>(ID_NAME, nameModel);
    form.add(nameField);
    BoxedTablePanel<SelectableBean<Integer>> table = createTable(ID_TABLE, dataTable);
    form.add(table);
    AjaxSubmitButton exportSelected = new AjaxSubmitButton(ID_EXPORT, getPageBase().createStringResource("ExportingPopupPanel.exportSelected")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit(AjaxRequestTarget target) {
            performSelectedColumns(table);
            if (exportedColumnsIndex.isEmpty()) {
                LOGGER.warn("None columns selected");
                getPageBase().warn(getPageBase().createStringResource("ExportingPanel.message.error.selectColumn").getString());
                target.add(feedbackList);
                return;
            }
            ((PageBase) getPage()).hideMainPopup(target);
            exportPerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    form.add(exportSelected);
    AjaxButton cancelButton = new AjaxButton(ID_CANCEL, new StringResourceModel("Button.cancel", this, null)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            cancelPerformed(target);
        }
    };
    form.add(cancelButton);
    add(form);
}
Also used : AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) TextPanel(com.evolveum.midpoint.web.component.input.TextPanel) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) FeedbackAlerts(com.evolveum.midpoint.web.component.message.FeedbackAlerts) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) MessagePanel(com.evolveum.midpoint.gui.api.component.result.MessagePanel) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 54 with SelectableBean

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

the class ReportObjectsListPanel method createProvider.

@Override
protected ISelectableDataProvider<C, SelectableBean<C>> createProvider() {
    SelectableBeanContainerDataProvider<C> provider = new SelectableBeanContainerDataProvider<>(this, getSearchModel(), null, false) {

        @Override
        public List<SelectableBean<C>> createDataObjectWrappers(Class<? extends C> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, Task task, OperationResult result) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
            Collection<SelectorOptions<GetOperationOptions>> defaultOptions = DefaultColumnUtils.createOption(getObjectCollectionView().getTargetClass(getPrismContext()), getSchemaService());
            QName qNameType = WebComponentUtil.containerClassToQName(getPrismContext(), type);
            VariablesMap variables = new VariablesMap();
            if (getSearchModel().getObject() != null) {
                variables.putAll(getSearchModel().getObject().getFilterVariables(getVariables(), getPageBase()));
                processReferenceVariables(variables);
            }
            List<C> list = (List<C>) getModelInteractionService().searchObjectsFromCollection(getReport().getObjectCollection().getCollection(), qNameType, defaultOptions, query.getPaging(), variables, task, result);
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Query {} resulted in {} objects", type.getSimpleName(), list.size());
            }
            List<SelectableBean<C>> data = new ArrayList<SelectableBean<C>>();
            for (C object : list) {
                data.add(createDataObjectWrapper(object));
            }
            return data;
        }

        @Override
        protected Integer countObjects(Class<? extends C> type, ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> currentOptions, Task task, OperationResult result) throws CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
            Collection<SelectorOptions<GetOperationOptions>> defaultOptions = DefaultColumnUtils.createOption(getObjectCollectionView().getTargetClass(getPrismContext()), getSchemaService());
            QName qNameType = WebComponentUtil.containerClassToQName(getPrismContext(), type);
            VariablesMap variables = new VariablesMap();
            if (getSearchModel().getObject() != null) {
                variables.putAll(getSearchModel().getObject().getFilterVariables(getVariables(), getPageBase()));
                processReferenceVariables(variables);
            }
            return getModelInteractionService().countObjectsFromCollection(getReport().getObjectCollection().getCollection(), qNameType, defaultOptions, null, variables, task, result);
        }

        @Override
        protected boolean isUseObjectCounting() {
            return !isDisableCounting();
        }

        @Override
        public boolean isOrderingDisabled() {
            return isDisableSorting();
        }

        @Override
        public ObjectQuery getQuery() {
            // fake query because of we need paging in method createDataObjectWrappers
            return getPrismContext().queryFor(ObjectType.class).build();
        }

        @Override
        @NotNull
        protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
            if (AuditEventRecordType.class.equals(getDefaultType()) && sortParam != null && sortParam.getProperty() != null) {
                OrderDirection order = sortParam.isAscending() ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
                return Collections.singletonList(getPrismContext().queryFactory().createOrdering(ItemPath.create(new QName(AuditEventRecordType.COMPLEX_TYPE.getNamespaceURI(), sortParam.getProperty())), order));
            }
            return super.createObjectOrderings(sortParam);
        }
    };
    if (provider.getSort() == null && hasView()) {
        if (ObjectType.class.isAssignableFrom(getDefaultType())) {
            provider.setSort("name", SortOrder.ASCENDING);
        } else if (AuditEventRecordType.class.isAssignableFrom(getDefaultType())) {
            provider.setSort("timestamp", SortOrder.ASCENDING);
        }
    }
    return provider;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectOrdering(com.evolveum.midpoint.prism.query.ObjectOrdering) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) SortParam(org.apache.wicket.extensions.markup.html.repeater.util.SortParam) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) SelectableBeanContainerDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanContainerDataProvider) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) OrderDirection(com.evolveum.midpoint.prism.query.OrderDirection)

Example 55 with SelectableBean

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

Aggregations

SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)73 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)39 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)37 IModel (org.apache.wicket.model.IModel)37 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)32 ArrayList (java.util.ArrayList)31 Label (org.apache.wicket.markup.html.basic.Label)22 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)16 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)16 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)15 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)14 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)12 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)12 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)12 Item (org.apache.wicket.markup.repeater.Item)11 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)9 SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)8 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)8 List (java.util.List)8 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)7