Search in sources :

Example 56 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class ProgressPanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    PageBase page = getPageBase();
    WebApplicationConfiguration config = page.getWebApplicationConfiguration();
    ProgressReporter reporter = new ProgressReporter(MidPointApplication.get());
    reporter.setRefreshInterval(config.getProgressRefreshInterval());
    reporter.setAsynchronousExecution(config.isProgressReportingEnabled());
    reporter.setAbortEnabled(config.isAbortEnabled());
    reporterModel = new AsyncWebProcessModel<>(reporter);
    initLayout();
    addRefreshingProgressPanel();
}
Also used : WebApplicationConfiguration(com.evolveum.midpoint.web.security.WebApplicationConfiguration) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Example 57 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class OrgTreeAssignablePanel method initLayout.

private void initLayout() {
    if (getPreselectedOrgsList() != null) {
        allTabsSelectedOrgs.addAll(getPreselectedOrgsList());
    }
    AbstractOrgTabPanel tabbedPanel = new AbstractOrgTabPanel(ID_ORG_TABS, getPageBase()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Panel createTreePanel(String id, Model<String> model, PageBase pageBase) {
            OrgTreePanel panel = new OrgTreePanel(id, model, selectable, pageBase, "", allTabsSelectedOrgs) {

                private static final long serialVersionUID = 1L;

                private final OrgStructurePanelStorage storage = new OrgStructurePanelStorage();

                @Override
                protected IModel<Boolean> getCheckBoxValueModel(IModel<TreeSelectableBean<OrgType>> rowModel) {
                    return new LoadableModel<>(true) {

                        @Override
                        public Boolean load() {
                            for (OrgType org : allTabsSelectedOrgs) {
                                if (rowModel.getObject().getValue().getOid().equals(org.getOid())) {
                                    return true;
                                }
                            }
                            return false;
                        }
                    };
                }

                @Override
                protected void onOrgTreeCheckBoxSelectionPerformed(AjaxRequestTarget target, IModel<TreeSelectableBean<OrgType>> rowModel) {
                    if (rowModel != null && rowModel.getObject() != null) {
                        boolean isAlreadyInList = false;
                        Iterator<OrgType> it = allTabsSelectedOrgs.iterator();
                        while (it.hasNext()) {
                            OrgType org = it.next();
                            if (org.getOid().equals(rowModel.getObject().getValue().getOid())) {
                                isAlreadyInList = true;
                                it.remove();
                            }
                        }
                        if (!isAlreadyInList) {
                            allTabsSelectedOrgs.add(rowModel.getObject().getValue());
                        }
                    }
                    OrgTreeAssignablePanel.this.onOrgTreeCheckBoxSelectionPerformed(target, rowModel);
                }

                @Override
                protected void selectTreeItemPerformed(TreeSelectableBean<OrgType> selected, AjaxRequestTarget target) {
                    onItemSelect(selected, target);
                }

                @Override
                public OrgTreeStateStorage getOrgTreeStateStorage() {
                    return storage;
                }

                @Override
                protected ObjectFilter getCustomFilter() {
                    return OrgTreeAssignablePanel.this.getCustomFilter();
                }
            };
            panel.setOutputMarkupId(true);
            panel.setOutputMarkupPlaceholderTag(true);
            return panel;
        }

        @Override
        protected boolean isWarnMessageVisible() {
            return false;
        }

        @Override
        protected ObjectFilter getAssignableItemsFilter() {
            return OrgTreeAssignablePanel.this.getCustomFilter();
        }

        @Override
        protected OrgStructurePanelStorage getOrgStructurePanelStorage() {
            return null;
        }
    };
    tabbedPanel.setOutputMarkupId(true);
    tabbedPanel.setOutputMarkupPlaceholderTag(true);
    add(tabbedPanel);
    AjaxButton assignButton = new AjaxButton(ID_ASSIGN, getPageBase().createStringResource("userBrowserDialog.button.addButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            assignSelectedOrgPerformed(getAllTabPanelsSelectedOrgs(), target);
        }
    };
    assignButton.setOutputMarkupId(true);
    assignButton.setOutputMarkupPlaceholderTag(true);
    assignButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isAssignButtonVisible();
        }
    });
    add(assignButton);
}
Also used : IModel(org.apache.wicket.model.IModel) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) StringResourceModel(org.apache.wicket.model.StringResourceModel) Model(org.apache.wicket.model.Model) IModel(org.apache.wicket.model.IModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) OrgStructurePanelStorage(com.evolveum.midpoint.web.session.OrgStructurePanelStorage) TreeSelectableBean(com.evolveum.midpoint.web.component.util.TreeSelectableBean) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 58 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class PageDebugDownloadBehaviour method initFile.

