Search in sources :

Example 46 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class MultiValueTextFormGroup method initButtons.

private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item) {
    AjaxLink add = new AjaxLink(ID_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target, item);
        }
    };
    add.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isAddButtonVisible(item);
        }
    });
    buttonGroup.add(add);
    AjaxLink remove = new AjaxLink(ID_REMOVE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeValuePerformed(target, item);
        }
    };
    remove.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isRemoveButtonVisible(item);
        }
    });
    buttonGroup.add(remove);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 47 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class MultiStateHorizontalButton method initLayout.

private void initLayout() {
    WebMarkupContainer buttonsPanel = new WebMarkupContainer(ID_BUTTONS_CONTAINER);
    buttonsPanel.setOutputMarkupId(true);
    add(buttonsPanel);
    RepeatingView buttons = new RepeatingView(ID_BUTTON);
    buttons.setOutputMarkupId(true);
    buttonsPanel.add(buttons);
    for (String propertyKey : propertyKeysList) {
        AjaxSubmitButton button = new AjaxSubmitButton(buttons.newChildId(), pageBase.createStringResource(propertyKey)) {

            @Override
            public void onSubmit(AjaxRequestTarget ajaxRequestTarget, Form form) {
                MultiStateHorizontalButton.this.onStateChanged(propertyKeysList.indexOf(propertyKey), ajaxRequestTarget);
            }

            @Override
            public void onError(AjaxRequestTarget ajaxRequestTarget, Form form) {
                MultiStateHorizontalButton.this.onStateChanged(propertyKeysList.indexOf(propertyKey), ajaxRequestTarget);
            }
        };
        button.add(getActiveButtonClassAppender(propertyKeysList.indexOf(propertyKey)));
        button.setOutputMarkupId(true);
        buttons.add(button);
    }
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Form(org.apache.wicket.markup.html.form.Form) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 48 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class FeedbackListView method populateItem.

@Override
protected void populateItem(final ListItem<FeedbackMessage> item) {
    final FeedbackMessage message = item.getModelObject();
    if (message.getMessage() instanceof OpResult) {
        OperationResultPanel panel = new OperationResultPanel("message", new PropertyModel<OpResult>(item.getModel(), "message"), getPage()) {

            private static final long serialVersionUID = 1L;

            @Override
            public void close(AjaxRequestTarget target) {
                super.close(target);
                message.markRendered();
            }

            protected void onAfterRender() {
                ((OpResult) message.getMessage()).setAlreadyShown(true);
                super.onAfterRender();
            }

            ;
        };
        panel.add(new VisibleEnableBehaviour() {

            private static final long serialVersionUID = 1L;

            public boolean isVisible() {
                return !((OpResult) item.getModelObject().getMessage()).isAlreadyShown();
            }

            ;
        });
        panel.setOutputMarkupId(true);
        item.add(panel);
    } else if (!(message.getMessage() instanceof OpResult)) {
        message.markRendered();
        ValidationErrorPanel validationPanel = new ValidationErrorPanel("message", item.getModel()) {

            private static final long serialVersionUID = 1L;

            @Override
            public void close(AjaxRequestTarget target) {
                super.close(target);
                message.markRendered();
            }
        };
        validationPanel.setOutputMarkupId(true);
        item.add(validationPanel);
    }
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ValidationErrorPanel(com.evolveum.midpoint.gui.api.component.result.ValidationErrorPanel) OpResult(com.evolveum.midpoint.gui.api.component.result.OpResult) OperationResultPanel(com.evolveum.midpoint.gui.api.component.result.OperationResultPanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) FeedbackMessage(org.apache.wicket.feedback.FeedbackMessage)

Example 49 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class FocusProjectionsTabPanel method initLayout.

private void initLayout(final PageBase page) {
    final WebMarkupContainer shadows = new WebMarkupContainer(ID_SHADOWS);
    shadows.setOutputMarkupId(true);
    add(shadows);
    InlineMenu accountMenu = new InlineMenu(ID_SHADOW_MENU, new Model((Serializable) createShadowMenu()));
    accountMenu.setVisible(!getObjectWrapper().isReadonly());
    shadows.add(accountMenu);
    final ListView<FocusSubwrapperDto<ShadowType>> projectionList = new ListView<FocusSubwrapperDto<ShadowType>>(ID_SHADOW_LIST, projectionModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<FocusSubwrapperDto<ShadowType>> item) {
            PackageResourceReference packageRef;
            final FocusSubwrapperDto<ShadowType> dto = item.getModelObject();
            final PropertyModel<ObjectWrapper<F>> objectWrapperModel = new PropertyModel<ObjectWrapper<F>>(item.getModel(), "object");
            final Panel shadowPanel;
            if (dto.isLoadedOK()) {
                packageRef = new PackageResourceReference(ImgResources.class, ImgResources.HDD_PRISM);
                shadowPanel = new PrismObjectPanel<F>(ID_SHADOW, new PropertyModel<ObjectWrapper<F>>(item.getModel(), "object"), packageRef, getMainForm(), getPageBase());
            } else {
                shadowPanel = new SimpleErrorPanel<ShadowType>(ID_SHADOW, item.getModel()) {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public void onShowMorePerformed(AjaxRequestTarget target) {
                        OperationResult fetchResult = dto.getResult();
                        if (fetchResult != null) {
                            showResult(fetchResult);
                            target.add(page.getFeedbackPanel());
                        }
                    }
                };
            }
            shadowPanel.setOutputMarkupId(true);
            shadowPanel.add(new VisibleEnableBehaviour() {

                private static final long serialVersionUID = 1L;

                @Override
                public boolean isVisible() {
                    FocusSubwrapperDto<ShadowType> shadowWrapperDto = item.getModelObject();
                    ObjectWrapper<ShadowType> shadowWrapper = shadowWrapperDto.getObject();
                    return !shadowWrapper.isMinimalized();
                }
            });
            item.add(shadowPanel);
            CheckTableHeader<F> shadowHeader = new CheckTableHeader<F>(ID_SHADOW_HEADER, objectWrapperModel) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onClickPerformed(AjaxRequestTarget target) {
                    super.onClickPerformed(target);
                    onExpandCollapse(target, item.getModel());
                    target.add(shadows);
                }
            };
            if (item.getModel().getObject().getStatus().equals(UserDtoStatus.DELETE)) {
                shadowHeader.add(new AttributeModifier("class", "box-header with-border delete"));
            }
            item.add(shadowHeader);
        }
    };
    AjaxCheckBox accountCheckAll = new AjaxCheckBox(ID_SHADOW_CHECK_ALL, new Model()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            for (FocusSubwrapperDto<ShadowType> dto : projectionList.getModelObject()) {
                if (dto.isLoadedOK()) {
                    ObjectWrapper<ShadowType> accModel = dto.getObject();
                    accModel.setSelected(getModelObject());
                }
            }
            target.add(shadows);
        }
    };
    shadows.add(accountCheckAll);
    shadows.add(projectionList);
}
Also used : Serializable(java.io.Serializable) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ImgResources(com.evolveum.midpoint.web.resource.img.ImgResources) ListView(org.apache.wicket.markup.html.list.ListView) FocusSubwrapperDto(com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto) PackageResourceReference(org.apache.wicket.request.resource.PackageResourceReference) InlineMenu(com.evolveum.midpoint.web.component.menu.cog.InlineMenu) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel) Panel(org.apache.wicket.markup.html.panel.Panel) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 50 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class ThreeStateBooleanPanel method initLayout.

