}
};
// show elements dependent on other values set.
FormItemDependencyRule hideClearDateSwitchDeps = RulesFactory.createCustomRule(dateSwitch, null, dependenciesDateSwitch, formLayout);
hideClearDateSwitchDeps.setDependencyRuleApplayable(new DependencyRuleApplayable() {
@SuppressWarnings("unused")
public void apply(FormItem triggerElement, Object triggerVal, Set<FormItem> targets) {
toDate.setDate(null);
toDate.setVisible(false);
fromDate.setDate(null);
fromDate.setVisible(false);
toDate.clearError();
fromDate.clearError();
dateSwitch.clearError();
dateSubContainer.setVisible(false);
fromDate.setFocus(false);
/*
* special rules for apply rules for coach and for assessment dependent
*/
//assessment switch only enabled if nodes to be selected
boolean coachExclIsOn = coachExclusive.getSelectedKeys().size() == 1;
assessmentSwitch.setEnabled(!coachExclIsOn && (nodeIdentList.size() > 0 || isSelectedNodeDeleted()));
boolean atLeastOneOn = dateSwitch.getSelectedKeys().size() == 1 || groupSwitch.getSelectedKeys().size() == 1 || assessmentSwitch.getSelectedKeys().size() == 1|| (attributeSwitch != null && attributeSwitch.getSelectedKeys().size()==1);
if(!applyRulesForCoach.isEnabled() && atLeastOneOn){
//not enabled AND at least another dependent on
applyRulesForCoach.setEnabled(true);
}else if(!atLeastOneOn){
//enabled (or not) AND not at least another dependent on
applyRulesForCoach.setEnabled(false);
applyRulesForCoach.select("ison", true);
}
}
});
RulesFactory.createShowRule(dateSwitch, "ison", dependenciesDateSwitch, formLayout);
FormItemDependencyRule toggleApplyRule = RulesFactory.createCustomRule(dateSwitch, "ison", dependenciesDateSwitch, formLayout);
toggleApplyRule.setDependencyRuleApplayable(new DependencyRuleApplayable() {
public void apply(FormItem triggerElement, Object triggerVal, Set<FormItem> targets) {
fromDate.setFocus(true);
//assessment switch only enabled if nodes to be selected
assessmentSwitch.setEnabled((nodeIdentList.size() > 0 || isSelectedNodeDeleted()));
if(!applyRulesForCoach.isEnabled()){
applyRulesForCoach.setEnabled(true);
}
}
});
if (ShibbolethModule.isEnableShibbolethLogins()) {
FormItemDependencyRule hideClearAttibuteSwitchDeps = RulesFactory.createCustomRule(attributeSwitch, null, dependenciesAttributeSwitch, formLayout);
hideClearAttibuteSwitchDeps.setDependencyRuleApplayable(new DependencyRuleApplayable() {
@SuppressWarnings("unused")
public void apply(FormItem triggerElement, Object triggerVal, Set<FormItem> targets) {
attributeSwitch.clearError();
attributeBconnector.select(BCON_VAL_AND, true);
attributeBconnector.setVisible(false);
if(attribteRowAdderSubform!=null){
attribteRowAdderSubform.cleanup();
}
boolean atLeastOneOn = dateSwitch.getSelectedKeys().size() == 1 || groupSwitch.getSelectedKeys().size() == 1 || assessmentSwitch.getSelectedKeys().size() == 1||attributeSwitch.getSelectedKeys().size()==1;
if(!applyRulesForCoach.isEnabled() && atLeastOneOn){
//not enabled AND at least another dependent on
applyRulesForCoach.setEnabled(true);
}else if(!atLeastOneOn){
//enabled (or not) AND not at least another dependent on
applyRulesForCoach.setEnabled(false);
applyRulesForCoach.select("ison", true);
}
}
});
RulesFactory.createShowRule(attributeSwitch, "ison", dependenciesAttributeSwitch, formLayout);
FormItemDependencyRule attributeSwitchtoggleApplyRule = RulesFactory.createCustomRule(attributeSwitch, "ison", dependenciesAttributeSwitch, formLayout);
attributeSwitchtoggleApplyRule.setDependencyRuleApplayable(new DependencyRuleApplayable() {
public void apply(FormItem triggerElement, Object triggerVal, Set<FormItem> targets) {
attributeBconnector.setVisible(true);
if(attribteRowAdderSubform!=null){
attribteRowAdderSubform.init();
}
if(!applyRulesForCoach.isEnabled()){
applyRulesForCoach.setEnabled(true);
}
}
});
}
//
// enable textfields and subworkflow-start-links if groups is yes
// disable it otherwise
final Set<FormItem> dependenciesGroupSwitch = new HashSet<FormItem>() {
{
add(groupSubContainer);
add(easyAreaTE);
add(chooseAreasLink);
add(createAreasLink);
add(easyGroupTE);
add(chooseGroupsLink);
add(createGroupsLink);
}
};
FormItemDependencyRule hideClearGroupSwitchDeps = RulesFactory.createCustomRule(groupSwitch, null, dependenciesGroupSwitch, formLayout);
hideClearGroupSwitchDeps.setDependencyRuleApplayable(new DependencyRuleApplayable() {
@SuppressWarnings("unused")
public void apply(FormItem triggerElement, Object triggerVal, Set<FormItem> targets) {
easyAreaTE.setValue("");
easyGroupTE.setValue("");
easyAreaTE.setVisible(false);
easyGroupTE.setVisible(false);
chooseAreasLink.setVisible(false);
createAreasLink.setVisible(false);
chooseGroupsLink.setVisible(false);
createGroupsLink.setVisible(false);
easyAreaTE.clearError();
easyGroupTE.clearError();
groupSwitch.clearError();
groupSubContainer.setVisible(false);
if (ShibbolethModule.isEnableShibbolethLogins()) {
attributeSwitch.clearError();
}
easyGroupTE.setFocus(false);
//assessment switch only enabled if nodes to be selected
boolean coachExclIsOn = coachExclusive.getSelectedKeys().size() == 1;
assessmentSwitch.setEnabled(!coachExclIsOn && (nodeIdentList.size() > 0 || isSelectedNodeDeleted()));
boolean atLeastOneOn = dateSwitch.getSelectedKeys().size() == 1 || groupSwitch.getSelectedKeys().size() == 1 || assessmentSwitch.getSelectedKeys().size() == 1||(attributeSwitch != null && attributeSwitch.getSelectedKeys().size()==1);
if(!applyRulesForCoach.isEnabled() && atLeastOneOn){
applyRulesForCoach.setEnabled(true);
}else if(!atLeastOneOn){
//enabled (or not) AND not at least another dependent on
applyRulesForCoach.setEnabled(false);
applyRulesForCoach.select("ison", true);
}
}
});
RulesFactory.createShowRule(groupSwitch, "ison", dependenciesGroupSwitch, formLayout);
toggleApplyRule = RulesFactory.createCustomRule(groupSwitch, "ison", dependenciesGroupSwitch, formLayout);
toggleApplyRule.setDependencyRuleApplayable(new DependencyRuleApplayable() {
public void apply(FormItem triggerElement, Object triggerVal, Set<FormItem> targets) {
easyGroupTE.setFocus(true);
//assessment switch only enabled if nodes to be selected
assessmentSwitch.setEnabled((nodeIdentList.size() > 0 || isSelectedNodeDeleted()));
if(!applyRulesForCoach.isEnabled()){
applyRulesForCoach.setEnabled(true);
}
}
});
//
// dependencies of assessment switch
final Set<FormItem> assessDeps = new HashSet<FormItem>() {
{
add(assessmentTypeSwitch);
add(nodePassed);
add(cutValue);
add(assessSubContainer);
}
};
// show elements dependent on other values set.
FormItemDependencyRule showAssessmentSwitchDeps = RulesFactory.createCustomRule(assessmentSwitch, "ison", assessDeps, formLayout);
showAssessmentSwitchDeps.setDependencyRuleApplayable(new DependencyRuleApplayable() {
public void apply(FormItem triggerElement, Object triggerVal, Set<FormItem> targets) {
boolean cutValueVisibility = assessmentTypeSwitch.getSelectedKey().equals(NODEPASSED_VAL_SCORE);
assessSubContainer.setVisible(true);
assessmentTypeSwitch.setVisible(true);
nodePassed.setVisible(true);
cutValue.setVisible(cutValueVisibility);
assessmentSwitch.clearError();
cutValue.clearError();
nodePassed.clearError();
if(!applyRulesForCoach.isEnabled()){
applyRulesForCoach.setEnabled(true);
}
}
});
// hide elements and reset values.
FormItemDependencyRule hideResetAssessmentSwitchDeps = RulesFactory.createCustomRule(assessmentSwitch, null, assessDeps, formLayout);
hideResetAssessmentSwitchDeps.setDependencyRuleApplayable(new DependencyRuleApplayable() {
public void apply(FormItem triggerElement, Object triggerVal, Set<FormItem> targets) {
assessSubContainer.setVisible(false);
assessmentTypeSwitch.select(NODEPASSED_VAL_PASSED, true);
assessmentTypeSwitch.setVisible(false);
nodePassed.select(NO_NODE_SELECTED_IDENTIFYER, true);
nodePassed.setVisible(false);
cutValue.setIntValue(0);
cutValue.setVisible(false);
boolean atLeastOneOn = dateSwitch.getSelectedKeys().size() == 1 || groupSwitch.getSelectedKeys().size() == 1 || assessmentSwitch.getSelectedKeys().size() == 1||(attributeSwitch != null && attributeSwitch.getSelectedKeys().size()==1);
if(!applyRulesForCoach.isEnabled() && atLeastOneOn){
applyRulesForCoach.setEnabled(true);
}else if(!atLeastOneOn){
//enabled (or not) AND not at least another dependent on
applyRulesForCoach.setEnabled(false);
applyRulesForCoach.select("ison", true);
}
}
});
final Set<FormItem> assessTypeDeps = new HashSet<FormItem>() {
{
add(cutValue);
}
};
RulesFactory.createHideRule(assessmentTypeSwitch, NODEPASSED_VAL_PASSED, assessTypeDeps, assessSubContainer);
RulesFactory.createShowRule(assessmentTypeSwitch, NODEPASSED_VAL_SCORE, assessTypeDeps, assessSubContainer);
//
//
final Set<FormItem> dependenciesCoachExclusiveReadonly = new HashSet<FormItem>() {
{
addAll(dependenciesDateSwitch);
addAll(dependenciesGroupSwitch);
addAll(assessDeps);
addAll(dependenciesAttributeSwitch);
}
};
// coach exclusive switch rules
// -> custom rule implementation because it is not a simple hide / show rule
// while disabling reset the elements
FormItemDependencyRule disableAndResetOthers = RulesFactory.createCustomRule(coachExclusive, "ison",
dependenciesCoachExclusiveReadonly, formLayout);
disableAndResetOthers.setDependencyRuleApplayable(new DependencyRuleApplayable() {
public void apply(FormItem triggerElement, Object triggerVal, Set<FormItem> targets) {
// disable and remove checkbox selection
// uncheck and disable checkboxes
dateSwitch.select("ison", false);
groupSwitch.select("ison", false);
assessmentSwitch.select("ison", false);
dateSwitch.setEnabled(false);
toDate.setDate(null);
fromDate.setDate(null);
groupSwitch.setEnabled(false);
easyAreaTE.setValue("");
easyGroupTE.setValue("");
assessmentSwitch.setEnabled(false);
// disable the shibboleth attributes switch and reset the row subform
if (attributeSwitch != null) {
attributeSwitch.select("ison", false);
attributeSwitch.setEnabled(false);
attribteRowAdderSubform.cleanup();
attributeSwitch.clearError();
}
//opposite meaning! see creation of applyRulesForCoach
applyRulesForCoach.select("ison", true);
applyRulesForCoach.setEnabled(false);
// hide (e.g. remove) general erros
dateSwitch.clearError();
groupSwitch.clearError();
assessmentSwitch.clearError();
// all dependent elements become invisible
for (Iterator<FormItem> iter = dependenciesCoachExclusiveReadonly.iterator(); iter.hasNext();) {
FormItem element = iter.next();
element.setVisible(false);
}
}
});
// two rules to bring them back visible and also checkable
// dependencies of assessment switch
final Set<FormItem> switchesOnly = new HashSet<FormItem>() {
{
add(dateSwitch);
add(groupSwitch);
add(assessmentSwitch);
add(applyRulesForCoach);
if (ShibbolethModule.isEnableShibbolethLogins()) {
add(attributeSwitch);
}
}
};
FormItemDependencyRule enableOthers = RulesFactory.createCustomRule(coachExclusive, null, switchesOnly, formLayout);
enableOthers.setDependencyRuleApplayable(new DependencyRuleApplayable() {
private boolean firedDuringInit = true;
public void apply(FormItem triggerElement, Object triggerVal, Set<FormItem> targets) {
dateSwitch.setEnabled(true);
groupSwitch.setEnabled(true);
//assessment switch only enabled if nodes to be selected