private static final long serialVersionUID = 1L;
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.getAjaxCallListeners().add(new ConfirmCallListener(833L));
}
@Override
protected void onEvent(AjaxRequestTarget target) {
Client c = item.getModelObject();
getBean(IUserService.class).kickUserByStreamId(getSid(), c.getStreamid()
, c.getServer() == null ? 0 : c.getServer().getId());
updateClients(target);
}
}));
}
};
add(clientsContainer.add(clients.setOutputMarkupId(true)).setOutputMarkupId(true));
// Moderators
final Select2Choice<User> moderatorChoice = new Select2Choice<User>("moderator2add", moderator2add, new AdminUserChoiceProvider() {
private static final long serialVersionUID = 1L;
@Override
public void query(String term, int page, Response<User> response) {
response.addAll(getBean(UserDao.class).get(term, false, page * PAGE_SIZE, PAGE_SIZE));
response.setHasMore(PAGE_SIZE == response.getResults().size());
}
@Override
protected String getDisplayText(User choice) {
Address a = choice.getAdresses();
return String.format("\"%s %s\" <%s>", choice.getFirstname(), choice.getLastname(), a == null ? "" : a.getEmail());
}
});
add(moderatorChoice.add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
Room r = RoomForm.this.getModelObject();
User u = moderator2add.getObject();
boolean found = false;
if (u != null) {
for (RoomModerator rm : r.getModerators()) {
if (rm.getUser().getUser_id().equals(u.getUser_id())) {
found = true;
break;
}
}
if (!found) {
RoomModerator rm = new RoomModerator();
rm.setRoomId(r.getRooms_id());
rm.setUser(u);
r.getModerators().add(0, rm);
moderator2add.setObject(null);
target.add(moderatorContainer, moderatorChoice);
}
}
}
}).setOutputMarkupId(true));
add(moderatorContainer.add(new ListView<RoomModerator>("moderators") {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<RoomModerator> item) {
RoomModerator moderator = item.getModelObject();
Label name = new Label("uName", moderator.getUser().getFirstname() + " " + moderator.getUser().getLastname());
if (moderator.getRoomModeratorsId() == 0) {
name.add(AttributeAppender.append("class", "newItem"));
}
item.add(new CheckBox("isSuperModerator", new PropertyModel<Boolean>(moderator, "isSuperModerator")))
.add(new Label("userId", "" + moderator.getUser().getUser_id()))
.add(name)
.add(new Label("email", moderator.getUser().getAdresses().getEmail()))
.add(new WebMarkupContainer("delete").add(new AjaxEventBehavior("onclick"){
private static final long serialVersionUID = 1L;
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.getAjaxCallListeners().add(new ConfirmCallListener(833L));
}
@Override
protected void onEvent(AjaxRequestTarget target) {
RoomForm.this.getModelObject().getModerators().remove(item.getIndex());