Search in sources :

Example 6 with TextArea

use of org.apache.wicket.markup.html.form.TextArea in project midpoint by Evolveum.

the class DelegationEditorPanel method initBodyLayout.

protected void initBodyLayout(WebMarkupContainer body) {
    DateInput validFrom = new DateInput(ID_DELEGATION_VALID_FROM, createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validFrom")));
    validFrom.setEnabled(getModel().getObject().isEditable());
    body.add(validFrom);
    DateInput validTo = new DateInput(ID_DELEGATION_VALID_TO, createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validTo")));
    validTo.setEnabled(getModel().getObject().isEditable());
    body.add(validTo);
    TextArea<String> description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(getModel(), AssignmentEditorDto.F_DESCRIPTION));
    description.setEnabled(getModel().getObject().isEditable());
    body.add(description);
    WebMarkupContainer assignmentPrivilegesContainer = new WebMarkupContainer(ID_ASSIGNMENT_PRIVILEGES_CONTAINER);
    assignmentPrivilegesContainer.setOutputMarkupId(true);
    assignmentPrivilegesContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            if (!UserDtoStatus.ADD.equals(getModelObject().getStatus())) {
                return true;
            }
            List<AssignmentsPreviewDto> privilegesList = privilegesListModel.getObject();
            return privilegesList != null && privilegesList.size() > 0;
        }
    });
    body.add(assignmentPrivilegesContainer);
    AjaxCheckBox assignmentPrivilegesCheckbox = new AjaxCheckBox(ID_ASSIGNMENT_PRIVILEGES_CHECKBOX, new IModel<Boolean>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Boolean getObject() {
            return getModelObject().getPrivilegeLimitationList() != null && getModelObject().getPrivilegeLimitationList().size() > 0;
        }

        @Override
        public void setObject(Boolean value) {
            if (value) {
                getModelObject().setPrivilegeLimitationList(privilegesListModel.getObject());
            } else {
                getModelObject().setPrivilegeLimitationList(new ArrayList<>());
            }
        }

        @Override
        public void detach() {
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(DelegationEditorPanel.this.get(ID_BODY).get(ID_ASSIGNMENT_PRIVILEGES_CONTAINER));
        }
    };
    assignmentPrivilegesCheckbox.setOutputMarkupId(true);
    assignmentPrivilegesCheckbox.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    assignmentPrivilegesCheckbox.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return UserDtoStatus.ADD.equals(getModelObject().getStatus());
        }
    });
    assignmentPrivilegesContainer.add(assignmentPrivilegesCheckbox);
    WebMarkupContainer labelContainer = new WebMarkupContainer(ID_ASSIGNMENT_PRIVILEGES_LABEL_CONTAINER);
    labelContainer.setOutputMarkupId(true);
    assignmentPrivilegesContainer.add(labelContainer);
    Label assignmentPrivilegesLabel = new Label(ID_ASSIGNMENT_PRIVILEGES_LABEL, createStringResource("DelegationEditorPanel.allPrivilegesLabel"));
    assignmentPrivilegesLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return true;
        }
    });
    assignmentPrivilegesLabel.setOutputMarkupId(true);
    labelContainer.add(assignmentPrivilegesLabel);
    addPrivilegesPanel(assignmentPrivilegesContainer);
    AjaxButton limitPrivilegesButton = new AjaxButton(ID_LIMIT_PRIVILEGES_BUTTON, pageBase.createStringResource("DelegationEditorPanel.limitPrivilegesButton")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            AssignmentPreviewDialog assignmentPreviewDialog = new AssignmentPreviewDialog(pageBase.getMainPopupBodyId(), selectExistingPrivileges(privilegesListModel.getObject()), null, pageBase, true) {

                @Override
                protected boolean isDelegationPreview() {
                    return true;
                }

                @Override
                public StringResourceModel getTitle() {
                    return new StringResourceModel("AssignmentPreviewDialog.delegationPreviewLabel");
                }

                @Override
                protected void addButtonClicked(AjaxRequestTarget target, List<AssignmentsPreviewDto> dtoList) {
                    DelegationEditorPanel.this.getModelObject().setPrivilegeLimitationList(dtoList);
                    pageBase.hideMainPopup(target);
                }
            };
            pageBase.showMainPopup(assignmentPreviewDialog, target);
        }
    };
    limitPrivilegesButton.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return UserDtoStatus.ADD.equals(getModelObject().getStatus()) && assignmentPrivilegesCheckbox.getModelObject();
        }
    });
    labelContainer.add(limitPrivilegesButton);
    AjaxCheckBox approvalRights = new AjaxCheckBox(ID_DELEGATE_APPROVAL_WI, new IModel<Boolean>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Boolean getObject() {
            AssignmentEditorDto dto = getModelObject();
            if (dto.getPrivilegesLimitation() == null || dto.getPrivilegesLimitation().getApprovalWorkItems() == null || dto.getPrivilegesLimitation().getApprovalWorkItems().isAll() == null) {
                return false;
            }
            return dto.getPrivilegesLimitation().getApprovalWorkItems().isAll();
        }

        @Override
        public void setObject(Boolean value) {
            AssignmentEditorDto dto = getModelObject();
            OtherPrivilegesLimitationType limitations = dto.getPrivilegesLimitation();
            if (limitations == null) {
                limitations = new OtherPrivilegesLimitationType();
                dto.setPrivilegesLimitation(limitations);
            }
            WorkItemSelectorType workItemSelector = new WorkItemSelectorType();
            workItemSelector.all(value);
            limitations.setApprovalWorkItems(workItemSelector);
        }

        @Override
        public void detach() {
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    approvalRights.setOutputMarkupId(true);
    approvalRights.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    approvalRights.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    body.add(approvalRights);
    AjaxCheckBox certificationRights = new AjaxCheckBox(ID_DELEGATE_CERTIFICATION_WI, new IModel<Boolean>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Boolean getObject() {
            AssignmentEditorDto dto = getModelObject();
            if (dto.getPrivilegesLimitation() == null || dto.getPrivilegesLimitation().getCertificationWorkItems() == null || dto.getPrivilegesLimitation().getCertificationWorkItems().isAll() == null) {
                return false;
            }
            return dto.getPrivilegesLimitation().getCertificationWorkItems().isAll();
        }

        @Override
        public void setObject(Boolean value) {
            AssignmentEditorDto dto = getModelObject();
            OtherPrivilegesLimitationType limitations = dto.getPrivilegesLimitation();
            if (limitations == null) {
                limitations = new OtherPrivilegesLimitationType();
                dto.setPrivilegesLimitation(limitations);
            }
            WorkItemSelectorType workItemSelector = new WorkItemSelectorType();
            workItemSelector.all(value);
            limitations.setCertificationWorkItems(workItemSelector);
        }

        @Override
        public void detach() {
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    certificationRights.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    certificationRights.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    certificationRights.setOutputMarkupId(true);
    body.add(certificationRights);
    AjaxCheckBox managementWorkItems = new AjaxCheckBox(ID_DELEGATE_MANAGEMENT_WI, new Model<Boolean>(false)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    managementWorkItems.setOutputMarkupId(true);
    managementWorkItems.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            //TODO not implemented yet
            return false;
        }
    });
    body.add(managementWorkItems);
    addAjaxOnUpdateBehavior(body);
}
Also used : TextArea(org.apache.wicket.markup.html.form.TextArea) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) WorkItemSelectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemSelectorType) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) OtherPrivilegesLimitationType(com.evolveum.midpoint.xml.ns._public.common.common_3.OtherPrivilegesLimitationType) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AssignmentPreviewDialog(com.evolveum.midpoint.web.page.admin.users.component.AssignmentPreviewDialog) DateInput(com.evolveum.midpoint.web.component.DateInput)

