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, "true", new HashSet<FormItem>(Arrays.asList(target1, target2)), formLayout).setDependencyRuleApplayable(new DependencyRuleApplayable() {
* public void apply(FormItem triggerElement, Object triggerVal, Set<FormItem> 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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations