Search in sources :

Example 1 with PropertyModel

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

the class SceneItemLinePanel method initLayout.

private void initLayout() {
    WebMarkupContainer nameCell = new WebMarkupContainer(ID_NAME_CONTAINER);
    nameCell.add(new AttributeModifier("rowspan", new PropertyModel<Integer>(getModel(), SceneItemLineDto.F_NUMBER_OF_LINES)));
    Label label = new Label("name", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            final SceneItemLineDto lineDto = getModel().getObject();
            if (lineDto == null || lineDto.getName() == null) {
                return null;
            }
            String key = lineDto.getName();
            return getLocalizer().getString(key, SceneItemLinePanel.this, key);
        }
    });
    nameCell.add(label);
    nameCell.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().isFirst();
        }
    });
    add(nameCell);
    WebMarkupContainer oldValueCell = new WebMarkupContainer(ID_OLD_VALUE_CONTAINER);
    oldValueCell.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().isDelta();
        }
    });
    SceneItemValuePanel sivp = new SceneItemValuePanel(ID_OLD_VALUE, new PropertyModel<SceneItemValue>(getModel(), SceneItemLineDto.F_OLD_VALUE));
    sivp.setRenderBodyOnly(true);
    oldValueCell.add(sivp);
    ImagePanel oldValueImagePanel = new ImagePanel(ID_OLD_VALUE_IMAGE, Model.of(GuiStyleConstants.CLASS_MINUS_CIRCLE_DANGER), createStringResource("SceneItemLinePanel.removedValue"));
    oldValueImagePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getOldValue() != null && getModelObject().getOldValue().getSourceValue() != null;
        }
    });
    oldValueCell.add(oldValueImagePanel);
    add(oldValueCell);
    WebMarkupContainer newValueCell = new WebMarkupContainer(ID_NEW_VALUE_CONTAINER);
    sivp = new SceneItemValuePanel(ID_NEW_VALUE, new PropertyModel<SceneItemValue>(getModel(), SceneItemLineDto.F_NEW_VALUE));
    sivp.setRenderBodyOnly(true);
    newValueCell.add(sivp);
    newValueCell.add(new AttributeModifier("colspan", new AbstractReadOnlyModel<Integer>() {

        @Override
        public Integer getObject() {
            return !getModelObject().isDelta() && getModelObject().isDeltaScene() ? 2 : 1;
        }
    }));
    newValueCell.add(new AttributeModifier("align", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return !getModelObject().isDelta() && getModelObject().isDeltaScene() ? "center" : null;
        }
    }));
    ImagePanel newValueImagePanel = new ImagePanel(ID_NEW_VALUE_IMAGE, !getModelObject().isDelta() && getModelObject().isDeltaScene() ? Model.of(GuiStyleConstants.CLASS_CIRCLE_FULL) : Model.of(GuiStyleConstants.CLASS_PLUS_CIRCLE_SUCCESS), !getModelObject().isDelta() && getModelObject().isDeltaScene() ? createStringResource("SceneItemLinePanel.unchangedValue") : createStringResource("SceneItemLinePanel.addedValue"));
    newValueImagePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getNewValue() != null && getModelObject().getNewValue().getSourceValue() != null;
        }
    });
    newValueImagePanel.add(new AttributeAppender("style", !getModelObject().isDelta() && getModelObject().isDeltaScene() ? "float: left; margin-right: 5px; width: 30%; position: absolute;" : "float: left; margin-right: 5px;"));
    newValueCell.add(newValueImagePanel);
    add(newValueCell);
}
Also used : SceneItemValue(com.evolveum.midpoint.model.api.visualizer.SceneItemValue) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PropertyModel(org.apache.wicket.model.PropertyModel) Label(org.apache.wicket.markup.html.basic.Label) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) ImagePanel(com.evolveum.midpoint.web.component.data.column.ImagePanel)

Example 2 with PropertyModel

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

the class ScannerHandlerPanel method initLayout.

