Search in sources :

Example 1 with InputPanel

use of com.evolveum.midpoint.web.component.prism.InputPanel in project midpoint by Evolveum.

the class RunReportPopupPanel method createInputMarkup.

private WebMarkupContainer createInputMarkup(final IModel<JasperReportValueDto> valueModel, JasperReportParameterDto param) {
    param.setEditing(true);
    WebMarkupContainer paramValueMarkup = new WebMarkupContainer("valueMarkup");
    paramValueMarkup.setOutputMarkupId(true);
    InputPanel input = createTypedInputPanel("inputValue", valueModel, "value", param);
    paramValueMarkup.add(input);
    //buttons
    AjaxLink<String> addButton = new AjaxLink<String>(ID_ADD_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValue(paramValueMarkup, param, target);
        }
    };
    addButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isAddButtonVisible(param);
        }
    });
    paramValueMarkup.add(addButton);
    AjaxLink<String> removeButton = new AjaxLink<String>(ID_REMOVE_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeValue(paramValueMarkup, param, valueModel.getObject(), target);
        }
    };
    removeButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isRemoveButtonVisible();
        }
    });
    paramValueMarkup.add(removeButton);
    return paramValueMarkup;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 2 with InputPanel

use of com.evolveum.midpoint.web.component.prism.InputPanel in project midpoint by Evolveum.

the class ACAttributeValuePanel method createTypedInputComponent.

private InputPanel createTypedInputComponent(String id, PrismPropertyDefinition definition) {
    QName valueType = definition.getTypeName();
    final String baseExpression = ACValueConstructionDto.F_VALUE;
    InputPanel panel;
    if (DOMUtil.XSD_DATETIME.equals(valueType)) {
        panel = new DatePanel(id, new PropertyModel<>(getModel(), baseExpression));
    } else if (ProtectedStringType.COMPLEX_TYPE.equals(valueType)) {
        panel = new PasswordPanel(id, new PropertyModel<>(getModel(), baseExpression));
    } else if (DOMUtil.XSD_BOOLEAN.equals(valueType)) {
        panel = new TriStateComboPanel(id, new PropertyModel<>(getModel(), baseExpression));
    } else if (SchemaConstants.T_POLY_STRING_TYPE.equals(valueType)) {
        panel = new TextPanel<>(id, new PropertyModel<>(getModel(), baseExpression + ".orig"), String.class);
    } else {
        Class type = XsdTypeMapper.getXsdToJavaMapping(valueType);
        if (type != null && type.isPrimitive()) {
            type = ClassUtils.primitiveToWrapper(type);
        }
        panel = new TextPanel<>(id, new PropertyModel<>(getModel(), baseExpression), type);
        if (ObjectType.F_NAME.equals(definition.getItemName())) {
            panel.getBaseFormComponent().setRequired(true);
        }
    }
    return panel;
}
Also used : TriStateComboPanel(com.evolveum.midpoint.web.component.input.TriStateComboPanel) PasswordPanel(com.evolveum.midpoint.gui.api.component.password.PasswordPanel) QName(javax.xml.namespace.QName) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) DatePanel(com.evolveum.midpoint.web.component.input.DatePanel) PropertyModel(org.apache.wicket.model.PropertyModel) TextPanel(com.evolveum.midpoint.web.component.input.TextPanel)

Example 3 with InputPanel

use of com.evolveum.midpoint.web.component.prism.InputPanel in project midpoint by Evolveum.

the class SearchSpecialItemPanel method initLayout.

protected void initLayout() {
    setOutputMarkupId(true);
    WebMarkupContainer searchItemContainer = new WebMarkupContainer(ID_SEARCH_ITEM_CONTAINER);
    searchItemContainer.setOutputMarkupId(true);
    add(searchItemContainer);
    IModel<String> labelModel = createLabelModel();
    Label searchItemLabel = new Label(ID_SEARCH_ITEM_LABEL, labelModel);
    searchItemLabel.setOutputMarkupId(true);
    searchItemLabel.add(new VisibleBehaviour(() -> StringUtils.isNotEmpty(labelModel.getObject())));
    IModel<String> titleModel = createTitleModel();
    if (StringUtils.isNotEmpty(titleModel.getObject())) {
        searchItemLabel.add(AttributeAppender.append("title", titleModel));
    }
    searchItemContainer.add(searchItemLabel);
    Label help = new Label(ID_HELP);
    IModel<String> helpModel = createHelpModel();
    help.add(AttributeModifier.replace("title", createStringResource(helpModel.getObject() != null ? helpModel.getObject() : "")));
    help.add(new InfoTooltipBehavior() {

        @Override
        public String getDataPlacement() {
            return "left";
        }
    });
    help.add(new VisibleBehaviour(() -> StringUtils.isNotEmpty(helpModel.getObject())));
    searchItemContainer.add(help);
    WebMarkupContainer inputPanel = initSearchItemField(ID_SEARCH_ITEM_FIELD);
    if (inputPanel instanceof InputPanel && !(inputPanel instanceof AutoCompleteTextPanel)) {
        ((InputPanel) inputPanel).getBaseFormComponent().add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
    }
    inputPanel.setOutputMarkupId(true);
    searchItemContainer.add(inputPanel);
}
Also used : InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AutoCompleteTextPanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel)