@Override
protected File initFile() {
    PageBase page = getPage();
    OperationResult result = new OperationResult(OPERATION_CREATE_DOWNLOAD_FILE);
    MidPointApplication application = page.getMidpointApplication();
    WebApplicationConfiguration config = application.getWebApplicationConfiguration();
    File folder = new File(config.getExportFolder());
    if (!folder.exists() || !folder.isDirectory()) {
        folder.mkdir();
    }
    String suffix = isUseZip() ? "zip" : "xml";
    String currentTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy_MM_dd_HH_m_s"));
    String fileName = "ExportedData_" + getType().getSimpleName() + "_" + currentTime + "." + suffix;
    File file = new File(folder, fileName);
    LOGGER.debug("Creating file '{}'.", file.getAbsolutePath());
    try (Writer writer = createWriter(file)) {
        LOGGER.debug("Exporting objects.");
        dumpHeader(writer);
        dumpObjectsToStream(writer, result);
        dumpFooter(writer);
        LOGGER.debug("Export finished.");
        result.recomputeStatus();
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't init download link", ex);
        result.recordFatalError(getPage().createStringResource("PageDebugDownloadBehaviour.message.initFile.fatalError").getString(), ex);
    }
    if (!WebComponentUtil.isSuccessOrHandledError(result)) {
        page.showResult(result);
        page.getSession().error(page.getString("pageDebugList.message.createFileException"));
        LOGGER.debug("Removing file '{}'.", file.getAbsolutePath());
        Files.remove(file);
        throw new RestartResponseException(PageDebugList.class);
    }
    return file;
}
Also used : MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) RestartResponseException(org.apache.wicket.RestartResponseException) WebApplicationConfiguration(com.evolveum.midpoint.web.security.WebApplicationConfiguration) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) File(org.apache.wicket.util.file.File) AjaxDownloadBehaviorFromFile(com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromFile) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Example 59 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class PageDebugDownloadBehaviour method dumpObjectsToStream.

private void dumpObjectsToStream(final Writer writer, OperationResult result) throws Exception {
    final PageBase page = getPage();
    ResultHandler handler = (object, parentResult) -> {
        try {
            String xml = page.getPrismContext().xmlSerializer().options(createSerializeForExport()).serialize(object);
            writer.write('\t');
            writer.write(xml);
            writer.write('\n');
        } catch (IOException | SchemaException ex) {
            throw new SystemException(ex.getMessage(), ex);
        }
        return true;
    };
    ModelService service = page.getModelService();
    GetOperationOptionsBuilder optionsBuilder = page.getSchemaService().getOperationOptionsBuilder().raw().resolveNames();
    if (showAllItems) {
        optionsBuilder = optionsBuilder.retrieve();
    }
    service.searchObjectsIterative(type, query, handler, optionsBuilder.build(), page.createSimpleTask(OPERATION_SEARCH_OBJECT), result);
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) LocalDateTime(java.time.LocalDateTime) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Trace(com.evolveum.midpoint.util.logging.Trace) StringUtils(org.apache.commons.lang3.StringUtils) MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) WebApplicationConfiguration(com.evolveum.midpoint.web.security.WebApplicationConfiguration) SchemaConstantsGenerated(com.evolveum.midpoint.schema.SchemaConstantsGenerated) RestartResponseException(org.apache.wicket.RestartResponseException) ZipEntry(java.util.zip.ZipEntry) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) WebComponentUtil(com.evolveum.midpoint.gui.api.util.WebComponentUtil) Files(org.apache.wicket.util.file.Files) GetOperationOptionsBuilder(com.evolveum.midpoint.schema.GetOperationOptionsBuilder) LoggingUtils(com.evolveum.midpoint.util.logging.LoggingUtils) PageDebugList(com.evolveum.midpoint.web.page.admin.configuration.PageDebugList) ModelService(com.evolveum.midpoint.model.api.ModelService) File(org.apache.wicket.util.file.File) java.io(java.io) SerializationOptions.createSerializeForExport(com.evolveum.midpoint.prism.SerializationOptions.createSerializeForExport) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) SystemException(com.evolveum.midpoint.util.exception.SystemException) DateTimeFormatter(java.time.format.DateTimeFormatter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AjaxDownloadBehaviorFromFile(com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromFile) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) SystemException(com.evolveum.midpoint.util.exception.SystemException) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) GetOperationOptionsBuilder(com.evolveum.midpoint.schema.GetOperationOptionsBuilder) ModelService(com.evolveum.midpoint.model.api.ModelService)

Example 60 with PageBase

use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.

the class AsyncDashboardPanel method onUpdateError.

@Override
protected void onUpdateError(AjaxRequestTarget target, Exception ex) {
    String message = "Error occurred while fetching data: " + ex.getMessage();
    Label errorLabel = new Label(ID_CONTENT, message);
    WebMarkupContainer dashboardContent = getDashboardContent();
    dashboardContent.replace(errorLabel);
    PageBase page = (PageBase) getPage();
    showResultIfError(page);
    target.add(this, page.getFeedbackPanel());
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Aggregations

PageBase (com.evolveum.midpoint.gui.api.page.PageBase)82 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)30 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)25 Task (com.evolveum.midpoint.task.api.Task)16 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)13 IModel (org.apache.wicket.model.IModel)12 Label (org.apache.wicket.markup.html.basic.Label)11 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)9 ArrayList (java.util.ArrayList)9 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)9 List (java.util.List)8 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)6 RestartResponseException (org.apache.wicket.RestartResponseException)6 StringResourceModel (org.apache.wicket.model.StringResourceModel)6 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)5 PrismObject (com.evolveum.midpoint.prism.PrismObject)5 ConfirmationPanel (com.evolveum.midpoint.web.component.dialog.ConfirmationPanel)5 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)5 QName (javax.xml.namespace.QName)5