Search in sources :

Example 36 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class PrismOptionButtonPanel method initButtons.

private void initButtons(final IModel<ObjectWrapper> model) {
    AjaxLink showEmpty = new AjaxLink("showEmptyButton") {

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

        @Override
        public boolean isVisible() {
            return !model.getObject().isReadonly();
        }
    });
    Image showEmptyImg = new Image("showEmptyImg", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isShowEmpty()) {
                return new PackageResourceReference(PrismObjectPanel.class, "ShowEmptyFalse.png");
            }
            return new PackageResourceReference(PrismObjectPanel.class, "ShowEmptyTrue.png");
        }
    });
    showEmptyImg.add(new AttributeAppender("title", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isShowEmpty()) {
                return getString("prismOptionButtonPanel.hideEmpty");
            }
            return getString("prismOptionButtonPanel.showEmpty");
        }
    }, ""));
    showEmpty.add(showEmptyImg);
    AjaxLink minimize = new AjaxLink("minimizeButton") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            minimizeOnClick(target);
        }
    };
    add(minimize);
    Image minimizeImg = new Image("minimizeImg", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isMinimalized()) {
                return new PackageResourceReference(PrismObjectPanel.class, "Maximize.png");
            }
            return new PackageResourceReference(PrismObjectPanel.class, "Minimize.png");
        }
    });
    minimizeImg.add(new AttributeAppender("title", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isMinimalized()) {
                return getString("prismOptionButtonPanel.maximize");
            }
            return getString("prismOptionButtonPanel.minimize");
        }
    }, ""));
    minimize.add(minimizeImg);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PackageResourceReference(org.apache.wicket.request.resource.PackageResourceReference) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) Image(org.apache.wicket.markup.html.image.Image) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 37 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class PrismValuePanel method initLayout.

private void initLayout(IModel<String> labelModel, Form form, String valueCssClass, String inputCssClass) {
    //container
    WebMarkupContainer valueContainer = new WebMarkupContainer(ID_VALUE_CONTAINER);
    valueContainer.setOutputMarkupId(true);
    valueContainer.add(new AttributeModifier("class", valueCssClass));
    add(valueContainer);
    //feedback
    FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK);
    feedback.setOutputMarkupId(true);
    add(feedback);
    //input
    Panel input = createInputComponent(ID_INPUT, labelModel, form);
    input.add(new AttributeModifier("class", inputCssClass));
    if (input instanceof InputPanel) {
        initAccessBehaviour((InputPanel) input);
        feedback.setFilter(new ComponentFeedbackMessageFilter(((InputPanel) input).getBaseFormComponent()));
    } else if (input instanceof LockoutStatusPanel) {
        feedback.setFilter(new ComponentFeedbackMessageFilter(input));
    } else if (input instanceof ValueChoosePanel) {
        feedback.setFilter(new ComponentFeedbackMessageFilter(input));
    } else if (input instanceof AssociationValueChoicePanel) {
        feedback.setFilter(new ComponentFeedbackMessageFilter(((AssociationValueChoicePanel) input).getTextComponent()));
    }
    valueContainer.add(input);
    //buttons
    AjaxLink addButton = new AjaxLink(ID_ADD_BUTTON) {

        private static final long serialVersionUID = 1L;

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

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isAddButtonVisible();
        }
    });
    valueContainer.add(addButton);
    AjaxLink removeButton = new AjaxLink(ID_REMOVE_BUTTON) {

        private static final long serialVersionUID = 1L;

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

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isRemoveButtonVisible();
        }
    });
    valueContainer.add(removeButton);
}
Also used : LockoutStatusPanel(com.evolveum.midpoint.web.component.LockoutStatusPanel) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) 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) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) AssociationValueChoicePanel(com.evolveum.midpoint.web.page.admin.users.component.AssociationValueChoicePanel) ValueChoosePanel(com.evolveum.midpoint.web.component.form.ValueChoosePanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 38 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class CheckTableHeader method initLayout.

private void initLayout() {
    AjaxCheckBox check = new AjaxCheckBox(ID_CHECK, new PropertyModel<Boolean>(getModel(), ObjectWrapper.F_SELECTED)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    add(check);
    Label icon = new Label(ID_ICON);
    icon.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return "check-table-header-icon " + createAccountIcon();
        }
    }));
    add(icon);
    Label trigger = new Label(ID_TRIGGER);
    trigger.add(AttributeModifier.replace("title", new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return createTriggerTooltip();
        }
    }));
    trigger.add(new TooltipBehavior());
    trigger.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return hasTriggers();
        }
    });
    add(trigger);
    BootstrapLabel status = new BootstrapLabel(ID_STATUS, createStringResource("CheckTableHeader.label.error"), new Model<>(BootstrapLabel.State.DANGER));
    status.add(createFetchErrorVisibleBehaviour());
    add(status);
    AjaxLink showMore = new AjaxLink(ID_SHOW_MORE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            onShowMorePerformed(target);
        }
    };
    showMore.add(createFetchErrorVisibleBehaviour());
    add(showMore);
    AjaxLink link = new AjaxLink(ID_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onClickPerformed(target);
        }
    };
    add(link);
    Label name = new Label(ID_NAME, new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getDisplayName();
        }
    });
    link.add(name);
    Label description = new Label(ID_DESCRIPTION, new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getDescription();
        }
    });
    add(description);
    ToggleIconButton expandButton = new ToggleIconButton(ID_EXPAND, GuiStyleConstants.CLASS_ICON_EXPAND, GuiStyleConstants.CLASS_ICON_COLLAPSE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            onClickPerformed(target);
        }

        @Override
        public boolean isOn() {
            return !CheckTableHeader.this.getModelObject().isMinimalized();
        }
    };
    add(expandButton);
}
Also used : ToggleIconButton(com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton) BootstrapLabel(com.evolveum.midpoint.web.component.BootstrapLabel) Label(org.apache.wicket.markup.html.basic.Label) BootstrapLabel(com.evolveum.midpoint.web.component.BootstrapLabel) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 39 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class SimpleErrorPanel method initLayout.

