Search in sources :

Example 26 with BoxedTablePanel

use of com.evolveum.midpoint.web.component.data.BoxedTablePanel in project midpoint by Evolveum.

the class MultipleAssignmentSelector method replaceTable.

private void replaceTable(AjaxRequestTarget target) {
    BoxedTablePanel table = initTablePanel();
    MultipleAssignmentSelector.this.replace(table);
    target.add(MultipleAssignmentSelector.this);
}
Also used : BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel)

Example 27 with BoxedTablePanel

use of com.evolveum.midpoint.web.component.data.BoxedTablePanel in project midpoint by Evolveum.

the class AuditLogViewerPanel method addOrReplaceTable.

private void addOrReplaceTable(Form mainForm) {
    AuditEventRecordProvider provider = new AuditEventRecordProvider(AuditLogViewerPanel.this) {

        private static final long serialVersionUID = 1L;

        public Map<String, Object> getParameters() {
            Map<String, Object> parameters = new HashMap<String, Object>();
            AuditSearchDto search = auditSearchDto.getObject();
            parameters.put("from", search.getFrom());
            parameters.put("to", search.getTo());
            if (search.getChannel() != null) {
                parameters.put("channel", QNameUtil.qNameToUri(search.getChannel()));
            }
            parameters.put("hostIdentifier", search.getHostIdentifier());
            if (search.getInitiatorName() != null) {
                parameters.put("initiatorName", search.getInitiatorName().getOid());
            }
            if (search.getTargetOwnerName() != null) {
                parameters.put("targetOwnerName", search.getTargetOwnerName().getOid());
            }
            List<String> targetOids = new ArrayList<>();
            if (isNotEmpty(search.getTargetNamesObjects())) {
                targetOids.addAll(search.getTargetNamesObjects().stream().map(ObjectType::getOid).collect(toList()));
            }
            if (isNotEmpty(search.getTargetNames())) {
                targetOids.addAll(search.getTargetNames().stream().map(ObjectReferenceType::getOid).collect(toList()));
            }
            if (!targetOids.isEmpty()) {
                parameters.put("targetNames", targetOids);
            }
            if (search.getChangedItem().toItemPath() != null) {
                ItemPath itemPath = search.getChangedItem().toItemPath();
                parameters.put("changedItem", CanonicalItemPath.create(itemPath).asString());
            }
            parameters.put("eventType", search.getEventType());
            parameters.put("eventStage", search.getEventStage());
            parameters.put("outcome", search.getOutcome());
            if (isNotEmpty(search.getvalueRefTargetNames())) {
                parameters.put(AuditEventRecordProvider.VALUE_REF_TARGET_NAMES_KEY, search.getvalueRefTargetNames().stream().map(ObjectType::getName).map(PolyStringType::getOrig).collect(toList()));
            }
            return parameters;
        }

        @Override
        protected void saveCurrentPage(long from, long count) {
            if (count != 0) {
                auditLogStorage.setPageNumber(from / count);
            }
        }
    };
    UserProfileStorage userProfile = pageBase.getSessionStorage().getUserProfile();
    int pageSize = DEFAULT_PAGE_SIZE;
    if (userProfile.getTables().containsKey(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER)) {
        pageSize = userProfile.getPagingSize(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER);
    }
    List<IColumn<AuditEventRecordType, String>> columns = initColumns();
    BoxedTablePanel<AuditEventRecordType> table = new BoxedTablePanel<AuditEventRecordType>(ID_TABLE, provider, columns, UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER, pageSize) {

        private static final long serialVersionUID = 1L;

        @Override
        protected WebMarkupContainer createButtonToolbar(String id) {
            String fileName = "AuditLogViewer_" + createStringResource("MainObjectListPanel.exportFileName").getString();
            CSVDataExporter csvDataExporter = new CSVDataExporter() {

                @Override
                public <T> void exportData(IDataProvider<T> dataProvider, List<IExportableColumn<T, ?>> columns, OutputStream outputStream) throws IOException {
                    ((AuditEventRecordProvider) dataProvider).setExportSize(true);
                    super.exportData(dataProvider, columns, outputStream);
                    ((AuditEventRecordProvider) dataProvider).setExportSize(false);
                }
            };
            ResourceStreamResource resource = (new ResourceStreamResource() {

                protected IResourceStream getResourceStream() {
                    return new ExportToolbar.DataExportResourceStreamWriter(csvDataExporter, getAuditLogViewerTable().getDataTable());
                }
            }).setFileName(fileName + "." + csvDataExporter.getFileNameExtension());
            AbstractLink exportDataLink = (new ResourceLink(id, resource)).setBody(csvDataExporter.getDataFormatNameModel());
            exportDataLink.add(new AttributeAppender("class", " btn btn-primary btn-sm"));
            return exportDataLink;
        }

        @Override
        public void setShowPaging(boolean show) {
        //we don't need to do anything here
        }
    };
    table.setShowPaging(true);
    table.setCurrentPage(auditLogStorage.getPageNumber());
    table.setOutputMarkupId(true);
    mainForm.addOrReplace(table);
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) CSVDataExporter(org.apache.wicket.extensions.markup.html.repeater.data.table.export.CSVDataExporter) HashMap(java.util.HashMap) AuditSearchDto(com.evolveum.midpoint.web.page.admin.reports.dto.AuditSearchDto) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) IDataProvider(org.apache.wicket.markup.repeater.data.IDataProvider) AuditEventRecordProvider(com.evolveum.midpoint.web.page.admin.reports.dto.AuditEventRecordProvider) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) ResourceStreamResource(org.apache.wicket.request.resource.ResourceStreamResource) ResourceLink(org.apache.wicket.markup.html.link.ResourceLink) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink) CanonicalItemPath(com.evolveum.midpoint.prism.path.CanonicalItemPath) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 28 with BoxedTablePanel

