Search in sources :

Example 1 with AjaxIconButton

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

the class PageCertDecisions method initColumns.

// private void addVisibleOnWarningBehavior(Component c) {
// c.add(new VisibleEnableBehaviour() {
// @Override
// public boolean isVisible() {
// return PageCertDecisions.this.getFeedbackMessages().hasMessage(FeedbackMessage.WARNING);
// }
// });
// }
private List<IColumn<CertWorkItemDto, String>> initColumns() {
    List<IColumn<CertWorkItemDto, String>> columns = new ArrayList<>();
    IColumn<CertWorkItemDto, String> column;
    column = new CheckBoxHeaderColumn<>();
    columns.add(column);
    column = helper.createTypeColumn(OBJECT, this);
    columns.add(column);
    column = helper.createObjectNameColumn(this, "PageCertDecisions.table.objectName");
    columns.add(column);
    column = helper.createTypeColumn(TARGET, this);
    columns.add(column);
    column = helper.createTargetNameColumn(this, "PageCertDecisions.table.targetName");
    columns.add(column);
    if (isDisplayingAllItems()) {
        column = helper.createReviewerNameColumn(this, "PageCertDecisions.table.reviewer");
        columns.add(column);
    }
    column = helper.createDetailedInfoColumn(this);
    columns.add(column);
    column = helper.createConflictingNameColumn(this, "PageCertDecisions.table.conflictingTargetName");
    columns.add(column);
    if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_CERTIFICATION_ALL_URL, AuthorizationConstants.AUTZ_UI_CERTIFICATION_CAMPAIGN_URL)) {
        column = new AjaxLinkColumn<CertWorkItemDto>(createStringResource("PageCertDecisions.table.campaignName"), SearchingUtils.CAMPAIGN_NAME, CertWorkItemDto.F_CAMPAIGN_NAME) {

            private static final long serialVersionUID = 1L;

            @Override
            public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, IModel<CertWorkItemDto> rowModel) {
                super.populateItem(item, componentId, rowModel);
                AccessCertificationCampaignType campaign = rowModel.getObject().getCampaign();
                if (campaign != null && campaign.getDescription() != null) {
                    item.add(AttributeModifier.replace("title", campaign.getDescription()));
                    item.add(new TooltipBehavior());
                }
            }

            @Override
            public void onClick(AjaxRequestTarget target, IModel<CertWorkItemDto> rowModel) {
                CertWorkItemDto dto = rowModel.getObject();
                PageParameters parameters = new PageParameters();
                parameters.add(OnePageParameterEncoder.PARAMETER, dto.getCampaignRef().getOid());
                navigateToNext(PageCertCampaign.class, parameters);
            }
        };
    } else {
        column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.campaignName"), SearchingUtils.CAMPAIGN_NAME) {

            private static final long serialVersionUID = 1L;

            @Override
            public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
                item.add(new Label(componentId, new IModel<Object>() {

                    @Override
                    public Object getObject() {
                        return rowModel.getObject().getCampaignName();
                    }
                }));
            }
        };
    }
    columns.add(column);
    column = new PropertyColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.iteration"), CertCaseOrWorkItemDto.F_ITERATION) {

        private static final long serialVersionUID = 1L;

        @Override
        public String getCssClass() {
            return "countLabel";
        }
    };
    columns.add(column);
    column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.campaignStage")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
            item.add(new Label(componentId, new IModel<String>() {

                @Override
                public String getObject() {
                    CertWorkItemDto dto = rowModel.getObject();
                    return dto.getCampaignStageNumber() + "/" + dto.getCampaignStageCount();
                }
            }));
            String stageName = rowModel.getObject().getCurrentStageName();
            if (stageName != null) {
                item.add(AttributeModifier.replace("title", stageName));
                item.add(new TooltipBehavior());
            }
        }

        @Override
        public String getCssClass() {
            return "countLabel";
        }
    };
    columns.add(column);
    column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.escalation")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
            item.add(new Label(componentId, new IModel<String>() {

                @Override
                public String getObject() {
                    CertWorkItemDto dto = rowModel.getObject();
                    Integer n = dto.getEscalationLevelNumber();
                    return n != null ? String.valueOf(n) : null;
                }
            }));
            String info = rowModel.getObject().getEscalationLevelInfo();
            if (info != null) {
                item.add(AttributeModifier.replace("title", info));
                item.add(new TooltipBehavior());
            }
        }

        @Override
        public String getCssClass() {
            return "countLabel";
        }
    };
    columns.add(column);
    column = new PropertyColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.requested"), SearchingUtils.CURRENT_REVIEW_REQUESTED_TIMESTAMP, CertWorkItemDto.F_REVIEW_REQUESTED) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, IModel<CertWorkItemDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            CertWorkItemDto dto = rowModel.getObject();
            Date started = dto.getStageStarted();
            if (started != null) {
                item.add(AttributeModifier.replace("title", WebComponentUtil.getShortDateTimeFormattedValue(started, PageCertDecisions.this)));
                item.add(new TooltipBehavior());
            }
        }
    };
    columns.add(column);
    column = new PropertyColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.deadline"), SearchingUtils.CURRENT_REVIEW_DEADLINE, CertWorkItemDto.F_DEADLINE_AS_STRING) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            XMLGregorianCalendar deadline = rowModel.getObject().getCertCase().getCurrentStageDeadline();
            if (deadline != null) {
                item.add(AttributeModifier.replace("title", WebComponentUtil.formatDate(deadline)));
                item.add(new TooltipBehavior());
            }
        }
    };
    columns.add(column);
    final AvailableResponses availableResponses = new AvailableResponses(this);
    final int responses = availableResponses.getResponseKeys().size();
    column = new AbstractColumn<CertWorkItemDto, String>(new Model<>()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> cellItem, String componentId, IModel<CertWorkItemDto> rowModel) {
            cellItem.add(new MultiButtonPanel<CertWorkItemDto>(componentId, rowModel, responses + 1) {

                private static final long serialVersionUID = 1L;

                @Override
                protected Component createButton(int index, String componentId, IModel<CertWorkItemDto> model) {
                    AjaxIconButton btn;
                    if (index < responses) {
                        btn = buildDefaultButton(componentId, null, new Model(availableResponses.getTitle(index)), new Model<>("btn btn-sm " + getDecisionButtonColor(model, availableResponses.getResponseValues().get(index))), target -> recordActionPerformed(target, model.getObject(), availableResponses.getResponseValues().get(index)));
                        btn.add(new EnableBehaviour(() -> !decisionEquals(model, availableResponses.getResponseValues().get(index))));
                    } else {
                        btn = buildDefaultButton(componentId, null, new Model(availableResponses.getTitle(index)), new Model<>("btn btn-sm " + ButtonColorClass.DANGER), null);
                        btn.setEnabled(false);
                        btn.add(new VisibleBehaviour(() -> !availableResponses.isAvailable(model.getObject().getResponse())));
                    }
                    return btn;
                }
            });
        }
    };
    columns.add(column);
    column = new DirectlyEditablePropertyColumn<CertWorkItemDto>(createStringResource("PageCertDecisions.table.comment"), CertWorkItemDto.F_COMMENT) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onBlur(AjaxRequestTarget target, IModel model) {
            // TODO determine somehow if the model.comment was really changed
            recordActionPerformed(target, (CertWorkItemDto) model.getObject(), null);
        }
    };
    columns.add(column);
    columns.add(new InlineMenuHeaderColumn(createInlineMenu(availableResponses)));
    return columns;
}
Also used : VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) Date(java.util.Date) PageDescriptor(com.evolveum.midpoint.authentication.api.authorization.PageDescriptor) AuthorizationConstants(com.evolveum.midpoint.security.api.AuthorizationConstants) ButtonColorClass(com.evolveum.midpoint.web.component.data.column.DoubleButtonColumn.ButtonColorClass) com.evolveum.midpoint.web.page.admin.certification.dto(com.evolveum.midpoint.web.page.admin.certification.dto) AbstractColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) Model(org.apache.wicket.model.Model) Component(org.apache.wicket.Component) MarkupContainer(org.apache.wicket.MarkupContainer) WebComponentUtil(com.evolveum.midpoint.gui.api.util.WebComponentUtil) Task(com.evolveum.midpoint.task.api.Task) AttributeModifier(org.apache.wicket.AttributeModifier) OnePageParameterEncoder(com.evolveum.midpoint.web.util.OnePageParameterEncoder) List(java.util.List) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) Item(org.apache.wicket.markup.repeater.Item) SystemException(com.evolveum.midpoint.util.exception.SystemException) SortOrder(org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType) Form(org.apache.wicket.markup.html.form.Form) com.evolveum.midpoint.web.component.data.column(com.evolveum.midpoint.web.component.data.column) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) Trace(com.evolveum.midpoint.util.logging.Trace) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) OBJECT(com.evolveum.midpoint.web.page.admin.certification.CertDecisionHelper.WhichObject.OBJECT) Table(com.evolveum.midpoint.web.component.data.Table) AvailableResponses(com.evolveum.midpoint.web.page.admin.certification.helpers.AvailableResponses) CheckBox(org.apache.wicket.markup.html.form.CheckBox) ArrayList(java.util.ArrayList) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) Fragment(org.apache.wicket.markup.html.panel.Fragment) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour) Url(com.evolveum.midpoint.authentication.api.authorization.Url) CertDecisionsStorage(com.evolveum.midpoint.web.session.CertDecisionsStorage) DataTable(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable) AccessCertificationResponseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationResponseType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) MultiButtonPanel(com.evolveum.midpoint.web.component.data.MultiButtonPanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) HeaderMenuAction(com.evolveum.midpoint.web.page.admin.configuration.component.HeaderMenuAction) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) TARGET(com.evolveum.midpoint.web.page.admin.certification.CertDecisionHelper.WhichObject.TARGET) AuthorizationAction(com.evolveum.midpoint.authentication.api.authorization.AuthorizationAction) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AvailableResponses(com.evolveum.midpoint.web.page.admin.certification.helpers.AvailableResponses) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour) IModel(org.apache.wicket.model.IModel) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Date(java.util.Date) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) MultiButtonPanel(com.evolveum.midpoint.web.component.data.MultiButtonPanel)

