/** * Adds a Trigger, wrapping it in a WeakReference. * * @param trigger */ void add(final Trigger trigger) { // this is the object to add to list Object o = (trigger.isPersistent()) ? trigger : (Object) new WeakReference /*<Trigger>*/(trigger); // Add a Trigger in the correct group of phases in the list for (ListIterator /*<Object>*/ it = listIterator(); it.hasNext();) { Trigger t = convert(it.next()); if (t == null) { it.remove(); } else if (trigger.phase() < t.phase()) { // add it before it.hasPrevious(); it.add(o); return; } else if (trigger.phase() == t.phase()) { // add it after it.add(o); return; } } super.add(o); }
/** * Called when a property's value has just changed. * * <p>If one of the triggers on the property throws a {@link * org.eigenbase.util.property.Trigger.VetoRT} exception, this method passes * it on. * * @param oldValue Previous value of the property * @param value New value of the property * * @throws org.eigenbase.util.property.Trigger.VetoRT if one of the triggers * threw a VetoRT */ public void onChange(String oldValue, String value) { if (TriggerableProperties.equals(oldValue, value)) { return; } triggerList.execute(this, value); }
/** * Removes the given Trigger. * * <p/>In addition, removes any {@link WeakReference} that is empty. * * @param trigger */ void remove(final Trigger trigger) { for (Iterator it = iterator(); it.hasNext();) { Trigger t = convert(it.next()); if (t == null) { it.remove(); } else if (t.equals(trigger)) { it.remove(); } } }
/** * Removes a trigger from this property. */ public synchronized void removeTrigger(Trigger trigger) { triggerList.remove(trigger); }
/** * Adds a trigger to this property. */ public synchronized void addTrigger(Trigger trigger) { triggerList.add(trigger); }