Search in sources :

Example 11 with ListModel

use of org.apache.wicket.model.util.ListModel in project webanno by webanno.

the class AutomationPage method commonInit.

private void commonInit() {
    setVersioned(false);
    setModel(Model.of(new AnnotatorStateImpl(Mode.AUTOMATION)));
    WebMarkupContainer rightSidebar = new WebMarkupContainer("rightSidebar");
    // Override sidebar width from preferencesa
    rightSidebar.add(new AttributeModifier("style", LambdaModel.of(() -> String.format("flex-basis: %d%%;", getModelObject().getPreferences().getSidebarSize()))));
    rightSidebar.setOutputMarkupId(true);
    add(rightSidebar);
    centerArea = new WebMarkupContainer("centerArea");
    centerArea.add(visibleWhen(() -> getModelObject().getDocument() != null));
    centerArea.setOutputMarkupPlaceholderTag(true);
    centerArea.add(new DocumentNamePanel("documentNamePanel", getModel()));
    actionBar = new ActionBar("actionBar");
    centerArea.add(actionBar);
    rightSidebar.add(detailEditor = createDetailEditor());
    annotationEditor = new BratAnnotationEditor("mergeView", getModel(), detailEditor, this::getEditorCas);
    centerArea.add(annotationEditor);
    add(centerArea);
    getModelObject().setPagingStrategy(new SentenceOrientedPagingStrategy());
    centerArea.add(getModelObject().getPagingStrategy().createPositionLabel(MID_NUMBER_OF_PAGES, getModel()).add(visibleWhen(() -> getModelObject().getDocument() != null)).add(LambdaBehavior.onEvent(RenderAnnotationsEvent.class, (c, e) -> e.getRequestHandler().add(c))));
    List<UserAnnotationSegment> segments = new LinkedList<>();
    UserAnnotationSegment userAnnotationSegment = new UserAnnotationSegment();
    if (getModelObject().getDocument() != null) {
        userAnnotationSegment.setSelectionByUsernameAndAddress(annotationSelectionByUsernameAndAddress);
        userAnnotationSegment.setAnnotatorState(getModelObject());
        segments.add(userAnnotationSegment);
    }
    suggestionView = new SuggestionViewPanel("automateView", new ListModel<>(segments)) {

        private static final long serialVersionUID = 2583509126979792202L;

        @Override
        public void onChange(AjaxRequestTarget aTarget) {
            try {
                // update begin/end of the curation segment based on bratAnnotatorModel changes
                // (like sentence change in auto-scroll mode,....
                aTarget.addChildren(getPage(), IFeedback.class);
                AnnotatorState state = AutomationPage.this.getModelObject();
                curationContainer.setState(state);
                CAS editorCas = getEditorCas();
                setCurationSegmentBeginEnd(editorCas);
                suggestionView.requestUpdate(aTarget, curationContainer, annotationSelectionByUsernameAndAddress, curationSegment);
                annotationEditor.requestRender(aTarget);
                update(aTarget);
            } catch (Exception e) {
                handleException(aTarget, e);
            }
        }
    };
    centerArea.add(suggestionView);
    curationContainer = new CurationContainer();
    curationContainer.setState(getModelObject());
}
Also used : AnnotatorStateImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) CurationContainer(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.CurationContainer) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) LinkedList(java.util.LinkedList) AnnotationException(de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException) UIMAException(org.apache.uima.UIMAException) IOException(java.io.IOException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CAS(org.apache.uima.cas.CAS) SuggestionViewPanel(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.SuggestionViewPanel) ListModel(org.apache.wicket.model.util.ListModel) BratAnnotationEditor(de.tudarmstadt.ukp.clarin.webanno.brat.annotation.BratAnnotationEditor) DocumentNamePanel(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.component.DocumentNamePanel) IFeedback(org.apache.wicket.feedback.IFeedback) ActionBar(de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.ActionBar) SentenceOrientedPagingStrategy(de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.SentenceOrientedPagingStrategy) UserAnnotationSegment(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment)

Example 12 with ListModel

use of org.apache.wicket.model.util.ListModel in project webanno by webanno.

the class ApplicationPageBase method commonInit.

private void commonInit() {
    for (GlobalInterceptor interceptor : interceptorsRegistry.getInterceptors()) {
        interceptor.intercept(this);
    }
    footerItems = new ListModel<>(new ArrayList<>());
    footerItemRegistry.getFooterItems().stream().map(c -> c.create("item")).forEach(c -> footerItems.getObject().add(c));
    footer = new WebMarkupContainer("footer");
    footer.setOutputMarkupId(true);
    add(footer);
    footer.add(new ListView<Component>("footerItems", footerItems) {

        private static final long serialVersionUID = 5912513189482015963L;

        {
            setReuseItems(true);
        }

        @Override
        protected void populateItem(ListItem<Component> aItem) {
            aItem.setOutputMarkupPlaceholderTag(true);
            aItem.add(aItem.getModelObject());
        }
    });
    Properties settings = SettingsUtil.getSettings();
    // Override locale to be used by application
    String locale = settings.getProperty(SettingsUtil.CFG_LOCALE, "en");
    switch(locale) {
        case "auto":
            // Do nothing - locale is picked up from browser
            break;
        default:
            // Override the locale in the session
            getSession().setLocale(Locale.forLanguageTag(locale));
            break;
    }
    // Add menubar
    try {
        Class<? extends Component> menubarClass = getApplication().getMetaData(MENUBAR_CLASS);
        if (menubarClass == null) {
            menubarClass = MenuBar.class;
        }
        add(ConstructorUtils.invokeConstructor(menubarClass, "menubar"));
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e1) {
        throw new RuntimeException(e1);
    }
    feedbackPanel = new BootstrapFeedbackPanel("feedbackPanel");
    feedbackPanel.setOutputMarkupId(true);
    feedbackPanel.setFilter((IFeedbackMessageFilter) aMessage -> {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        String username = auth != null ? auth.getName() : "SYSTEM";
        if (aMessage.isFatal()) {
            LOG.error("{}: {}", username, aMessage.getMessage());
        } else if (aMessage.isError()) {
            LOG.error("{}: {}", username, aMessage.getMessage());
        } else if (aMessage.isWarning()) {
            LOG.warn("{}: {}", username, aMessage.getMessage());
        } else if (aMessage.isInfo()) {
            LOG.info("{}: {}", username, aMessage.getMessage());
        } else if (aMessage.isDebug()) {
            LOG.debug("{}: {}", username, aMessage.getMessage());
        }
        return true;
    });
    add(feedbackPanel);
}
Also used : RuntimeConfigurationType(org.apache.wicket.RuntimeConfigurationType) SettingsUtil(de.tudarmstadt.ukp.clarin.webanno.support.SettingsUtil) SpringBean(org.apache.wicket.spring.injection.annot.SpringBean) LoggerFactory(org.slf4j.LoggerFactory) IFeedbackMessageFilter(org.apache.wicket.feedback.IFeedbackMessageFilter) GlobalInterceptorsRegistry(de.tudarmstadt.ukp.clarin.webanno.support.interceptors.GlobalInterceptorsRegistry) ArrayList(java.util.ArrayList) RequestCycle(org.apache.wicket.request.cycle.RequestCycle) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Locale(java.util.Locale) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) NoOpResourceCachingStrategy(org.apache.wicket.request.resource.caching.NoOpResourceCachingStrategy) BootstrapFeedbackPanel(de.tudarmstadt.ukp.clarin.webanno.support.bootstrap.BootstrapFeedbackPanel) IModel(org.apache.wicket.model.IModel) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) ListView(org.apache.wicket.markup.html.list.ListView) ListModel(org.apache.wicket.model.util.ListModel) Properties(java.util.Properties) Logger(org.slf4j.Logger) ListItem(org.apache.wicket.markup.html.list.ListItem) Component(org.apache.wicket.Component) InvocationTargetException(java.lang.reflect.InvocationTargetException) List(java.util.List) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) MetaDataKey(org.apache.wicket.MetaDataKey) GlobalInterceptor(de.tudarmstadt.ukp.clarin.webanno.support.interceptors.GlobalInterceptor) ConstructorUtils(org.apache.commons.lang3.reflect.ConstructorUtils) WebPage(org.apache.wicket.markup.html.WebPage) Authentication(org.springframework.security.core.Authentication) IPartialPageRequestHandler(org.apache.wicket.core.request.handler.IPartialPageRequestHandler) FooterItemRegistry(de.tudarmstadt.ukp.clarin.webanno.ui.core.footer.FooterItemRegistry) GlobalInterceptor(de.tudarmstadt.ukp.clarin.webanno.support.interceptors.GlobalInterceptor) ArrayList(java.util.ArrayList) Properties(java.util.Properties) BootstrapFeedbackPanel(de.tudarmstadt.ukp.clarin.webanno.support.bootstrap.BootstrapFeedbackPanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) InvocationTargetException(java.lang.reflect.InvocationTargetException) Authentication(org.springframework.security.core.Authentication) Component(org.apache.wicket.Component)

