internal static MappingViewModel CreateViewModel(EditingContext ctx, EFObject selection)
        {
            // clear out the xref so its clean for this new view model
            var xref = ModelToMappingModelXRef.GetModelToMappingModelXRef(ctx);
            xref.Clear();

            // we might be creating a view model for an entity or an association or a FunctionImport
            var entityType = selection as EntityType;
            var association = selection as Association;
            var fim = selection as FunctionImportMapping;

            // create the view model root
            MappingEFElement root = null;
            if (entityType != null)
            {
                root = ModelToMappingModelXRef.GetNewOrExisting(ctx, entityType, null);
            }
            else if (association != null)
            {
                root = ModelToMappingModelXRef.GetNewOrExisting(ctx, association, null);
            }
            else if (fim != null)
            {
                root = ModelToMappingModelXRef.GetNewOrExisting(ctx, fim, null);
            }
            else
            {
                throw new ArgumentException("selection");
            }

            return new MappingViewModel(ctx, root);
        }
        internal void RecalculateResults(EditingContext context, ModelSearchResults modelSearchResults)
        {
            // reset all old IsInSearchResults values
            foreach (var oldSearchResult in Results)
            {
                oldSearchResult.IsInSearchResults = false;
            }

            // now recalculate the results based on the new ModelSearchResults
            Reset();
            _targetString = modelSearchResults.TargetString;
            _elementTextToSearch = modelSearchResults.ElementTextToSearch;
            var modelToExplorerModelXRef = ModelToExplorerModelXRef.GetModelToBrowserModelXRef(context);
            if (null != modelToExplorerModelXRef)
            {
                // add all the ExplorerEFElements to _results
                foreach (var result in modelSearchResults.Results)
                {
                    var resultsExplorerElement = modelToExplorerModelXRef.GetExisting(result);
                    if (resultsExplorerElement != null)
                    {
                        resultsExplorerElement.IsInSearchResults = true;
                        _results.Add(resultsExplorerElement);
                    }
                }

                // now sort _results according to the order they appear in the Explorer
                SortResults();
            }
        }
 public MappingFunctionEntityType(EditingContext context, EntityType entityType, MappingEFElement parent)
     : base(context, entityType, parent)
 {
     _insertMapping = new MappingModificationFunctionMapping(context, null, this, ModificationFunctionType.Insert);
     _updateMapping = new MappingModificationFunctionMapping(context, null, this, ModificationFunctionType.Update);
     _deleteMapping = new MappingModificationFunctionMapping(context, null, this, ModificationFunctionType.Delete);
 }
예제 #4
0
        public ExplorerDiagrams(EditingContext context, Diagrams diagrams, ExplorerEFElement parent)
            : base(context, diagrams, parent)
        {
            var name = Resources.DiagramTypesGhostNodeName;
            base.Name = name;

            _typesGhostNode = new ExplorerTypes(name, context, this);
        }
 public ExplorerEntityContainerAssociationSets(string name, EditingContext context, ExplorerEFElement parent)
     : base(context, null, parent)
 {
     if (name != null)
     {
         base.Name = name;
     }
 }
예제 #6
0
 public ExplorerEnumTypes(string name, EditingContext context, ExplorerEFElement parent)
     : base(context, null, parent)
 {
     if (name != null)
     {
         base.Name = name;
     }
 }
