use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class DelegationEditorPanel method initHeaderRow.
@Override
protected void initHeaderRow() {
if (delegatedToMe) {
privilegesListModel = new LoadableModel<List<AssignmentsPreviewDto>>(false) {
@Override
protected List<AssignmentsPreviewDto> load() {
return DelegationEditorPanel.this.getModelObject().getPrivilegeLimitationList();
}
};
}
AjaxCheckBox selected = new AjaxCheckBox(ID_SELECTED, new PropertyModel<>(getModel(), AssignmentEditorDto.F_SELECTED)) {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
};
selected.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModel().getObject().isSimpleView();
}
});
headerRow.add(selected);
Label arrowIcon = new Label(ID_ARROW_ICON);
headerRow.add(arrowIcon);
WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE);
typeImage.add(AttributeModifier.append("class", createImageTypeModel(getModel())));
headerRow.add(typeImage);
AjaxLink name = new AjaxLink(ID_NAME) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
nameClickPerformed(target);
}
};
headerRow.add(name);
Label nameLabel;
if (delegatedToMe) {
OperationResult result = new OperationResult(OPERATION_GET_TARGET_REF_NAME);
Task task = pageBase.createSimpleTask(OPERATION_GET_TARGET_REF_NAME);
nameLabel = new Label(ID_NAME_LABEL, WebModelServiceUtils.resolveReferenceName(getModelObject().getTargetRef(), pageBase, task, result));
} else {
nameLabel = new Label(ID_NAME_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel"));
}
nameLabel.setOutputMarkupId(true);
name.add(nameLabel);
AssignmentEditorDto dto = getModelObject();
dto.getTargetRef();
WebMarkupContainer delegatedToTypeImage = new WebMarkupContainer(ID_DELEGATED_TO_IMAGE);
if (delegatedToMe) {
delegatedToTypeImage.add(AttributeModifier.append("class", WebComponentUtil.createDefaultIcon(((PageUser) pageBase).getObjectWrapper().getObject())));
} else {
if (getModelObject().getDelegationOwner() != null) {
delegatedToTypeImage.add(AttributeModifier.append("class", WebComponentUtil.createDefaultIcon(getModelObject().getDelegationOwner().asPrismObject())));
}
}
headerRow.add(delegatedToTypeImage);
AjaxLink delegatedToName = new AjaxLink(ID_DELEGATED_TO) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
nameClickPerformed(target);
}
};
headerRow.add(delegatedToName);
Label delegatedToNameLabel;
if (delegatedToMe) {
delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel"));
} else {
delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, getUserDisplayName());
}
delegatedToNameLabel.setOutputMarkupId(true);
delegatedToName.add(delegatedToNameLabel);
ToggleIconButton expandButton = new ToggleIconButton(ID_EXPAND, GuiStyleConstants.CLASS_ICON_EXPAND, GuiStyleConstants.CLASS_ICON_COLLAPSE) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
nameClickPerformed(target);
}
@Override
public boolean isOn() {
return !DelegationEditorPanel.this.getModelObject().isMinimized();
}
};
headerRow.add(expandButton);
}
use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class MultipleAssignmentSelector method initSearchPanel.
private void initSearchPanel() {
final Form searchForm = new Form(ID_SEARCH_FORM);
add(searchForm);
searchForm.setOutputMarkupId(true);
SearchPanel search = new SearchPanel(ID_SEARCH, (IModel) searchModel, false) {
@Override
public void searchPerformed(ObjectQuery query, AjaxRequestTarget target) {
MultipleAssignmentSelector.this.searchPerformed(query, target);
}
};
searchForm.add(search);
}
use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class MultipleAssignmentSelector method createRowLink.
private Component createRowLink(String id, final IModel<SelectableBean<AssignmentEditorDto>> rowModel) {
AjaxLink<SelectableBean<AssignmentEditorDto>> button = new AjaxLink<SelectableBean<AssignmentEditorDto>>(id, rowModel) {
@Override
public IModel<?> getBody() {
AssignmentEditorDto dto = (AssignmentEditorDto) rowModel.getObject();
String name = StringUtils.isNotEmpty(dto.getNameForTargetObject()) ? dto.getNameForTargetObject() : dto.getName();
return new Model<>(name);
}
@Override
public void onClick(AjaxRequestTarget target) {
LOGGER.trace("{} CLICK: {}", this, rowModel.getObject());
toggleRow(rowModel);
target.add(this);
}
@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
if (rowModel.getObject().isSelected()) {
tag.put("class", "list-group-item active");
tag.put("style", "background-color: #eee; border-color: #d6d6d6; color: #000;");
} else {
tag.put("class", "list-group-item");
}
String description = ((AssignmentEditorDto) rowModel.getObject()).getDescription();
if (description != null) {
tag.put("title", description);
}
}
};
button.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return ((AssignmentEditorDto) rowModel.getObject()).getStatus() != UserDtoStatus.DELETE;
}
});
button.setOutputMarkupId(true);
return button;
}
use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class MultipleAssignmentSelectorPanel method initLayout.
private void initLayout(Class<H> targetFocusClass, PageBase page) {
IModel<List<AssignmentEditorDto>> availableAssignmentModel = createAvailableAssignmentModel();
final MultipleAssignmentSelector availableAssignmentsPanel = new MultipleAssignmentSelector<F, H>(ID_AVAILABLE_ASSIGNMENTS, availableAssignmentModel, targetFocusClass, type, focus, getFilterModel(true), page);
final MultipleAssignmentSelector currentAssignmentsPanel = new MultipleAssignmentSelector<F, H>(ID_CURRENT_ASSIGNMENTS, assignmentsModel, targetFocusClass, type, null, getFilterModel(true), page) {
@Override
protected List<AssignmentEditorDto> getListProviderDataList() {
return assignmentsModel.getObject();
}
};
currentAssignmentsPanel.setFilterButtonVisibility(false);
AjaxButton add = new AjaxButton(ID_BUTTON_ADD) {
@Override
protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form form) {
addToAssignmentsModel(target, availableAssignmentsPanel, currentAssignmentsPanel);
}
};
AjaxButton remove = new AjaxButton(ID_BUTTON_REMOVE) {
@Override
protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form form) {
deleteFromAssignmentsModel(target, currentAssignmentsPanel, availableAssignmentsPanel);
}
};
remove.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_UNASSIGN_ACTION_URL);
}
});
AjaxLink<String> buttonReset = new AjaxLink<String>(ID_BUTTON_RESET) {
@Override
public void onClick(AjaxRequestTarget target) {
reset(currentAssignmentsPanel);
target.add(currentAssignmentsPanel);
}
};
buttonReset.setBody(createStringResource("MultipleAssignmentSelector.reset"));
Form<?> form = new Form<Void>(ID_FORM);
form.add(createTenantContainer());
form.add(createOrgContainer());
form.add(availableAssignmentsPanel);
form.add(currentAssignmentsPanel);
form.add(buttonReset);
form.add(add);
form.add(remove);
add(form);
}
use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class MultiButtonTable method populateCell.
protected void populateCell(WebMarkupContainer cellContainer, final AssignmentEditorDto assignment) {
AjaxLink inner = new AjaxLink(ID_INNER) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
targetObjectDetailsPerformed(assignment, ajaxRequestTarget);
}
};
inner.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return isMultiUserRequest() || canAssign(assignment);
}
});
cellContainer.add(inner);
Label nameLabel = new Label(ID_INNER_LABEL, assignment.getName());
inner.add(nameLabel);
Label descriptionLabel = new Label(ID_INNER_DESCRIPTION, assignment.getTargetRef() != null ? assignment.getTargetRef().getDescription() : "");
descriptionLabel.setOutputMarkupId(true);
inner.add(descriptionLabel);
AjaxLink detailsLink = new AjaxLink(ID_DETAILS_LINK) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
assignmentDetailsPerformed(assignment, ajaxRequestTarget);
}
};
detailsLink.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return isMultiUserRequest() || canAssign(assignment);
}
});
cellContainer.add(detailsLink);
Label detailsLinkLabel = new Label(ID_DETAILS_LINK_LABEL, pageBase.createStringResource("MultiButtonPanel.detailsLink"));
detailsLinkLabel.setRenderBodyOnly(true);
detailsLink.add(detailsLinkLabel);
AjaxLink detailsLinkIcon = new AjaxLink(ID_DETAILS_LINK_ICON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
}
};
detailsLinkIcon.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return isMultiUserRequest() || canAssign(assignment);
}
});
detailsLink.add(detailsLinkIcon);
AjaxLink addToCartLink = new AjaxLink(ID_ADD_TO_CART_LINK) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
addAssignmentPerformed(assignment, ajaxRequestTarget);
}
};
addToCartLink.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return isMultiUserRequest() || canAssign(assignment);
}
});
cellContainer.add(addToCartLink);
AjaxLink addToCartLinkIcon = new AjaxLink(ID_ADD_TO_CART_LINK_ICON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
}
};
addToCartLinkIcon.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return isMultiUserRequest() || canAssign(assignment);
}
});
addToCartLink.add(addToCartLinkIcon);
WebMarkupContainer icon = new WebMarkupContainer(ID_TYPE_ICON);
icon.add(new AttributeAppender("class", getIconClass(assignment.getType())));
cellContainer.add(icon);
WebMarkupContainer alreadyAssignedIcon = new WebMarkupContainer(ID_ALREADY_ASSIGNED_ICON);
alreadyAssignedIcon.add(new AttributeAppender("title", getAlreadyAssignedIconTitleModel(assignment)));
alreadyAssignedIcon.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !isMultiUserRequest() && assignment.isAlreadyAssigned();
}
});
cellContainer.add(alreadyAssignedIcon);
}
Aggregations