Search in sources :

Example 46 with AjaxButton

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

the class SearchItemPanel method initPopover.

private void initPopover() {
    WebMarkupContainer popover = new WebMarkupContainer(ID_POPOVER);
    popover.setOutputMarkupId(true);
    add(popover);
    WebMarkupContainer popoverBody = new WebMarkupContainer(ID_POPOVER_BODY);
    popoverBody.setOutputMarkupId(true);
    popover.add(popoverBody);
    ListView values = new ListView<DisplayableValue>(ID_VALUES, new PropertyModel<List<DisplayableValue>>(popoverModel, SearchItem.F_VALUES)) {

        @Override
        protected void populateItem(final ListItem<DisplayableValue> item) {
            item.add(AttributeModifier.replace("style", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    return item.getIndex() != 0 ? "margin-top: 5px;" : null;
                }
            }));
            SearchPopupPanel fragment = createPopoverFragment(item.getModel());
            fragment.setRenderBodyOnly(true);
            item.add(fragment);
        }
    };
    popoverBody.add(values);
    AjaxSubmitButton update = new AjaxSubmitButton(ID_UPDATE, createStringResource("SearchItemPanel.update")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            updateItemPerformed(target);
        }
    };
    popoverBody.add(update);
    AjaxButton close = new AjaxButton(ID_CLOSE, createStringResource("SearchItemPanel.close")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            closeEditPopoverPerformed(target);
        }
    };
    popoverBody.add(close);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) Form(org.apache.wicket.markup.html.form.Form) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 47 with AjaxButton

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

the class SearchPanel method initPopover.

private void initPopover() {
    WebMarkupContainer popover = new WebMarkupContainer(ID_POPOVER);
    popover.setOutputMarkupId(true);
    add(popover);
    final WebMarkupContainer propList = new WebMarkupContainer(ID_PROP_LIST);
    propList.setOutputMarkupId(true);
    popover.add(propList);
    ListView properties = new ListView<Property>(ID_PROPERTIES, new PropertyModel<List<Property>>(moreDialogModel, MoreDialogDto.F_PROPERTIES)) {

        @Override
        protected void populateItem(final ListItem<Property> item) {
            CheckBox check = new CheckBox(ID_CHECK, new PropertyModel<Boolean>(item.getModel(), Property.F_SELECTED));
            check.add(new AjaxFormComponentUpdatingBehavior("change") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                //nothing, just update model.
                }
            });
            item.add(check);
            AjaxLink propLink = new AjaxLink(ID_PROP_LINK) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    addOneItemPerformed(item.getModelObject(), target);
                }
            };
            item.add(propLink);
            Label name = new Label(ID_PROP_NAME, new PropertyModel<>(item.getModel(), Property.F_NAME));
            name.setRenderBodyOnly(true);
            propLink.add(name);
            item.add(new VisibleEnableBehaviour() {

                @Override
                public boolean isVisible() {
                    Property property = item.getModelObject();
                    Search search = SearchPanel.this.getModelObject();
                    if (!search.getAvailableDefinitions().contains(property.getDefinition())) {
                        return false;
                    }
                    MoreDialogDto dto = moreDialogModel.getObject();
                    String nameFilter = dto.getNameFilter();
                    String propertyName = property.getName().toLowerCase();
                    if (StringUtils.isNotEmpty(nameFilter) && !propertyName.contains(nameFilter.toLowerCase())) {
                        return false;
                    }
                    return true;
                }
            });
        }
    };
    propList.add(properties);
    TextField addText = new TextField(ID_ADD_TEXT, new PropertyModel(moreDialogModel, MoreDialogDto.F_NAME_FILTER));
    addText.add(new Behavior() {

        @Override
        public void bind(Component component) {
            super.bind(component);
            component.add(AttributeModifier.replace("onkeydown", Model.of("if(event.keyCode == 13) {event.preventDefault();}")));
        }
    });
    popover.add(addText);
    addText.add(new AjaxFormComponentUpdatingBehavior("keyup") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(propList);
        }
    });
    popover.add(addText);
    AjaxButton add = new AjaxButton(ID_ADD, createStringResource("SearchPanel.add")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addItemPerformed(target);
        }
    };
    popover.add(add);
    AjaxButton close = new AjaxButton(ID_CLOSE, createStringResource("SearchPanel.close")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            closeMorePopoverPerformed(target);
        }
    };
    popover.add(close);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) CheckBox(org.apache.wicket.markup.html.form.CheckBox) TextField(org.apache.wicket.markup.html.form.TextField) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) 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)

