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);
}
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);
}
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);
}
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);
}
Aggregations