public void addUnique(T element)
        {
            if (isNotificationRequired())
            {
                //int index = size;
                int index = size() - 1;

                //boolean oldIsSet = isSet();
                bool oldIsSet = this.notEmpty();

                //doAddUnique(object);
                this.Add(element);
                //NotificationImpl notification = createNotification(NotificationImpl.ADD, null, element, index, oldIsSet);

                NotificationImpl notification = new NotificationImpl(NotificationImpl.ADD, null, element, index, oldIsSet);

                if (hasInverse())
                {
                    NotificationChain notifications = inverseAdd(element, null);

                    /*
                     * if (hasShadow())
                     * {
                     *  notifications = shadowAdd(object, notifications);
                     * }
                     */

                    if (notifications == null)
                    {
                        dispatchNotification(notification);
                    }
                    else
                    {
                        notifications.add(notification);
                        notifications.dispatch();
                    }
                }
                else
                {
                    dispatchNotification(notification);
                }
            }
            else
            {
                //doAddUnique(object);
                this.Add(element);

                if (hasInverse())
                {
                    NotificationChain notifications = inverseAdd(element, null);
                    if (notifications != null)
                    {
                        notifications.dispatch();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public virtual void dispatch()
        {
            object notifier = getNotifier();

            if (notifier != null && getEventType() != -1)
            {
                ((Notifier)notifier).eNotify(this);
            }

            if (next != null)
            {
                next.dispatch();
            }
        }
        public T remove_(T element)
        {
            if (isNotificationRequired())
            {
                NotificationChain notifications = null;
                //bool oldIsSet = isSet();
                bool oldIsSet = this.Count != 0;

                /*
                 * if (hasShadow())
                 * {
                 *  notifications = shadowRemove(basicGet(index), null);
                 * }
                 */
                this.Remove(element);
                T oldObject = element;
                //TODO determine index if possible
                var index = 1000;
                //NotificationImpl notification = createNotification(NotificationImpl.REMOVE, oldObject, null, index, oldIsSet);
                NotificationImpl notification = new NotificationImpl(NotificationImpl.REMOVE, oldObject, null, index, oldIsSet);
                if (hasInverse() && oldObject != null)
                {
                    notifications = inverseRemove(oldObject, notifications);
                    if (notifications == null)
                    {
                        dispatchNotification(notification);
                    }
                    else
                    {
                        notifications.add(notification);
                        notifications.dispatch();
                    }
                }
                else
                {
                    if (notifications == null)
                    {
                        dispatchNotification(notification);
                    }
                    else
                    {
                        notifications.add(notification);
                        notifications.dispatch();
                    }
                }
                return(oldObject);
            }
            else
            {
                this.Remove(element);
                T oldObject = element;
                if (hasInverse() && oldObject != null)
                {
                    NotificationChain notifications = inverseRemove(oldObject, null);
                    if (notifications != null)
                    {
                        notifications.dispatch();
                    }
                }
                return(oldObject);
            }
        }