Example 2 with AjaxIconButton

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

the class PageCertCampaign method initColumns.

private List<IColumn<CertCaseDto, String>> initColumns() {
    List<IColumn<CertCaseDto, String>> columns = new ArrayList<>();
    IColumn column;
    column = helper.createTypeColumn(OBJECT, this);
    columns.add(column);
    column = helper.createObjectNameColumn(this, "PageCertCampaign.table.objectName");
    columns.add(column);
    column = helper.createTypeColumn(TARGET, this);
    columns.add(column);
    column = helper.createTargetNameColumn(this, "PageCertCampaign.table.targetName");
    columns.add(column);
    column = helper.createDetailedInfoColumn(this);
    columns.add(column);
    if (AccessCertificationApiConstants.EXCLUSION_HANDLER_URI.equals(campaignModel.getObject().getHandlerUri())) {
        column = helper.createConflictingNameColumn(this, "PageCertCampaign.table.conflictingTargetName");
        columns.add(column);
    }
    column = new PropertyColumn(createStringResource("PageCertCampaign.table.reviewers"), CertCaseDto.F_CURRENT_REVIEWERS);
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaign.table.reviewedAt"), CertCaseDto.F_REVIEWED_AT);
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaign.table.reviewedBy"), CertCaseDto.F_REVIEWED_BY);
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaign.table.reviewedInStage"), CertCaseDto.F_CURRENT_RESPONSE_STAGE_NUMBER);
    columns.add(column);
    final AvailableResponses availableResponses = new AvailableResponses(this);
    final int responses = availableResponses.getCount();
    column = new AbstractColumn<CertCaseDto, String>(new Model<>()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<CertCaseDto>> cellItem, String componentId, IModel<CertCaseDto> rowModel) {
            cellItem.add(new MultiButtonPanel<CertCaseDto>(componentId, rowModel, responses + 1) {

                private static final long serialVersionUID = 1L;

                @Override
                protected Component createButton(int index, String componentId, IModel<CertCaseDto> model) {
                    AjaxIconButton btn = null;
                    if (index < responses) {
                        btn = buildDefaultButton(componentId, null, new Model(availableResponses.getTitle(index)), new Model<>("btn btn-sm " + getDecisionButtonColor(model, availableResponses.getResponseValues().get(index))), null);
                    } else {
                        btn = buildDefaultButton(componentId, null, new Model(availableResponses.getTitle(index)), new Model<>("btn btn-sm " + ButtonColorClass.DANGER), null);
                        btn.add(new VisibleBehaviour(() -> !availableResponses.isAvailable(model.getObject().getOverallOutcome())));
                    }
                    btn.setEnabled(false);
                    return btn;
                }
            });
        }
    };
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaign.table.comments"), CertCaseDto.F_COMMENTS);
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageCertCampaign.table.remediedAt"), CertCaseDto.F_REMEDIED_AT);
    columns.add(column);
    return columns;
}
Also used : IModel(org.apache.wicket.model.IModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) CertCaseDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCaseDto) AvailableResponses(com.evolveum.midpoint.web.page.admin.certification.helpers.AvailableResponses) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) NonEmptyLoadableModel(com.evolveum.midpoint.gui.api.model.NonEmptyLoadableModel) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) MultiButtonPanel(com.evolveum.midpoint.web.component.data.MultiButtonPanel)

