Search in sources :

Example 1 with AjaxChannel

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

the class NavigatorPanel method initFirst.

private void initFirst() {
    WebMarkupContainer first = new WebMarkupContainer(ID_FIRST);
    first.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return isFirstEnabled() ? "" : "disabled";
        }
    }));
    add(first);
    AjaxLink firstLink = new AjaxLink(ID_FIRST_LINK) {

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

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

        @Override
        public boolean isEnabled() {
            return BooleanUtils.isTrue(showPageListingModel.getObject()) && isFirstEnabled();
        }
    });
    first.add(firstLink);
}
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 2 with AjaxChannel

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

the class NavigatorPanel method initPrevious.

private void initPrevious() {
    WebMarkupContainer previous = new WebMarkupContainer(ID_PREVIOUS);
    previous.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return isPreviousEnabled() ? "" : "disabled";
        }
    }));
    add(previous);
    AjaxLink previousLink = new AjaxLink(ID_PREVIOUS_LINK) {

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

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

        @Override
        public boolean isEnabled() {
            return isPreviousEnabled();
        }
    });
    previous.add(previousLink);
}
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 3 with AjaxChannel

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

the class NavigatorPanel method initNext.

private void initNext() {
    WebMarkupContainer next = new WebMarkupContainer(ID_NEXT);
    next.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return isNextEnabled() ? "" : "disabled";
        }
    }));
    add(next);
    AjaxLink nextLink = new AjaxLink(ID_NEXT_LINK) {

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

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

        @Override
        public boolean isEnabled() {
            return isNextEnabled();
        }
    });
    next.add(nextLink);
}
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 4 with AjaxChannel

use of org.apache.wicket.ajax.AjaxChannel 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 5 with AjaxChannel

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

Aggregations

VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)6 AjaxChannel (org.apache.wicket.ajax.AjaxChannel)6 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)6 AjaxRequestAttributes (org.apache.wicket.ajax.attributes.AjaxRequestAttributes)6 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)5 AttributeModifier (org.apache.wicket.AttributeModifier)4 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)4 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)4 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)2 Label (org.apache.wicket.markup.html.basic.Label)2 AssignmentEditorDto (com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)1 PageAssignmentShoppingKart (com.evolveum.midpoint.web.page.self.PageAssignmentShoppingKart)1 RoleCatalogStorage (com.evolveum.midpoint.web.session.RoleCatalogStorage)1 SessionStorage (com.evolveum.midpoint.web.session.SessionStorage)1