Search in sources :

Example 6 with AjaxRequestAttributes

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

the class AbstractRoleMainPanel method initShoppingCartPanel.

private void initShoppingCartPanel(PageAdminObjectDetails<R> parentPage) {
    RoleCatalogStorage storage = parentPage.getSessionStorage().getRoleCatalog();
    WebMarkupContainer shoppingCartButtonsPanel = new WebMarkupContainer(ID_SHOPPING_CART_BUTTONS_PANEL);
    shoppingCartButtonsPanel.setOutputMarkupId(true);
    shoppingCartButtonsPanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            // Role Catalog page
            return PageAssignmentShoppingKart.class.equals(getPreviousPage(parentPage));
        }
    });
    getMainForm().add(shoppingCartButtonsPanel);
    AjaxButton addToCartButton = new AjaxButton(ID_ADD_TO_CART_BUTTON, parentPage.createStringResource("PageAssignmentDetails.addToCartButton")) {

        private static final long serialVersionUID = 1L;

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

        @Override
        public void onClick(AjaxRequestTarget target) {
            AssignmentEditorDto dto = AssignmentEditorDto.createDtoFromObject(getObject().asObjectable(), UserDtoStatus.ADD, parentPage);
            storage.getAssignmentShoppingCart().add(dto);
            target.add(shoppingCartButtonsPanel);
        }
    };
    addToCartButton.setOutputMarkupId(true);
    addToCartButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            AssignmentEditorDto dto = AssignmentEditorDto.createDtoFromObject(getObject().asObjectable(), UserDtoStatus.ADD, parentPage);
            return storage.isMultiUserRequest() || dto.isAssignable();
        }
    });
    shoppingCartButtonsPanel.add(addToCartButton);
    AjaxButton shoppingCartButton = new AjaxButton(ID_SHOPPING_CART_BUTTON) {

        private static final long serialVersionUID = 1L;

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

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            parentPage.navigateToNext(PageAssignmentsList.class);
        }
    };
    shoppingCartButton.setOutputMarkupId(true);
    shoppingCartButtonsPanel.add(shoppingCartButton);
    Label cartItemsCount = new Label(ID_ITEMS_COUNT, new LoadableModel<String>(true) {

        private static final long serialVersionUID = 1L;

        @Override
        public String load() {
            return Integer.toString(storage.getAssignmentShoppingCart().size());
        }
    });
    cartItemsCount.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            if (storage.getAssignmentShoppingCart().size() == 0) {
                return false;
            } else {
                return true;
            }
        }
    });
    cartItemsCount.setOutputMarkupId(true);
    shoppingCartButton.add(cartItemsCount);
}
Also used : AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto) RoleCatalogStorage(com.evolveum.midpoint.web.session.RoleCatalogStorage) Label(org.apache.wicket.markup.html.basic.Label) PageAssignmentShoppingKart(com.evolveum.midpoint.web.page.self.PageAssignmentShoppingKart) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) AjaxChannel(org.apache.wicket.ajax.AjaxChannel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 7 with AjaxRequestAttributes

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

the class MenuLinkPanel method initLayout.

private void initLayout(IModel<InlineMenuItem> item) {
    InlineMenuItem dto = item.getObject();
    AbstractLink a;
    if (dto.isSubmit()) {
        a = new AjaxSubmitLink(ID_MENU_ITEM_LINK) {

            @Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                MenuLinkPanel.this.onSubmit(target, form, dto.getAction(), item);
            }

            @Override
            protected void onError(AjaxRequestTarget target, Form<?> form) {
                MenuLinkPanel.this.onError(target, form, dto.getAction());
            }

            @Override
            protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                super.updateAjaxAttributes(attributes);
                attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
            }
        };
    } else {
        a = new AjaxLink(ID_MENU_ITEM_LINK) {

            @Override
            public void onClick(AjaxRequestTarget target) {
                MenuLinkPanel.this.onClick(target, dto.getAction(), item);
            }

            @Override
            protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                super.updateAjaxAttributes(attributes);
                attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
            }
        };
    }
    add(a);
    a.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (dto.getAction() == null) {
                return false;
            }
            return true;
        }
    });
    Label span = new Label(ID_MENU_ITEM_LABEL, dto.getLabel());
    span.setRenderBodyOnly(true);
    a.add(span);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 8 with AjaxRequestAttributes

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

the class AssignmentCatalogPanel method initCartButton.

private void initCartButton(WebMarkupContainer headerPanel) {
    AjaxButton cartButton = new AjaxButton(ID_CART_BUTTON) {

        private static final long serialVersionUID = 1L;

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

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            pageBase.navigateToNext(PageAssignmentsList.class);
        }
    };
    cartButton.add(new VisibleEnableBehaviour() {

        public boolean isVisible() {
            return !isCatalogOidEmpty();
        }
    });
    cartButton.setOutputMarkupId(true);
    headerPanel.add(cartButton);
    Label cartItemsCount = new Label(ID_CART_ITEMS_COUNT, new LoadableModel<String>(true) {

        private static final long serialVersionUID = 1L;

        @Override
        public String load() {
            return Integer.toString(getRoleCatalogStorage().getAssignmentShoppingCart().size());
        }
    });
    cartItemsCount.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            SessionStorage storage = pageBase.getSessionStorage();
            if (storage.getRoleCatalog().getAssignmentShoppingCart().size() == 0) {
                return false;
            } else {
                return true;
            }
        }
    });
    cartItemsCount.setOutputMarkupId(true);
    cartButton.add(cartItemsCount);
}
Also used : AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Label(org.apache.wicket.markup.html.basic.Label) AjaxChannel(org.apache.wicket.ajax.AjaxChannel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) SessionStorage(com.evolveum.midpoint.web.session.SessionStorage)

Example 9 with AjaxRequestAttributes

use of org.apache.wicket.ajax.attributes.AjaxRequestAttributes 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)

Aggregations

AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)9 AjaxRequestAttributes (org.apache.wicket.ajax.attributes.AjaxRequestAttributes)9 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)8 AjaxChannel (org.apache.wicket.ajax.AjaxChannel)6 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)6 Label (org.apache.wicket.markup.html.basic.Label)5 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)4 AttributeModifier (org.apache.wicket.AttributeModifier)4 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)4 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)1 AssignmentEditorDto (com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)1 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)1 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)1 MenuLinkPanel (com.evolveum.midpoint.web.component.menu.cog.MenuLinkPanel)1 PageAssignmentShoppingKart (com.evolveum.midpoint.web.page.self.PageAssignmentShoppingKart)1 RoleCatalogStorage (com.evolveum.midpoint.web.session.RoleCatalogStorage)1