Example 3 with AjaxIconButton

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

the class CsvDownloadButtonPanel method initLayout.

private void initLayout() {
    CSVDataExporter csvDataExporter = new CSVDataExporter() {

        private static final long serialVersionUID = 1L;

        @Override
        public <T> void exportData(IDataProvider<T> dataProvider, List<IExportableColumn<T, ?>> columns, OutputStream outputStream) {
            if (dataProvider instanceof SelectableBeanContainerDataProvider) {
                // TODO implement more nicely
                ((SelectableBeanContainerDataProvider) dataProvider).setExport(true);
            }
            try {
                ((BaseSortableDataProvider) dataProvider).setExportSize(true);
                super.exportData(dataProvider, getExportableColumns(), outputStream);
                ((BaseSortableDataProvider) dataProvider).setExportSize(false);
            } catch (Exception ex) {
                LOGGER.error("Unable to export data,", ex);
            } finally {
                if (dataProvider instanceof SelectableBeanContainerDataProvider) {
                    ((SelectableBeanContainerDataProvider) dataProvider).setExport(false);
                }
            }
        }

        @Override
        protected <T> IModel<T> wrapModel(IModel<T> model) {
            if (model.getObject() == null) {
                return () -> (T) "";
            }
            if (model.getObject() instanceof Referencable) {
                return () -> {
                    String value = WebModelServiceUtils.resolveReferenceName((Referencable) model.getObject(), getPageBase());
                    return (T) (value == null ? "" : value);
                };
            }
            return super.wrapModel(model);
        }
    };
    IModel<String> name = Model.of("");
    final AbstractAjaxDownloadBehavior ajaxDownloadBehavior = new AbstractAjaxDownloadBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        public IResourceStream getResourceStream() {
            return new ExportToolbar.DataExportResourceStreamWriter(csvDataExporter, getDataTable());
        }

        public String getFileName() {
            if (StringUtils.isEmpty(name.getObject())) {
                return CsvDownloadButtonPanel.this.getFilename();
            }
            return name.getObject();
        }
    };
    add(ajaxDownloadBehavior);
    AjaxIconButton exportDataLink = new AjaxIconButton(ID_EXPORT_DATA, new Model<>("fa fa-download"), createStringResource("CsvDownloadButtonPanel.export")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            long exportSizeLimit = -1;
            try {
                CompiledGuiProfile adminGuiConfig = getPageBase().getCompiledGuiProfile();
                if (adminGuiConfig.getDefaultExportSettings() != null && adminGuiConfig.getDefaultExportSettings().getSizeLimit() != null) {
                    exportSizeLimit = adminGuiConfig.getDefaultExportSettings().getSizeLimit();
                }
            } catch (Exception ex) {
                LOGGER.error("Unable to get csv export size limit,", ex);
            }
            boolean askForSizeLimitConfirmation;
            if (exportSizeLimit < 0) {
                askForSizeLimitConfirmation = false;
            } else {
                if (canCountBeforeExporting) {
                    IDataProvider<?> dataProvider = getDataTable().getDataProvider();
                    long size = dataProvider.size();
                    askForSizeLimitConfirmation = size > exportSizeLimit;
                } else {
                    // size is unknown
                    askForSizeLimitConfirmation = true;
                }
            }
            Long useExportSizeLimit = null;
            if (askForSizeLimitConfirmation) {
                useExportSizeLimit = exportSizeLimit;
            }
            exportableColumnsIndex.clear();
            ExportingPanel exportingPanel = new ExportingPanel(getPageBase().getMainPopupBodyId(), getDataTable(), exportableColumnsIndex, useExportSizeLimit, name) {

                private static final long serialVersionUID = 1L;

                @Override
                public void exportPerformed(AjaxRequestTarget target) {
                    ajaxDownloadBehavior.initiate(target);
                }
            };
            getPageBase().showMainPopup(exportingPanel, target);
        }
    };
    add(exportDataLink);
}
Also used : Referencable(com.evolveum.midpoint.prism.Referencable) CSVDataExporter(org.apache.wicket.extensions.markup.html.repeater.data.table.export.CSVDataExporter) IModel(org.apache.wicket.model.IModel) OutputStream(java.io.OutputStream) IDataProvider(org.apache.wicket.markup.repeater.data.IDataProvider) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) BaseSortableDataProvider(com.evolveum.midpoint.web.component.data.BaseSortableDataProvider) SelectableBeanContainerDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanContainerDataProvider) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) ArrayList(java.util.ArrayList) List(java.util.List) ExportingPanel(com.evolveum.midpoint.web.component.dialog.ExportingPanel) AbstractAjaxDownloadBehavior(com.evolveum.midpoint.web.component.AbstractAjaxDownloadBehavior) CompiledGuiProfile(com.evolveum.midpoint.model.api.authentication.CompiledGuiProfile)