private void initLayout() {
    WebMarkupContainer lastScanTimestampContainer = new WebMarkupContainer(ID_LAST_SCAN_TIMESTAMP_CONTAINER);
    //		lastScanTimestampContainer.add(new VisibleEnableBehaviour() {
    //			@Override
    //			public boolean isVisible() {
    //				return getModelObject().getTaskDto().getObjectRefOid() != null;
    //			}
    //		});
    lastScanTimestampContainer.add(new Label(ID_LAST_SCAN_TIMESTAMP, new PropertyModel<>(getModel(), ScannerHandlerDto.F_LAST_SCAN_TIMESTAMP)));
    add(lastScanTimestampContainer);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 3 with PropertyModel

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

the class SynchronizationStep method initObjectSyncEditor.

private void initObjectSyncEditor(WebMarkupContainer editor) {
    Label editorLabel = new Label(ID_EDITOR_LABEL, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (!isAnySelected()) {
                // shouldn't occur
                return null;
            }
            String name = syncDtoModel.getObject().getSelected().getName() != null ? syncDtoModel.getObject().getSelected().getName() : "";
            return getString("SynchronizationStep.label.editSyncObject", name);
        }
    });
    editorLabel.setOutputMarkupId(true);
    editor.add(editorLabel);
    TextField editorName = new TextField<>(ID_EDITOR_NAME, new PropertyModel<String>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".name"));
    editorName.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorName);
    editor.add(editorName);
    TextArea editorDescription = new TextArea<>(ID_EDITOR_DESCRIPTION, new PropertyModel<String>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".description"));
    parentPage.addEditingEnabledBehavior(editorDescription);
    editor.add(editorDescription);
    DropDownChoice editorKind = new DropDownChoice<>(ID_EDITOR_KIND, new PropertyModel<ShadowKindType>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".kind"), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>());
    editorKind.setNullValid(true);
    editorKind.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorKind);
    editor.add(editorKind);
    TextField editorIntent = new TextField<>(ID_EDITOR_INTENT, new PropertyModel<String>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".intent"));
    editorIntent.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorIntent);
    editor.add(editorIntent);
    MultiValueAutoCompleteTextPanel<QName> editorObjectClass = new MultiValueAutoCompleteTextPanel<QName>(ID_EDITOR_OBJECT_CLASS, new PropertyModel<List<QName>>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".objectClass"), true, parentPage.getReadOnlyModel()) {

        @Override
        protected IModel<String> createTextModel(final IModel<QName> model) {
            return new PropertyModel<>(model, "localPart");
        }

        @Override
        protected QName createNewEmptyItem() {
            return new QName("");
        }

        @Override
        protected boolean buttonsDisabled() {
            return !isAnySelected();
        }

        @Override
        protected List<QName> createObjectList() {
            return syncDtoModel.getObject().getObjectClassList();
        }

        @Override
        protected String createAutoCompleteObjectLabel(QName object) {
            return object.getLocalPart();
        }

        @Override
        protected IValidator<String> createAutoCompleteValidator() {
            return createObjectClassValidator(new AbstractReadOnlyModel<List<QName>>() {

                @Override
                public List<QName> getObject() {
                    return syncDtoModel.getObject().getObjectClassList();
                }
            });
        }
    };
    parentPage.addEditingEnabledBehavior(editorObjectClass);
    editor.add(editorObjectClass);
    // TODO: switch to ObjectTypeSelectPanel
    DropDownChoice editorFocus = new DropDownChoice<>(ID_EDITOR_FOCUS, new PropertyModel<QName>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".focusType"), new AbstractReadOnlyModel<List<QName>>() {

        @Override
        public List<QName> getObject() {
            return WebComponentUtil.createFocusTypeList();
        }
    }, new QNameChoiceRenderer());
    editorFocus.setNullValid(true);
    editorFocus.add(new UpdateNamesBehaviour());
    parentPage.addEditingEnabledBehavior(editorFocus);
    editor.add(editorFocus);
    CheckBox editorEnabled = new CheckBox(ID_EDITOR_ENABLED, new PropertyModel<Boolean>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".enabled"));
    parentPage.addEditingEnabledBehavior(editorEnabled);
    editor.add(editorEnabled);
    AjaxSubmitLink editorCondition = new AjaxSubmitLink(ID_EDITOR_BUTTON_CONDITION) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            conditionEditPerformed(target);
        }
    };
    addDisableClassModifier(editorCondition);
    editor.add(editorCondition);
    AjaxSubmitLink editorConfirmation = new AjaxSubmitLink(ID_EDITOR_BUTTON_CONFIRMATION) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            confirmationEditPerformed(target);
        }
    };
    addDisableClassModifier(editorConfirmation);
    editor.add(editorConfirmation);
    DropDownChoice editorObjectTemplate = new DropDownChoice<>(ID_EDITOR_OBJECT_TEMPLATE, new PropertyModel<ObjectReferenceType>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".objectTemplateRef"), new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

        @Override
        public List<ObjectReferenceType> getObject() {
            return WebModelServiceUtils.createObjectReferenceList(ObjectTemplateType.class, getPageBase(), syncDtoModel.getObject().getObjectTemplateMap());
        }
    }, new ObjectReferenceChoiceRenderer(syncDtoModel.getObject().getObjectTemplateMap()));
    editorObjectTemplate.setNullValid(true);
    parentPage.addEditingEnabledBehavior(editorObjectTemplate);
    editor.add(editorObjectTemplate);
    CheckBox editorReconcile = new CheckBox(ID_EDITOR_RECONCILE, new PropertyModel<Boolean>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".reconcile"));
    parentPage.addEditingEnabledBehavior(editorReconcile);
    editor.add(editorReconcile);
    TriStateComboPanel opportunistic = new TriStateComboPanel(ID_EDITOR_OPPORTUNISTIC, new PropertyModel<Boolean>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".opportunistic"));
    parentPage.addEditingEnabledBehavior(opportunistic);
    editor.add(opportunistic);
    MultiValueTextEditPanel editorCorrelation = new MultiValueTextEditPanel<ConditionalSearchFilterType>(ID_EDITOR_EDITOR_CORRELATION, new PropertyModel<List<ConditionalSearchFilterType>>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".correlation"), new PropertyModel<ConditionalSearchFilterType>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED_CORRELATION), false, true, parentPage.getReadOnlyModel()) {

        @Override
        protected IModel<String> createTextModel(final IModel<ConditionalSearchFilterType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    StringBuilder sb = new StringBuilder();
                    ConditionalSearchFilterType searchFilter = model.getObject();
                    if (searchFilter != null && searchFilter.getDescription() != null) {
                        sb.append(searchFilter.getDescription());
                    }
                    if (sb.toString().isEmpty()) {
                        sb.append(getString("SynchronizationStep.label.notSpecified"));
                    }
                    return sb.toString();
                }
            };
        }

        @Override
        protected ConditionalSearchFilterType createNewEmptyItem() {
            return new ConditionalSearchFilterType();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, ConditionalSearchFilterType object) {
            correlationEditPerformed(target, object);
        }

        @Override
        protected void performAddValueHook(AjaxRequestTarget target, ConditionalSearchFilterType added) {
            parentPage.refreshIssues(target);
        }

        @Override
        protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<ConditionalSearchFilterType> item) {
            parentPage.refreshIssues(target);
        }

        @Override
        protected boolean buttonsDisabled() {
            return !isAnySelected();
        }
    };
    editor.add(editorCorrelation);
    MultiValueTextEditPanel editorReaction = new MultiValueTextEditPanel<SynchronizationReactionType>(ID_EDITOR_REACTION, new PropertyModel<List<SynchronizationReactionType>>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED + ".reaction"), new PropertyModel<SynchronizationReactionType>(syncDtoModel, ResourceSynchronizationDto.F_SELECTED_REACTION), false, true, parentPage.getReadOnlyModel()) {

        @Override
        protected IModel<String> createTextModel(final IModel<SynchronizationReactionType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    SynchronizationReactionType reaction = model.getObject();
                    if (reaction == null) {
                        return "";
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.append(reaction.getName() != null ? reaction.getName() + " " : "");
                    sb.append("(");
                    if (reaction.getSituation() != null) {
                        sb.append(reaction.getSituation());
                    }
                    if (Boolean.TRUE.equals(reaction.isSynchronize()) || !reaction.getAction().isEmpty()) {
                        sb.append(" -> ");
                        if (!reaction.getAction().isEmpty()) {
                            boolean first = true;
                            for (SynchronizationActionType action : reaction.getAction()) {
                                if (first) {
                                    first = false;
                                } else {
                                    sb.append(", ");
                                }
                                sb.append(StringUtils.substringAfter(action.getHandlerUri(), "#"));
                            }
                        } else {
                            // TODO i18n
                            sb.append("sync");
                        }
                    }
                    sb.append(")");
                    return sb.toString();
                }
            };
        }

        @Override
        protected SynchronizationReactionType createNewEmptyItem() {
            return new SynchronizationReactionType();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, SynchronizationReactionType object) {
            reactionEditPerformed(target, object);
        }

        @Override
        protected void performAddValueHook(AjaxRequestTarget target, SynchronizationReactionType added) {
            parentPage.refreshIssues(target);
        }

        @Override
        protected void performRemoveValueHook(AjaxRequestTarget target, ListItem<SynchronizationReactionType> item) {
            parentPage.refreshIssues(target);
        }

        @Override
        protected boolean buttonsDisabled() {
            return !isAnySelected();
        }
    };
    editorReaction.setOutputMarkupId(true);
    editor.add(editorReaction);
    Label kindTooltip = new Label(ID_T_KIND);
    kindTooltip.add(new InfoTooltipBehavior());
    editor.add(kindTooltip);
    Label intentTooltip = new Label(ID_T_INTENT);
    intentTooltip.add(new InfoTooltipBehavior());
    editor.add(intentTooltip);
    Label objClassTooltip = new Label(ID_T_OBJ_CLASS);
    objClassTooltip.add(new InfoTooltipBehavior());
    editor.add(objClassTooltip);
    Label focusTooltip = new Label(ID_T_FOCUS);
    focusTooltip.add(new InfoTooltipBehavior());
    editor.add(focusTooltip);
    Label enabledTooltip = new Label(ID_T_ENABLED);
    enabledTooltip.add(new InfoTooltipBehavior());
    editor.add(enabledTooltip);
    Label conditionTooltip = new Label(ID_T_CONDITION);
    conditionTooltip.add(new InfoTooltipBehavior());
    editor.add(conditionTooltip);
    Label confirmationTooltip = new Label(ID_T_CONFIRMATION);
    confirmationTooltip.add(new InfoTooltipBehavior());
    editor.add(confirmationTooltip);
    Label objTemplateTooltip = new Label(ID_T_OBJ_TEMPLATE);
    objTemplateTooltip.add(new InfoTooltipBehavior());
    editor.add(objTemplateTooltip);
    Label reconcileTooltip = new Label(ID_T_RECONCILE);
    reconcileTooltip.add(new InfoTooltipBehavior());
    editor.add(reconcileTooltip);
    Label opportunisticTooltip = new Label(ID_T_OPPORTUNISTIC);
    opportunisticTooltip.add(new InfoTooltipBehavior());
    editor.add(opportunisticTooltip);
    Label correlationTooltip = new Label(ID_T_CORRELATION);
    correlationTooltip.add(new InfoTooltipBehavior());
    editor.add(correlationTooltip);
    Label reactionTooltip = new Label(ID_T_REACTION);
    reactionTooltip.add(new InfoTooltipBehavior());
    editor.add(reactionTooltip);
}
Also used : ObjectReferenceChoiceRenderer(com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer) TriStateComboPanel(com.evolveum.midpoint.web.component.input.TriStateComboPanel) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) MultiValueTextEditPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel) MultiValueAutoCompleteTextPanel(com.evolveum.midpoint.web.component.form.multivalue.MultiValueAutoCompleteTextPanel) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) NonEmptyLoadableModel(com.evolveum.midpoint.gui.api.model.NonEmptyLoadableModel) PropertyModel(org.apache.wicket.model.PropertyModel) NonEmptyWrapperModel(com.evolveum.midpoint.gui.api.model.NonEmptyWrapperModel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 4 with PropertyModel

use of org.apache.wicket.model.PropertyModel 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 5 with PropertyModel

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

the class TextPopupPanel method initTextField.

private TextField initTextField() {
    IModel data = new PropertyModel(getModel(), SearchValue.F_VALUE);
    if (lookup == null) {
        return new TextField(ID_TEXT_INPUT, data);
    }
    AutoCompleteSettings settings = new AutoCompleteSettings();
    settings.setShowListOnEmptyInput(true);
    return new AutoCompleteTextField(ID_TEXT_INPUT, data, settings) {

        @Override
        protected Iterator getChoices(String input) {
            return prepareAutoCompleteList(input).iterator();
        }
    };
}
Also used : AutoCompleteSettings(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings) IModel(org.apache.wicket.model.IModel) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) PropertyModel(org.apache.wicket.model.PropertyModel) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) TextField(org.apache.wicket.markup.html.form.TextField)

Aggregations

PropertyModel (org.apache.wicket.model.PropertyModel)70 Label (org.apache.wicket.markup.html.basic.Label)38 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)37 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)32 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)29 ArrayList (java.util.ArrayList)22 List (java.util.List)21 IModel (org.apache.wicket.model.IModel)21 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)20 ListItem (org.apache.wicket.markup.html.list.ListItem)17 ListView (org.apache.wicket.markup.html.list.ListView)15 Model (org.apache.wicket.model.Model)13 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)10 TextField (org.apache.wicket.markup.html.form.TextField)10 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)9 QName (javax.xml.namespace.QName)8 Form (org.apache.wicket.markup.html.form.Form)8 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)6 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)6 MultiValueTextEditPanel (com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel)5