use of com.evolveum.midpoint.web.component.data.BoxedTablePanel in project midpoint by Evolveum.

the class JasperReportConfigurationPanel method initParametersTable.

private void initParametersTable() {
    ISortableDataProvider<JasperReportParameterDto, String> provider = new ListDataProvider<JasperReportParameterDto>(this, new PropertyModel<List<JasperReportParameterDto>>(getModel(), "jasperReportDto.parameters"));
    BoxedTablePanel<JasperReportParameterDto> table = new BoxedTablePanel<>(ID_PARAMETERS_TABLE, provider, initParameterColumns(), null, 10);
    //		table.setShowPaging(false);
    table.setOutputMarkupId(true);
    add(table);
    AjaxButton addParameter = new AjaxButton(ID_BUTTON_ADD_PARAMETER, createStringResource("JasperReportConfigurationPanel.addParameter")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addParameterPerformed(target);
        }
    };
    add(addParameter);
    AjaxButton deleteParameter = new AjaxButton(ID_DELETE_PARAMETER, createStringResource("JasperReportConfigurationPanel.deleteParameter")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            deleteParameterPerformed(target);
        }
    };
    add(deleteParameter);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ArrayList(java.util.ArrayList) List(java.util.List) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) JasperReportParameterDto(com.evolveum.midpoint.web.page.admin.reports.dto.JasperReportParameterDto)

Example 29 with BoxedTablePanel

use of com.evolveum.midpoint.web.component.data.BoxedTablePanel in project midpoint by Evolveum.

the class PageDebugList method addOrReplaceTable.

private void addOrReplaceTable(RepositoryObjectDataProvider provider) {
    Form mainForm = (Form) get(ID_MAIN_FORM);
    BoxedTablePanel table = new BoxedTablePanel(ID_TABLE, provider, initColumns(provider.getType()), UserProfileStorage.TableId.CONF_DEBUG_LIST_PANEL, (int) getItemsPerPage(UserProfileStorage.TableId.CONF_DEBUG_LIST_PANEL)) {

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return new SearchFragment(headerId, ID_TABLE_HEADER, PageDebugList.this, searchModel, resourcesModel);
        }
    };
    table.setOutputMarkupId(true);
    ConfigurationStorage storage = getSessionStorage().getConfiguration();
    table.setCurrentPage(storage.getPaging());
    mainForm.addOrReplace(table);
}
Also used : ConfigurationStorage(com.evolveum.midpoint.web.session.ConfigurationStorage) Form(org.apache.wicket.markup.html.form.Form) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel)

Example 30 with BoxedTablePanel

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

Aggregations

BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)39 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)13 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)13 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)12 IModel (org.apache.wicket.model.IModel)10 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)9 ArrayList (java.util.ArrayList)9 Item (org.apache.wicket.markup.repeater.Item)9 QName (javax.xml.namespace.QName)6 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)5 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)5 List (java.util.List)5 Label (org.apache.wicket.markup.html.basic.Label)5 Form (org.apache.wicket.markup.html.form.Form)5 ListItem (org.apache.wicket.markup.html.list.ListItem)5 ReadOnlyModel (com.evolveum.midpoint.gui.api.model.ReadOnlyModel)4 ObjectOrdering (com.evolveum.midpoint.prism.query.ObjectOrdering)4