Example 4 with AjaxIconButton

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

the class NotificationConfigTabPanel method initServersTable.

private BoxedTablePanel<MailServerConfiguration> initServersTable(PropertyModel<MailConfigurationType> mailConfigType) {
    List<MailServerConfiguration> mailServers = getListOfMailServerConfiguration(mailConfigType.getObject().getServer());
    PageStorage pageStorage = getPageBase().getSessionStorage().getNotificationConfigurationTabMailServerTableStorage();
    ISortableDataProvider<MailServerConfiguration, String> provider = new ListDataProvider<>(this, new ListModel<>(mailServers) {

        private static final long serialVersionUID = 1L;

        @Override
        public void setObject(List<MailServerConfiguration> object) {
            super.setObject(object);
            mailConfigType.getObject().getServer().clear();
            for (MailServerConfiguration value : object) {
                mailConfigType.getObject().server(value.getValue());
            }
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected PageStorage getPageStorage() {
            return pageStorage;
        }
    };
    UserProfileStorage.TableId tableId = UserProfileStorage.TableId.NOTIFICATION_TAB_MAIL_SERVER_TABLE;
    BoxedTablePanel<MailServerConfiguration> table = new BoxedTablePanel<>(ID_MAIL_SERVERS_TABLE, provider, initMailServersColumns(), tableId) {

        private static final long serialVersionUID = 1L;

        @Override
        public int getItemsPerPage() {
            return getPageBase().getSessionStorage().getUserProfile().getTables().get(getTableId());
        }

        @Override
        protected WebMarkupContainer createButtonToolbar(String id) {
            AjaxIconButton newObjectIcon = new AjaxIconButton(id, new Model<>("fa fa-plus"), createStringResource("MainObjectListPanel.newObject")) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    newItemPerformed(target, mailServers, mailConfigType);
                }
            };
            newObjectIcon.add(AttributeModifier.append("class", Model.of("btn btn-success btn-sm")));
            return newObjectIcon;
        }
    };
    table.setOutputMarkupId(true);
    table.setShowPaging(true);
    return table;
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) PageStorage(com.evolveum.midpoint.web.session.PageStorage)

