private ClassDefinitionCtrl(ClassDefinitionDecorator cls, SchemaDesignContext context, NodeUpdateHandler updater, NodeUpdateHandler idUpdater) : this() { _cls = cls; _context = context; txtName.DataBindings.Add("Text", cls, "Name"); txtDescription.DataBindings.Add("Text", cls, "Description"); txtType.Text = cls.ClassType.ToString(); BindIdentityProperties(cls, idUpdater); //cmbBaseClass.DisplayMember = "Name"; //cmbBaseClass.DataSource = _context.GetClassesExceptFor(cls.ParentName, cls.Name); //cmbBaseClass.DataBindings.Add("SelectedItem", cls, "BaseClass"); chkAbstract.DataBindings.Add("Checked", cls, "IsAbstract"); chkComputed.DataBindings.Add("Checked", cls, "IsComputed"); cls.PropertyChanged += (s, evt) => { if (evt.PropertyName == "Name") updater(); }; lstUniqueConstraints.DataSource = cls.GetUniqueConstraints(); lnkEditUniqueConstraints.Enabled = _context.CanHaveUniqueConstraints; }
private void OnClassSelected(TreeNode node) { ClassDefinition cls = (ClassDefinition)node.Tag; //C# Lambdas, making code and design compact and elegant since 2007 NodeUpdateHandler update = () => { node.Text = cls.Name; node.Name = cls.Name; }; NodeUpdateHandler idUpdater = () => { //Go through all the data property nodes and update their images //to reflect what they currently are foreach (TreeNode pn in node.Nodes) { string pName = pn.Name; if (cls.Properties.Contains(pName)) { var p = cls.Properties[pName]; if (p.PropertyType == PropertyType.PropertyType_DataProperty) { pn.ImageIndex = pn.SelectedImageIndex = IDX_DATA_PROPERTY; if (cls.IdentityProperties.Contains(pName)) { pn.ImageIndex = pn.SelectedImageIndex = IDX_KEY; } } } } }; Control c = null; if (cls.ClassType == ClassType.ClassType_Class) { _view.TAB_LOGICAL.Text = "Logical Class"; c = new ClassDefinitionCtrl(new ClassDecorator((Class)cls), _context, update, idUpdater); } else if (cls.ClassType == ClassType.ClassType_FeatureClass) { _view.TAB_LOGICAL.Text = "Logical Feature Class"; c = new ClassDefinitionCtrl(new FeatureClassDecorator((FeatureClass)cls), _context, update, idUpdater); } if (c != null) { _view.SetLogicalControl(c); _view.PhysicalMappingsVisible = this.ShowPhysicalMappings; _view.RightPaneVisible = true; } else { _view.RightPaneVisible = false; } }
public DataPropertyCtrl(DataPropertyDefinitionDecorator p, SchemaDesignContext context, NodeUpdateHandler updater) : this() { _context = context; _dp = p; txtName.DataBindings.Add("Text", p, "Name"); txtDescription.DataBindings.Add("Text", p, "Description"); cmbDataType.DataSource = _context.SupportedDataTypes; cmbDataType.DataBindings.Add("SelectedItem", p, "DataType"); chkReadOnly.DataBindings.Add("Checked", p, "ReadOnly"); numLength.DataBindings.Add("Value", p, "Length"); numPrecision.DataBindings.Add("Value", p, "Precision"); numScale.DataBindings.Add("Value", p, "Scale"); chkAutogenerated.Checked = p.IsAutoGenerated; chkAutogenerated.CheckedChanged += (s, e) => { p.IsAutoGenerated = chkAutogenerated.Checked; if (p.IsAutoGenerated) { //Not databound, so we have to modfiy UI state chkNullable.Checked = false; } }; chkNullable.Checked = p.Nullable; chkNullable.CheckedChanged += (s, e) => { p.Nullable = chkNullable.Checked; if (p.Nullable) { //Not databound, so we have to modfiy UI state chkAutogenerated.Checked = false; } }; p.PropertyChanged += (s, evt) => { if (evt.PropertyName == "Name") updater(); }; chkNullable.Enabled = !p.IsIdentity(); if (p.ValueConstraint != null) txtValueConstraint.Text = p.ValueConstraint.ToString(); btnEditConstraint.Enabled = _context.SupportsValueConstraints; }
public SchemaCtrl(FeatureSchemaDecorator schema, NodeUpdateHandler updater) : this() { txtName.DataBindings.Add("Text", schema, "Name"); txtDescription.DataBindings.Add("Text", schema, "Description"); schema.PropertyChanged += (s, evt) => { if (evt.PropertyName == "Name") updater(); }; }
public SchemaCtrl(FeatureSchemaDecorator schema, NodeUpdateHandler updater) : this() { txtName.DataBindings.Add("Text", schema, "Name"); txtDescription.DataBindings.Add("Text", schema, "Description"); schema.PropertyChanged += (s, evt) => { if (evt.PropertyName == "Name") { updater(); } }; }
private void OnSchemaSelected(TreeNode node) { FeatureSchema schema = (FeatureSchema)node.Tag; //C# Lambdas, making code and design compact and elegant since 2007 NodeUpdateHandler update = () => { node.Text = schema.Name; node.Name = schema.Name; }; var c = new SchemaCtrl(new FeatureSchemaDecorator(schema), update); _view.SetLogicalControl(c); _view.PhysicalMappingsVisible = false; _view.RightPaneVisible = true; }
public GeometricPropertyCtrl(GeometricPropertyDefinitionDecorator p, SchemaDesignContext context, NodeUpdateHandler updater) : this() { _context = context; txtName.DataBindings.Add("Text", p, "Name"); txtDescription.DataBindings.Add("Text", p, "Description"); chkElevation.DataBindings.Add("Checked", p, "HasElevation"); chkMeasure.DataBindings.Add("Checked", p, "HasMeasure"); cmbSpatialContext.DisplayMember = "Name"; var scNames = _context.GetSpatialContextNames(); cmbSpatialContext.DataSource = scNames; //Assign current association if defined if (!string.IsNullOrEmpty(p.SpatialContextAssociation)) { cmbSpatialContext.SelectedItem = p.SpatialContextAssociation; } //Setup event handler that will update the model EventHandler scChanged = (s, e) => { if (cmbSpatialContext.SelectedItem != null) p.SpatialContextAssociation = cmbSpatialContext.SelectedItem.ToString(); }; //Wire it up cmbSpatialContext.SelectedIndexChanged += scChanged; //If spatial contexts available and this property hasn't been assigned one, assign //it to the first available spatial context name if (string.IsNullOrEmpty(p.SpatialContextAssociation) && scNames.Length > 0) { cmbSpatialContext.SelectedIndex = 0; scChanged(this, EventArgs.Empty); } chkGeometryTypes.GeometryTypes = p.GeometryTypes; //Now wire up change listener chkGeometryTypes.ItemCheck += (s, e) => { p.GeometryTypes = chkGeometryTypes.GetPostCheckValue(e); }; p.PropertyChanged += (s, evt) => { if (evt.PropertyName == "Name") updater(); }; }
public AssociationPropertyCtrl(AssociationPropertyDefinitionDecorator p, SchemaDesignContext context, NodeUpdateHandler updater) : this() { _context = context; _mappings = new BindingList<KeyMapping>(); _ap = p; txtName.DataBindings.Add("Text", p, "Name"); txtDescription.DataBindings.Add("Text", p, "Description"); string schema = p.DecoratedObject.Parent.Parent.Name; cmbDeleteRule.DataSource = Enum.GetValues(typeof(DeleteRule)); cmbDeleteRule.DataBindings.Add("SelectedItem", p, "DeleteRule"); var mappings = _ap.GetMappings(); cmbAssociatedClass.DisplayMember = "Name"; cmbAssociatedClass.DataSource = _context.GetClasses(schema); cmbAssociatedClass.DataBindings.Add("SelectedItem", p, "AssociatedClass"); txtMultiplicity.DataBindings.Add("Text", p, "Multiplicity"); chkReadOnly.DataBindings.Add("Checked", p, "IsReadOnly"); chkLockCascade.DataBindings.Add("Checked", p, "LockCascade"); txtReverseName.DataBindings.Add("Text", p, "ReverseName"); txtRevMultiplicity.DataBindings.Add("Text", p, "ReverseMultiplicity"); foreach (var map in mappings) { _mappings.Add(map); } grdMappings.DataSource = _mappings; _mappings.ListChanged += new ListChangedEventHandler(OnMappingsChanged); p.PropertyChanged += (s, evt) => { if (evt.PropertyName == "Name") updater(); }; }
private void OnPropertySelected(TreeNode node) { PropertyDefinition prop = (PropertyDefinition)node.Tag; //C# Lambdas, making code and design compact and elegant since 2007 NodeUpdateHandler update = () => { node.Text = prop.Name; node.Name = prop.Name; }; Control c = null; if (prop.PropertyType == PropertyType.PropertyType_DataProperty) { _view.TAB_LOGICAL.Text = "Logical Data Property"; c = new DataPropertyCtrl(new DataPropertyDefinitionDecorator((DataPropertyDefinition)prop), _context, update); } else if (prop.PropertyType == PropertyType.PropertyType_GeometricProperty) { _view.TAB_LOGICAL.Text = "Logical Geometric Property"; c = new GeometricPropertyCtrl(new GeometricPropertyDefinitionDecorator((GeometricPropertyDefinition)prop), _context, update); } else if (prop.PropertyType == PropertyType.PropertyType_AssociationProperty) { _view.TAB_LOGICAL.Text = "Logical Association Property"; c = new AssociationPropertyCtrl(new AssociationPropertyDefinitionDecorator((AssociationPropertyDefinition)prop), _context, update); } else if (prop.PropertyType == PropertyType.PropertyType_ObjectProperty) { _view.TAB_LOGICAL.Text = "Logical Object Property"; c = new ObjectPropertyCtrl(new ObjectPropertyDefinitionDecorator((ObjectPropertyDefinition)prop), _context, update); } if (c != null) { _view.SetLogicalControl(c); _view.PhysicalMappingsVisible = this.ShowPhysicalMappings; _view.RightPaneVisible = true; } else { _view.RightPaneVisible = false; } }
private void BindIdentityProperties(ClassDefinitionDecorator cls, NodeUpdateHandler idUpdater) { //Fill the list foreach (PropertyDefinition p in cls.Properties) { if (p.PropertyType == PropertyType.PropertyType_DataProperty) { chkIdentityProperties.Items.Add(p.Name, false); } } //Now check the ones which are identity foreach (DataPropertyDefinition p in cls.IdentityProperties) { var idx = chkIdentityProperties.Items.IndexOf(p.Name); if (idx >= 0) { chkIdentityProperties.SetItemChecked(idx, true); } } //Now wire up change listener chkIdentityProperties.ItemCheck += (s, e) => { var idx = e.Index; string name = chkIdentityProperties.Items[idx].ToString(); if (e.NewValue == CheckState.Checked) { cls.MarkAsIdentity(name); idUpdater(); } else if (e.NewValue == CheckState.Unchecked) { cls.RemoveIdentityProperty(name); idUpdater(); } }; }
private void BindIdentityProperties(ClassDefinitionDecorator cls, NodeUpdateHandler idUpdater) { //Fill the list foreach (PropertyDefinition p in cls.Properties) { if (p.PropertyType == PropertyType.PropertyType_DataProperty) { chkIdentityProperties.Items.Add(p.Name, false); } } //Now check the ones which are identity foreach (DataPropertyDefinition p in cls.IdentityProperties) { var idx = chkIdentityProperties.Items.IndexOf(p.Name); if (idx >= 0) chkIdentityProperties.SetItemChecked(idx, true); } //Now wire up change listener chkIdentityProperties.ItemCheck += (s, e) => { var idx = e.Index; string name = chkIdentityProperties.Items[idx].ToString(); if (e.NewValue == CheckState.Checked) { cls.MarkAsIdentity(name); idUpdater(); } else if (e.NewValue == CheckState.Unchecked) { cls.RemoveIdentityProperty(name); idUpdater(); } }; }
public ClassDefinitionCtrl(FeatureClassDecorator cls, SchemaDesignContext context, NodeUpdateHandler updater, NodeUpdateHandler idUpdater) : this((ClassDefinitionDecorator)cls, context, updater, idUpdater) { // Fill available properties cmbGeometricProperty.DataSource = cls.AvailableGeometricProperties; // Assign designated one as selected item if (cls.GeometryProperty != null) { cmbGeometricProperty.SelectedItem = cls.GeometryProperty.Name; } // Setup event handler that will update the model EventHandler selIndexChanged = (s, e) => { if (cmbGeometricProperty.SelectedItem != null) { cls.AssignGeometricProperty(cmbGeometricProperty.SelectedItem.ToString()); } }; // Wire this up cmbGeometricProperty.SelectedIndexChanged += selIndexChanged; // Basically if no geometry property has been designated but the feature class // has geometric properties, then we want to auto-assign the first geometry // property out of the available ones if (cls.GeometryProperty == null) { if (cls.AvailableGeometricProperties.Count > 0) { cmbGeometricProperty.SelectedIndex = 0; selIndexChanged(this, EventArgs.Empty); } } }
public ClassDefinitionCtrl(ClassDecorator cls, SchemaDesignContext context, NodeUpdateHandler updater, NodeUpdateHandler idUpdater) : this((ClassDefinitionDecorator)cls, context, updater, idUpdater) { cmbGeometricProperty.Enabled = false; }
public ObjectPropertyCtrl(ObjectPropertyDefinitionDecorator p, SchemaDesignContext context, NodeUpdateHandler updater) : this() { _context = context; txtName.DataBindings.Add("Text", p, "Name"); txtDescription.DataBindings.Add("Text", p, "Description"); cmbObjectType.DataSource = Enum.GetValues(typeof(ObjectType)); cmbOrderType.DataSource = Enum.GetValues(typeof(OrderType)); cmbObjectType.DataBindings.Add("SelectedItem", p, "ObjectType"); cmbOrderType.DataBindings.Add("SelectedItem", p, "OrderType"); string schema = p.DecoratedObject.Parent.Parent.Name; cmbClass.DisplayMember = "Name"; cmbClass.DataSource = _context.GetClasses(schema); EventHandler clsIndexChanged = (sender, e) => { var cls = cmbClass.SelectedItem as ClassDefinition; if (cls != null) { p.Class = cls; cmbIdentityProperty.DisplayMember = "Name"; List<DataPropertyDefinition> dataProps = new List<DataPropertyDefinition>(); foreach (PropertyDefinition prop in cls.Properties) { if (prop.PropertyType == PropertyType.PropertyType_DataProperty) dataProps.Add((DataPropertyDefinition)prop); } cmbIdentityProperty.DataSource = dataProps; if (p.IdentityProperty != null && cls.Properties.Contains(p.IdentityProperty)) { cmbIdentityProperty.SelectedItem = p.IdentityProperty; } else { if (cmbIdentityProperty.Items.Count == 0) cmbIdentityProperty.SelectedIndex = 0; } } }; EventHandler prpIndexChanged = (sender, e) => { var prop = cmbIdentityProperty.SelectedItem as DataPropertyDefinition; if (prop != null) { p.IdentityProperty = prop; } else { p.IdentityProperty = null; } }; cmbClass.SelectedItem = p.Class; cmbClass.SelectedIndexChanged += clsIndexChanged; cmbIdentityProperty.SelectedIndexChanged += prpIndexChanged; clsIndexChanged(this, EventArgs.Empty); p.PropertyChanged += (s, evt) => { if (evt.PropertyName == "Name") updater(); }; }
private ClassDefinitionCtrl(ClassDefinitionDecorator cls, SchemaDesignContext context, NodeUpdateHandler updater, NodeUpdateHandler idUpdater) : this() { _cls = cls; _context = context; txtName.DataBindings.Add("Text", cls, "Name"); txtDescription.DataBindings.Add("Text", cls, "Description"); txtType.Text = cls.ClassType.ToString(); BindIdentityProperties(cls, idUpdater); //cmbBaseClass.DisplayMember = "Name"; //cmbBaseClass.DataSource = _context.GetClassesExceptFor(cls.ParentName, cls.Name); //cmbBaseClass.DataBindings.Add("SelectedItem", cls, "BaseClass"); chkAbstract.DataBindings.Add("Checked", cls, "IsAbstract"); chkComputed.DataBindings.Add("Checked", cls, "IsComputed"); cls.PropertyChanged += (s, evt) => { if (evt.PropertyName == "Name") { updater(); } }; lstUniqueConstraints.DataSource = cls.GetUniqueConstraints(); lnkEditUniqueConstraints.Enabled = _context.CanHaveUniqueConstraints; }
public ObjectPropertyCtrl(ObjectPropertyDefinitionDecorator p, SchemaDesignContext context, NodeUpdateHandler updater) : this() { _context = context; txtName.DataBindings.Add("Text", p, "Name"); txtDescription.DataBindings.Add("Text", p, "Description"); cmbObjectType.DataSource = Enum.GetValues(typeof(ObjectType)); cmbOrderType.DataSource = Enum.GetValues(typeof(OrderType)); cmbObjectType.DataBindings.Add("SelectedItem", p, "ObjectType"); cmbOrderType.DataBindings.Add("SelectedItem", p, "OrderType"); string schema = p.DecoratedObject.Parent.Parent.Name; cmbClass.DisplayMember = "Name"; cmbClass.DataSource = _context.GetClasses(schema); EventHandler clsIndexChanged = (sender, e) => { var cls = cmbClass.SelectedItem as ClassDefinition; if (cls != null) { p.Class = cls; cmbIdentityProperty.DisplayMember = "Name"; List <DataPropertyDefinition> dataProps = new List <DataPropertyDefinition>(); foreach (PropertyDefinition prop in cls.Properties) { if (prop.PropertyType == PropertyType.PropertyType_DataProperty) { dataProps.Add((DataPropertyDefinition)prop); } } cmbIdentityProperty.DataSource = dataProps; if (p.IdentityProperty != null && cls.Properties.Contains(p.IdentityProperty)) { cmbIdentityProperty.SelectedItem = p.IdentityProperty; } else { if (cmbIdentityProperty.Items.Count == 0) { cmbIdentityProperty.SelectedIndex = 0; } } } }; EventHandler prpIndexChanged = (sender, e) => { var prop = cmbIdentityProperty.SelectedItem as DataPropertyDefinition; if (prop != null) { p.IdentityProperty = prop; } else { p.IdentityProperty = null; } }; cmbClass.SelectedItem = p.Class; cmbClass.SelectedIndexChanged += clsIndexChanged; cmbIdentityProperty.SelectedIndexChanged += prpIndexChanged; clsIndexChanged(this, EventArgs.Empty); p.PropertyChanged += (s, evt) => { if (evt.PropertyName == "Name") { updater(); } }; }
public GeometricPropertyCtrl(GeometricPropertyDefinitionDecorator p, SchemaDesignContext context, NodeUpdateHandler updater) : this() { _context = context; txtName.DataBindings.Add("Text", p, "Name"); txtDescription.DataBindings.Add("Text", p, "Description"); chkElevation.DataBindings.Add("Checked", p, "HasElevation"); chkMeasure.DataBindings.Add("Checked", p, "HasMeasure"); cmbSpatialContext.DisplayMember = "Name"; var scNames = _context.GetSpatialContextNames(); cmbSpatialContext.DataSource = scNames; //Assign current association if defined if (!string.IsNullOrEmpty(p.SpatialContextAssociation)) { cmbSpatialContext.SelectedItem = p.SpatialContextAssociation; } //Setup event handler that will update the model EventHandler scChanged = (s, e) => { if (cmbSpatialContext.SelectedItem != null) { p.SpatialContextAssociation = cmbSpatialContext.SelectedItem.ToString(); } }; //Wire it up cmbSpatialContext.SelectedIndexChanged += scChanged; //If spatial contexts available and this property hasn't been assigned one, assign //it to the first available spatial context name if (string.IsNullOrEmpty(p.SpatialContextAssociation) && scNames.Length > 0) { cmbSpatialContext.SelectedIndex = 0; scChanged(this, EventArgs.Empty); } chkGeometryTypes.GeometryTypes = p.GeometryTypes; //Now wire up change listener chkGeometryTypes.ItemCheck += (s, e) => { p.GeometryTypes = chkGeometryTypes.GetPostCheckValue(e); }; p.PropertyChanged += (s, evt) => { if (evt.PropertyName == "Name") { updater(); } }; }
public AssociationPropertyCtrl(AssociationPropertyDefinitionDecorator p, SchemaDesignContext context, NodeUpdateHandler updater) : this() { _context = context; _mappings = new BindingList <KeyMapping>(); _ap = p; txtName.DataBindings.Add("Text", p, "Name"); txtDescription.DataBindings.Add("Text", p, "Description"); string schema = p.DecoratedObject.Parent.Parent.Name; cmbDeleteRule.DataSource = Enum.GetValues(typeof(DeleteRule)); cmbDeleteRule.DataBindings.Add("SelectedItem", p, "DeleteRule"); var mappings = _ap.GetMappings(); cmbAssociatedClass.DisplayMember = "Name"; cmbAssociatedClass.DataSource = _context.GetClasses(schema); cmbAssociatedClass.DataBindings.Add("SelectedItem", p, "AssociatedClass"); txtMultiplicity.DataBindings.Add("Text", p, "Multiplicity"); chkReadOnly.DataBindings.Add("Checked", p, "IsReadOnly"); chkLockCascade.DataBindings.Add("Checked", p, "LockCascade"); txtReverseName.DataBindings.Add("Text", p, "ReverseName"); txtRevMultiplicity.DataBindings.Add("Text", p, "ReverseMultiplicity"); foreach (var map in mappings) { _mappings.Add(map); } grdMappings.DataSource = _mappings; _mappings.ListChanged += new ListChangedEventHandler(OnMappingsChanged); p.PropertyChanged += (s, evt) => { if (evt.PropertyName == "Name") { updater(); } }; }
public DataPropertyCtrl(DataPropertyDefinitionDecorator p, SchemaDesignContext context, NodeUpdateHandler updater) : this() { _context = context; _dp = p; txtName.DataBindings.Add("Text", p, "Name"); txtDescription.DataBindings.Add("Text", p, "Description"); cmbDataType.DataSource = _context.SupportedDataTypes; cmbDataType.DataBindings.Add("SelectedItem", p, "DataType"); chkReadOnly.DataBindings.Add("Checked", p, "ReadOnly"); numLength.DataBindings.Add("Value", p, "Length"); numPrecision.DataBindings.Add("Value", p, "Precision"); numScale.DataBindings.Add("Value", p, "Scale"); chkAutogenerated.Checked = p.IsAutoGenerated; chkAutogenerated.CheckedChanged += (s, e) => { p.IsAutoGenerated = chkAutogenerated.Checked; if (p.IsAutoGenerated) { //Not databound, so we have to modfiy UI state chkNullable.Checked = false; } }; chkNullable.Checked = p.Nullable; chkNullable.CheckedChanged += (s, e) => { p.Nullable = chkNullable.Checked; if (p.Nullable) { //Not databound, so we have to modfiy UI state chkAutogenerated.Checked = false; } }; p.PropertyChanged += (s, evt) => { if (evt.PropertyName == "Name") { updater(); } }; chkNullable.Enabled = !p.IsIdentity(); if (p.ValueConstraint != null) { txtValueConstraint.Text = p.ValueConstraint.ToString(); } btnEditConstraint.Enabled = _context.SupportsValueConstraints; }