예제 #7
0
 public ExplorerProperty(EditingContext context, Property property, ExplorerEFElement parent)
     : base(context, property, parent)
 {
     if (null != property)
     {
         _isKeyProperty = property.IsKeyProperty;
     }
 }
 public MappingAssociation(EditingContext context, Association assoc, MappingEFElement parent)
     : base(context, assoc, parent)
 {
     Debug.Assert(assoc != null, "MappingAssociation cannot accept a null Association");
     Debug.Assert(
         assoc.AssociationSet != null,
         "MappingAssociation cannot accept an Association " + assoc.ToPrettyString() + " with a null AssociationSet");
 }
 public ExplorerFunctionImports(string name, EditingContext context, ExplorerEFElement parent)
     : base(context, null, parent)
 {
     if (name != null)
     {
         base.Name = name;
     }
 }
 internal static Uri GetArtifactUri(EditingContext context)
 {
     var item = GetArtifact(context);
     if (item != null)
     {
         return item.Uri;
     }
     return null;
 }
        public static EditingContext GetEditingContext(this EFArtifact artifact)
        {
            Debug.Assert(artifact != null, "artifact != null");

            var service = new EFArtifactService(artifact);
            var editingContext = new EditingContext();
            editingContext.SetEFArtifactService(service);
            return editingContext;
        }
        public override void CreateViewModel(EditingContext ctx)
        {
            var service = ctx.GetEFArtifactService();
            Debug.Assert(service != null, "Null service in ExplorerViewModelHelper.CreateViewModel()");
            var artifact = service.Artifact;
            Debug.Assert(artifact != null, "Null artifact in ExplorerViewModelHelper.CreateViewModel()");

            var xref = ModelToExplorerModelXRef.GetModelToBrowserModelXRef(ctx);
            xref.Clear();

            var edmRootNode = new ExplorerRootNode(ctx, null, artifact.Uri);

            var designerInfo = artifact.DesignerInfo();
            if (designerInfo != null
                && designerInfo.Diagrams != null)
            {
                var explorerDiagrams = (ExplorerDiagrams)
                                       ModelToExplorerModelXRef.GetNewOrExisting(
                                           ctx, designerInfo.Diagrams, edmRootNode, typeof(ExplorerDiagrams));
                edmRootNode.Diagrams = explorerDiagrams;
            }

            if (artifact.ConceptualModel() != null)
            {
                var browserCsdlEntityModel = (ExplorerConceptualEntityModel)
                                             ModelToExplorerModelXRef.GetNewOrExisting(
                                                 ctx, artifact.ConceptualModel(), edmRootNode, typeof(ExplorerConceptualEntityModel));
                edmRootNode.ConceptualModel = browserCsdlEntityModel;
            }

            if (artifact.StorageModel() != null)
            {
                var browserSsdlEntityModel = (ExplorerStorageEntityModel)
                                             ModelToExplorerModelXRef.GetNewOrExisting(
                                                 ctx, artifact.StorageModel(), edmRootNode, typeof(ExplorerStorageEntityModel));
                edmRootNode.StorageModel = browserSsdlEntityModel;
            }

            // expand the tree view so that the Conceptual, Storage Models, and Diagram nodes are visible
            if (edmRootNode.Diagrams != null)
            {
                edmRootNode.Diagrams.Types.ExpandTreeViewToMe();
            }

            if (edmRootNode.ConceptualModel != null)
            {
                edmRootNode.ConceptualModel.Types.ExpandTreeViewToMe();
            }

            if (edmRootNode.StorageModel != null)
            {
                edmRootNode.StorageModel.Types.ExpandTreeViewToMe();
            }

            base.ViewModel = new ExplorerViewModel(ctx, edmRootNode);
        }
 internal static ModelTranslator<BaseTranslatorStrategy> GetEntityModelTranslator(EditingContext context)
 {
     var translatorContextItem = context.Items.GetValue<ModelTranslatorContextItem>();
     if (translatorContextItem.Translator == null)
     {
         translatorContextItem.Translator =
             new ModelTranslator<BaseTranslatorStrategy>(new EntityModelToDslModelTranslatorStrategy(context));
     }
     return translatorContextItem.Translator;
 }
 public ExplorerStorageEntityModel(EditingContext context, StorageEntityModel entityModel, ExplorerEFElement parent)
     : base(context, entityModel, parent)
 {
     _typesGhostNode = new ExplorerTypes(
         Resources.StorageTypesGhostNodeName, context, this);
     _funcsGhostNode = new ExplorerFunctions(
         Resources.StorageFunctionsGhostNodeName, context, this);
     _assocsGhostNode = new ExplorerAssociations(
         Resources.StorageAssociationsGhostNodeName, context, this);
 }
 public MappingModificationFunctionMapping(EditingContext context, ModificationFunction functionMapping, MappingEFElement parent)
     : base(context, functionMapping, parent)
 {
     if (functionMapping != null)
     {
         _functionType = functionMapping.FunctionType;
         _properties = new MappingFunctionScalarProperties(context, functionMapping, this);
         _resultBindings = new MappingResultBindings(context, functionMapping, this);
     }
 }
