use of org.olat.core.gui.control.generic.closablewrapper.CloseableModalController in project OpenOLAT by OpenOLAT.
the class GroupController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Controller sourceController, Event event) {
if (sourceController == tableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
// Single row selects
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
final Identity identity = identitiesTableModel.getObject(te.getRowId()).getIdentity();
if (actionid.equals(COMMAND_VCARD)) {
// get identity and open new visiting card controller in new window
ControllerCreator userInfoMainControllerCreator = new ControllerCreator() {
@Override
public Controller createController(UserRequest lureq, WindowControl lwControl) {
return new UserInfoMainController(lureq, lwControl, identity, true, false);
}
};
// wrap the content controller into a full header layout
ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, userInfoMainControllerCreator);
// open in new browser window
PopupBrowserWindow pbw = getWindowControl().getWindowBackOffice().getWindowManager().createNewPopupBrowserWindowFor(ureq, layoutCtrlr);
pbw.open(ureq);
//
} else if (actionid.equals(COMMAND_SELECTUSER)) {
fireEvent(ureq, new SingleIdentityChosenEvent(identity));
} else if (COMMAND_IM.equals(actionid)) {
doIm(ureq, identity);
}
} else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
// Multiselect events
TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
if (tmse.getAction().equals(COMMAND_REMOVEUSER)) {
if (tmse.getSelection().isEmpty()) {
// empty selection
showWarning("msg.selectionempty");
return;
}
int size = identitiesTableModel.getObjects().size();
toRemove = identitiesTableModel.getIdentities(tmse.getSelection());
// list is never null, but can be empty
if (keepAtLeastOne && (size == 1 || size - toRemove.size() == 0)) {
// at least one must be kept
// do not delete the last one => ==1
// do not allow to delete all => size - selectedCnt == 0
showError("msg.atleastone");
} else {
// valid selection to be deleted.
if (removeUserMailDefaultTempl == null) {
doBuildConfirmDeleteDialog(ureq);
} else {
removeAsListenerAndDispose(removeUserMailCtr);
removeUserMailCtr = new MailNotificationEditController(getWindowControl(), ureq, removeUserMailDefaultTempl, true, false, true);
listenTo(removeUserMailCtr);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), removeUserMailCtr.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
}
}
}
} else if (sourceController == removeUserMailCtr) {
if (event == Event.DONE_EVENT) {
removeUserMailCustomTempl = removeUserMailCtr.getMailTemplate();
cmc.deactivate();
doBuildConfirmDeleteDialog(ureq);
} else {
cmc.deactivate();
}
} else if (sourceController == usc) {
if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
} else {
if (event instanceof SingleIdentityChosenEvent) {
SingleIdentityChosenEvent singleEvent = (SingleIdentityChosenEvent) event;
Identity choosenIdentity = singleEvent.getChosenIdentity();
if (choosenIdentity == null) {
showError("msg.selectionempty");
return;
}
toAdd = new ArrayList<Identity>();
toAdd.add(choosenIdentity);
} else if (event instanceof MultiIdentityChosenEvent) {
MultiIdentityChosenEvent multiEvent = (MultiIdentityChosenEvent) event;
toAdd = multiEvent.getChosenIdentities();
if (toAdd.size() == 0) {
showError("msg.selectionempty");
return;
}
} else {
throw new RuntimeException("unknown event ::" + event.getCommand());
}
if (toAdd.size() == 1) {
// check if already in group [makes only sense for a single choosen identity]
if (groupDao.hasRole(group, toAdd.get(0), role)) {
String fullName = userManager.getUserDisplayName(toAdd.get(0));
getWindowControl().setInfo(translate("msg.subjectalreadyingroup", new String[] { fullName }));
return;
}
} else if (toAdd.size() > 1) {
// check if already in group
List<Identity> alreadyInGroup = new ArrayList<Identity>();
for (int i = 0; i < toAdd.size(); i++) {
if (groupDao.hasRole(group, toAdd.get(i), role)) {
tableCtr.setMultiSelectSelectedAt(i, false);
alreadyInGroup.add(toAdd.get(i));
}
}
if (!alreadyInGroup.isEmpty()) {
StringBuilder names = new StringBuilder();
for (Identity ident : alreadyInGroup) {
if (names.length() > 0)
names.append(", ");
names.append(userManager.getUserDisplayName(ident));
toAdd.remove(ident);
}
getWindowControl().setInfo(translate("msg.subjectsalreadyingroup", names.toString()));
}
if (toAdd.isEmpty()) {
return;
}
}
// in both cases continue adding the users or asking for the mail
// template if available (=not null)
cmc.deactivate();
if (addUserMailDefaultTempl == null) {
doAddIdentitiesToGroup(ureq, toAdd, null);
} else {
removeAsListenerAndDispose(addUserMailCtr);
addUserMailCtr = new MailNotificationEditController(getWindowControl(), ureq, addUserMailDefaultTempl, true, mandatoryEmail, true);
listenTo(addUserMailCtr);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("close"), addUserMailCtr.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
}
// in any case cleanup this controller, not used anymore
usc.dispose();
usc = null;
} else if (sourceController == addUserMailCtr) {
if (event == Event.DONE_EVENT) {
MailTemplate customTemplate = addUserMailCtr.getMailTemplate();
doAddIdentitiesToGroup(ureq, toAdd, customTemplate);
cmc.deactivate();
} else if (event == Event.CANCELLED_EVENT) {
cmc.deactivate();
} else {
throw new RuntimeException("unknown event ::" + event.getCommand());
}
} else if (sourceController == confirmDelete) {
if (DialogBoxUIFactory.isYesEvent(event)) {
// before deleting, assure it is allowed
if (!mayModifyMembers)
throw new AssertException("not allowed to remove member!");
// list is never null, but can be empty
// TODO: Theoretically it can happen that the table model here is not accurate!
// the 'keep at least one' should be handled by the security manager that should
// synchronizes the method on the group
int size = identitiesTableModel.getObjects().size();
if (keepAtLeastOne && (size - toRemove.size() == 0)) {
showError("msg.atleastone");
} else {
doRemoveIdentitiesFromGroup(ureq, toRemove, removeUserMailCustomTempl);
}
}
} else if (sourceController == userToGroupWizard) {
if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
getWindowControl().pop();
removeAsListenerAndDispose(userToGroupWizard);
userToGroupWizard = null;
if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
reloadData();
}
}
}
}
use of org.olat.core.gui.control.generic.closablewrapper.CloseableModalController in project OpenOLAT by OpenOLAT.
the class FolderCallback method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest urequest, Controller source, Event event) {
if (source == projectBrokerConditionController) {
if (event == Event.CHANGED_EVENT) {
node.setConditionProjectBroker(projectBrokerConditionController.getCondition());
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
} else if (source == dialogBoxController) {
if (DialogBoxUIFactory.isOkEvent(event)) {
// ok: open task folder
String relPath = TACourseNode.getTaskFolderPathRelToFolderRoot(CourseFactory.loadCourse(courseId), node);
OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(relPath, null);
OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(translate("taskfolder"), rootFolder);
namedFolder.setLocalSecurityCallback(new FolderCallback(relPath, false));
removeAsListenerAndDispose(frc);
frc = new FolderRunController(namedFolder, false, urequest, getWindowControl());
listenTo(frc);
removeAsListenerAndDispose(cmc);
cmc = new CloseableModalController(getWindowControl(), translate("folder.close"), frc.getInitialComponent());
listenTo(cmc);
cmc.activate();
fireEvent(urequest, Event.CHANGED_EVENT);
}
} else if (source == scoringController) {
if (event == Event.CANCELLED_EVENT) {
if (hasLogEntries) {
scoringController.setDisplayOnly(true);
}
editScoring.contextPut("isOverwriting", new Boolean(false));
return;
} else if (event == Event.DONE_EVENT) {
scoringController.updateModuleConfiguration(config);
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
} else if (source == modulesForm) {
boolean onoff = event.getCommand().endsWith("true");
if (event.getCommand().startsWith("dropbox")) {
config.set(ProjectBrokerCourseNode.CONF_DROPBOX_ENABLED, onoff);
} else if (event.getCommand().startsWith("returnbox")) {
config.set(ProjectBrokerCourseNode.CONF_RETURNBOX_ENABLED, onoff);
}
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
return;
} else if (source == accountManagerGroupController) {
if (event instanceof IdentitiesAddEvent) {
IdentitiesAddEvent identitiesAddedEvent = (IdentitiesAddEvent) event;
BusinessGroupAddResponse response = businessGroupService.addParticipants(urequest.getIdentity(), urequest.getUserSession().getRoles(), identitiesAddedEvent.getAddIdentities(), accountManagerGroup, null);
identitiesAddedEvent.setIdentitiesAddedEvent(response.getAddedIdentities());
identitiesAddedEvent.setIdentitiesWithoutPermission(response.getIdentitiesWithoutPermission());
identitiesAddedEvent.setIdentitiesAlreadyInGroup(response.getIdentitiesAlreadyInGroup());
getLogger().info("Add users as account-managers");
fireEvent(urequest, Event.CHANGED_EVENT);
} else if (event instanceof IdentitiesRemoveEvent) {
businessGroupService.removeParticipants(urequest.getIdentity(), ((IdentitiesRemoveEvent) event).getRemovedIdentities(), accountManagerGroup, null);
getLogger().info("Remove users as account-managers");
fireEvent(urequest, Event.CHANGED_EVENT);
}
} else if (source == optionsForm) {
if (event == Event.CANCELLED_EVENT) {
return;
} else if (event == Event.DONE_EVENT) {
projectBrokerModuleConfiguration.setNbrParticipantsPerTopic(optionsForm.getNnbrOfAttendees());
if (projectBrokerModuleConfiguration.isAcceptSelectionManually() && !optionsForm.getSelectionAccept()) {
// change 'Accept manually' to 'Accept automatically' => enroll all candidates
projectGroupManager.acceptAllCandidates(projectBrokerId, urequest.getIdentity(), projectBrokerModuleConfiguration.isAutoSignOut(), optionsForm.getSelectionAccept());
}
projectBrokerModuleConfiguration.setAcceptSelectionManaually(optionsForm.getSelectionAccept());
projectBrokerModuleConfiguration.setSelectionAutoSignOut(optionsForm.getSelectionAutoSignOut());
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
} else if (source == customfieldsForm || source == projectEventForm) {
if (event == Event.CANCELLED_EVENT) {
return;
} else if (event == Event.DONE_EVENT) {
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
} else if (event == NodeEditController.NODECONFIG_CHANGED_EVENT) {
getLogger().debug("NODECONFIG_CHANGED_node.shortTitle=" + node.getShortTitle());
String groupName = translate("account.manager.groupname", node.getShortTitle());
String groupDescription = translate("account.manager.groupdescription", node.getShortTitle());
accountManagerGroup = projectGroupManager.updateAccountManagerGroupName(getIdentity(), groupName, groupDescription, accountManagerGroup);
} else if (source == dropboxForm) {
if (event == Event.CANCELLED_EVENT) {
return;
} else if (event == Event.DONE_EVENT) {
config.set(ProjectBrokerCourseNode.CONF_DROPBOX_ENABLEMAIL, dropboxForm.mailEnabled());
config.set(ProjectBrokerCourseNode.CONF_DROPBOX_CONFIRMATION, dropboxForm.getConfirmation());
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
return;
}
} else {
getLogger().warn("Can not handle event in ProjectBrokerCourseEditorController source=" + source + " " + event.toString());
}
}
use of org.olat.core.gui.control.generic.closablewrapper.CloseableModalController in project OpenOLAT by OpenOLAT.
the class CheckListAssessmentController method doOpenBoxAssessment.
private void doOpenBoxAssessment(UserRequest ureq) {
if (boxAssessmentCtrl != null)
return;
List<CheckListAssessmentRow> rows = model.getObjects();
boxAssessmentCtrl = new CheckboxAssessmentController(ureq, getWindowControl(), checkboxList, rows, courseOres, courseNode);
listenTo(boxAssessmentCtrl);
String title = translate("box.assessment");
Component content = boxAssessmentCtrl.getInitialComponent();
cmc = new CloseableModalController(getWindowControl(), translate("close"), content, true, title);
listenTo(cmc);
cmc.activate();
}
use of org.olat.core.gui.control.generic.closablewrapper.CloseableModalController in project OpenOLAT by OpenOLAT.
the class CheckListBoxListEditController method doOpenEdit.
private void doOpenEdit(UserRequest ureq, Checkbox checkbox, boolean newCheckbox, String title) {
if (editCtrl != null)
return;
Boolean hasScore = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
boolean withScore = (hasScore == null || hasScore.booleanValue());
editCtrl = new CheckboxEditController(ureq, getWindowControl(), courseOres, courseNode, checkbox, newCheckbox, withScore);
listenTo(editCtrl);
Component content = editCtrl.getInitialComponent();
cmc = new CloseableModalController(getWindowControl(), translate("close"), content, true, title);
listenTo(cmc);
cmc.activate();
}
use of org.olat.core.gui.control.generic.closablewrapper.CloseableModalController in project OpenOLAT by OpenOLAT.
the class GTASampleSolutionsEditController method doCreateSolutionEditor.
private void doCreateSolutionEditor(UserRequest ureq, Solution solution) {
String documentName = solution.getFilename();
VFSItem item = solutionContainer.resolve(documentName);
if (item == null) {
item = solutionContainer.createChildLeaf(documentName);
} else {
documentName = VFSManager.rename(solutionContainer, documentName);
item = solutionContainer.createChildLeaf(documentName);
}
if (item instanceof MetaTagged) {
MetaInfo metaInfo = ((MetaTagged) item).getMetaInfo();
if (metaInfo != null) {
metaInfo.setAuthor(getIdentity());
}
metaInfo.write();
}
newSolutionEditorCtrl = WysiwygFactory.createWysiwygController(ureq, getWindowControl(), solutionContainer, documentName, "media", true, true);
newSolutionEditorCtrl.getRichTextConfiguration().disableMedia();
newSolutionEditorCtrl.getRichTextConfiguration().setAllowCustomMediaFactory(false);
newSolutionEditorCtrl.setNewFile(true);
newSolutionEditorCtrl.setUserObject(solution);
listenTo(newSolutionEditorCtrl);
cmc = new CloseableModalController(getWindowControl(), "close", newSolutionEditorCtrl.getInitialComponent());
listenTo(cmc);
cmc.activate();
}
Aggregations