Ejemplo n.º 1
0
        /// <summary>
        /// Loads the document from a given file name.
        /// </summary>
        /// <param name="fileName">Filename from which to load the document data.</param>
        /// <param name="isReload">True if the document is reloading.</param>
        public virtual void Load(string fileName, bool isReload)
        {
            Reset();

            if (isReload)
            {
                OnDocumentReloading(new EventArgs());
            }

            else
            {
                OnDocumentLoading(new EventArgs());
            }

            //currentModelFileName = fileName;

            Microsoft.VisualStudio.Modeling.Transaction transaction = this.ModelData.Store.TransactionManager.BeginTransaction("Load Model", true);
            ModelData.DoSendModelEvents = false;
            try
            {
                LoadDocument(fileName, isReload);
                transaction.Commit();
            }
            catch (Exception ex)
            {
                transaction.Rollback();

                this.SerializationResult.AddMessage(new SerializationMessage(ModelValidationMessageIds.SerializationLoadErrorId, ModelValidationViolationType.Error,
                                                                             ex.Message, fileName, 0, 0));
            }
            ModelData.DoSendModelEvents = true;

            // clear undo manager stack
            if (!this.ModelData.Store.TransactionActive)
            {
                this.ModelData.UndoManager.Flush();
            }
            this.ModelData.RaiseUndoRedoChangeEvents();

            this.IsDirty = false;

            OnPropertyChanged("CanUndo");
            OnPropertyChanged("CanRedo");

            if (isReload)
            {
                OnDocumentReloaded(new EventArgs());
            }

            else
            {
                OnDocumentLoaded(new EventArgs());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handler for incrementing the version of the selected version
        /// </summary>
        internal virtual void OnMenuIncrementEventVersion(object sender, global::System.EventArgs e)
        {
            EventDefinitionCompartmentShape evt = this.CurrentSelection.OfType <EventDefinitionCompartmentShape>().FirstOrDefault();

            if (null != evt)
            {
                Microsoft.VisualStudio.Modeling.Transaction tVersion = evt.Store.TransactionManager.BeginTransaction("Version increment");
                evt.IncrementVersionNumber();
                tVersion.Commit();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Saves the document to a given file name. This serialization is treated as temporarly and as such does
        /// not change the default saving location of the current domain model.
        /// </summary>
        /// <param name="fileName">Filename to save the document data to.</param>
        public virtual void SaveTemporarly(string fileName)
        {
            Microsoft.VisualStudio.Modeling.Transaction transaction = this.ModelData.Store.TransactionManager.BeginTransaction("Save Model Temporarly", true);
            try
            {
                SaveDocumentTemporarly(fileName);
                transaction.Commit();
            }
            catch (Exception ex)
            {
                transaction.Rollback();

                this.SerializationResult.AddMessage(new SerializationMessage(ModelValidationMessageIds.SerializationSaveErrorId, ModelValidationViolationType.Error,
                                                                             ex.Message, fileName, 0, 0));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handler for incrementing the version of the selected version
        /// </summary>
        internal virtual void OnMenuExpandCollapseAggregate(object sender, global::System.EventArgs e)
        {
            AggregateGeometryShape agg = this.CurrentSelection.OfType <AggregateGeometryShape>().FirstOrDefault();

            if (null != agg)
            {
                agg.ChildrenHidden = !agg.ChildrenHidden;

                Microsoft.VisualStudio.Modeling.Transaction tShowHide = agg.Store.TransactionManager.BeginTransaction("Show or hide children");
                // Show/hide all the child links and shapes
                foreach (BinaryLinkShape linkedChild in agg.FromRoleLinkShapes.OfType <BinaryLinkShape>())
                {
                    linkedChild.SetShowHideState(!agg.ChildrenHidden);
                    if (linkedChild.ToShape != null)
                    {
                        linkedChild.ToShape.SetShowHideState(!agg.ChildrenHidden);
                    }
                }
                tShowHide.Commit();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Loads the document from a given file name. This will not replace the currently loaded domain model neither will it send events.
        /// </summary>
        /// <param name="fileName">Filename from which to load the document data.</param>
        public virtual Microsoft.VisualStudio.Modeling.ModelElement LoadInternal(string fileName)
        {
            Microsoft.VisualStudio.Modeling.Transaction transaction = this.ModelData.Store.TransactionManager.BeginTransaction("Load Model Internal", true);

            try
            {
                Microsoft.VisualStudio.Modeling.ModelElement modelElement = LoadDocumentInternal(fileName);
                transaction.Commit();

                return(modelElement);
            }
            catch (Exception ex)
            {
                transaction.Rollback();

                this.SerializationResult.AddMessage(new SerializationMessage(ModelValidationMessageIds.SerializationLoadErrorId, ModelValidationViolationType.Error,
                                                                             ex.Message, fileName, 0, 0));

                return(null);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Saves the document to a given file name.
        /// </summary>
        /// <param name="fileName">Filename to save the document data to.</param>
        public virtual void Save(string fileName)
        {
            OnDocumentSaving(new EventArgs());

            Microsoft.VisualStudio.Modeling.Transaction transaction = this.ModelData.Store.TransactionManager.BeginTransaction("Save Model", true);
            try
            {
                SaveDocument(fileName);
                transaction.Commit();
            }
            catch (Exception ex)
            {
                transaction.Rollback();

                this.SerializationResult.AddMessage(new SerializationMessage(ModelValidationMessageIds.SerializationSaveErrorId, ModelValidationViolationType.Error,
                                                                             ex.Message, fileName, 0, 0));
            }

            this.IsDirty = false;

            OnDocumentSaved(new EventArgs());
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Reset ressources.
        /// </summary>
        public virtual void Reset()
        {
            // notify other views to execute the reset command
            EventManager.GetEvent <ResetViewModelEvent>().Publish(new ViewModelEventArgs(this));

            using (Microsoft.VisualStudio.Modeling.Transaction t = this.Store.TransactionManager.BeginTransaction("Reset data"))
            {
                this.EventManager.GetEvent <ResetDataEvent>().Publish(new EventArgs());
                t.Commit();
            }

            if (this.SelectedModelContextViewModel != null)
            {
                this.SelectedModelContextViewModel.Reset();
            }

            if (this.NavigationManager != null)
            {
                this.NavigationManager.Reset();
            }

            OnPropertyChanged("ActiveViewModel");
        }
Ejemplo n.º 8
0
 public Microsoft.VisualStudio.Modeling.CanCommitResult CanCommitCallback(Microsoft.VisualStudio.Modeling.Transaction transaction)
 {
     return(Microsoft.VisualStudio.Modeling.CanCommitResult.Commit);
 }