Search in sources :

Example 1 with FormItemDependencyRule

use of org.olat.core.gui.components.form.flexible.FormItemDependencyRule in project OpenOLAT by OpenOLAT.

the class FormLayoutContainer method evalDependencyRuleSetFor.

/**
 * @see org.olat.core.gui.components.form.flexible.api.FormItemContainer#evalDependencyRuleSetFor(org.olat.core.gui.UserRequest, org.olat.core.gui.components.form.flexible.api.FormItem)
 */
public void evalDependencyRuleSetFor(UserRequest ureq, FormItem dispatchFormItem) {
    String key = dispatchFormItem.getName();
    if (dependencyRules.containsKey(key)) {
        Map<String, FormItemDependencyRule> ruleSet = dependencyRules.get(key);
        Collection<FormItemDependencyRule> rules = ruleSet.values();
        for (Iterator<FormItemDependencyRule> iter = rules.iterator(); iter.hasNext(); ) {
            FormItemDependencyRule tmp = iter.next();
            if (tmp.applyRule(this)) {
                setDirty(true);
            }
        }
    }
}
Also used : FormItemDependencyRule(org.olat.core.gui.components.form.flexible.FormItemDependencyRule)

Example 2 with FormItemDependencyRule

use of org.olat.core.gui.components.form.flexible.FormItemDependencyRule in project OpenOLAT by OpenOLAT.

the class RulesFactory method createReadOnlyRule.

/**
 * @param triggerElement
 * @param triggerValue
 * @param targets
 * @return
 */
public static FormItemDependencyRule createReadOnlyRule(FormItem triggerElement, Object triggerValue, Set<FormItem> targets, FormItemContainer formLayout) {
    FormItemDependencyRule fidr = createRule(triggerElement, triggerValue, targets, FormItemDependencyRuleImpl.MAKE_READONLY);
    formLayout.addDependencyRule(fidr);
    return fidr;
}
Also used : FormItemDependencyRule(org.olat.core.gui.components.form.flexible.FormItemDependencyRule)

Example 3 with FormItemDependencyRule

use of org.olat.core.gui.components.form.flexible.FormItemDependencyRule in project OpenOLAT by OpenOLAT.

the class RulesFactory method createHideRule.

/**
 * @param triggerElement
 * @param triggerValue
 * @param targets
 * @return
 */
public static FormItemDependencyRule createHideRule(FormItem triggerElement, Object triggerValue, Set<FormItem> targets, FormItemContainer formLayout) {
    FormItemDependencyRule fidr = createRule(triggerElement, triggerValue, targets, FormItemDependencyRuleImpl.MAKE_INVISIBLE);
    formLayout.addDependencyRule(fidr);
    return fidr;
}
Also used : FormItemDependencyRule(org.olat.core.gui.components.form.flexible.FormItemDependencyRule)

Example 4 with FormItemDependencyRule

use of org.olat.core.gui.components.form.flexible.FormItemDependencyRule in project OpenOLAT by OpenOLAT.

the class RulesFactory method createCustomRule.

/**
 * Creates a custom rule which is triggered whenever
 * <code>triggerElement</code> is set to <code>triggerValue</code>. The code
 * which gets executed resides in the <code>apply</code> method of a
 * {@link DependencyRuleApplayable} object. An implementation that executes if
 * a trigger element changes to "true" could look like this:
 *
 * <pre>
 * {@code
 * RulesFactory.createCustomRule(triggerElement, &quot;true&quot;, new HashSet&lt;FormItem&gt;(Arrays.asList(target1, target2)), formLayout).setDependencyRuleApplayable(new DependencyRuleApplayable() {
 *   public void apply(FormItem triggerElement, Object triggerVal, Set&lt;FormItem&gt; targets) {
 *     for (FormItem target : targets) {
 *       target.setEnabled(true);
 *     }
 *   }
 * });
 * }
 * </pre>
 *
 * (Note that this example uses an anonymous class which makes it unnecessary
 * for you to create a separate class which implements
 * <code>DependencyRuleApplayable</code> for each of your rules.) Don't forget
 * to add action listeners for
 * {@link org.olat.core.gui.components.form.flexible.impl.FormEvent.ONCHANGE}
 * to your trigger elements.
 *
 * @param triggerElement The element that is being watched for changes.
 * @param triggerValue Triggers if the <code>triggerElement</code>'s key
 *          changes to <code>triggerValue</code>
 * @param targets The targets.
 * @param formLayout The container.
 * @return The rule
 * @see		DependencyRuleApplayable
 */
public static FormItemDependencyRule createCustomRule(FormItem triggerElement, Object triggerValue, Set<FormItem> targets, FormItemContainer formLayout) {
    FormItemDependencyRule fidr = createRule(triggerElement, triggerValue, targets, FormItemDependencyRuleImpl.CUSTOM);
    formLayout.addDependencyRule(fidr);
    return fidr;
}
Also used : FormItemDependencyRule(org.olat.core.gui.components.form.flexible.FormItemDependencyRule)

Example 5 with FormItemDependencyRule

use of org.olat.core.gui.components.form.flexible.FormItemDependencyRule in project openolat by klemens.

the class FormLayoutContainer method evalDependencyRuleSetFor.

/**
 * @see org.olat.core.gui.components.form.flexible.api.FormItemContainer#evalDependencyRuleSetFor(org.olat.core.gui.UserRequest, org.olat.core.gui.components.form.flexible.api.FormItem)
 */
public void evalDependencyRuleSetFor(UserRequest ureq, FormItem dispatchFormItem) {
    String key = dispatchFormItem.getName();
    if (dependencyRules.containsKey(key)) {
        Map<String, FormItemDependencyRule> ruleSet = dependencyRules.get(key);
        Collection<FormItemDependencyRule> rules = ruleSet.values();
        for (Iterator<FormItemDependencyRule> iter = rules.iterator(); iter.hasNext(); ) {
            FormItemDependencyRule tmp = iter.next();
            if (tmp.applyRule(this)) {
                setDirty(true);
            }
        }
    }
}
Also used : FormItemDependencyRule(org.olat.core.gui.components.form.flexible.FormItemDependencyRule)

Aggregations

FormItemDependencyRule (org.olat.core.gui.components.form.flexible.FormItemDependencyRule)18 HashSet (java.util.HashSet)4 FormItem (org.olat.core.gui.components.form.flexible.FormItem)4 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 DependencyRuleApplayable (org.olat.core.gui.components.form.flexible.DependencyRuleApplayable)2 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 FormItemDependencyRuleImpl (org.olat.core.gui.components.form.flexible.impl.rules.FormItemDependencyRuleImpl)2