예제 #16
0
        public ExplorerTypes(string name, EditingContext context, ExplorerEFElement parent)
            : base(context, null, parent)
        {
            if (name != null)
            {
                base.Name = name;
            }

            _isConceptual = (typeof(ExplorerConceptualEntityModel) == parent.GetType()) ? true : false;
        }
 public ExplorerEntityContainer(
     EditingContext context,
     BaseEntityContainer entityContainer, ExplorerEFElement parent)
     : base(context, entityContainer, parent)
 {
     _entitySetsGhostNode = new ExplorerEntityContainerEntitySets(
         Resources.EntitySetsGhostNodeName, context, this);
     _assocSetsGhostNode = new ExplorerEntityContainerAssociationSets(
         Resources.AssociationSetsGhostNodeName, context, this);
 }
 internal static ModelToMappingModelXRef GetModelToMappingModelXRef(EditingContext context)
 {
     var xref = context.Items.GetValue<ModelToMappingModelXRef>();
     if (xref == null)
     {
         xref = new ModelToMappingModelXRef();
         context.Items.SetValue(xref);
     }
     return xref;
 }
 internal static ModelToDesignerModelXRef GetModelToDesignerModelXRef(EditingContext context)
 {
     // Update EFObject to ModelElement cross reference so that Search Results can later access it
     var xref = context.Items.GetValue<ModelToDesignerModelXRef>();
     if (xref == null)
     {
         xref = new ModelToDesignerModelXRef();
         context.Items.SetValue(xref);
     }
     return xref;
 }
예제 #20
0
        internal void SetMappingDetailsInfo(
            MappingDetailsWindow mappingWindow,
            EditingContext context,
            EdmPackage.SelectionContainer<MappingDetailsSelection> selectionContainer)
        {
            _mappingWindow = mappingWindow;
            _context = context;
            _selectionContainer = selectionContainer;

            _context.Disposing += OnContextDisposing;
            _context.Items.SetValue(this);
        }
 internal static EFArtifact GetArtifact(EditingContext context)
 {
     if (context != null)
     {
         var service = context.GetEFArtifactService();
         if (service != null)
         {
             return service.Artifact;
         }
     }
     return null;
 }
        internal PropertyExtensionContextImpl(
            EditingContext editingContext, ProjectItem projectItem, Version targetSchemaVersion, byte[] extensionToken)
        {
            Debug.Assert(editingContext != null, "editingContext should not be null");
            Debug.Assert(editingContext.GetEFArtifactService().Artifact != null, "editingContext should not have null artifact");
            Debug.Assert(projectItem != null, "projectItem should not be null");
            Debug.Assert(extensionToken != null, "extensionToken should not be null");

            _editingContext = editingContext;
            _projectItem = projectItem;
            _targetSchemaVersion = targetSchemaVersion;
            _extensionToken = extensionToken;
        }
        public EntityDesignExplorerFrame(EditingContext context)
            : base(context)
        {
            DefineCmd(WorkspaceCommands.Activate, ExecuteActivate, CanExecuteActivate);
            DefineCmd(WorkspaceCommands.PutInRenameMode, ExecutePutInRenameMode, CanExecutePutInRenameMode);
            _putSelectedExplorerItemInRenameModeRequest = new DeferredRequest(PutSelectedItemInRenameMode);
            Loaded += ExplorerFrameLoaded;

#if VS12ORNEWER
    // set bitmap scaling mode to most appropriate value based on text scaling
            RenderOptions.SetBitmapScalingMode(this, DpiHelper.BitmapScalingMode);
#endif
        }
 internal void BeginPropertyValueUpdate(EditingContext editingContext, string transactionName)
 {
     if (_cpc == null)
     {
         Debug.Assert(_counter == 0, "CommandProcessorContext is null when counter value is not 0?");
         if (_counter == 0)
         {
             _cpc = PropertyWindowViewModelHelper.CreateCommandProcessorContext(editingContext, transactionName);
             _cpc.EditingContext.ParentUndoUnitStarted = true;
             _cpc.Artifact.XmlModelProvider.BeginUndoScope(transactionName);
         }
     }
 }
        internal void Add(EFObject obj, ModelElement viewElement, EditingContext context)
        {
            var viewModel = viewElement as EntityDesignerViewModel;
            if (viewModel != null)
            {
                viewModel.EditingContext = context;
            }

            Remove(obj);
            Remove(viewElement);

            _modelToViewModel.Add(obj, viewElement);
            _viewModelToModel.Add(viewElement, obj);
        }
