Search in sources :

Example 71 with PageBase

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

the class LeftMenuPanel method createSystemConfigurationMenu.

private void createSystemConfigurationMenu(SideBarMenuItem item) {
    MainMenuItem system = createMainMenuItem("PageAdmin.menu.top.configuration.basic", "fa fa-cog", com.evolveum.midpoint.gui.impl.page.admin.systemconfiguration.PageSystemConfiguration.class);
    PageBase page = getPageBase();
    if (page != null && PageBaseSystemConfiguration.class.isAssignableFrom(page.getClass())) {
        // title key is not nice - model should be sent there...
        MenuItem menuItem = new MenuItem(page.getClass().getSimpleName() + ".title", page.getClass(), new PageParameters());
        system.addMenuItem(menuItem);
    }
    item.addMainMenuItem(system);
    MainMenuItem systemConfigMenu = createMainMenuItem("PageAdmin.menu.top.configuration.basic", "fa fa-cog");
    createSystemConfigurationTabMebu(systemConfigMenu);
    item.addMainMenuItem(systemConfigMenu);
}
Also used : PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) PageBaseSystemConfiguration(com.evolveum.midpoint.gui.impl.page.admin.systemconfiguration.page.PageBaseSystemConfiguration)

Example 72 with PageBase

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

the class ProgressPanel method backPerformed.

protected void backPerformed(AjaxRequestTarget target) {
    PageBase page = getPageBase();
    page.redirectBack();
}
Also used : PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Example 73 with PageBase

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

the class ProgressPanel method executeChangesInBackground.

public void executeChangesInBackground(Collection<ObjectDelta<? extends ObjectType>> deltas, boolean previewOnly, ModelExecuteOptions options, Task task, OperationResult result, AjaxRequestTarget target) {
    PageBase page = getPageBase();
    ProgressReporter reporter = reporterModel.getProcessData();
    try {
        TaskManager taskManager = page.getTaskManager();
        MidPointPrincipal user = AuthUtil.getPrincipalUser();
        if (user == null) {
            throw new RestartResponseException(PageLogin.class);
        } else {
            task.setOwner(user.getFocus().asPrismObject());
        }
        task.setRootActivityDefinition(createNonIterativeChangeExecutionDef(deltas, toModelExecutionOptionsBean(options)));
        task.setChannel(SchemaConstants.CHANNEL_USER_URI);
        task.setName("Execute changes");
        task.setInitiallyRunnable();
        PrismObject<TaskType> taskType = task.getUpdatedTaskObject();
        AssignmentType archetypeAssignment = new AssignmentType();
        archetypeAssignment.setTargetRef(ObjectTypeUtil.createObjectRef(SystemObjectsType.ARCHETYPE_UTILITY_TASK.value(), ObjectTypes.ARCHETYPE));
        taskType.asObjectable().getAssignment().add(archetypeAssignment);
        taskType.asObjectable().getArchetypeRef().add(ObjectTypeUtil.createObjectRef(SystemObjectsType.ARCHETYPE_UTILITY_TASK.value(), ObjectTypes.ARCHETYPE));
        taskManager.switchToBackground(task, result);
        result.setBackgroundTaskOid(task.getOid());
    } catch (Exception e) {
        result.recordFatalError(e);
    } finally {
        result.computeStatusIfUnknown();
    }
    if (page instanceof ProgressReportingAwarePage) {
        ProgressReportingAwarePage aware = (ProgressReportingAwarePage) page;
        aware.finishProcessing(target, reporter.getObjectDeltaOperation(), reporter.isAsynchronousExecution(), result);
    }
}
Also used : TaskManager(com.evolveum.midpoint.task.api.TaskManager) RestartResponseException(org.apache.wicket.RestartResponseException) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) RestartResponseException(org.apache.wicket.RestartResponseException) CommonException(com.evolveum.midpoint.util.exception.CommonException) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal)

Example 74 with PageBase

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

the class ProgressPanel method executeChanges.

/**
 * Executes changes on behalf of the parent page. By default, changes are executed asynchronously (in
 * a separate thread). However, when set in the midpoint configuration, changes are executed synchronously.
 *
 * @param deltas  Deltas to be executed.
 * @param options Model execution options.
 * @param task    Task in context of which the changes have to be executed.
 * @param result  Operation result.
 */
public void executeChanges(Collection<ObjectDelta<? extends ObjectType>> deltas, boolean previewOnly, ModelExecuteOptions options, Task task, OperationResult result, AjaxRequestTarget target) {
    PageBase page = getPageBase();
    ProgressReporter reporter = reporterModel.getProcessData();
    if (page instanceof ProgressReportingAwarePage) {
        ProgressReportingAwarePage aware = (ProgressReportingAwarePage) page;
        aware.startProcessing(target, result);
    }
    if (reporter.isAsynchronousExecution() && page instanceof ProgressReportingAwarePage) {
        reporter.setAsyncOperationResult(null);
        clearProgressPanel();
        startRefreshingProgressPanel(target);
        show();
        if (reporter.isAbortEnabled()) {
            showAbortButton(target);
        }
        showBackButton(target);
        setTask(task);
        executeChangesAsync(reporter, deltas, previewOnly, options, task, result);
    } else {
        executeChangesSync(reporter, deltas, previewOnly, options, task, result);
    }
    if (!reporter.isAsynchronousExecution() && page instanceof ProgressReportingAwarePage) {
        ProgressReportingAwarePage aware = (ProgressReportingAwarePage) page;
        aware.finishProcessing(target, reporter.getObjectDeltaOperation(), reporter.isAsynchronousExecution(), result);
    }
}
Also used : PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Example 75 with PageBase

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

the class ProgressPanel method startRefreshingProgressPanel.

// mess
private void startRefreshingProgressPanel(AjaxRequestTarget target) {
    if (refreshingBehavior != null) {
        return;
    }
    ProgressReporter reporter = reporterModel.getProcessData();
    int refreshInterval = reporter.getRefreshInterval();
    refreshingBehavior = new AjaxSelfUpdatingTimerBehavior(Duration.milliseconds(refreshInterval)) {

        @Override
        protected void onPostProcessTarget(AjaxRequestTarget target) {
            invalidateCache();
            ProgressReporter reporter = reporterModel.getProcessData();
            OperationResult asyncOperationResult = reporter.getAsyncOperationResult();
            if (asyncOperationResult != null) {
                // by checking this we know that async operation has been finished
                // because we set it to in-progress
                asyncOperationResult.recomputeStatus();
                stopRefreshingProgressPanel(target);
                PageBase page = getPageBase();
                if (reporter.isAbortRequested()) {
                    page.showResult(asyncOperationResult);
                    target.add(page.getFeedbackPanel());
                    return;
                }
                if (page instanceof ProgressReportingAwarePage) {
                    ProgressReportingAwarePage aware = (ProgressReportingAwarePage) page;
                    aware.finishProcessing(target, reporter.getObjectDeltaOperation(), true, asyncOperationResult);
                }
                reporter.setAsyncOperationResult(null);
            }
        }

        @Override
        public boolean isEnabled(Component component) {
            return component != null;
        }
    };
    add(refreshingBehavior);
    target.add(this);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceOperationResult(com.evolveum.midpoint.web.component.progress.ProgressReportActivityDto.ResourceOperationResult) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) Component(org.apache.wicket.Component) AjaxSelfUpdatingTimerBehavior(org.apache.wicket.ajax.AjaxSelfUpdatingTimerBehavior)

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