Example 48 with AjaxButton

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

the class PagePreviewChanges method initButtons.

private void initButtons(Form mainForm) {
    AjaxButton cancel = new AjaxButton(ID_CONTINUE_EDITING, createStringResource("PagePreviewChanges.button.continueEditing")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            cancelPerformed(target);
        }
    };
    mainForm.add(cancel);
    AjaxButton save = new AjaxButton(ID_SAVE, createStringResource("PagePreviewChanges.button.save")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            savePerformed(target);
        }
    };
    mainForm.add(save);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton)

Example 49 with AjaxButton

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

the class PageMyPasswordQuestions method initButtons.

public void initButtons(Form mainForm) {
    AjaxSubmitButton save = new AjaxSubmitButton(ID_SAVE, createStringResource("PageBase.button.save")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            savePerformed(target);
        }
    };
    mainForm.add(save);
    AjaxButton back = new AjaxButton(ID_BACK, createStringResource("PageBase.button.back")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            cancelPerformed(target);
        }
    };
    mainForm.add(back);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Form(org.apache.wicket.markup.html.form.Form)

Example 50 with AjaxButton

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

the class OrgTreeAssignablePanel method initLayout.

private void initLayout() {
    AbstractOrgTabPanel tabbedPanel = new AbstractOrgTabPanel(ID_ORG_TABS, getPageBase()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Panel createTreePanel(String id, Model<String> model, PageBase pageBase) {
            OrgTreePanel panel = new OrgTreePanel(id, model, selectable) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void selectTreeItemPerformed(SelectableBean<OrgType> selected, AjaxRequestTarget target) {
                    onItemSelect(selected, target);
                }
            };
            panel.setOutputMarkupId(true);
            return panel;
        }
    };
    tabbedPanel.setOutputMarkupId(true);
    add(tabbedPanel);
    AjaxButton assignButton = new AjaxButton(ID_ASSIGN, getPageBase().createStringResource("Button.assign")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            AbstractOrgTabPanel orgPanel = (AbstractOrgTabPanel) getParent().get(ID_ORG_TABS);
            OrgTreePanel treePanel = (OrgTreePanel) orgPanel.getPanel();
            List<OrgType> selectedOrgs = treePanel.getSelectedOrgs();
            assignSelectedOrgPerformed(selectedOrgs, target);
        }
    };
    assignButton.setOutputMarkupId(true);
    assignButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return selectable;
        }
    });
    add(assignButton);
}
Also used : PageBase(com.evolveum.midpoint.gui.api.page.PageBase) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) StringResourceModel(org.apache.wicket.model.StringResourceModel) Model(org.apache.wicket.model.Model) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Aggregations

AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)67 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)65 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)26 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)20 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)18 Form (org.apache.wicket.markup.html.form.Form)13 Label (org.apache.wicket.markup.html.basic.Label)12 ArrayList (java.util.ArrayList)11 List (java.util.List)10 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)7 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)7 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)7 Form (com.evolveum.midpoint.web.component.form.Form)6 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)6 AjaxRequestAttributes (org.apache.wicket.ajax.attributes.AjaxRequestAttributes)4 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)4 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)4 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)4 TextArea (org.apache.wicket.markup.html.form.TextArea)4 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)3