// check if already in model
boolean alreadyAssociated = PersistenceHelper.listContainsObjectByKey(this.repoTableModelEntries, re);
if (!alreadyAssociated) {
doAddRepositoryEntry(re);
fireEvent(ureq, Event.CHANGED_EVENT);
MultiUserEvent mue = new BGContextEvent(BGContextEvent.RESOURCE_ADDED, this.groupContext);
CoordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(mue, this.groupContext);
}
}
}
} else if (source == this.ownerCtr) {
if(event instanceof IdentitiesAddEvent ) {
List<Identity> addedIdentities = new ArrayList<Identity>();
for (Identity identity : ((IdentitiesAddEvent) event).getAddIdentities()) {
if (!ManagerFactory.getManager().isIdentityInSecurityGroup(identity, this.groupContext.getOwnerGroup())) {
ManagerFactory.getManager().addIdentityToSecurityGroup(identity, this.groupContext.getOwnerGroup());
addedIdentities.add(identity);
}
}
((IdentitiesAddEvent) event).setIdentitiesAddedEvent(addedIdentities);
} else if (event instanceof IdentitiesRemoveEvent) {
for (Identity identity : ((IdentitiesRemoveEvent) event).getRemovedIdentities()) {
if (ManagerFactory.getManager().isIdentityInSecurityGroup(identity, this.groupContext.getOwnerGroup())) {
ManagerFactory.getManager().removeIdentityFromSecurityGroup(identity, this.groupContext.getOwnerGroup());
}
}
}
fireEvent(ureq, Event.CHANGED_EVENT);
} else if (source == this.resourcesCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
int rowid = te.getRowId();
this.currentRepoEntry = (RepositoryEntry)this.repoTableModel.getObject(rowid);
if (actionid.equals(RepositoryTableModel.TABLE_ACTION_SELECT_LINK)) {
if (this.groupContext.isDefaultContext()) {
if (this.repoTableModelEntries.size() == 1) {
// display error and exit - do not remove resource
getWindowControl().setError(translate("resource.error.isDefault"));
this.contextController.setValues(this.groupContext);
return;
}
}
//present dialog box if resource should be removed
String text = getTranslator().translate("resource.remove", new String[] { this.groupContext.getName(), this.currentRepoEntry.getDisplayname() });
this.confirmRemoveResource = activateYesNoDialog(ureq, null, text, this.confirmRemoveResource);
}
}
} else if (source == this.confirmRemoveResource) {
if (DialogBoxUIFactory.isYesEvent(event)) { // yes case
doRemoveResource(this.currentRepoEntry);
fireEvent(ureq, Event.CHANGED_EVENT);
MultiUserEvent mue = new BGContextEvent(BGContextEvent.RESOURCE_REMOVED, this.groupContext);
CoordinatorManager.getCoordinator().getEventBus().fireEventToListenersOf(mue, this.groupContext);
}
} else if (source == this.contextController) {
if (event == Event.DONE_EVENT) {
doUpdateContext(ureq);