Example 13 with ListModel

use of org.apache.wicket.model.util.ListModel in project webanno by webanno.

the class CurationPage method commonInit.

private void commonInit() {
    setModel(Model.of(new AnnotatorStateImpl(Mode.CURATION)));
    centerArea = new WebMarkupContainer("centerArea");
    centerArea.add(visibleWhen(() -> getModelObject().getDocument() != null));
    centerArea.setOutputMarkupPlaceholderTag(true);
    centerArea.add(new DocumentNamePanel("documentNamePanel", getModel()));
    add(centerArea);
    actionBar = new ActionBar("actionBar");
    centerArea.add(actionBar);
    getModelObject().setPagingStrategy(new SentenceOrientedPagingStrategy());
    centerArea.add(getModelObject().getPagingStrategy().createPositionLabel(MID_NUMBER_OF_PAGES, getModel()).add(visibleWhen(() -> getModelObject().getDocument() != null)).add(LambdaBehavior.onEvent(RenderAnnotationsEvent.class, (c, e) -> e.getRequestHandler().add(c))));
    // Ensure that a user is set
    getModelObject().setUser(new User(CURATION_USER, Role.ROLE_USER));
    curationContainer = new CurationContainer();
    curationContainer.setState(getModelObject());
    WebMarkupContainer sidebarCell = new WebMarkupContainer("rightSidebar");
    sidebarCell.setOutputMarkupPlaceholderTag(true);
    // Override sidebar width from preferences
    sidebarCell.add(new AttributeModifier("style", () -> String.format("flex-basis: %d%%;", getModelObject() != null ? getModelObject().getPreferences().getSidebarSize() : 10)));
    add(sidebarCell);
    curationView = new SourceListView();
    List<UserAnnotationSegment> segments = new LinkedList<>();
    UserAnnotationSegment userAnnotationSegments = new UserAnnotationSegment();
    if (getModelObject() != null) {
        userAnnotationSegments.setSelectionByUsernameAndAddress(annotationSelectionByUsernameAndAddress);
        userAnnotationSegments.setAnnotatorState(getModelObject());
        segments.add(userAnnotationSegments);
    }
    // update source list model only first time.
    sourceListModel = sourceListModel == null ? curationContainer.getCurationViews() : sourceListModel;
    suggestionViewPanel = new SuggestionViewPanel("suggestionViewPanel", new ListModel<>(segments)) {

        private static final long serialVersionUID = 2583509126979792202L;

        @Override
        public void onChange(AjaxRequestTarget aTarget) {
            try {
                // update begin/end of the curationsegment based on annotator state
                // changes
                // (like sentence change in auto-scroll mode,....
                aTarget.addChildren(getPage(), IFeedback.class);
                CurationPage.this.updatePanel(aTarget, curationContainer);
            } catch (UIMAException e) {
                error(ExceptionUtils.getRootCause(e));
            } catch (ClassNotFoundException | AnnotationException | IOException e) {
                error("Error: " + e.getMessage());
            }
        }
    };
    suggestionViewPanel.setOutputMarkupPlaceholderTag(true);
    suggestionViewPanel.add(visibleWhen(() -> getModelObject() != null && getModelObject().getDocument() != null));
    centerArea.add(suggestionViewPanel);
    editor = new AnnotationDetailEditorPanel("annotationDetailEditorPanel", this, getModel()) {

        private static final long serialVersionUID = 2857345299480098279L;

        @Override
        protected void onChange(AjaxRequestTarget aTarget) {
            aTarget.addChildren(getPage(), IFeedback.class);
            try {
                updatePanel(aTarget, curationContainer);
            } catch (UIMAException e) {
                LOG.error("Error: " + e.getMessage(), e);
                error("Error: " + ExceptionUtils.getRootCauseMessage(e));
            } catch (Exception e) {
                LOG.error("Error: " + e.getMessage(), e);
                error("Error: " + e.getMessage());
            }
        }

        @Override
        protected void onAutoForward(AjaxRequestTarget aTarget) {
            annotationEditor.requestRender(aTarget);
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            setEnabled(getModelObject() != null && getModelObject().getDocument() != null && !documentService.getSourceDocument(getModelObject().getDocument().getProject(), getModelObject().getDocument().getName()).getState().equals(SourceDocumentState.CURATION_FINISHED));
        }

        @Override
        public CAS getEditorCas() throws IOException {
            return CurationPage.this.getEditorCas();
        }
    };
    sidebarCell.add(editor);
    annotationEditor = new BratAnnotationEditor("mergeView", getModel(), editor, this::getEditorCas);
    annotationEditor.setHighlightEnabled(false);
    annotationEditor.add(visibleWhen(() -> getModelObject() != null && getModelObject().getDocument() != null));
    annotationEditor.setOutputMarkupPlaceholderTag(true);
    // reset sentenceAddress and lastSentenceAddress to the orginal once
    centerArea.add(annotationEditor);
    // add container for sentences panel
    sentenceListContainer = new WebMarkupContainer("sentenceListContainer");
    sentenceListContainer.setOutputMarkupPlaceholderTag(true);
    sentenceListContainer.add(visibleWhen(() -> getModelObject() != null && getModelObject().getDocument() != null));
    add(sentenceListContainer);
    // add container for list of sentences panel
    sentenceLinksListView = new WebMarkupContainer("sentenceLinkListView");
    sentenceLinksListView.setOutputMarkupPlaceholderTag(true);
    sentenceLinksListView.add(new ListView<SourceListView>("sentenceLinkList", LoadableDetachableModel.of(() -> curationContainer.getCurationViews())) {

        private static final long serialVersionUID = 8539162089561432091L;

        @Override
        protected void populateItem(ListItem<SourceListView> item) {
            item.add(new SentenceLink("sentenceNumber", item.getModel()));
        }
    });
    sentenceListContainer.add(sentenceLinksListView);
}
Also used : User(de.tudarmstadt.ukp.clarin.webanno.security.model.User) AnnotatorStateImpl(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorStateImpl) SourceListView(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.SourceListView) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AnnotationDetailEditorPanel(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.detail.AnnotationDetailEditorPanel) DocumentNamePanel(de.tudarmstadt.ukp.clarin.webanno.ui.annotation.component.DocumentNamePanel) IFeedback(org.apache.wicket.feedback.IFeedback) UIMAException(org.apache.uima.UIMAException) ActionBar(de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.ActionBar) SentenceOrientedPagingStrategy(de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.SentenceOrientedPagingStrategy) CurationContainer(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.CurationContainer) IOException(java.io.IOException) AttributeModifier(org.apache.wicket.AttributeModifier) LinkedList(java.util.LinkedList) NoResultException(javax.persistence.NoResultException) AnnotationException(de.tudarmstadt.ukp.clarin.webanno.api.annotation.exception.AnnotationException) UIMAException(org.apache.uima.UIMAException) IOException(java.io.IOException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CAS(org.apache.uima.cas.CAS) SuggestionViewPanel(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.SuggestionViewPanel) ListModel(org.apache.wicket.model.util.ListModel) BratAnnotationEditor(de.tudarmstadt.ukp.clarin.webanno.brat.annotation.BratAnnotationEditor) UserAnnotationSegment(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment)

Example 14 with ListModel

use of org.apache.wicket.model.util.ListModel in project midpoint by Evolveum.

the class ResourceTasksPanel method createTaskModel.

private ListModel<TaskType> createTaskModel(PrismObject<ResourceType> object) {
    OperationResult result = new OperationResult(OPERATION_LOAD_TASKS);
    List<PrismObject<TaskType>> tasks = WebModelServiceUtils.searchObjects(TaskType.class, QueryBuilder.queryFor(TaskType.class, pageBase.getPrismContext()).item(TaskType.F_OBJECT_REF).ref(object.getOid()).build(), result, pageBase);
    List<TaskType> tasksType = new ArrayList<TaskType>();
    for (PrismObject<TaskType> task : tasks) {
        tasksType.add(task.asObjectable());
    }
    return new ListModel<>(tasksType);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ListModel(org.apache.wicket.model.util.ListModel) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 15 with ListModel

use of org.apache.wicket.model.util.ListModel in project midpoint by Evolveum.

the class AuditLogViewerPanel method initParametersPanel.

private void initParametersPanel(Form mainForm) {
    WebMarkupContainer parametersPanel = new WebMarkupContainer(ID_PARAMETERS_PANEL);
    parametersPanel.setOutputMarkupId(true);
    mainForm.add(parametersPanel);
    PropertyModel<XMLGregorianCalendar> fromModel = new PropertyModel<XMLGregorianCalendar>(auditSearchDto, AuditSearchDto.F_FROM);
    DatePanel from = new DatePanel(ID_FROM, fromModel);
    DateValidator dateFromValidator = WebComponentUtil.getRangeValidator(mainForm, new ItemPath(AuditSearchDto.F_FROM));
    dateFromValidator.setMessageKey("AuditLogViewerPanel.dateValidatorMessage");
    dateFromValidator.setDateFrom((DateTimeField) from.getBaseFormComponent());
    for (FormComponent<?> formComponent : from.getFormComponents()) {
        formComponent.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    }
    from.setOutputMarkupId(true);
    parametersPanel.add(from);
    PropertyModel<XMLGregorianCalendar> toModel = new PropertyModel<XMLGregorianCalendar>(auditSearchDto, AuditSearchDto.F_TO);
    DatePanel to = new DatePanel(ID_TO, toModel);
    DateValidator dateToValidator = WebComponentUtil.getRangeValidator(mainForm, new ItemPath(AuditSearchDto.F_FROM));
    dateToValidator.setMessageKey("AuditLogViewerPanel.dateValidatorMessage");
    dateToValidator.setDateTo((DateTimeField) to.getBaseFormComponent());
    for (FormComponent<?> formComponent : to.getFormComponents()) {
        formComponent.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    }
    to.setOutputMarkupId(true);
    parametersPanel.add(to);
    PropertyModel<ItemPathDto> changedItemModel = new PropertyModel<ItemPathDto>(auditSearchDto, AuditSearchDto.F_CHANGED_ITEM);
    ItemPathPanel changedItemPanel = new ItemPathPanel(ID_CHANGED_ITEM, changedItemModel, pageBase);
    //        changedItemPanel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    //        changedItemPanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    changedItemPanel.setOutputMarkupId(true);
    parametersPanel.add(changedItemPanel);
    PropertyModel<String> hostIdentifierModel = new PropertyModel<>(auditSearchDto, AuditSearchDto.F_HOST_IDENTIFIER);
    TextPanel<String> hostIdentifier = new TextPanel<>(ID_HOST_IDENTIFIER, hostIdentifierModel);
    hostIdentifier.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    hostIdentifier.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    hostIdentifier.setOutputMarkupId(true);
    parametersPanel.add(hostIdentifier);
    ListModel<AuditEventTypeType> eventTypeListModel = new ListModel<AuditEventTypeType>(Arrays.asList(AuditEventTypeType.values()));
    PropertyModel<AuditEventTypeType> eventTypeModel = new PropertyModel<AuditEventTypeType>(auditSearchDto, AuditSearchDto.F_EVENT_TYPE);
    DropDownChoicePanel<AuditEventTypeType> eventType = new DropDownChoicePanel<AuditEventTypeType>(ID_EVENT_TYPE, eventTypeModel, eventTypeListModel, new EnumChoiceRenderer<AuditEventTypeType>(), true);
    eventType.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    eventType.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    eventType.setOutputMarkupId(true);
    parametersPanel.add(eventType);
    WebMarkupContainer eventStage = new WebMarkupContainer(ID_EVENT_STAGE);
    eventStage.add(visibilityByKey(visibilityMap, EVENT_STAGE_LABEL_VISIBILITY));
    eventStage.setOutputMarkupId(true);
    parametersPanel.add(eventStage);
    ListModel<AuditEventStageType> eventStageListModel = new ListModel<AuditEventStageType>(Arrays.asList(AuditEventStageType.values()));
    PropertyModel<AuditEventStageType> eventStageModel = new PropertyModel<AuditEventStageType>(auditSearchDto, AuditSearchDto.F_EVENT_STAGE);
    DropDownChoicePanel<AuditEventStageType> eventStageField = new DropDownChoicePanel<AuditEventStageType>(ID_EVENT_STAGE_FIELD, eventStageModel, eventStageListModel, new EnumChoiceRenderer<AuditEventStageType>(), true);
    eventStageField.add(visibilityByKey(visibilityMap, EVENT_STAGE_FIELD_VISIBILITY));
    eventStageField.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    eventStageField.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    eventStageField.setOutputMarkupId(true);
    eventStage.add(eventStageField);
    ListModel<OperationResultStatusType> outcomeListModel = new ListModel<OperationResultStatusType>(Arrays.asList(OperationResultStatusType.values()));
    PropertyModel<OperationResultStatusType> outcomeModel = new PropertyModel<OperationResultStatusType>(auditSearchDto, AuditSearchDto.F_OUTCOME);
    DropDownChoicePanel<OperationResultStatusType> outcome = new DropDownChoicePanel<OperationResultStatusType>(ID_OUTCOME, outcomeModel, outcomeListModel, new EnumChoiceRenderer<OperationResultStatusType>(), true);
    outcome.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    outcome.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    outcome.setOutputMarkupId(true);
    parametersPanel.add(outcome);
    List<String> channelList = WebComponentUtil.getChannelList();
    List<QName> channelQnameList = new ArrayList<QName>();
    for (int i = 0; i < channelList.size(); i++) {
        String channel = channelList.get(i);
        if (channel != null) {
            QName channelQName = QNameUtil.uriToQName(channel);
            channelQnameList.add(channelQName);
        }
    }
    ListModel<QName> channelListModel = new ListModel<QName>(channelQnameList);
    PropertyModel<QName> channelModel = new PropertyModel<QName>(auditSearchDto, AuditSearchDto.F_CHANNEL);
    DropDownChoicePanel<QName> channel = new DropDownChoicePanel<QName>(ID_CHANNEL, channelModel, channelListModel, new QNameChoiceRenderer(), true);
    channel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    channel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    channel.setOutputMarkupId(true);
    parametersPanel.add(channel);
    List<Class<? extends ObjectType>> allowedClasses = new ArrayList<>();
    allowedClasses.add(UserType.class);
    MultiValueChoosePanel<ObjectType> chooseInitiatorPanel = new SingleValueChoosePanel<ObjectReferenceType, ObjectType>(ID_INITIATOR_NAME, allowedClasses, objectReferenceTransformer, new PropertyModel<ObjectReferenceType>(auditSearchDto, AuditSearchDto.F_INITIATOR_NAME));
    parametersPanel.add(chooseInitiatorPanel);
    WebMarkupContainer targetOwnerName = new WebMarkupContainer(ID_TARGET_OWNER_NAME);
    targetOwnerName.add(visibilityByKey(visibilityMap, TARGET_OWNER_LABEL_VISIBILITY));
    parametersPanel.add(targetOwnerName);
    MultiValueChoosePanel<ObjectType> chooseTargerOwnerPanel = new SingleValueChoosePanel<ObjectReferenceType, ObjectType>(ID_TARGET_OWNER_NAME_FIELD, allowedClasses, objectReferenceTransformer, new PropertyModel<ObjectReferenceType>(auditSearchDto, AuditSearchDto.F_TARGET_OWNER_NAME));
    chooseTargerOwnerPanel.add(visibilityByKey(visibilityMap, TARGET_OWNER_FIELD_VISIBILITY));
    targetOwnerName.add(chooseTargerOwnerPanel);
    WebMarkupContainer targetName = new WebMarkupContainer(ID_TARGET_NAME);
    targetName.add(visibilityByKey(visibilityMap, TARGET_NAME_LABEL_VISIBILITY));
    parametersPanel.add(targetName);
    List<Class<? extends ObjectType>> allowedClassesAll = new ArrayList<>();
    allowedClassesAll.addAll(ObjectTypes.getAllObjectTypes());
    MultiValueChoosePanel<ObjectType> chooseTargetPanel = new MultiValueChoosePanel<ObjectType>(ID_TARGET_NAME_FIELD, new PropertyModel<List<ObjectType>>(auditSearchDto, AuditSearchDto.F_TARGET_NAMES_OBJECTS), allowedClassesAll);
    chooseTargetPanel.setOutputMarkupId(true);
    chooseTargetPanel.add(visibilityByKey(visibilityMap, TARGET_NAME_FIELD_VISIBILITY));
    targetName.add(chooseTargetPanel);
    AjaxSubmitButton ajaxButton = new AjaxSubmitButton(ID_SEARCH_BUTTON, createStringResource("BasicSearchPanel.search")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            auditLogStorage.setSearchDto(searchDto);
            auditLogStorage.setPageNumber(0);
            Form mainForm = (Form) getParent().getParent();
            addOrReplaceTable(mainForm);
            getFeedbackPanel().getFeedbackMessages().clear();
            target.add(getFeedbackPanel());
            target.add(mainForm);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
        }
    };
    WebMarkupContainer valueRefTargetNameContainer = new WebMarkupContainer(ID_VALUE_REF_TARGET_NAMES);
    valueRefTargetNameContainer.add(visibilityByKey(visibilityMap, TARGET_NAME_LABEL_VISIBILITY));
    parametersPanel.add(valueRefTargetNameContainer);
    MultiValueChoosePanel<ObjectType> chooseValueRefTargetNamePanel = new MultiValueChoosePanel<ObjectType>(ID_VALUE_REF_TARGET_NAMES_FIELD, new PropertyModel<List<ObjectType>>(auditSearchDto, AuditSearchDto.F_VALUE_REF_TARGET_NAME), allowedClassesAll);
    chooseValueRefTargetNamePanel.setOutputMarkupId(true);
    chooseValueRefTargetNamePanel.add(visibilityByKey(visibilityMap, VALUE_REF_TARGET_NAME_FIELD_VISIBILITY));
    valueRefTargetNameContainer.add(chooseValueRefTargetNamePanel);
    ajaxButton.setOutputMarkupId(true);
    parametersPanel.add(ajaxButton);
}
Also used : ArrayList(java.util.ArrayList) TextPanel(com.evolveum.midpoint.web.component.input.TextPanel) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) DatePanel(com.evolveum.midpoint.web.component.input.DatePanel) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) ItemPathPanel(com.evolveum.midpoint.gui.api.component.path.ItemPathPanel) MultiValueChoosePanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueChoosePanel) DateValidator(com.evolveum.midpoint.web.util.DateValidator) OperationResultStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType) ItemPathDto(com.evolveum.midpoint.gui.api.component.path.ItemPathDto) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AuditEventStageType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventStageType) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) Form(org.apache.wicket.markup.html.form.Form) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) QName(javax.xml.namespace.QName) PropertyModel(org.apache.wicket.model.PropertyModel) ListModel(org.apache.wicket.model.util.ListModel) AuditEventTypeType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventTypeType) CanonicalItemPath(com.evolveum.midpoint.prism.path.CanonicalItemPath) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

ListModel (org.apache.wicket.model.util.ListModel)28 ArrayList (java.util.ArrayList)14 List (java.util.List)13 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)12 IModel (org.apache.wicket.model.IModel)9 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)8 Test (org.junit.Test)8 FormTester (org.apache.wicket.util.tester.FormTester)7 Model (org.apache.wicket.model.Model)5 QName (javax.xml.namespace.QName)4 EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)3 IOException (java.io.IOException)3 FilterCriteriaManager (ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager)3 IFilterCriteriaManager (ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager)3 AutoCompleteTextPanel (com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)2 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)2 ColumnTypeDto (com.evolveum.midpoint.web.component.data.column.ColumnTypeDto)2