Search in sources :

Example 6 with FormItemDependencyRule

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

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 7 with FormItemDependencyRule

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

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 8 with FormItemDependencyRule

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

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 9 with FormItemDependencyRule

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

the class RulesFactory method createWritableRule.

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

Example 10 with FormItemDependencyRule

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

the class RulesFactory method createShowRule.

/**
 * @param triggerElement
 * @param triggerValue
 * @param targets
 * @return
 */
public static FormItemDependencyRule createShowRule(FormItem triggerElement, Object triggerValue, Set<FormItem> targets, FormItemContainer formLayout) {
    FormItemDependencyRule fidr = createRule(triggerElement, triggerValue, targets, FormItemDependencyRuleImpl.MAKE_VISIBLE);
    formLayout.addDependencyRule(fidr);
    return fidr;
}
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