/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.course.nodes.en;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItem;
import org.olat.core.gui.components.form.flexible.FormItemContainer;
import org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement;
import org.olat.core.gui.components.form.flexible.elements.TextElement;
import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
import org.olat.core.gui.components.form.flexible.impl.FormEvent;
import org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer;
import org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl;
import org.olat.core.gui.components.form.flexible.impl.elements.FormSubmit;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.generic.closablewrapper.CloseableModalController;
import org.olat.core.util.StringHelper;
import org.olat.core.util.Util;
import org.olat.course.condition.Condition;
import org.olat.course.condition.GroupOrAreaSelectionController;
import org.olat.course.editor.CourseEditorEnv;
import org.olat.course.editor.NodeEditController;
import org.olat.course.groupsandrights.CourseGroupManager;
import org.olat.course.nodes.ENCourseNode;
import org.olat.group.context.BGContext;
import org.olat.group.ui.BGControllerFactory;
import org.olat.group.ui.NewAreaController;
import org.olat.group.ui.NewBGController;
import org.olat.group.ui.context.BGContextEvent;
import org.olat.modules.ModuleConfiguration;
/**
* Description:<br>
* TODO: patrickb Class Description for ENEditGroupAreaFormController
*
* <P>
* Initial Date: 12.08.2007 <br>
* @author patrickb
*/
class ENEditGroupAreaFormController extends FormBasicController {
private ModuleConfiguration moduleConfig;
private CourseEditorEnv cev;
private MultipleSelectionElement enableCancelEnroll;
private TextElement easyGroupTE;
private FormLinkImpl chooseGroupsLink;
private FormLinkImpl createGroupsLink;
private TextElement easyAreaTE;
private FormLinkImpl chooseAreasLink;
private FormLinkImpl createAreasLink;
private boolean hasAreas;
private boolean hasGroups;
private FormSubmit subm;
private FormLinkImpl fixGroupError;
private FormLinkImpl fixAreaError;
private CloseableModalController cmc;
private NewAreaController areaCreateCntrllr;
private NewBGController groupCreateCntrllr;
private GroupOrAreaSelectionController areaChooseC;
private GroupOrAreaSelectionController groupChooseC;
private FormLayoutContainer areaChooseSubContainer, groupChooseSubContainer ;
public ENEditGroupAreaFormController(UserRequest ureq, WindowControl wControl, ModuleConfiguration moduleConfig, CourseEditorEnv cev) {
super(ureq, wControl, null, Util.createPackageTranslator(Condition.class, ureq.getLocale()));
this.moduleConfig = moduleConfig;
this.cev = cev;
hasAreas = cev.getCourseGroupManager().getAllAreasFromAllContexts().size() > 0;
hasGroups = cev.getCourseGroupManager().getAllLearningGroupsFromAllContexts().size() > 0;
/*
* init all elements the last thing to do
*/
initForm(this.flc, this, ureq);
}
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#doDispose(boolean)
*/
@Override
protected void doDispose() {
// TODO Auto-generated method stub
}
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#formOK(org.olat.core.gui.UserRequest)
*/
@Override
protected void formOK(UserRequest ureq) {
// 1. group names
String groupName = "";
if (StringHelper.containsNonWhitespace(easyGroupTE.getValue())){
groupName = easyGroupTE.getValue();
}
moduleConfig.set(ENCourseNode.CONFIG_GROUPNAME, groupName);
// 2. area names
String areaName = "";
if (StringHelper.containsNonWhitespace(easyAreaTE.getValue())){
areaName = easyAreaTE.getValue();
}
moduleConfig.set(ENCourseNode.CONFIG_AREANAME, areaName);
// 3. chnacel-enroll-enabled flag
Boolean cancelEnrollEnabled = enableCancelEnroll.getSelectedKeys().size()==1;
moduleConfig.set(ENCourseNode.CONF_CANCEL_ENROLL_ENABLED, cancelEnrollEnabled);
// Inform all listeners about the changed condition
fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer, org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// Get initial value from config
String groupInitVal = (String) moduleConfig.get(ENCourseNode.CONFIG_GROUPNAME);
String areaInitVal = (String) moduleConfig.get(ENCourseNode.CONFIG_AREANAME);
Boolean initialCancelEnrollEnabled = (Boolean) moduleConfig.get(ENCourseNode.CONF_CANCEL_ENROLL_ENABLED);
groupChooseSubContainer = (FormLayoutContainer)FormLayoutContainer.createHorizontalFormLayout("groupChooseSubContainer", getTranslator());
groupChooseSubContainer.setLabel("form.groupnames", null);
formLayout.add(groupChooseSubContainer);
//
easyGroupTE = uifactory.addTextElement("group", null, 1024, groupInitVal, groupChooseSubContainer);
easyGroupTE.setDisplaySize(24);
easyGroupTE.setExampleKey("form.groupnames.example", null);
/*
* check for defaultcontext
*/
boolean hasDefaultContext = getDefaultBGContext() != null;
//
chooseGroupsLink = new FormLinkImpl("choosegroups", "choose");
chooseGroupsLink.setCustomEnabledLinkCSS("b_form_groupchooser");
// prepare create groups link which is used instead of chooseGroupsLink in
// the
// case where no groups are configured in the groupmanagement
createGroupsLink = new FormLinkImpl("choosegroups", "create");
createGroupsLink.setCustomEnabledLinkCSS("b_form_groupchooser");
// create groups if no groups in groupmanagement, and default context
// available
groupChooseSubContainer.add(hasDefaultContext && !hasGroups ? createGroupsLink : chooseGroupsLink);
areaChooseSubContainer = (FormLayoutContainer)FormLayoutContainer.createHorizontalFormLayout("areaChooseSubContainer", getTranslator());
areaChooseSubContainer.setLabel("form.areanames", null);
formLayout.add(areaChooseSubContainer);
easyAreaTE = uifactory.addTextElement("area", null, 1024, areaInitVal, areaChooseSubContainer);
easyAreaTE.setDisplaySize(24);
easyAreaTE.setExampleKey("form.areanames.example", null);
chooseAreasLink = new FormLinkImpl("chooseareas", "choose");
chooseAreasLink.setCustomEnabledLinkCSS("b_form_groupchooser");
// prepare create are link which is used instead of choose area link in the
// case where no areas are configured in the groupmanagement
createAreasLink = new FormLinkImpl("chooseareas", "create");
createAreasLink.setCustomEnabledLinkCSS("b_form_groupchooser");
//
areaChooseSubContainer.add(hasDefaultContext && !hasAreas ? createAreasLink : chooseAreasLink);
//
enableCancelEnroll = uifactory.addCheckboxesHorizontal("enableCancelEnroll", "form.enableCancelEnroll", formLayout, new String[] { "ison" }, new String[] { "" }, null);
// initialise selection
enableCancelEnroll.select("ison", initialCancelEnrollEnabled);
//
// the submit button
subm = new FormSubmit("subm", "submit");
formLayout.add(subm);
}
@Override
protected boolean validateFormLogic(UserRequest ureq){
boolean retVal = true;
String[] activeGroupSelection = new String[0];
String[] activeAreaSelection = new String[0];
if (!easyGroupTE.isEmpty()) {
// check whether groups exist
activeGroupSelection = easyGroupTE.getValue().split(",");
boolean exists = false;
Set<String> missingGroups = new HashSet<String>();
for (int i = 0; i < activeGroupSelection.length; i++) {
String trimmed = activeGroupSelection[i].trim();
exists = cev.existsGroup(trimmed);
if (!exists) {
missingGroups.add(trimmed);
}
}
if (missingGroups.size() > 0) {
retVal = false;
String labelKey = missingGroups.size() == 1 ? "error.notfound.name" : "error.notfound.names";
String csvMissGrps = StringHelper.formatAsCSVString(missingGroups);
String[] params = new String[] { "-", csvMissGrps };
/*
* create error with link to fix it
*/
String vc_errorPage = velocity_root + "/erroritem.html";
FormLayoutContainer errorGroupItemLayout = (FormLayoutContainer) FormLayoutContainer.createCustomFormLayout("errorgroupitem",
getTranslator(), vc_errorPage);
boolean hasDefaultContext = getDefaultBGContext() != null;
if (hasDefaultContext) {
groupChooseSubContainer.setErrorComponent(errorGroupItemLayout, this.flc);
// FIXING LINK ONLY IF A DEFAULTCONTEXT EXISTS
fixGroupError = new FormLinkImpl("error.fix", "create");
// link
fixGroupError.setCustomEnabledLinkCSS("b_button");
errorGroupItemLayout.add(fixGroupError);
fixGroupError.setErrorKey(labelKey, params);
fixGroupError.showError(true);
fixGroupError.showLabel(false);
// hinty to pass the information if one group is
// missing or if 2 or more groups are missing
// (see fixGroupErrer.getUserObject to understand)
// e.g. if userobject String[].lenght == 1 -> one group only
// String[].lenght > 1 -> show bulkmode creation group
if (missingGroups.size() > 1) {
fixGroupError.setUserObject(new String[] { csvMissGrps, "dummy" });
} else {
fixGroupError.setUserObject(new String[] { csvMissGrps });
}
} else {
// fix helper link not possible -> errortext only
groupChooseSubContainer.setErrorKey(labelKey, params);
}
/*
*
*/
groupChooseSubContainer.showError(true);
} else {
// no more errors
groupChooseSubContainer.clearError();
}
}
if (!easyAreaTE.isEmpty()) {
// check whether areas exist
activeAreaSelection = easyAreaTE.getValue().split(",");
boolean exists = false;
Set<String> missingAreas = new HashSet<String>();
for (int i = 0; i < activeAreaSelection.length; i++) {
String trimmed = activeAreaSelection[i].trim();
exists = cev.existsArea(trimmed);
if (!exists) {
missingAreas.add(trimmed);
}
}
if (missingAreas.size() > 0) {
retVal = false;
String labelKey = missingAreas.size() == 1 ? "error.notfound.name" : "error.notfound.names";
String csvMissAreas = StringHelper.formatAsCSVString(missingAreas);
String[] params = new String[] { "-", csvMissAreas };
/*
* create error with link to fix it
*/
String vc_errorPage = velocity_root + "/erroritem.html";
FormLayoutContainer errorAreaItemLayout = (FormLayoutContainer) FormLayoutContainer.createCustomFormLayout("errorareaitem",
getTranslator(), vc_errorPage);
boolean hasDefaultContext = getDefaultBGContext() != null;
if (hasDefaultContext) {
areaChooseSubContainer.setErrorComponent(errorAreaItemLayout, this.flc);
// FXINGIN LINK ONLY IF DEFAULT CONTEXT EXISTS
fixAreaError = new FormLinkImpl("error.fix", "create");// erstellen
// link
fixAreaError.setCustomEnabledLinkCSS("b_button");
errorAreaItemLayout.add(fixAreaError);
fixAreaError.setErrorKey(labelKey, params);
fixAreaError.showError(true);
fixAreaError.showLabel(false);
// hint to pass the information if one area is
// missing or if 2 or more areas are missing
// (see fixGroupErrer.getUserObject to understand)
// e.g. if userobject String[].lenght == 1 -> one group only
// String[].lenght > 1 -> show bulkmode creation group
if (missingAreas.size() > 1) {
fixAreaError.setUserObject(new String[] { csvMissAreas, "dummy" });
} else {
fixAreaError.setUserObject(new String[] { csvMissAreas });
}
} else {
// fixing help link not possible -> text only
areaChooseSubContainer.setErrorKey(labelKey, params);
}
/*
*
*/
areaChooseSubContainer.showError(true);
} else {
// TODO:pb:introduce clear error instead hiding error!
areaChooseSubContainer.clearError();
}
}
boolean easyGroupOK = (!easyGroupTE.isEmpty() && activeGroupSelection.length != 0);
boolean easyAreaOK = (!easyAreaTE.isEmpty() && activeAreaSelection.length != 0);
if (easyGroupOK || easyAreaOK) {
// clear general error
this.flc.clearError();
} else {
// error concerns both fields -> set it as switch error
this.flc.setErrorKey("form.noGroupsOrAreas", null);
retVal = false;
}
//raise error if someone removed all groups and areas from form
if (!retVal && !easyGroupOK && !easyAreaOK) {
if (!easyGroupOK) areaChooseSubContainer.setErrorKey("form.noGroupsOrAreas", null);
if (!easyAreaOK) groupChooseSubContainer.setErrorKey("form.noGroupsOrAreas", null);
} else if (retVal) {
areaChooseSubContainer.clearError();
groupChooseSubContainer.clearError();
}
return retVal;
}
@Override
@SuppressWarnings("unused")
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
/*
*
*/
if (source == chooseGroupsLink) {
// user wants to choose groups.. either link clicked -> Startpoint for
// group choosing workflow
if (groupChooseC != null) groupChooseC.dispose();
// already groups -> it is about selecting groups
groupChooseC = new GroupOrAreaSelectionController(0, getWindowControl(), ureq, "group", cev.getCourseGroupManager(),
easyGroupTE.getValue());
groupChooseC.addControllerListener(this);
//the main form gets overlayed -> hence do not mark as dirty
//otherwise clicking any link in the overlay results in a
//alert box -> "you have unsaved form data"
//one has to listen for cmc closing events and then reactivate
//dirty setting!! TODO:pb: find a better solution as this is error prone
this.flc.getRootForm().setDirtyMarking(false);
if (cmc != null) cmc.dispose();
cmc = new CloseableModalController(getWindowControl(), "close", groupChooseC.getInitialComponent(), true, getTranslator().translate("popupchoosegroups"));
cmc.addControllerListener(this);
cmc.activate();
} else if (source == createGroupsLink) {
// no groups in group management -> directly show group create dialog
BGContext bgContext = getDefaultBGContext();
String[] csvGroupName = easyGroupTE.isEmpty() ? new String[0] : easyGroupTE.getValue().split(",");
// determine if bulkmode or not
if (groupCreateCntrllr != null) groupCreateCntrllr.dispose();
boolean bulkMode = csvGroupName.length > 1;
groupCreateCntrllr = BGControllerFactory.getInstance().createNewBGController(ureq, getWindowControl(), true,
bgContext, bulkMode, easyGroupTE.getValue());
groupCreateCntrllr.addControllerListener(this);
//the main form gets overlayed -> hence do not mark as dirty
//otherwise clicking any link in the overlay results in a
//alert box -> "you have unsaved form data"
//one has to listen for cmc closing events and then reactivate
//dirty setting!! TODO:pb: find a better solution as this is error prone
this.flc.getRootForm().setDirtyMarking(false);
if (cmc != null) cmc.dispose();
cmc = new CloseableModalController(getWindowControl(), "close", groupCreateCntrllr.getInitialComponent());
cmc.addControllerListener(this);
cmc.activate();
} else if (source == chooseAreasLink) {
if (areaChooseC != null) areaChooseC.dispose();
// already areas -> choose areas
if (areaChooseC != null) areaChooseC.dispose();
areaChooseC = new GroupOrAreaSelectionController(1, getWindowControl(), ureq, "area", cev.getCourseGroupManager(),
easyAreaTE.getValue());
areaChooseC.addControllerListener(this);
//the main form gets overlayed -> hence do not mark as dirty
//otherwise clicking any link in the overlay results in a
//alert box -> "you have unsaved form data"
//one has to listen for cmc closing events and then reactivate
//dirty setting!! TODO:pb: find a better solution as this is error prone
this.flc.getRootForm().setDirtyMarking(false);
if (cmc != null) cmc.dispose();
cmc = new CloseableModalController(getWindowControl(), "close", areaChooseC.getInitialComponent(), true, getTranslator().translate("popupchooseareas"));
cmc.addControllerListener(this);
cmc.activate();
} else if (source == createAreasLink) {
// no areas -> directly show creation dialog
BGContext bgContext = getDefaultBGContext();
if (areaCreateCntrllr != null) areaCreateCntrllr.dispose();
String[] csvAreaName = easyAreaTE.isEmpty() ? new String[0] : easyAreaTE.getValue().split(",");
// determine if bulkmode or not
boolean bulkMode = csvAreaName.length > 1;
areaCreateCntrllr = BGControllerFactory.getInstance().createNewAreaController(ureq, getWindowControl(),
bgContext, bulkMode, easyAreaTE.getValue());
areaCreateCntrllr.addControllerListener(this);
//the main form gets overlayed -> hence do not mark as dirty
//otherwise clicking any link in the overlay results in a
//alert box -> "you have unsaved form data"
//one has to listen for cmc closing events and then reactivate
//dirty setting!! TODO:pb: find a better solution as this is error prone
this.flc.getRootForm().setDirtyMarking(false);
if (cmc != null) cmc.dispose();
cmc = new CloseableModalController(getWindowControl(), "close", areaCreateCntrllr.getInitialComponent());
cmc.addControllerListener(this);
cmc.activate();
} else if (source == fixGroupError) {
/*
* user wants to fix problem with fixing group error link e.g. create one
* or more group at once.
*/
BGContext bgContext = getDefaultBGContext();
if (groupCreateCntrllr != null) groupCreateCntrllr.dispose();
String[] csvGroupName = (String[]) fixGroupError.getUserObject();
// determine if bulkmode or not
boolean bulkMode = csvGroupName.length > 1;
groupCreateCntrllr = BGControllerFactory.getInstance().createNewBGController(ureq, getWindowControl(), true,
bgContext, bulkMode, csvGroupName[0]);
groupCreateCntrllr.addControllerListener(this);
//the main form gets overlayed -> hence do not mark as dirty
//otherwise clicking any link in the overlay results in a
//alert box -> "you have unsaved form data"
//one has to listen for cmc closing events and then reactivate
//dirty setting!! TODO:pb: find a better solution as this is error prone
this.flc.getRootForm().setDirtyMarking(false);
if (cmc != null) cmc.dispose();
cmc = new CloseableModalController(getWindowControl(), "close", groupCreateCntrllr.getInitialComponent());
cmc.addControllerListener(this);
cmc.activate();
} else if (source == fixAreaError) {
/*
* user wants to fix problem with fixing area error link e.g. create one
* or more areas at once.
*/
BGContext bgContext = getDefaultBGContext();
if (areaCreateCntrllr != null) areaCreateCntrllr.dispose();
String[] csvAreaName = (String[]) fixAreaError.getUserObject();
// determine if bulkmode or not
boolean bulkMode = csvAreaName.length > 1;
areaCreateCntrllr = BGControllerFactory.getInstance().createNewAreaController(ureq, getWindowControl(),
bgContext, bulkMode, csvAreaName[0]);
areaCreateCntrllr.addControllerListener(this);
//the main form gets overlayed -> hence do not mark as dirty
//otherwise clicking any link in the overlay results in a
//alert box -> "you have unsaved form data"
//one has to listen for cmc closing events and then reactivate
//dirty setting!! TODO:pb: find a better solution as this is error prone
this.flc.getRootForm().setDirtyMarking(false);
if (cmc != null) cmc.dispose();
cmc = new CloseableModalController(getWindowControl(), "close", areaCreateCntrllr.getInitialComponent());
cmc.addControllerListener(this);
cmc.activate();
}
}
@Override
@SuppressWarnings("unused")
protected void event(UserRequest ureq, Controller source, org.olat.core.gui.control.Event event) {
/*
* if source { if event { pattern
*/
if(source == cmc){
if(CloseableModalController.CLOSE_MODAL_EVENT == event){
//close event is the only sent out by cmc
//TODO:pb find better solution
this.flc.getRootForm().setDirtyMarking(true);
this.flc.setDirty(true);
}
}else if (source == groupChooseC) {
if (Event.DONE_EVENT == event) {
//TODO:pb find better solution
this.flc.getRootForm().setDirtyMarking(true);
this.flc.setDirty(true);
cmc.deactivate();
String selection = "";// FIXME:pb strange
selection = StringHelper.formatAsCSVString(groupChooseC.getSelectedEntries());
// apply selection to textelement
easyGroupTE.setValue(selection);
validateFormLogic(ureq);
}else if (Event.CANCELLED_EVENT == event){
closeCMCandSetWholeFormDirty(source);
return;
}else if(Event.CHANGED_EVENT == event){
//a group was created in group chooser
if(!hasGroups)
//fires an Multiuser designed bgcontext event NOT on the systembus if business group were created
fireEvent(ureq, new BGContextEvent(BGContextEvent.RESOURCE_ADDED,getDefaultBGContext()));
}
} else if (source == areaChooseC) {
if (org.olat.core.gui.control.Event.DONE_EVENT == event) {
//TODO:pb find better solution
this.flc.getRootForm().setDirtyMarking(true);
this.flc.setDirty(true);
cmc.deactivate();
String selection = "";
selection = StringHelper.formatAsCSVString(areaChooseC.getSelectedEntries());
// apply selection to textelement
easyAreaTE.setValue(selection);
validateFormLogic(ureq);
}else if (org.olat.core.gui.control.Event.CANCELLED_EVENT == event){
closeCMCandSetWholeFormDirty(source);
return;
}else if(Event.CHANGED_EVENT == event){
if(!hasAreas){
//an area was created in area chooser
//fires an Multiuser designed bgcontext event NOT on the systembus if area were created
fireEvent(ureq, new BGContextEvent(BGContextEvent.RESOURCE_ADDED,getDefaultBGContext()));
}
}
} else if (source == groupCreateCntrllr) {
if (org.olat.core.gui.control.Event.DONE_EVENT == event) {
// validate element -> e.g. remove error
if (easyGroupTE.isEmpty()) {
// was empty before -> set the created groups
easyGroupTE.setValue(StringHelper.formatAsCSVString(groupCreateCntrllr.getCreatedGroupNames()));
}
validateFormLogic(ureq);
// toggle prepared links (create -> choose)
flc.remove(createGroupsLink);
flc.add(chooseGroupsLink);
groupCreateCntrllr.dispose();
//TODO:pb find better solution
this.flc.getRootForm().setDirtyMarking(true);
this.flc.setDirty(true);
cmc.deactivate();
if(!hasGroups){
//fires an Multiuser designed bgcontext event NOT on the systembus if business group were created
fireEvent(ureq, new BGContextEvent(BGContextEvent.RESOURCE_ADDED,getDefaultBGContext()));
}
hasGroups = true;// at least one group created
}else if (org.olat.core.gui.control.Event.CANCELLED_EVENT == event){
closeCMCandSetWholeFormDirty(source);
return;
}
} else if (source == areaCreateCntrllr) {
if (org.olat.core.gui.control.Event.DONE_EVENT == event) {
// validate element -> e.g. remove error
if (easyAreaTE.isEmpty()) {
// was empty before -> set the created groups
easyAreaTE.setValue(StringHelper.formatAsCSVString(areaCreateCntrllr.getCreatedAreaNames()));
}
validateFormLogic(ureq);
// toggle prepared links (create -> choose)
flc.remove(createAreasLink);
flc.add(chooseAreasLink);
areaCreateCntrllr.dispose();
//TODO:pb find better solution
this.flc.getRootForm().setDirtyMarking(true);
this.flc.setDirty(true);
cmc.deactivate();
if (!hasAreas) {
// fires an Multiuser designed bgcontext event NOT on the systembus if
// area were created
fireEvent(ureq, new BGContextEvent(BGContextEvent.RESOURCE_ADDED,getDefaultBGContext()));
}
hasAreas = true;// at least one group created
}else if (org.olat.core.gui.control.Event.CANCELLED_EVENT == event){
closeCMCandSetWholeFormDirty(source);
return;
}
}
}
/**
* @param source
*/
private void closeCMCandSetWholeFormDirty(Controller source) {
cmc.deactivate();
//TODO:pb find better solution
this.flc.getRootForm().setDirtyMarking(true);
this.flc.setDirty(true);
source.dispose();
}
/*
* find default context if one is present
*/
private BGContext getDefaultBGContext() {
CourseGroupManager courseGrpMngr = cev.getCourseGroupManager();
List courseLGContextes = courseGrpMngr.getLearningGroupContexts();
for (Iterator iter = courseLGContextes.iterator(); iter.hasNext();) {
BGContext bctxt = (BGContext) iter.next();
if (bctxt.isDefaultContext()) { return bctxt; }
}
return null;
// not found! -> disable easy creation of groups! (no workflows for choosing
// contexts
}
public ModuleConfiguration getModuleConfiguration() {
return moduleConfig;
}
}