Example 5 with AjaxIconButton

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

the class FocusHistoryPanel method initLayout.

protected void initLayout() {
    AuditLogViewerPanel panel = new AuditLogViewerPanel(ID_MAIN_PANEL) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<IColumn<SelectableBean<AuditEventRecordType>, String>> createColumns() {
            List<IColumn<SelectableBean<AuditEventRecordType>, String>> columns = super.createColumns();
            IColumn<SelectableBean<AuditEventRecordType>, String> column = new AbstractColumn<SelectableBean<AuditEventRecordType>, String>(new Model<>()) {

                private static final long serialVersionUID = 1L;

                @Override
                public void populateItem(Item<ICellPopulator<SelectableBean<AuditEventRecordType>>> cellItem, String componentId, IModel<SelectableBean<AuditEventRecordType>> rowModel) {
                    cellItem.add(new MultiButtonPanel<SelectableBean<AuditEventRecordType>>(componentId, rowModel, 2) {

                        private static final long serialVersionUID = 1L;

                        @Override
                        protected Component createButton(int index, String componentId, IModel<SelectableBean<AuditEventRecordType>> model) {
                            AjaxIconButton btn = null;
                            switch(index) {
                                case 0:
                                    btn = buildDefaultButton(componentId, new Model<>("fa fa-circle-o"), createStringResource("ObjectHistoryTabPanel.viewHistoricalObjectDataTitle"), new Model<>("btn btn-sm " + DoubleButtonColumn.ButtonColorClass.INFO), target -> currentStateButtonClicked(target, getReconstructedObject(getObjectWrapper().getOid(), unwrapModel(model).getEventIdentifier(), getObjectWrapper().getCompileTimeClass()), WebComponentUtil.getLocalizedDate(unwrapModel(model).getTimestamp(), DateLabelComponent.SHORT_NOTIME_STYLE)));
                                    break;
                                case 1:
                                    btn = buildDefaultButton(componentId, new Model<>(GuiStyleConstants.CLASS_FILE_TEXT), createStringResource("ObjectHistoryTabPanel.viewHistoricalObjectXmlTitle"), new Model<>("btn btn-sm " + DoubleButtonColumn.ButtonColorClass.SUCCESS), target -> viewObjectXmlButtonClicked(getObjectWrapper().getOid(), unwrapModel(model).getEventIdentifier(), getObjectWrapper().getCompileTimeClass(), WebComponentUtil.getLocalizedDate(unwrapModel(model).getTimestamp(), DateLabelComponent.SHORT_NOTIME_STYLE)));
                                    break;
                            }
                            return btn;
                        }
                    });
                }
            };
            columns.add(column);
            return columns;
        }

        @Override
        protected ObjectQuery getCustomizeContentQuery() {
            return getPageBase().getPrismContext().queryFor(AuditEventRecordType.class).item(AuditEventRecordType.F_TARGET_REF).ref(getObjectWrapper().getOid()).and().item(AuditEventRecordType.F_EVENT_STAGE).eq(AuditEventStageType.EXECUTION).build();
        }

        @Override
        protected String getAuditStorageKey(String collectionNameValue) {
            if (StringUtils.isNotEmpty(collectionNameValue)) {
                return SessionStorage.KEY_OBJECT_HISTORY_AUDIT_LOG + "." + collectionNameValue + "." + getObjectWrapper().getTypeName().getLocalPart();
            }
            return SessionStorage.KEY_OBJECT_HISTORY_AUDIT_LOG + "." + getObjectWrapper().getTypeName().getLocalPart();
        }

        @Override
        protected boolean isObjectHistoryPanel() {
            return true;
        }
    };
    panel.setOutputMarkupId(true);
    add(panel);
}
Also used : IModel(org.apache.wicket.model.IModel) AbstractColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn) Item(org.apache.wicket.markup.repeater.Item) AuditLogViewerPanel(com.evolveum.midpoint.web.page.admin.reports.component.AuditLogViewerPanel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) Component(org.apache.wicket.Component) DateLabelComponent(com.evolveum.midpoint.web.component.DateLabelComponent)

Aggregations

AjaxIconButton (com.evolveum.midpoint.web.component.AjaxIconButton)31 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)27 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)11 Component (org.apache.wicket.Component)9 IModel (org.apache.wicket.model.IModel)9 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)7 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)6 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)5 ArrayList (java.util.ArrayList)5 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)4 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)3 List (java.util.List)3 AbstractColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn)3 Item (org.apache.wicket.markup.repeater.Item)3 ChooseMemberPopup (com.evolveum.midpoint.gui.api.component.ChooseMemberPopup)2 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)2 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)2 CompiledObjectCollectionView (com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2