private void initLayout(final String optionOneLabel, final String optionTwoLabel, final String optionThreeLabel, final String buttonCssClass) {
    AjaxButton buttonTrue = new AjaxButton(ID_BUTTON_ONE, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (optionOneLabel == null) {
                return getString("ThreeStateBooleanPanel.true");
            } else {
                return getString(optionOneLabel);
            }
        }
    }) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            stateChanged(Boolean.TRUE, target);
        }
    };
    buttonTrue.setOutputMarkupId(true);
    buttonTrue.add(prepareButtonCssClass(buttonCssClass));
    buttonTrue.add(prepareActiveButtonAppender(Boolean.TRUE));
    add(buttonTrue);
    AjaxButton buttonUndef = new AjaxButton(ID_BUTTON_TWO, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (optionTwoLabel == null) {
                return getString("ThreeStateBooleanPanel.undef");
            } else {
                return getString(optionTwoLabel);
            }
        }
    }) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            stateChanged(null, target);
        }
    };
    buttonUndef.setOutputMarkupId(true);
    buttonUndef.add(prepareButtonCssClass(buttonCssClass));
    buttonUndef.add(prepareActiveButtonAppender(null));
    add(buttonUndef);
    AjaxButton buttonFalse = new AjaxButton(ID_BUTTON_THREE, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (optionThreeLabel == null) {
                return getString("ThreeStateBooleanPanel.false");
            } else {
                return getString(optionThreeLabel);
            }
        }
    }) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            stateChanged(Boolean.FALSE, target);
        }
    };
    buttonFalse.setOutputMarkupId(true);
    buttonFalse.add(prepareButtonCssClass(buttonCssClass));
    buttonFalse.add(prepareActiveButtonAppender(Boolean.FALSE));
    add(buttonFalse);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton)

Aggregations

AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)393 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)116 Label (org.apache.wicket.markup.html.basic.Label)108 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)105 ArrayList (java.util.ArrayList)91 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)82 Form (org.apache.wicket.markup.html.form.Form)78 IModel (org.apache.wicket.model.IModel)73 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)71 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)65 List (java.util.List)56 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)48 ListItem (org.apache.wicket.markup.html.list.ListItem)43 Model (org.apache.wicket.model.Model)43 PropertyModel (org.apache.wicket.model.PropertyModel)42 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)37 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)34 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)34 ListView (org.apache.wicket.markup.html.list.ListView)32 TextField (org.apache.wicket.markup.html.form.TextField)30