Example 7 with TextArea

use of org.apache.wicket.markup.html.form.TextArea in project midpoint by Evolveum.

the class SearchPanel method initLayout.

private void initLayout() {
    moreDialogModel = new LoadableModel<MoreDialogDto>(false) {

        @Override
        protected MoreDialogDto load() {
            MoreDialogDto dto = new MoreDialogDto();
            dto.setProperties(createPropertiesList());
            return dto;
        }
    };
    Form form = new Form(ID_FORM);
    add(form);
    ListView items = new ListView<SearchItem>(ID_ITEMS, new PropertyModel<List<SearchItem>>(getModel(), Search.F_ITEMS)) {

        @Override
        protected void populateItem(ListItem<SearchItem> item) {
            SearchItemPanel searchItem = new SearchItemPanel(ID_ITEM, item.getModel());
            item.add(searchItem);
        }
    };
    items.add(createVisibleBehaviour(SearchBoxModeType.BASIC));
    form.add(items);
    WebMarkupContainer moreGroup = new WebMarkupContainer(ID_MORE_GROUP);
    moreGroup.add(createVisibleBehaviour(SearchBoxModeType.BASIC));
    form.add(moreGroup);
    AjaxLink more = new AjaxLink(ID_MORE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            Component button = SearchPanel.this.get(createComponentPath(ID_FORM, ID_MORE_GROUP, ID_MORE));
            Component popover = SearchPanel.this.get(createComponentPath(ID_POPOVER));
            togglePopover(target, button, popover, 14);
        }
    };
    more.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            Search search = getModelObject();
            return !search.getAvailableDefinitions().isEmpty();
        }
    });
    more.setOutputMarkupId(true);
    moreGroup.add(more);
    WebMarkupContainer searchContainer = new WebMarkupContainer(ID_SEARCH_CONTAINER);
    searchContainer.setOutputMarkupId(true);
    form.add(searchContainer);
    AjaxSubmitButton searchSimple = new AjaxSubmitButton(ID_SEARCH_SIMPLE) {

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(form);
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            searchPerformed(target);
        }
    };
    searchSimple.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            if (SearchBoxModeType.BASIC.equals(getModelObject().getSearchType()) || SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType())) {
                return true;
            }
            return false;
        }

        @Override
        public boolean isVisible() {
            return SearchBoxModeType.BASIC.equals(getModelObject().getSearchType()) || SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType());
        }
    });
    searchSimple.setOutputMarkupId(true);
    searchContainer.add(searchSimple);
    WebMarkupContainer searchDropdown = new WebMarkupContainer(ID_SEARCH_DROPDOWN);
    searchDropdown.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return SearchBoxModeType.ADVANCED.equals(getModelObject().getSearchType()) && queryPlagroundAccessible;
        }
    });
    searchContainer.add(searchDropdown);
    AjaxSubmitButton searchButtonBeforeDropdown = new AjaxSubmitButton(ID_SEARCH_BUTTON_BEFORE_DROPDOWN) {

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(form);
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            searchPerformed(target);
        }
    };
    searchButtonBeforeDropdown.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            if (SearchBoxModeType.BASIC.equals(getModelObject().getSearchType()) || SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType())) {
                return true;
            }
            Search search = getModelObject();
            PrismContext ctx = getPageBase().getPrismContext();
            return search.isAdvancedQueryValid(ctx);
        }
    });
    searchDropdown.add(searchButtonBeforeDropdown);
    List<InlineMenuItem> searchItems = new ArrayList<>();
    InlineMenuItem searchItem = new InlineMenuItem(createStringResource("SearchPanel.search"), new InlineMenuItemAction() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            PrismContext ctx = getPageBase().getPrismContext();
            if (getModelObject().isAdvancedQueryValid(ctx)) {
                searchPerformed(target);
            }
        }
    });
    searchItems.add(searchItem);
    searchItem = new InlineMenuItem(createStringResource("SearchPanel.debug"), new InlineMenuItemAction() {

        @Override
        public void onClick(AjaxRequestTarget target) {
            debugPerformed();
        }
    });
    searchItems.add(searchItem);
    ListView<InlineMenuItem> li = new ListView<InlineMenuItem>(ID_MENU_ITEM, Model.ofList(searchItems)) {

        @Override
        protected void populateItem(ListItem<InlineMenuItem> item) {
            WebMarkupContainer menuItemBody = new MenuLinkPanel(ID_MENU_ITEM_BODY, item.getModel());
            menuItemBody.setRenderBodyOnly(true);
            item.add(menuItemBody);
        }
    };
    searchDropdown.add(li);
    WebMarkupContainer linksContainer = new WebMarkupContainer(ID_LINKS_CONTAINER);
    linksContainer.setOutputMarkupId(true);
    form.add(linksContainer);
    AjaxButton advanced = new AjaxButton(ID_ADVANCED, createStringResource("SearchPanel.advanced")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            searchTypeUpdated(target, SearchBoxModeType.ADVANCED);
        }
    };
    advanced.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !SearchBoxModeType.ADVANCED.equals(getModelObject().getSearchType());
        }
    });
    linksContainer.add(advanced);
    AjaxButton fullTextButton = new AjaxButton(ID_FULL_TEXT, createStringResource("SearchPanel.fullText")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            searchTypeUpdated(target, SearchBoxModeType.FULLTEXT);
        }
    };
    fullTextButton.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isFullTextSearchEnabled() && !SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType());
        }
    });
    linksContainer.add(fullTextButton);
    AjaxButton basicSearchButton = new AjaxButton(ID_BASIC_SEARCH, createStringResource("SearchPanel.basic")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            searchTypeUpdated(target, SearchBoxModeType.BASIC);
        }
    };
    basicSearchButton.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !SearchBoxModeType.BASIC.equals(getModelObject().getSearchType());
        }
    });
    linksContainer.add(basicSearchButton);
    advanced.add(new AttributeAppender("style", new LoadableModel<String>() {

        @Override
        public String load() {
            return basicSearchButton.isVisible() ? "margin-top: -20px;" : "display: table-cell; vertical-align: top;";
        }
    }));
    initPopover();
    WebMarkupContainer fullTextContainer = new WebMarkupContainer(ID_FULL_TEXT_CONTAINER);
    fullTextContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isFullTextSearchEnabled() && getModelObject().getSearchType().equals(SearchBoxModeType.FULLTEXT);
        }
    });
    fullTextContainer.setOutputMarkupId(true);
    form.add(fullTextContainer);
    TextField fullTextInput = new TextField(ID_FULL_TEXT_FIELD, new PropertyModel<String>(getModel(), Search.F_FULL_TEXT));
    fullTextInput.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    fullTextInput.add(new Behavior() {

        @Override
        public void bind(Component component) {
            super.bind(component);
            component.add(AttributeModifier.replace("onkeydown", Model.of("if(event.keyCode == 13) {$('[about=\"searchSimple\"]').click();}")));
        }
    });
    fullTextInput.setOutputMarkupId(true);
    fullTextInput.add(new AttributeAppender("placeholder", createStringResource("SearchPanel.fullTextSearch")));
    fullTextInput.add(createVisibleBehaviour(SearchBoxModeType.FULLTEXT));
    fullTextContainer.add(fullTextInput);
    WebMarkupContainer advancedGroup = new WebMarkupContainer(ID_ADVANCED_GROUP);
    advancedGroup.add(createVisibleBehaviour(SearchBoxModeType.ADVANCED));
    advancedGroup.add(AttributeAppender.append("class", createAdvancedGroupStyle()));
    advancedGroup.setOutputMarkupId(true);
    form.add(advancedGroup);
    Label advancedCheck = new Label(ID_ADVANCED_CHECK);
    advancedCheck.add(AttributeAppender.append("class", createAdvancedGroupLabelStyle()));
    advancedGroup.add(advancedCheck);
    final TextArea advancedArea = new TextArea(ID_ADVANCED_AREA, new PropertyModel(getModel(), Search.F_ADVANCED_QUERY));
    advancedArea.add(new AjaxFormComponentUpdatingBehavior("keyup") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateAdvancedArea(advancedArea, target);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.setThrottlingSettings(new ThrottlingSettings(ID_ADVANCED_AREA, Duration.milliseconds(500), true));
        }
    });
    advancedGroup.add(advancedArea);
    Label advancedError = new Label(ID_ADVANCED_ERROR, new PropertyModel<String>(getModel(), Search.F_ADVANCED_ERROR));
    advancedError.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            Search search = getModelObject();
            if (!search.isShowAdvanced()) {
                return false;
            }
            return StringUtils.isNotEmpty(search.getAdvancedError());
        }
    });
    advancedGroup.add(advancedError);
}
Also used : ThrottlingSettings(org.apache.wicket.ajax.attributes.ThrottlingSettings) Form(org.apache.wicket.markup.html.form.Form) TextArea(org.apache.wicket.markup.html.form.TextArea) PrismContext(com.evolveum.midpoint.prism.PrismContext) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ArrayList(java.util.ArrayList) List(java.util.List) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Behavior(org.apache.wicket.behavior.Behavior) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) Component(org.apache.wicket.Component) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) MenuLinkPanel(com.evolveum.midpoint.web.component.menu.cog.MenuLinkPanel) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 8 with TextArea

