Search in sources :

Example 16 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class TextAreaFormGroup method initLayout.

private void initLayout(IModel<String> label, final String tooltipKey, boolean isTooltipInModal, String labelSize, String textSize, boolean required, int rowNumber) {
    WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
    add(labelContainer);
    Label l = new Label(ID_LABEL, label);
    if (StringUtils.isNotEmpty(labelSize)) {
        labelContainer.add(AttributeAppender.prepend("class", labelSize));
    }
    labelContainer.add(l);
    Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
    tooltipLabel.add(new AttributeAppender("data-original-title", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getString(tooltipKey);
        }
    }));
    tooltipLabel.add(new InfoTooltipBehavior(isTooltipInModal));
    tooltipLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return tooltipKey != null;
        }
    });
    tooltipLabel.setOutputMarkupId(true);
    tooltipLabel.setOutputMarkupPlaceholderTag(true);
    labelContainer.add(tooltipLabel);
    WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
    if (StringUtils.isNotEmpty(textSize)) {
        textWrapper.add(AttributeAppender.prepend("class", textSize));
    }
    add(textWrapper);
    TextArea text = new TextArea<>(ID_TEXT, getModel());
    text.add(new AttributeModifier("rows", rowNumber));
    text.setOutputMarkupId(true);
    text.setRequired(required);
    text.setLabel(label);
    text.add(AttributeAppender.replace("placeholder", label));
    textWrapper.add(text);
}
Also used : InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) TextArea(org.apache.wicket.markup.html.form.TextArea) Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 17 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class MultiValueTextEditPanel method initButtons.

private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item, NonEmptyModel<Boolean> readOnlyModel) {
    AjaxSubmitLink edit = new AjaxSubmitLink(ID_EDIT) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            editPerformed(target, item.getModelObject());
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    edit.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (buttonsDisabled()) {
                return " " + CSS_DISABLED;
            }
            return "";
        }
    }));
    buttonGroup.add(edit);
    AjaxLink add = new AjaxLink(ID_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
        }
    };
    add.add(new AttributeAppender("class", getPlusClassModifier(item)));
    add.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    buttonGroup.add(add);
    AjaxLink remove = new AjaxLink(ID_REMOVE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeValuePerformed(target, item);
        }
    };
    remove.add(new AttributeAppender("class", getMinusClassModifier()));
    remove.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    buttonGroup.add(remove);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Form(org.apache.wicket.markup.html.form.Form) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 18 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class MultiValueTextEditPanel method initLayout.

private void initLayout(final boolean inputEnabled, final boolean showPlaceholder, final NonEmptyModel<Boolean> readOnlyModel) {
    WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return showPlaceholder && (getModel().getObject() == null || getModel().getObject().isEmpty());
        }
    });
    add(placeholderContainer);
    AjaxLink placeholderAdd = new AjaxLink(ID_PLACEHOLDER_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
        }
    };
    placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (buttonsDisabled()) {
                return " " + CSS_DISABLED;
            }
            return "";
        }
    }));
    placeholderAdd.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    placeholderAdd.setOutputMarkupId(true);
    placeholderAdd.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(placeholderAdd);
    ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<T> item) {
            TextField text = new TextField<>(ID_TEXT, createTextModel(item.getModel()));
            text.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            text.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder()));
            if (selectedModel != null && item.getModelObject() == selectedModel.getObject()) {
                // TODO color constant
                text.add(AttributeAppender.append("style", "background-color: #FFFFD0;"));
            }
            if (!inputEnabled) {
                text.add(new AttributeModifier("disabled", "disabled"));
            }
            item.add(text);
            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            item.add(buttonGroup);
            initButtons(buttonGroup, item, readOnlyModel);
        }
    };
    repeater.setOutputMarkupId(true);
    repeater.setOutputMarkupPlaceholderTag(true);
    repeater.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModel().getObject() != null && !getModel().getObject().isEmpty();
        }
    });
    add(repeater);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ListView(org.apache.wicket.markup.html.list.ListView) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) TextField(org.apache.wicket.markup.html.form.TextField) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 19 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class AceEditorFormGroup method initLayout.

private void initLayout(IModel<String> label, final String tooltipKey, boolean isTooltipInModal, String labelSize, String textSize, boolean required, int rowNumber) {
    WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
    add(labelContainer);
    Label l = new Label(ID_LABEL, label);
    if (StringUtils.isNotEmpty(labelSize)) {
        labelContainer.add(AttributeAppender.prepend("class", labelSize));
    }
    labelContainer.add(l);
    Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
    tooltipLabel.add(new AttributeAppender("data-original-title", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getString(tooltipKey);
        }
    }));
    tooltipLabel.add(new InfoTooltipBehavior(isTooltipInModal));
    tooltipLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return tooltipKey != null;
        }
    });
    tooltipLabel.setOutputMarkupId(true);
    tooltipLabel.setOutputMarkupPlaceholderTag(true);
    labelContainer.add(tooltipLabel);
    WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
    if (StringUtils.isNotEmpty(textSize)) {
        textWrapper.add(AttributeAppender.prepend("class", textSize));
    }
    add(textWrapper);
    AceEditor text = new AceEditor(ID_TEXT, getModel());
    text.add(new AttributeModifier("rows", rowNumber));
    text.setOutputMarkupId(true);
    text.setRequired(required);
    text.setLabel(label);
    text.add(AttributeAppender.replace("placeholder", label));
    textWrapper.add(text);
}
Also used : InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) AceEditor(com.evolveum.midpoint.web.component.AceEditor) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 20 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class CheckFormGroup method initLayout.

private void initLayout(IModel<String> label, final String tooltipKey, boolean isTooltipInModal, String labelSize, String textSize) {
    WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
    add(labelContainer);
    Label l = new Label(ID_LABEL, label);
    if (StringUtils.isNotEmpty(labelSize)) {
        labelContainer.add(AttributeAppender.prepend("class", labelSize));
    }
    labelContainer.add(l);
    Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
    tooltipLabel.add(new AttributeAppender("data-original-title", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getString(tooltipKey);
        }
    }));
    tooltipLabel.add(new InfoTooltipBehavior(isTooltipInModal));
    tooltipLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return tooltipKey != null;
        }
    });
    tooltipLabel.setOutputMarkupId(true);
    tooltipLabel.setOutputMarkupPlaceholderTag(true);
    labelContainer.add(tooltipLabel);
    WebMarkupContainer checkWrapper = new WebMarkupContainer(ID_CHECK_WRAPPER);
    if (StringUtils.isNotEmpty(textSize)) {
        checkWrapper.add(AttributeAppender.prepend("class", textSize));
    }
    add(checkWrapper);
    CheckBox check = new CheckBox(ID_CHECK, getModel());
    check.setLabel(label);
    checkWrapper.add(check);
}
Also used : InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) CheckBox(org.apache.wicket.markup.html.form.CheckBox) Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

AttributeAppender (org.apache.wicket.behavior.AttributeAppender)51 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)29 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)25 Label (org.apache.wicket.markup.html.basic.Label)24 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)24 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)23 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)17 IModel (org.apache.wicket.model.IModel)10 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)8 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)7 ListItem (org.apache.wicket.markup.html.list.ListItem)7 ListView (org.apache.wicket.markup.html.list.ListView)6 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 AttributeModifier (org.apache.wicket.AttributeModifier)5 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)5 TextField (org.apache.wicket.markup.html.form.TextField)5 PropertyModel (org.apache.wicket.model.PropertyModel)5 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)4