public void AddCollection() { if (!this.schemaItem.Schema.DataSource.IsSampleDataSource) { return; } SampleDataSet sampleData = this.schemaItem.Schema.DataSource.SampleData; SampleCompositeType effectiveType = this.DataSchemaNode.EffectiveType; if (effectiveType == null) { return; } this.model.SelectionContext.Clear(); string uniquePropertyName = effectiveType.GetUniquePropertyName("Collection"); string uniqueTypeName = sampleData.GetUniqueTypeName(uniquePropertyName + "Item"); SampleCompositeType compositeType = sampleData.CreateCompositeType(uniqueTypeName); SampleCollectionType collectionType = sampleData.CreateCollectionType((SampleNonBasicType)compositeType); effectiveType.AddProperty(uniquePropertyName, (SampleType)collectionType); string schemaNodePath = DataSchemaItem.ProvideNodePathForPendingEdit(this, uniquePropertyName); this.model.RenameSampleDataSchemaItemUponRebuild(this.schemaItem.Schema.DataSource, schemaNodePath); this.model.ExtendSelectionUponRebuild(this.schemaItem.Schema.DataSource, schemaNodePath); this.IsExpanded = true; using (TemporaryCursor.SetWaitCursor()) sampleData.CommitChanges(this.ViewModel.DesignerContext.MessageDisplayService); }
public void MakeHierarchicalCollection() { if (!this.schemaItem.Schema.DataSource.IsSampleDataSource) { return; } SampleDataSet sampleData = this.schemaItem.Schema.DataSource.SampleData; SampleCompositeType effectiveType = this.DataSchemaNode.EffectiveType; if (effectiveType == null) { return; } this.model.SelectionContext.Clear(); SampleNonBasicType sampleNonBasicType = (SampleNonBasicType)this.DataSchemaNode.SampleType; string uniquePropertyName1 = effectiveType.GetUniquePropertyName(this.DataSchemaNode.PathName); SampleProperty hierarchicalProperty = effectiveType.AddProperty(uniquePropertyName1, (SampleType)sampleNonBasicType); SampleProperty sampleProperty = this.DataSchemaNode.EffectiveParentType.GetSampleProperty(this.DataSchemaNode.PathName); string uniquePropertyName2 = DataSchemaItem.GetUniquePropertyName(sampleProperty, hierarchicalProperty, uniquePropertyName1); string schemaNodePath = DataSchemaItem.ProvideNodePathForPendingEdit(this, uniquePropertyName2, sampleProperty, hierarchicalProperty); sampleProperty.Rename(uniquePropertyName2); hierarchicalProperty.Rename(uniquePropertyName2); this.model.RenameSampleDataSchemaItemUponRebuild(this.schemaItem.Schema.DataSource, schemaNodePath); this.model.ExtendSelectionUponRebuild(this.schemaItem.Schema.DataSource, schemaNodePath); this.IsExpanded = true; using (TemporaryCursor.SetWaitCursor()) sampleData.CommitChanges(this.ViewModel.DesignerContext.MessageDisplayService); }
private string CreateNewProperty(SampleDataSet dataSet, string newProperyName) { string uniqueTypeName = dataSet.GetUniqueTypeName(newProperyName); SampleProperty sampleProperty = dataSet.RootType.AddProperty(uniqueTypeName, (SampleType)SampleBasicType.String); DocumentCompositeNode newRootNode = (DocumentCompositeNode)dataSet.RootNode.Clone(dataSet.RootNode.Context); newRootNode.Properties[(IPropertyId)sampleProperty] = (DocumentNode)newRootNode.Context.CreateNode(StringTable.DefaultValueDataStore); dataSet.CommitChanges(newRootNode, this.ObjectSet.ViewModel.DesignerContext.MessageDisplayService); return(uniqueTypeName); }
private void ChangeEffectivePropertyIfValid(DataSchemaItem.ModifySamplePropertyOperation operation) { SampleCompositeType effectiveParentType = this.DataSchemaNode.EffectiveParentType; if (effectiveParentType == null) { return; } SampleDataSet declaringDataSet = effectiveParentType.DeclaringDataSet; SampleProperty sampleProperty = effectiveParentType.GetSampleProperty(this.DataSchemaNode.PathName); if (sampleProperty == null) { return; } operation(effectiveParentType, sampleProperty); using (TemporaryCursor.SetWaitCursor()) declaringDataSet.CommitChanges(this.ViewModel.DesignerContext.MessageDisplayService); }