Search in sources :

Example 26 with AttributeModifier

use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.

the class MultiValueAutoCompleteTextPanel method initLayout.

private void initLayout(final boolean inputEnabled, 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 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.setOutputMarkupId(true);
    placeholderAdd.setOutputMarkupPlaceholderTag(true);
    placeholderAdd.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    placeholderContainer.add(placeholderAdd);
    ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<T> item) {
            AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
            autoCompleteSettings.setShowListOnEmptyInput(true);
            autoCompleteSettings.setMaxHeightInPx(200);
            AutoCompleteTextField<String> autoCompleteEditor = new AutoCompleteTextField<String>(ID_TEXT, createTextModel(item.getModel()), autoCompleteSettings) {

                @Override
                protected Iterator<String> getChoices(String input) {
                    return createAutoCompleteObjectList(input);
                }
            };
            autoCompleteEditor.add(createAutoCompleteValidator());
            autoCompleteEditor.add(new AjaxFormComponentUpdatingBehavior("change") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
            item.add(autoCompleteEditor);
            autoCompleteEditor.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder()));
            if (!inputEnabled) {
                autoCompleteEditor.add(new AttributeModifier("disabled", "disabled"));
            }
            item.add(autoCompleteEditor);
            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().isEmpty();
        }
    });
    add(repeater);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AutoCompleteSettings(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) ListView(org.apache.wicket.markup.html.list.ListView) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 27 with AttributeModifier

use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.

the class NavigatorPanel method initLast.

private void initLast() {
    WebMarkupContainer last = new WebMarkupContainer(ID_LAST);
    last.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return isLastEnabled() ? "" : "disabled";
        }
    }));
    add(last);
    AjaxLink lastLink = new AjaxLink(ID_LAST_LINK) {

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            lastPerformed(target);
        }
    };
    lastLink.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return BooleanUtils.isTrue(showPageListingModel.getObject()) && isLastEnabled();
        }
    });
    last.add(lastLink);
}
Also used : AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) AjaxChannel(org.apache.wicket.ajax.AjaxChannel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 28 with AttributeModifier

use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.

the class AbstractSummaryPanel method initLayoutCommon.

protected void initLayoutCommon() {
    box = new WebMarkupContainer(ID_BOX);
    add(box);
    box.add(new AttributeModifier("class", BOX_CSS_CLASS + " " + getBoxAdditionalCssClass()));
    box.add(new Label(ID_DISPLAY_NAME, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getDisplayNamePropertyName())));
    WebMarkupContainer identifierPanel = new WebMarkupContainer(ID_IDENTIFIER_PANEL);
    identifierPanel.add(new Label(ID_IDENTIFIER, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getIdentifierPropertyName())));
    identifierPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isIdentifierVisible();
        }
    });
    box.add(identifierPanel);
    if (getTitlePropertyName() != null) {
        box.add(new Label(ID_TITLE, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getTitlePropertyName())));
    } else if (getTitleModel() != null) {
        box.add(new Label(ID_TITLE, getTitleModel()));
    } else {
        box.add(new Label(ID_TITLE, " "));
    }
    if (getTitle2PropertyName() != null) {
        box.add(new Label(ID_TITLE2, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getTitle2PropertyName())));
    } else if (getTitle2Model() != null) {
        box.add(new Label(ID_TITLE2, getTitle2Model()));
    } else {
        Label label = new Label(ID_TITLE2, " ");
        label.setVisible(false);
        box.add(label);
    }
    if (getTitle3PropertyName() != null) {
        box.add(new Label(ID_TITLE3, new PrismPropertyRealValueFromContainerableModel<>(getModel(), getTitle3PropertyName())));
    } else if (getTitle3Model() != null) {
        box.add(new Label(ID_TITLE3, getTitle3Model()));
    } else {
        Label label = new Label(ID_TITLE3, " ");
        label.setVisible(false);
        box.add(label);
    }
    Label parentOrgLabel = new Label(ID_ORGANIZATION, getParentOrgModel());
    parentOrgLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getParentOrgModel().getObject() != null;
        }
    });
    box.add(parentOrgLabel);
    iconBox = new WebMarkupContainer(ID_ICON_BOX);
    box.add(iconBox);
    if (getIconBoxAdditionalCssClass() != null) {
        iconBox.add(new AttributeModifier("class", ICON_BOX_CSS_CLASS + " " + getIconBoxAdditionalCssClass()));
    }
    Label icon = new Label(ID_ICON, "");
    icon.add(new AttributeModifier("class", getIconCssClass()));
    icon.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getPhotoModel().getObject() == null;
        }
    });
    iconBox.add(icon);
    NonCachingImage img = new NonCachingImage(ID_PHOTO, getPhotoModel());
    img.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getPhotoModel().getObject() != null;
        }
    });
    iconBox.add(img);
    tagBox = new WebMarkupContainer(ID_TAG_BOX);
    if (getTagBoxCssClass() != null) {
        tagBox.add(new AttributeModifier("class", getTagBoxCssClass()));
    }
    box.add(tagBox);
}
Also used : PrismPropertyRealValueFromContainerableModel(com.evolveum.midpoint.web.model.PrismPropertyRealValueFromContainerableModel) NonCachingImage(org.apache.wicket.markup.html.image.NonCachingImage) 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)

Example 29 with AttributeModifier

use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.

the class PrismValuePanel method createInputComponent.

