Example #1
0
        public override void ElementDeleted(ElementDeletedEventArgs e)
        {
            //Only prevent commit of the source is Normal
            if (e.ChangeSource == ChangeSource.Normal)
            {
                //Note we don't want to simply abort the transaction, as other code may be expecting the transaction
                //to still be alive

                //The first time register the CanCommitCallback
                if (commitBlocker == null)
                {
                    commitBlocker = new CommitBlocker(e.ModelElement.Store);
                }

                commitBlocker.BlockCommitIf(true);
            }
        }
Example #2
0
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            base.ElementPropertyChanged(e);

            if (e.DomainProperty.Id == Module.NameDomainPropertyId)
            {
                var module = (Module)e.ModelElement;
                module.Name = Module.FixName((string)e.NewValue);

                if (commitBlocker == null)
                {
                    commitBlocker = new CommitBlocker(e.ModelElement.Store);
                }

                commitBlocker.BlockCommitIf(string.IsNullOrWhiteSpace(module.Name) || module.CountModulesWithName(module.Name) > 1);
            }
        }