/// <summary>
        ///     this is called by the handler in ExplorerFrame so that we can catch
        ///     exceptions and reload the UI if needed - don't call this from anywhere else
        /// </summary>
        internal void ProcessModelChangesCommitted(EditingContext ctx, EfiChangedEventArgs e)
        {
            if (ctx == null)
            {
                // some other view has caused the context and/or artifact to close & reload
                // and we are still in the middle of firing the ModelChangesCommitted event
                // so just exit
                return;
            }

            var xref = ModelToExplorerModelXRef.GetModelToBrowserModelXRef(ctx);
            var artifacts = GetCurrentArtifactsInView(ctx);

            foreach (var change in e.ChangeGroup.Changes)
            {
                // only process changes for the artifact this view model is associated with
                if (artifacts.Contains(change.Changed.Artifact) == false)
                {
                    continue;
                }

                switch (change.Type)
                {
                        // Create and Delete have the same action at the moment
                    case EfiChange.EfiChangeType.Create:
                    case EfiChange.EfiChangeType.Delete:
                        if (!ProcessCreateOrDeleteChange(ctx, xref, change))
                        {
                            // don't process any more
                            return;
                        }
                        break;

                    case EfiChange.EfiChangeType.Update:
                        var updatedElement = change.Changed as EFElement;
                        if (updatedElement != null)
                        {
                            var explorerItem = xref.GetExisting(updatedElement);
                            if (explorerItem != null)
                            {
                                foreach (var propName in change.Properties.Keys)
                                {
                                    explorerItem.OnModelPropertyChanged(propName);
                                }
                            }
                        }
                        else
                        {
                            var defaultableValue = change.Changed as DefaultableValue;
                            if (defaultableValue != null)
                            {
                                updatedElement = defaultableValue.Parent as EFElement;
                                if (updatedElement != null)
                                {
                                    var explorerItem = xref.GetExisting(updatedElement);
                                    if (explorerItem != null)
                                    {
                                        explorerItem.OnModelPropertyChanged(defaultableValue.PropertyName);
                                    }
                                }
                            }
                        }
                        break;
                }
            }
        }
        /// <summary>
        ///     this is called by the *real* handler in ExplorerWindow so that we can catch
        ///     exceptions and reload the UI if needed - don't call this from anywhere else
        /// </summary>
        internal void OnModelChangesCommitted(object sender, EfiChangedEventArgs e)
        {
            Debug.Assert(_viewModelHelper != null, "Null _viewModelHelper in ExplorerFrame.OnModelChangesCommitted()");
            Debug.Assert(_context != null, "ExplorerFrame was disposed");
            _viewModelHelper.ProcessModelChangesCommitted(_context, e);

            // search results may have had elements removed/renamed
            // this updates adorners and Next & Previous in background    
            _modelChangesCommittingInProgress = true;
            WaitForExpansionThenProcessTreeView();
        }
Example #3
0
 internal void RouteChangeGroups()
 {
     try
     {
         while (_changeGroups.Count > 0)
         {
             var changeGroup = _changeGroups.Dequeue();
             var args = new EfiChangedEventArgs(changeGroup);
             if (ModelChangesCommitted != null)
             {
                 // now tell everyone that things have changed
                 ModelChangesCommitted(this, args);
             }
         }
     }
     finally
     {
         ClearChangeGroups();
     }
 }
        // <summary>
        //     Event handler when we change any properties of the model. For now we'll handle just the renaming
        //     the entity container name.
        // </summary>
        private void OnModelChangesCommitted(object sender, EfiChangedEventArgs e)
        {
            var changeEnum = e.ChangeGroup.Changes.GetEnumerator();
            while (changeEnum.MoveNext())
            {
                // update operation?
                if (changeEnum.Current.Type == EfiChange.EfiChangeType.Update)
                {
                    // are we updating the entity container name?
                    var entityContainer = changeEnum.Current.Changed as SingleItemBinding<ConceptualEntityContainer>;
                    if (entityContainer != null)
                    {
                        // get the values from the EfiChange properties, use those to construct the arguments
                        var pair = changeEnum.Current.Properties[EntityContainerMapping.AttributeCdmEntityContainer];
                        var args = new ModelChangeEventArgs();
                        args.OldEntityContainerName = (string)pair.OldValue;

                        AfterEntityContainerNameChange(this, args);

                        // ignore any further action
                        continue;
                    }
                }

                // are we updating the metadata artifact processing value?
                var metadataArtifactProcessingValue = changeEnum.Current.Changed as DefaultableValue<string>;
                if (metadataArtifactProcessingValue != null)
                {
                    var mapProp = metadataArtifactProcessingValue.Parent as DesignerProperty;

                    if (mapProp != null
                        && mapProp.LocalName != null
                        && String.Compare(
                            mapProp.LocalName.Value, ConnectionDesignerInfo.AttributeMetadataArtifactProcessing,
                            StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        var pair = changeEnum.Current.Properties[DesignerProperty.AttributeValue];
                        var args = new ModelChangeEventArgs();
                        args.OldMetadataArtifactProcessing = (string)pair.OldValue;
                        AfterMetadataArtifactProcessingChange(this, args);
                        continue;
                    }
                }
            }
        }
 private void OnModelChangesCommitted(object sender, EfiChangedEventArgs e)
 {
     if (_currentExplorerInfo != null
         &&
         _currentExplorerInfo._explorerFrame != null)
     {
         try
         {
             _currentExplorerInfo._explorerFrame.OnModelChangesCommitted(sender, e);
         }
         catch (Exception ex)
         {
             Debug.Fail("Exception caught while processing changes to the explorer", ex.Message);
             ClearAndReload();
         }
     }
 }
 // <summary>
 //     This is our handler to watch for model changes
 // </summary>
 private void OnModelChangesCommitted(object sender, EfiChangedEventArgs e)
 {
     if (e.ChangeGroup.Transaction.OriginatorId != EfiTransactionOriginator.MappingDetailsOriginatorId)
     {
         if (Context != null)
         {
             var selection = Context.Items.GetValue<MappingDetailsSelection>();
             RefreshCurrentSelection();
             if (e.ChangeGroup.Transaction.OriginatorId == EfiTransactionOriginator.PropertyWindowOriginatorId
                 &&
                 selection != null)
             {
                 // if the change originated from Property Window we need to restore previuos selection
                 // otherwise the Property Window will become empty
                 Context.Items.SetValue(selection);
             }
         }
         else
         {
             InitializeView();
         }
     }
 }
        private void OnModelChangesCommitted(object sender, EfiChangedEventArgs e)
        {
            if (e.ChangeGroup.Transaction != null
                && e.ChangeGroup.Transaction.OriginatorId == EfiTransactionOriginator.MappingDetailsOriginatorId)
            {
                // if its an edit from the mapping designer, there is nothing to process
                return;
            }

            if (RespondToModelChanges == false)
            {
                return;
            }

            ProcessModelChanges(e.ChangeGroup);

            if (e.ChangeGroup.Transaction != null
                && e.ChangeGroup.Transaction.OriginatorId == EfiTransactionOriginator.XmlEditorOriginatorId)
            {
                // if this transaction came from the Xml Editor, then the user is typing and
                // we are going to be creating and deleting lots of items, so just try and 
                // layout the shapes
                try
                {
                    _reloading = true;
                    MicrosoftDataEntityDesignSerializationHelper.ReloadDiagram(this);
                }
                catch (Exception)
                {
                    // no-op, at some point, they might have changed the file so much that we can't
                    // lay things out anymore
                }
                finally
                {
                    _reloading = false;
                }
            }
        }