private Panel createInputComponent(String id, IModel<String> labelModel, Form form) {
    ValueWrapper valueWrapper = valueWrapperModel.getObject();
    ObjectWrapper objectWrapper = null;
    if (valueWrapper.getItem().getContainer() != null) {
        objectWrapper = valueWrapper.getItem().getContainer().getObject();
    }
    Item property = valueWrapper.getItem().getItem();
    boolean required = property.getDefinition().getMinOccurs() > 0;
    Panel component = createTypedInputComponent(id);
    if (component instanceof InputPanel) {
        InputPanel inputPanel = (InputPanel) component;
        //adding valid from/to date range validator, if necessary
        ItemPath activation = new ItemPath(UserType.F_ACTIVATION);
        if (ActivationType.F_VALID_FROM.equals(property.getElementName())) {
            DateValidator validator = WebComponentUtil.getRangeValidator(form, activation);
            validator.setDateFrom((DateTimeField) inputPanel.getBaseFormComponent());
        } else if (ActivationType.F_VALID_TO.equals(property.getElementName())) {
            DateValidator validator = WebComponentUtil.getRangeValidator(form, activation);
            validator.setDateTo((DateTimeField) inputPanel.getBaseFormComponent());
        }
        final List<FormComponent> formComponents = inputPanel.getFormComponents();
        for (FormComponent formComponent : formComponents) {
            formComponent.setLabel(labelModel);
            formComponent.setRequired(required);
            if (formComponent instanceof TextField) {
                formComponent.add(new AttributeModifier("size", "42"));
            }
            formComponent.add(new AjaxFormComponentUpdatingBehavior("blur") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
        // Validation occurs when submitting the form
        //            if (form != null) {
        //                AjaxFormValidatingBehavior validator = new AjaxFormValidatingBehavior(form, "Blur"); 
        //                 
        //                formComponent.add(validator);
        //            }
        }
    }
    if (component == null) {
        throw new RuntimeException("Cannot create input component for item " + property + " (" + valueWrapper + ") in " + objectWrapper);
    }
    return component;
}
Also used : DateValidator(com.evolveum.midpoint.web.util.DateValidator) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) FormComponent(org.apache.wicket.markup.html.form.FormComponent) DateTimeField(org.apache.wicket.extensions.yui.calendar.DateTimeField) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) LockoutStatusPanel(com.evolveum.midpoint.web.component.LockoutStatusPanel) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) AutoCompleteTextPanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel) ValueChoosePanel(com.evolveum.midpoint.web.component.form.ValueChoosePanel) PasswordPanel(com.evolveum.midpoint.gui.api.component.password.PasswordPanel) ModificationsPanel(com.evolveum.midpoint.web.component.model.delta.ModificationsPanel) Panel(org.apache.wicket.markup.html.panel.Panel) AssociationValueChoicePanel(com.evolveum.midpoint.web.page.admin.users.component.AssociationValueChoicePanel) TextField(org.apache.wicket.markup.html.form.TextField) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 30 with AttributeModifier

use of org.apache.wicket.AttributeModifier in project midpoint by Evolveum.

the class AutoRefreshPanel method initLayout.

private void initLayout(final Refreshable refreshable, boolean inSummaryPanel) {
    final LinkIconPanel refreshNow = new LinkIconPanel(ID_REFRESH_NOW, new Model("fa fa-refresh"), createStringResource("autoRefreshPanel.refreshNow")) {

        @Override
        protected void onClickPerformed(AjaxRequestTarget target) {
            refreshable.refresh(target);
        }
    };
    refreshNow.setRenderBodyOnly(true);
    add(refreshNow);
    final LinkIconPanel resumeRefreshing = new LinkIconPanel(ID_START, new Model("fa fa-play"), createStringResource("autoRefreshPanel.resumeRefreshing")) {

        @Override
        protected void onClickPerformed(AjaxRequestTarget target) {
            getModelObject().setEnabled(true);
            refreshable.refresh(target);
            startRefreshing(refreshable, target);
        }
    };
    resumeRefreshing.setRenderBodyOnly(true);
    resumeRefreshing.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModelObject().isEnabled();
        }
    });
    add(resumeRefreshing);
    final LinkIconPanel pauseRefreshing = new LinkIconPanel(ID_PAUSE, new Model("fa fa-pause"), createStringResource("autoRefreshPanel.pauseRefreshing")) {

        @Override
        protected void onClickPerformed(AjaxRequestTarget target) {
            getModelObject().setEnabled(false);
            refreshable.refresh(target);
            stopRefreshing(refreshable, target);
        }
    };
    pauseRefreshing.setRenderBodyOnly(true);
    pauseRefreshing.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().isEnabled();
        }
    });
    add(pauseRefreshing);
    final Label status = new Label(ID_STATUS, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            AutoRefreshDto dto = getModelObject();
            if (dto.isEnabled()) {
                return createStringResource("autoRefreshPanel.refreshingEach", dto.getInterval() / 1000).getString();
            } else {
                return createStringResource("autoRefreshPanel.noRefreshing").getString();
            }
        }
    });
    status.setRenderBodyOnly(true);
    add(status);
    if (inSummaryPanel) {
        add(new AttributeModifier("class", "summary-tag"));
    }
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier) LinkIconPanel(com.evolveum.midpoint.web.component.data.column.LinkIconPanel)

Aggregations

AttributeModifier (org.apache.wicket.AttributeModifier)37 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)23 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)23 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)21 Label (org.apache.wicket.markup.html.basic.Label)19 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)18 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)12 IModel (org.apache.wicket.model.IModel)9 PropertyModel (org.apache.wicket.model.PropertyModel)9 ListItem (org.apache.wicket.markup.html.list.ListItem)8 ListView (org.apache.wicket.markup.html.list.ListView)8 Model (org.apache.wicket.model.Model)7 ArrayList (java.util.ArrayList)6 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)5 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)5 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)4 PasswordPanel (com.evolveum.midpoint.gui.api.component.password.PasswordPanel)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)3 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)3 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)3