예제 #26
0
        public ChangeScopeImpl(
            EfiTransaction efiTransaction, EditingContext editingContext, byte[] extensionToken, IChangeScopeContainer container)
        {
            _editingContext = editingContext;
            _efiTransaction = efiTransaction;
            _container = container;

            if (extensionToken != null)
            {
                _trustedExtension = IsExtensionTrusted(extensionToken);
            }

            AddEventHandler();
        }
 /// <summary>
 ///     Note:  If createTransactionImmediately is set to true, the caller is responsible for calling CommandProcessor's FinalizeTransaction().  This is a bit wonky.  User can spin up a CommandProcessor
 ///     with this context, and then invoke that method on that command processor.
 /// </summary>
 /// <param name="editingContext"></param>
 /// <param name="originatorId"></param>
 /// <param name="transactionName"></param>
 /// <param name="artifact"></param>
 /// <param name="transactionContext"></param>
 /// <param name="createTransactionImmediately"></param>
 internal CommandProcessorContext(
     EditingContext editingContext, string originatorId, string transactionName, EFArtifact artifact,
     EfiTransactionContext transactionContext, bool createTransactionImmediately)
 {
     _editingContext = editingContext;
     _originatorId = originatorId;
     _transactionName = transactionName;
     _artifact = artifact;
     _transactionContext = transactionContext;
     if (createTransactionImmediately)
     {
         _transaction = CreateTransaction();
     }
 }
예제 #28
0
        protected ExplorerFrame(EditingContext context)
        {
            EditingContext = context;

            // search text commands
            _searchCommand = new DelegateCommand(OnSearchCommand);
            _resetSearchCommand = new DelegateCommand(OnResetSearchCommand);

            // navigate search commands
            _selectPreviousSearchResult = new DelegateCommand(OnSelectPreviousSearchResult);
            _selectNextSearchResult = new DelegateCommand(OnSelectNextSearchResult);

            _deferredExpansionAndCalculateAdorners = new DeferredRequest(OnExpanded);
            _deferredUpdateNextAndPreviousSearchResults = new DeferredRequest(OnUpdateNextAndPreviousResults);
        }
        internal override void Initialize(EFObject obj, EditingContext editingContext, bool runningInVS)
        {
            _entityTypeShape = obj as EntityTypeShape;

            Debug.Assert(_entityTypeShape != null, "EFObject is null or is not a type of EntityTypeShape.");

            if (_entityTypeShape != null)
            {
                var entityType = _entityTypeShape.EntityType.Target;
                Debug.Assert(entityType != null, "EntityTypeShape does not contain instance of an entity type.");
                if (entityType != null)
                {
                    base.Initialize(entityType, editingContext, runningInVS);
                }
            }
        }
 public ReflectedPropertyDescriptor(EditingContext editingContext, PropertyDescriptor reflectedPropDescriptor, object component)
     : base(
         editingContext, component, reflectedPropDescriptor.Name,
         PropertyWindowViewModelHelper.GetArrayFromCollection<Attribute>(reflectedPropDescriptor.Attributes))
 {
     _reflectedPropDescriptor = reflectedPropDescriptor;
     var propertyName = reflectedPropDescriptor.Name;
     _descriptionMethod = FindMethod(
         _reflectedPropDescriptor.ComponentType, "Description" + propertyName, Type.EmptyTypes, typeof(string), false);
     _isReadOnlyMethod = FindMethod(
         _reflectedPropDescriptor.ComponentType, "IsReadOnly" + propertyName, Type.EmptyTypes, typeof(bool), false);
     _isBrowsableMethod = FindMethod(
         _reflectedPropDescriptor.ComponentType, "IsBrowsable" + propertyName, Type.EmptyTypes, typeof(bool), false);
     _canResetMethod = FindMethod(
         _reflectedPropDescriptor.ComponentType, "CanReset" + propertyName, Type.EmptyTypes, typeof(bool), false);
 }
예제 #31
0
 //
 // Internal API that calls OnItemChanged.  This is invoked from the
 // abstract ContextItemCollection class so deriving classes can still
 // invoke it.
 //
 internal void InvokeOnItemChanged(EditingContext context, ContextItem previousItem)
 {
     OnItemChanged(context, previousItem);
 }
예제 #32
0
 /// <summary>
 ///     This method is called on a context item before it is stored in the context item
 ///     manager.  The previous item in the context item manager is passed.
 /// </summary>
 /// <param name="context">The editing context that is making this change.</param>
 /// <param name="previousItem">The previously active item in the context.  Because items must have default constructors a default item will be fabricated if an item is first passed into the context.</param>
 /// <returns></returns>
 protected virtual void OnItemChanged(EditingContext context, ContextItem previousItem)
 {
 }