use of org.apache.wicket.markup.html.form.TextArea 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)

Example 9 with TextArea

use of org.apache.wicket.markup.html.form.TextArea in project midpoint by Evolveum.

the class PageAssignmentsList method initLayout.

public void initLayout() {
    setOutputMarkupId(true);
    Form mainForm = new Form(ID_FORM);
    mainForm.setOutputMarkupId(true);
    add(mainForm);
    AssignmentTablePanel panel = new AssignmentTablePanel<UserType>(ID_ASSIGNMENT_TABLE_PANEL, createStringResource("FocusType.assignment"), assignmentsModel, PageAssignmentsList.this) {

        @Override
        protected List<InlineMenuItem> createAssignmentMenu() {
            List<InlineMenuItem> items = new ArrayList<>();
            InlineMenuItem item = new InlineMenuItem(createStringResource("AssignmentTablePanel.menu.unassign"), new InlineMenuItemAction() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteAssignmentPerformed(target);
                }
            });
            items.add(item);
            return items;
        }
    };
    mainForm.add(panel);
    WebMarkupContainer targetUserPanel = new TargetUserSelectorComponent(ID_TARGET_USER_PANEL, PageAssignmentsList.this);
    targetUserPanel.setOutputMarkupId(true);
    mainForm.add(targetUserPanel);
    TextArea descriptionInput = new TextArea<String>(ID_DESCRIPTION, descriptionModel);
    descriptionInput.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            getSessionStorage().getRoleCatalog().setRequestDescription(getDescriptionComponent().getValue());
        }
    });
    mainForm.add(descriptionInput);
    AjaxButton back = new AjaxButton(ID_BACK, createStringResource("PageAssignmentDetails.backButton")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            redirectBack();
        }
    };
    mainForm.add(back);
    AjaxSubmitButton requestAssignments = new AjaxSubmitButton(ID_REQUEST_BUTTON, createStringResource("PageAssignmentsList.requestButton")) {

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            target.add(getFeedbackPanel());
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            if (getSessionStorage().getRoleCatalog().getTargetUserList() == null || getSessionStorage().getRoleCatalog().getTargetUserList().size() <= 1) {
                onSingleUserRequestPerformed(target);
            } else {
                onMultiUserRequestPerformed(target);
            }
        }
    };
    requestAssignments.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return getSessionStorage().getRoleCatalog().isMultiUserRequest() || areConflictsResolved();
        }
    });
    mainForm.add(requestAssignments);
    AjaxSubmitButton resolveAssignments = new AjaxSubmitButton(ID_RESOLVE_CONFLICTS_BUTTON, createStringResource("PageAssignmentsList.resolveConflicts")) {

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            target.add(getFeedbackPanel());
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            PageAssignmentsList.this.navigateToNext(PageAssignmentConflicts.class);
        }
    };
    resolveAssignments.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getSessionStorage().getRoleCatalog().isMultiUserRequest() && getSessionStorage().getRoleCatalog().getConflictsList() != null && getSessionStorage().getRoleCatalog().getConflictsList().size() > 0;
        }
    });
    mainForm.add(resolveAssignments);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Form(com.evolveum.midpoint.web.component.form.Form) TextArea(org.apache.wicket.markup.html.form.TextArea) TargetUserSelectorComponent(com.evolveum.midpoint.web.component.assignment.TargetUserSelectorComponent) AssignmentTablePanel(com.evolveum.midpoint.web.component.assignment.AssignmentTablePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 10 with TextArea

use of org.apache.wicket.markup.html.form.TextArea in project midpoint by Evolveum.

the class ReportCreateHandlerPanel method initLayout.

private void initLayout(final PageTaskEdit parentPage) {
    final AjaxDownloadBehaviorFromStream ajaxDownloadBehavior = new AjaxDownloadBehaviorFromStream() {

        @Override
        protected InputStream initStream() {
            String outputOid = getModelObject().getReportOutputOid();
            if (outputOid == null) {
                return null;
            }
            Task task = parentPage.createSimpleTask(OPERATION_LOAD_REPORT_OUTPUT);
            PrismObject<ReportOutputType> reportObject = WebModelServiceUtils.loadObject(ReportOutputType.class, outputOid, parentPage, task, task.getResult());
            if (reportObject != null) {
                return PageCreatedReports.createReport(reportObject.asObjectable(), this, parentPage);
            } else {
                return null;
            }
        }
    };
    parentPage.getForm().add(ajaxDownloadBehavior);
    WebMarkupContainer reportParametersContainer = new WebMarkupContainer(ID_REPORT_PARAMETERS_CONTAINER);
    TextArea reportParameters = new TextArea<>(ID_REPORT_PARAMETERS, new PropertyModel<>(getModel(), ReportCreateHandlerDto.F_REPORT_PARAMS));
    reportParameters.setEnabled(false);
    reportParametersContainer.add(reportParameters);
    add(reportParametersContainer);
    WebMarkupContainer downloadContainer = new WebMarkupContainer(ID_DOWNLOAD_CONTAINER);
    AjaxButton download = new AjaxButton(ID_DOWNLOAD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            ajaxDownloadBehavior.initiate(target);
        }
    };
    downloadContainer.add(download);
    downloadContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().getReportOutputOid() != null;
        }
    });
    add(downloadContainer);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Task(com.evolveum.midpoint.task.api.Task) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) AjaxDownloadBehaviorFromStream(com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromStream) TextArea(org.apache.wicket.markup.html.form.TextArea) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ReportOutputType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportOutputType) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Aggregations

TextArea (org.apache.wicket.markup.html.form.TextArea)17 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)13 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)10 Label (org.apache.wicket.markup.html.basic.Label)10 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)9 List (java.util.List)5 PropertyModel (org.apache.wicket.model.PropertyModel)5 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)4 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)4 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)3 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)3 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 AceEditor (com.evolveum.midpoint.web.component.AceEditor)2 DateInput (com.evolveum.midpoint.web.component.DateInput)2 Form (com.evolveum.midpoint.web.component.form.Form)2 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)2 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)2 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)2