Example 4 with InputPanel

use of com.evolveum.midpoint.web.component.prism.InputPanel in project midpoint by Evolveum.

the class SearchTypePanel method initSearchItemField.

protected void initSearchItemField(WebMarkupContainer searchItemContainer) {
    Component searchItemField = new WebMarkupContainer(ID_SEARCH_ITEM_FIELD);
    ContainerTypeSearchItem<C> item = getModelObject();
    if (item != null && item.getAllowedValues() != null) {
        List<DisplayableValue<Class<C>>> allowedValues = item.getAllowedValues();
        if (allowedValues != null && !allowedValues.isEmpty()) {
            IModel<List<DisplayableValue<?>>> choices = new ListModel(item.getAllowedValues());
            searchItemField = WebComponentUtil.createDropDownChoices(ID_SEARCH_ITEM_FIELD, new PropertyModel(getModel(), ContainerTypeSearchItem.F_TYPE), (IModel) choices, false, getPageBase());
        }
    }
    if (searchItemField instanceof InputPanel && !(searchItemField instanceof AutoCompleteTextPanel)) {
        ((InputPanel) searchItemField).getBaseFormComponent().add(AttributeAppender.append("style", "width: 175px; max-width: 400px !important;"));
        ((InputPanel) searchItemField).getBaseFormComponent().add(new OnChangeAjaxBehavior() {

            private static final long serialVersionUID = 1L;

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                searchPerformed(target);
            }
        });
    }
    searchItemField.setOutputMarkupId(true);
    searchItemContainer.add(searchItemField);
}
Also used : IModel(org.apache.wicket.model.IModel) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) PropertyModel(org.apache.wicket.model.PropertyModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AutoCompleteTextPanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DisplayableValue(com.evolveum.midpoint.util.DisplayableValue) ListModel(org.apache.wicket.model.util.ListModel) List(java.util.List) Component(org.apache.wicket.Component)

Example 5 with InputPanel

use of com.evolveum.midpoint.web.component.prism.InputPanel in project midpoint by Evolveum.

the class PolyStringEditorPanel method initLayout.

private void initLayout() {
    setOutputMarkupId(true);
    String localizedValue = getLocalizedPolyStringValue();
    WebMarkupContainer localizedValueContainer = new WebMarkupContainer(ID_LOCALIZED_VALUE_CONTAINER);
    localizedValueContainer.setOutputMarkupId(true);
    localizedValueContainer.add(getInputFieldClassAppenderForContainer());
    localizedValueContainer.add(new VisibleBehaviour(() -> showFullData || StringUtils.isNotEmpty(localizedValue)));
    add(localizedValueContainer);
    Label localizedValueLabel = new Label(ID_LOCALIZED_VALUE_LABEL, ((PageBase) getPage()).createStringResource("PolyStringEditorPanel.localizedValue"));
    localizedValueLabel.setOutputMarkupId(true);
    localizedValueLabel.add(new VisibleBehaviour(() -> showFullData));
    localizedValueContainer.add(localizedValueLabel);
    WebMarkupContainer localizedValueWithButton = new WebMarkupContainer(ID_LOCALIZED_VALUE_WITH_BUTTON);
    localizedValueWithButton.setOutputMarkupId(true);
    localizedValueWithButton.add(getInputFieldClassAppender());
    localizedValueContainer.add(localizedValueWithButton);
    TextPanel<String> localizedValuePanel = new TextPanel<>(ID_LOCALIZED_VALUE_PANEL, Model.of(localizedValue));
    localizedValuePanel.setOutputMarkupId(true);
    localizedValuePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    localizedValuePanel.add(new EnableBehaviour(() -> false));
    localizedValueWithButton.add(localizedValuePanel);
    AjaxButton showHideLanguagesLocalizedButton = new AjaxButton(ID_SHOW_HIDE_LANGUAGES_LOCALIZED) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showHideLanguagesPerformed(target);
        }
    };
    showHideLanguagesLocalizedButton.setOutputMarkupId(true);
    // showHideLanguagesLocalizedButton.add(AttributeAppender.append("style", "cursor: pointer;"));
    localizedValueWithButton.add(showHideLanguagesLocalizedButton);
    WebMarkupContainer originValueContainer = new WebMarkupContainer(ID_ORIGIN_VALUE_CONTAINER);
    originValueContainer.setOutputMarkupId(true);
    originValueContainer.add(getInputFieldClassAppenderForContainer());
    originValueContainer.add(new VisibleBehaviour(() -> showFullData || StringUtils.isEmpty(localizedValue)));
    add(originValueContainer);
    Label origValueLabel = new Label(ID_ORIG_VALUE_LABEL, ((PageBase) getPage()).createStringResource("PolyStringEditorPanel.origValue"));
    origValueLabel.setOutputMarkupId(true);
    origValueLabel.add(new VisibleBehaviour(() -> showFullData));
    originValueContainer.add(origValueLabel);
    WebMarkupContainer origValueWithButton = new WebMarkupContainer(ID_ORIG_VALUE_WITH_BUTTON);
    origValueWithButton.add(getInputFieldClassAppender());
    origValueWithButton.setOutputMarkupId(true);
    originValueContainer.add(origValueWithButton);
    InputPanel origValuePanel;
    IModel<String> origValueModel = new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getModelObject() != null ? getModelObject().getOrig() : null;
        }

        @Override
        public void setObject(String object) {
            PolyString oldModelObject = getModelObject();
            if (oldModelObject != null && (oldModelObject.getTranslation() != null || MapUtils.isNotEmpty(oldModelObject.getLang()))) {
                getModel().setObject(new PolyString(object, oldModelObject.getNorm(), oldModelObject.getTranslation(), oldModelObject.getLang()));
            } else if (StringUtils.isNotBlank(object)) {
                getModel().setObject(new PolyString(object));
            } else {
                getModel().setObject(null);
            }
        }

        @Override
        public void detach() {
        }
    };
    if (predefinedValuesLookupTable == null) {
        origValuePanel = new TextPanel<>(ID_ORIG_VALUE, origValueModel, String.class, false);
    } else {
        origValuePanel = new AutoCompleteTextPanel<String>(ID_ORIG_VALUE, origValueModel, String.class, hasValueEnumerationRef, predefinedValuesLookupTable) {

            private static final long serialVersionUID = 1L;

            @Override
            public Iterator<String> getIterator(String input) {
                return getPredefinedValuesIterator(input).iterator();
            }
        };
    }
    origValuePanel.setOutputMarkupId(true);
    origValuePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    origValueWithButton.add(origValuePanel);
    WebMarkupContainer fullDataContainer = new WebMarkupContainer(ID_FULL_DATA_CONTAINER);
    fullDataContainer.setOutputMarkupId(true);
    fullDataContainer.add(new VisibleBehaviour(() -> showFullData));
    add(fullDataContainer);
    TextPanel<String> keyValue = new TextPanel<>(ID_KEY_VALUE, new IModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getModelObject() != null && getModelObject().getTranslation() != null ? getModelObject().getTranslation().getKey() : null;
        }

        @Override
        public void setObject(String object) {
            if (getModelObject() == null) {
                getModel().setObject(new PolyString(""));
            }
            if (getModelObject().getTranslation() == null) {
                getModelObject().setTranslation(new PolyStringTranslationType());
            }
            getModelObject().getTranslation().setKey(object);
        }

        @Override
        public void detach() {
        }
    });
    keyValue.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    keyValue.setOutputMarkupId(true);
    fullDataContainer.add(keyValue);
    IModel<String> langChoiceModel = Model.of();
    WebMarkupContainer languageEditorContainer = new WebMarkupContainer(ID_LANGUAGE_EDITOR);
    languageEditorContainer.setOutputMarkupId(true);
    languageEditorContainer.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(getLanguageChoicesModel().getObject())));
    fullDataContainer.add(languageEditorContainer);
    final DropDownChoicePanel<String> languageChoicePanel = new DropDownChoicePanel<>(ID_LANGUAGES_LIST, langChoiceModel, getLanguageChoicesModel(), true);
    languageChoicePanel.setOutputMarkupId(true);
    languageChoicePanel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    languageChoicePanel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
            removeLanguageValue(currentlySelectedLang.toString());
            clearSelectedLanguageValue();
            currentlySelectedLang.append(getLanguagesChoicePanel().getBaseFormComponent().getModelObject());
        }
    });
    languageEditorContainer.add(languageChoicePanel);
    final TextPanel<String> newLanguageValue = new TextPanel<>(ID_VALUE_TO_ADD, Model.of());
    newLanguageValue.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateLanguageValue(languageChoicePanel.getBaseFormComponent().getModelObject(), newLanguageValue.getBaseFormComponent().getValue());
        }
    });
    languageChoicePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateLanguageValue(languageChoicePanel.getBaseFormComponent().getModelObject(), newLanguageValue.getBaseFormComponent().getValue());
        }
    });
    newLanguageValue.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
            updateLanguageValue(languageChoicePanel.getBaseFormComponent().getModelObject(), newLanguageValue.getBaseFormComponent().getValue());
        }
    });
    newLanguageValue.setOutputMarkupId(true);
    languageEditorContainer.add(newLanguageValue);
    AjaxLink<Void> addLanguageButton = new AjaxLink<Void>(ID_ADD_LANGUAGE_VALUE_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            updateLanguageValue(languageChoicePanel.getModel().getObject(), newLanguageValue.getBaseFormComponent().getModelObject());
            languageChoicePanel.getModel().setObject(null);
            newLanguageValue.getBaseFormComponent().getModel().setObject(null);
            clearSelectedLanguageValue();
            target.add(PolyStringEditorPanel.this);
        }
    };
    addLanguageButton.add(AttributeAppender.append("style", "cursor: pointer;"));
    addLanguageButton.setOutputMarkupId(true);
    languageEditorContainer.add(addLanguageButton);
    ListView<String> languagesContainer = new ListView<String>(ID_LANGUAGES_REPEATER, getLanguagesListModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<String> listItem) {
            TextPanel<String> languageName = new TextPanel<>(ID_LANGUAGE_NAME, listItem.getModel());
            languageName.add(new EnableBehaviour(() -> false));
            languageName.setOutputMarkupId(true);
            listItem.add(languageName);
            TextPanel<String> translation = new TextPanel<>(ID_TRANSLATION, Model.of(getLanguageValueByKey(listItem.getModelObject())));
            translation.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    updateLanguageValue(languageName.getBaseFormComponent().getValue(), translation.getBaseFormComponent().getValue());
                }
            });
            translation.setOutputMarkupId(true);
            translation.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior() {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
                    updateLanguageValue(languageName.getBaseFormComponent().getValue(), translation.getBaseFormComponent().getValue());
                }
            });
            listItem.add(translation);
            AjaxLink<Void> removeButton = new AjaxLink<Void>(ID_REMOVE_LANGUAGE_BUTTON) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    removeLanguageValue(listItem.getModelObject());
                    target.add(PolyStringEditorPanel.this);
                }
            };
            removeButton.setOutputMarkupId(true);
            listItem.add(removeButton);
        }
    };
    languagesContainer.setOutputMarkupId(true);
    fullDataContainer.add(languagesContainer);
    AjaxButton showHideLanguagesButton = new AjaxButton(ID_SHOW_HIDE_LANGUAGES_ORIG) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showHideLanguagesPerformed(target);
        }
    };
    showHideLanguagesButton.setOutputMarkupId(true);
    // showHideLanguagesButton.add(AttributeAppender.append("style", "cursor: pointer;"));
    origValueWithButton.add(showHideLanguagesButton);
}
Also used : DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Label(org.apache.wicket.markup.html.basic.Label) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) AutoCompleteTextPanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel) TextPanel(com.evolveum.midpoint.web.component.input.TextPanel) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) EmptyOnChangeAjaxFormUpdatingBehavior(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) PolyStringTranslationType(com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour) IModel(org.apache.wicket.model.IModel) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ListItem(org.apache.wicket.markup.html.list.ListItem)

Aggregations

InputPanel (com.evolveum.midpoint.web.component.prism.InputPanel)14 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)9 PropertyModel (org.apache.wicket.model.PropertyModel)9 IModel (org.apache.wicket.model.IModel)8 Component (org.apache.wicket.Component)7 AutoCompleteTextPanel (com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)6 FormComponent (org.apache.wicket.markup.html.form.FormComponent)6 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)5 TextPanel (com.evolveum.midpoint.web.component.input.TextPanel)4 LookupTableType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)3 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)3 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)3 Label (org.apache.wicket.markup.html.basic.Label)3 PasswordPanel (com.evolveum.midpoint.gui.api.component.password.PasswordPanel)2 DisplayableValue (com.evolveum.midpoint.util.DisplayableValue)2