@Override
protected void initLayout() {
    Label icon = new Label(ID_ICON);
    add(icon);
    Label description = new Label(ID_DESCRIPTION, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getDescription();
        }
    });
    add(description);
    AjaxLink link = new AjaxLink(ID_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onShowMorePerformed(target);
        }
    };
    add(link);
    Label showMore = new Label(ID_SHOW_MORE, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return createStringResource("simpleErrorPanel.label.showMore").getString();
        }
    });
    link.add(showMore);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 40 with AjaxLink

use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.

the class AssociationValueChoicePanel method initLayout.

private void initLayout(final IModel<PrismContainerValue<ShadowAssociationType>> value, final List<PrismPropertyValue> values, final boolean required, Class<C> type) {
    WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
    textWrapper.setOutputMarkupId(true);
    TextField<String> text = new TextField<>(ID_TEXT, createTextModel(value));
    text.add(new AjaxFormComponentUpdatingBehavior("blur") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
        }
    });
    text.setRequired(required);
    text.setEnabled(false);
    textWrapper.add(text);
    FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text));
    feedback.setFilter(new ComponentFeedbackMessageFilter(text));
    textWrapper.add(feedback);
    AjaxLink edit = new AjaxLink(ID_EDIT) {

        private static final long serialVersionUID = 1L;

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

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return model.getObject().isEmpty();
        }
    });
    textWrapper.add(edit);
    add(textWrapper);
    initDialog(type, values);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) TextField(org.apache.wicket.markup.html.form.TextField) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Aggregations

AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)83 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)82 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)50 Label (org.apache.wicket.markup.html.basic.Label)50 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)44 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)28 ListItem (org.apache.wicket.markup.html.list.ListItem)21 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)17 ListView (org.apache.wicket.markup.html.list.ListView)17 TextField (org.apache.wicket.markup.html.form.TextField)15 ArrayList (java.util.ArrayList)13 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)13 AttributeModifier (org.apache.wicket.AttributeModifier)12 List (java.util.List)11 Form (org.apache.wicket.markup.html.form.Form)11 AjaxSubmitLink (org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink)10 IModel (org.apache.wicket.model.IModel)9 Model (org.apache.wicket.model.Model)8 ComponentFeedbackMessageFilter (org.apache.wicket.feedback.ComponentFeedbackMessageFilter)6 FeedbackPanel (org.apache.wicket.markup.html.panel.FeedbackPanel)6