public NotificationChain basicRemove(T element, NotificationChain notifications)
 {
     //int index = indexOf(object);
     //if (index != -1)
     if (this.Contains(element))
     {
         if (isNotificationRequired())
         {
             //bool oldIsSet = isSet();
             bool oldIsSet = this.Count != 0;
             //Object oldObject = doRemove(index);
             var oldObject = element;
             //TODO fix me:
             var index = 1000;
             this.Remove(element);
             //NotificationImpl notification = createNotification(Notification.REMOVE, oldObject, null, index, oldIsSet);
             NotificationImpl notification = new NotificationImpl(NotificationImpl.REMOVE, oldObject, null, index, oldIsSet);
             if (notifications == null)
             {
                 notifications = notification;
             }
             else
             {
                 notifications.add(notification);
             }
         }
         else
         {
             //doRemove(index);
             this.Remove(element);
         }
     }
     return(notifications);
 }
        /*
         * public NotificationChain basicAdd(T element, NotificationChain msgs)
         * {
         *  this.Add(element);
         *
         *  if (element is InternalEObject && owner != null)
         *  {
         *      var oclelement = element as InternalEObject;
         *      oclelement.eBasicSetContainer(owner, -1, null);
         *  }
         *
         *  return msgs;
         * }
         */

        public NotificationChain basicAdd(T element, NotificationChain notifications)
        {
            if (isNotificationRequired())
            {
                int  index    = Count;
                bool oldIsSet = this.notEmpty();
                //doAddUnique(index, object);
                this.Add(element);
                NotificationImpl notification = new NotificationImpl(NotificationImpl.ADD, null, element, index, oldIsSet); //createNotification(Notification.ADD, null, object, index, oldIsSet);
                if (notifications == null)
                {
                    notifications = notification;
                }
                else
                {
                    notifications.add(notification);
                }
            }
            else
            {
                //doAddUnique(size, object);
                this.Add(element);
            }
            return(notifications);
        }
        public NotificationChain inverseRemove(T element, NotificationChain notifications)
        {
            InternalEObject internalEObject = (InternalEObject)element;

            if (hasNavigableInverse())
            {
                if (!hasInstanceClass())
                {
                    return
                        (internalEObject.eInverseRemove
                             (owner,
                             internalEObject.eClass().getFeatureID(getInverseEReference()),
                             null,
                             notifications));
                }
                else
                {
                    return
                        (internalEObject.eInverseRemove
                             (owner,
                             this.oppositeFeatureId,
                             getInverseFeatureClass(),
                             notifications));
                }
            }
            else
            {
                return
                    (internalEObject.eInverseRemove
                         (owner,
                         BasicEObjectImpl.EOPPOSITE_FEATURE_BASE - featureId,
                         null,
                         notifications));
            }
        }
        public void NotificationChain_should_Configure_until_Finish_called()
        {
            var preFinishObservingProperty            = "ObservingProperty1";
            var postFinishObservingProperty           = "ObservingProperty2";
            var preFinishConfigureActionCalled        = false;
            var postFinishConfigureActionCalled       = false;
            NotificationChain preFinishConfigureChain = null;

            Chain.Configure(cn =>
            {
                preFinishConfigureActionCalled = true;
                preFinishConfigureChain        = cn;
                cn.On(preFinishObservingProperty);
            });
            Chain.Finish();
            Chain.Configure(cn =>
            {
                postFinishConfigureActionCalled = true;
                cn.On(postFinishObservingProperty);
            });

            Assert.True(preFinishConfigureActionCalled);
            Assert.Same(Chain, preFinishConfigureChain);
            Assert.True(Chain.ObservedPropertyNames.Contains(preFinishObservingProperty));
            Assert.False(postFinishConfigureActionCalled);
            Assert.False(Chain.ObservedPropertyNames.Contains(postFinishObservingProperty));
        }
        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();
                    }
                }
            }
        }
        protected override void Establish_context()
        {
            base.Establish_context ();

            m_IsBecauseOfExceptionExpected = false;

            myManager = new NotificationChainManager ();
            myChain = new NotificationChain (myManager, DependentPropertyName);
        }
        public NotificationChain basicSetLabel(LabeledStatement newobj, NotificationChain msgs)
        {
            var oldobj = _label;

            _label = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.BREAKSTATEMENT_LABEL, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
Beispiel #8
0
        public NotificationChain basicSetBody(Statement newobj, NotificationChain msgs)
        {
            var oldobj = _body;

            _body = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.LABELEDSTATEMENT_BODY, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
Beispiel #9
0
        public NotificationChain basicSetSelection(OtherClass newobj, NotificationChain msgs)
        {
            var oldobj = _selection;

            _selection = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, SerializationPackageImpl.MY_CLASS__SELECTION, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
Beispiel #10
0
        public NotificationChain basicSetZero_one_no_no(Target newobj, NotificationChain msgs)
        {
            var oldobj = _zero_one_no_no;

            _zero_one_no_no = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, TestmodelPackageImpl.SOURCE_ZERO_ONE_NO_NO, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
        public NotificationChain basicSetBound(TypeAccess newobj, NotificationChain msgs)
        {
            var oldobj = _bound;

            _bound = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.WILDCARDTYPE_BOUND, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
        public NotificationChain basicSetMethod(AbstractMethodDeclaration newobj, NotificationChain msgs)
        {
            var oldobj = _method;

            _method = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.METHODREF_METHOD, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
Beispiel #13
0
        public NotificationChain basicSetInitializer(ArrayInitializer newobj, NotificationChain msgs)
        {
            var oldobj = _initializer;

            _initializer = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.ARRAYCREATION_INITIALIZER, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
        public NotificationChain basicSetModifier(Modifier newobj, NotificationChain msgs)
        {
            var oldobj = _modifier;

            _modifier = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.SINGLEVARIABLEDECLARATION_MODIFIER, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
        public NotificationChain basicSetType(TypeAccess newobj, NotificationChain msgs)
        {
            var oldobj = _type;

            _type = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.ABSTRACTVARIABLESCONTAINER_TYPE, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
Beispiel #16
0
        public NotificationChain basicSetDefault(Expression newobj, NotificationChain msgs)
        {
            var oldobj = _default;

            _default = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.ANNOTATIONTYPEMEMBERDECLARATION_DEFAULT, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
Beispiel #17
0
        public NotificationChain basicSetExpression(Expression newobj, NotificationChain msgs)
        {
            var oldobj = _expression;

            _expression = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.RETURNSTATEMENT_EXPRESSION, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
Beispiel #18
0
        public NotificationChain basicSetOriginalClassFile(ClassFile newobj, NotificationChain msgs)
        {
            var oldobj = _originalClassFile;

            _originalClassFile = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.ASTNODE_ORIGINALCLASSFILE, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
        public NotificationChain basicSetDeclaration(AbstractTypeDeclaration newobj, NotificationChain msgs)
        {
            var oldobj = _declaration;

            _declaration = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.TYPEDECLARATIONSTATEMENT_DECLARATION, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
        public NotificationChain basicSetEPackage(EPackage newobj, NotificationChain msgs)
        {
            var oldobj = _ePackage;

            _ePackage = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, EcorePackageImpl.EFACTORY_EPACKAGE, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
        public NotificationChain basicSetField(SingleVariableAccess newobj, NotificationChain msgs)
        {
            var oldobj = _field;

            _field = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.SUPERFIELDACCESS_FIELD, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
        public NotificationChain basicSetQualifier(TypeAccess newobj, NotificationChain msgs)
        {
            var oldobj = _qualifier;

            _qualifier = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.METHODREF_QUALIFIER, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
        public NotificationChain basicSetVariable(VariableDeclaration newobj, NotificationChain msgs)
        {
            var oldobj = _variable;

            _variable = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.SINGLEVARIABLEACCESS_VARIABLE, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
Beispiel #24
0
        public NotificationChain basicSetType(Type newobj, NotificationChain msgs)
        {
            var oldobj = _type;

            _type = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.TYPEACCESS_TYPE, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
        public NotificationChain basicSetQualifier(Expression newobj, NotificationChain msgs)
        {
            var oldobj = _qualifier;

            _qualifier = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.SINGLEVARIABLEACCESS_QUALIFIER, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
Beispiel #26
0
        public NotificationChain basicSetQualifier(ASTNode newobj, NotificationChain msgs)
        {
            var oldobj = _qualifier;

            _qualifier = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.UNRESOLVEDITEMACCESS_QUALIFIER, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
        public NotificationChain basicSetSuperClass(TypeAccess newobj, NotificationChain msgs)
        {
            var oldobj = _superClass;

            _superClass = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.CLASSDECLARATION_SUPERCLASS, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
Beispiel #28
0
        public NotificationChain basicSetReturnType(TypeAccess newobj, NotificationChain msgs)
        {
            var oldobj = _returnType;

            _returnType = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.METHODDECLARATION_RETURNTYPE, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
Beispiel #29
0
        public NotificationChain basicSetEOpposite(EReference newobj, NotificationChain msgs)
        {
            var oldobj = _eOpposite;

            _eOpposite = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, EcorePackageImpl.EREFERENCE_EOPPOSITE, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
        public NotificationChain basicSetPackage(Package newobj, NotificationChain msgs)
        {
            var oldobj = _package;

            _package = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.COMPILATIONUNIT_PACKAGE, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
Beispiel #31
0
        public NotificationChain basicSetElement(UnresolvedItem newobj, NotificationChain msgs)
        {
            var oldobj = _element;

            _element = newobj;
            if (eNotificationRequired())
            {
                var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.UNRESOLVEDITEMACCESS_ELEMENT, oldobj, newobj);
                if (msgs == null)
                {
                    msgs = notification;
                }
                else
                {
                    msgs.add(notification);
                }
            }
            return(msgs);
        }
 protected override void Because_of()
 {
     try
     {
         myChain.Configure (cn => {
                                m_PreFinishConfigureActionCalled = true;
                                m_PreFinishConfigureChain = cn;
                                cn.On (m_PreFinishObservingProperty);
                            });
         myChain.Finish();
         myChain.Configure (cn => {
                                m_PostFinishConfigureActionCalled = true;
                                cn.On (m_PostFinishObservingProperty);
                            });
     }
     catch (Exception ex)
     {
         m_BecauseOfException = ex;
     }
 }