Search in sources :

Example 1 with TaskDtoExecutionStatus

use of com.evolveum.midpoint.web.page.admin.server.dto.TaskDtoExecutionStatus in project midpoint by Evolveum.

the class TaskBasicTabPanel method initLayoutBasic.

private void initLayoutBasic() {
    // Name
    WebMarkupContainer nameContainer = new WebMarkupContainer(ID_NAME_CONTAINER);
    RequiredTextField<String> name = new RequiredTextField<>(ID_NAME, new PropertyModel<String>(taskDtoModel, TaskDto.F_NAME));
    name.add(parentPage.createEnabledIfEdit(new ItemPath(TaskType.F_NAME)));
    name.add(new AttributeModifier("style", "width: 100%"));
    name.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    nameContainer.add(name);
    nameContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_NAME)));
    add(nameContainer);
    // Description
    WebMarkupContainer descriptionContainer = new WebMarkupContainer(ID_DESCRIPTION_CONTAINER);
    TextArea<String> description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(taskDtoModel, TaskDto.F_DESCRIPTION));
    description.add(parentPage.createEnabledIfEdit(new ItemPath(TaskType.F_DESCRIPTION)));
    //        description.add(new AttributeModifier("style", "width: 100%"));
    //        description.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    descriptionContainer.add(description);
    descriptionContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_DESCRIPTION)));
    add(descriptionContainer);
    // OID
    Label oid = new Label(ID_OID, new PropertyModel(getObjectWrapperModel(), ID_OID));
    add(oid);
    // Identifier
    WebMarkupContainer identifierContainer = new WebMarkupContainer(ID_IDENTIFIER_CONTAINER);
    identifierContainer.add(new Label(ID_IDENTIFIER, new PropertyModel(taskDtoModel, TaskDto.F_IDENTIFIER)));
    identifierContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_TASK_IDENTIFIER)));
    add(identifierContainer);
    // Category
    WebMarkupContainer categoryContainer = new WebMarkupContainer(ID_CATEGORY_CONTAINER);
    categoryContainer.add(new Label(ID_CATEGORY, WebComponentUtil.createCategoryNameModel(this, new PropertyModel(taskDtoModel, TaskDto.F_CATEGORY))));
    categoryContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_CATEGORY)));
    add(categoryContainer);
    // Parent
    WebMarkupContainer parentContainer = new WebMarkupContainer(ID_PARENT_CONTAINER);
    final LinkPanel parent = new LinkPanel(ID_PARENT, new PropertyModel<String>(taskDtoModel, TaskDto.F_PARENT_TASK_NAME)) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            String oid = taskDtoModel.getObject().getParentTaskOid();
            if (oid != null) {
                PageParameters parameters = new PageParameters();
                parameters.add(OnePageParameterEncoder.PARAMETER, oid);
                getPageBase().navigateToNext(PageTaskEdit.class, parameters);
            }
        }
    };
    parentContainer.add(parent);
    parentContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_PARENT)));
    add(parentContainer);
    // Owner
    WebMarkupContainer ownerContainer = new WebMarkupContainer(ID_OWNER_CONTAINER);
    final LinkPanel owner = new LinkPanel(ID_OWNER, new PropertyModel<String>(taskDtoModel, TaskDto.F_OWNER_NAME)) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            String oid = taskDtoModel.getObject().getOwnerOid();
            if (oid != null) {
                PageParameters parameters = new PageParameters();
                parameters.add(OnePageParameterEncoder.PARAMETER, oid);
                getPageBase().navigateToNext(PageUser.class, parameters);
            }
        }
    };
    ownerContainer.add(owner);
    ownerContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_OWNER_REF)));
    add(ownerContainer);
    // Handler URI
    ListView<String> handlerUriContainer = new ListView<String>(ID_HANDLER_URI_CONTAINER, new PropertyModel(taskDtoModel, TaskDto.F_HANDLER_URI_LIST)) {

        @Override
        protected void populateItem(ListItem<String> item) {
            item.add(new Label(ID_HANDLER_URI, item.getModelObject()));
        }
    };
    handlerUriContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_HANDLER_URI), new ItemPath(TaskType.F_OTHER_HANDLERS_URI_STACK)));
    add(handlerUriContainer);
    // Execution
    WebMarkupContainer executionContainer = new WebMarkupContainer(ID_EXECUTION_CONTAINER);
    Label execution = new Label(ID_EXECUTION, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            TaskDtoExecutionStatus executionStatus = taskDtoModel.getObject().getExecution();
            if (executionStatus != TaskDtoExecutionStatus.CLOSED) {
                return getString(TaskDtoExecutionStatus.class.getSimpleName() + "." + executionStatus.name());
            } else {
                return getString(TaskDtoExecutionStatus.class.getSimpleName() + "." + executionStatus.name() + ".withTimestamp", new AbstractReadOnlyModel<String>() {

                    @Override
                    public String getObject() {
                        if (taskDtoModel.getObject().getCompletionTimestamp() != null) {
                            // todo correct formatting
                            return new Date(taskDtoModel.getObject().getCompletionTimestamp()).toLocaleString();
                        } else {
                            return "?";
                        }
                    }
                });
            }
        }
    });
    executionContainer.add(execution);
    Label node = new Label(ID_NODE, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            TaskDto dto = taskDtoModel.getObject();
            if (!TaskDtoExecutionStatus.RUNNING.equals(dto.getExecution())) {
                return null;
            }
            return parentPage.getString("pageTaskEdit.message.node", dto.getExecutingAt());
        }
    });
    executionContainer.add(node);
    executionContainer.add(parentPage.createVisibleIfAccessible(new ItemPath(TaskType.F_EXECUTION_STATUS), new ItemPath(TaskType.F_NODE_AS_OBSERVED)));
    add(executionContainer);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) TextArea(org.apache.wicket.markup.html.form.TextArea) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) TaskDtoExecutionStatus(com.evolveum.midpoint.web.page.admin.server.dto.TaskDtoExecutionStatus) RequiredTextField(org.apache.wicket.markup.html.form.RequiredTextField) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) AttributeModifier(org.apache.wicket.AttributeModifier) TaskDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskDto) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Date(java.util.Date) LinkPanel(com.evolveum.midpoint.web.component.data.column.LinkPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) ListItem(org.apache.wicket.markup.html.list.ListItem) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 LinkPanel (com.evolveum.midpoint.web.component.data.column.LinkPanel)1 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)1 TaskDto (com.evolveum.midpoint.web.page.admin.server.dto.TaskDto)1 TaskDtoExecutionStatus (com.evolveum.midpoint.web.page.admin.server.dto.TaskDtoExecutionStatus)1 Date (java.util.Date)1 AttributeModifier (org.apache.wicket.AttributeModifier)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 RequiredTextField (org.apache.wicket.markup.html.form.RequiredTextField)1 TextArea (org.apache.wicket.markup.html.form.TextArea)1 ListItem (org.apache.wicket.markup.html.list.ListItem)1 ListView (org.apache.wicket.markup.html.list.ListView)1 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)1 PropertyModel (org.apache.wicket.model.PropertyModel)1 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)1