public IntTblWiz3(IModel model) { InitializeComponent(); this.model = (IntermediateTableWizardModel)model; #if !NDO11 this.radioArrayList.Text = "List<T>"; this.radioIList.Text = "IList<T>"; this.radioNDOArrayList.Visible = false; #endif }
protected override void SwitchToState(int newState, out ViewBase newView, out WizardState wizardState) { int oldState = this.State; IntermediateTableWizardModel model = (IntermediateTableWizardModel)this.Model; RelationDirection dir = model.IntermediateTableNode.IntermediateTable[0].RelationDirection; if (dir == RelationDirection.DirectedFromMe) { base.LastState = 2; } else { base.LastState = 3; } // State 2 is shared, state 3 is a dummy. // State 2: Index = 0 // State 3: Index = 1 if (newState == 2) // means: State == 1 { if (dir == RelationDirection.DirectedToMe) { // Skip State 2, Index 0 model.Index = 1; base.LastState = 2; } else { model.Index = 0; } } if (newState == 1 && State == 2 && model.Index == 1 && dir != RelationDirection.DirectedToMe) { newState = 2; model.Index = 0; } if (newState == 3) { // dir == RelationDirection.DirectedFromMe shouldn't occur newState = 2; model.Index = 1; base.LastState = 2; } base.SwitchToState(newState, out newView, out wizardState); }
public override DialogResult Run(IModel model) { IntermediateTableWizardModel intTWizModel = (IntermediateTableWizardModel)model; TableNode empTableNode = null; TableNode terrTableNode = null; foreach (TableNode tn in intTWizModel.TableNodes) { if (tn.Text == "Employees") { empTableNode = tn; } if (tn.Text == "Territories") { terrTableNode = tn; } } Assertion.AssertNotNull(empTableNode); Assertion.AssertNotNull(terrTableNode); IntermediateTable intTable = intTWizModel.IntermediateTableNode.IntermediateTable; intTable[0].CodingStyle = CodingStyle.IList; intTable[0].RelationDirection = RelationDirection.Bidirectional; // intTable[0].RelationDirection = RelationDirection.DirectedToMe; intTable[0].IsComposite = false; intTable[0].IsElement = false; intTable[0].RelationName = "Hi"; intTable[0].Table = empTableNode.Table.Name; intTable[0].Type = empTableNode.Table.ClassName; intTable[0].FieldName = "territories"; intTable[0].ForeignKeyColumnName = "EmployeeID"; intTable[0].ChildForeignKeyColumnName = "TerritoryID"; intTable[1].CodingStyle = CodingStyle.IList; intTable[1].RelationDirection = RelationDirection.Bidirectional; // intTable[1].RelationDirection = RelationDirection.DirectedFromMe; intTable[1].IsComposite = false; intTable[1].IsElement = false; intTable[1].RelationName = "Hi"; intTable[1].Table = terrTableNode.Table.Name; intTable[1].Type = terrTableNode.Table.ClassName; intTable[1].FieldName = "employees"; intTable[1].ForeignKeyColumnName = "TerritoryID"; intTable[1].ChildForeignKeyColumnName = "EmployeeID"; return(DialogResult.OK); }
public void MapIntermediateTable(TableNode tn) { IntermediateTable it = new IntermediateTable(tn.Text); IntermediateTableNode itn = new IntermediateTableNode(it, tn); IList tableNodes = databaseNode.TableNodes; tableNodes.Remove(tn); IntermediateTableWizardModel model = new IntermediateTableWizardModel(itn, tableNodes); IWizardController controller = ApplicationController.wizardControllerFactory.Create ("IntermediateTableWizController", "IntTblWiz", "Intermediate Table Wizard"); //controller.FrameSize = new Size(544, 416); DialogResult r = controller.Run(model); if (r == DialogResult.OK) { DatabaseNode parent = (DatabaseNode)tn.Parent; //tn.Parent.Nodes. Remove(tn); int index = parent.Nodes.IndexOf(tn); tn.Remove(); tn.Parent.Nodes.Insert(index, itn); itn.TreeView.SelectedNode = itn; itn.Nodes.Add(tn); // This ensures persisting the column nodes with file/save. RelatedTableInfo rti0 = it[0]; RelatedTableInfo rti1 = it[1]; TableNode relTn0 = null; TableNode relTn1 = null; RelationNode relNode0 = null; RelationNode relNode1 = null; foreach (TableNode loopTn in tableNodes) { if (loopTn.Text == rti0.Table) { relTn0 = loopTn; if (rti0.RelationDirection != RelationDirection.DirectedToMe) { ForeignIntermediateTableRelation fitr = new ForeignIntermediateTableRelation(rti0, tn.Text); relNode0 = new RelationNode(fitr, relTn0); relTn0.Nodes.Add(relNode0); } } if (loopTn.Text == rti1.Table) { relTn1 = loopTn; if (rti1.RelationDirection != RelationDirection.DirectedToMe) { ForeignIntermediateTableRelation fitr = new ForeignIntermediateTableRelation(rti1, tn.Text); relNode1 = new RelationNode(fitr, relTn1); relTn1.Nodes.Add(relNode1); } } } if (relNode0 != null) { relNode0.RelatedTableNode = relTn1; } if (relNode1 != null) { relNode1.RelatedTableNode = relTn0; } } }
public IntTblWiz2(IModel model) { InitializeComponent(); this.model = (IntermediateTableWizardModel)model; }