public EditRelationDialog(ActiveRecordDescriptor descriptor, Project project, ActiveRecordPropertyRelationDescriptor prop) : base(descriptor, project) { // This call is required by the Windows Form Designer. InitializeComponent(); AssociationEnum assoc = AssociationEnum.Undefined; if (prop is ActiveRecordHasManyDescriptor) { hasManyButton.Checked = true; assoc = AssociationEnum.HasMany; } else if (prop is ActiveRecordBelongsToDescriptor) { belongsToButton.Checked = true; assoc = AssociationEnum.BelongsTo; } else if (prop is ActiveRecordHasAndBelongsToManyDescriptor) { hasAndBelongsToManyButton.Checked = true; assoc = AssociationEnum.HasAndBelongsToMany; } SelectedTarget = prop.TargetType; SwitchViewTo(assoc); }
public RelationshipInfo(AssociationEnum association, ActiveRecordDescriptor descriptor, ActiveRecordDescriptor targetDescriptor) { if (association == AssociationEnum.Undefined) throw new ArgumentException("association"); if (descriptor == null) throw new ArgumentNullException("descriptor"); if (targetDescriptor == null) throw new ArgumentNullException("targetDescriptor"); this.association = association; this.descriptor = descriptor; this.targetDescriptor = targetDescriptor; }
protected void SwitchViewTo(AssociationEnum association) { // Nothing's changed? if (_oldDescSelection == SelectedTarget && association == _association) { // Aparently not return; } // Saves _oldDescSelection = SelectedTarget; _association = association; // Disabling associationTable.Enabled = associationTableLabel.Enabled = false; parentCols.Enabled = parentColsLabel.Enabled = false; relatedCols.Enabled = relatedColsLabel.Enabled = false; if (association == AssociationEnum.BelongsTo) { parentCols.Enabled = parentColsLabel.Enabled = true; PopulateColumnsInListBox(parentCols, _descriptor.Table); } else if (association == AssociationEnum.HasAndBelongsToMany) { associationTable.Enabled = associationTableLabel.Enabled = true; parentCols.Enabled = parentColsLabel.Enabled = true; relatedCols.Enabled = relatedColsLabel.Enabled = true; associationTable.SelectedIndex = -1; parentCols.Items.Clear(); relatedCols.Items.Clear(); PopulateTablesInComboBox(associationTable, _descriptor.Table.DatabaseDefinition); } else if (association == AssociationEnum.HasMany) { relatedCols.Enabled = relatedColsLabel.Enabled = true; PopulateColumnsInListBox(relatedCols, SelectedTarget.Table); } }
public RelationshipInfo(AssociationEnum association, ActiveRecordDescriptor descriptor, ActiveRecordDescriptor targetDescriptor) { if (association == AssociationEnum.Undefined) { throw new ArgumentException("association"); } if (descriptor == null) { throw new ArgumentNullException("descriptor"); } if (targetDescriptor == null) { throw new ArgumentNullException("targetDescriptor"); } this.association = association; this.descriptor = descriptor; this.targetDescriptor = targetDescriptor; }
protected void SwitchViewTo(AssociationEnum association) { // Nothing's changed? if (_oldDescSelection == SelectedTarget && association == _association) { // Aparently not return; } // Saves _oldDescSelection = SelectedTarget; _association = association; // Disabling associationTable.Enabled = associationTableLabel.Enabled = false; parentCols.Enabled = parentColsLabel.Enabled = false; relatedCols.Enabled = relatedColsLabel.Enabled = false; if (association == AssociationEnum.BelongsTo) { parentCols.Enabled = parentColsLabel.Enabled = true; PopulateColumnsInListBox( parentCols, _descriptor.Table); } else if (association == AssociationEnum.HasAndBelongsToMany) { associationTable.Enabled = associationTableLabel.Enabled = true; parentCols.Enabled = parentColsLabel.Enabled = true; relatedCols.Enabled = relatedColsLabel.Enabled = true; associationTable.SelectedIndex = -1; parentCols.Items.Clear(); relatedCols.Items.Clear(); PopulateTablesInComboBox(associationTable, _descriptor.Table.DatabaseDefinition); } else if (association == AssociationEnum.HasMany) { relatedCols.Enabled = relatedColsLabel.Enabled = true; PopulateColumnsInListBox( relatedCols, SelectedTarget.Table); } }