public static IObjectEditor CreateObjectEditor(object contextObject, string command) { if (contextObject == null) { return null; } if (command == "" || command == null) { command = "Default"; } IObjectEditor editor = null; if (contextObject is OleDbDataSource) { editor = new OleDbDataSourceEditor(); } else if (contextObject is DataSource) { editor = new DataSourceEditor(); } if (contextObject.GetType() == typeof(MetadataFile)) { editor = new OREntityEditor(); } if (contextObject.GetType() == typeof(CodeGeneratorCommand)) { if (command.ToUpper() == "EDIT") { editor = new CodeGenerationTemplateEditor(); } else { editor = new CodeGeneratorCommandEditor(); } } if (contextObject is Ch3Etah.Core.ProjectLib.InputParameterCollection) { editor = new InputParameterCollectionEditor((Ch3Etah.Core.ProjectLib.InputParameterCollection) contextObject); } if (contextObject is Template) { string path = ((Template)contextObject).GetFullPath(); return new TextFileEditor(path); } if (contextObject is MacroLibrary) { string path = ((MacroLibrary)contextObject).GetFullPath(); return new TextFileEditor(path); } if (editor != null) { editor.SelectedObject = contextObject; } return editor; }
private void AddDataSource_Click(object sender, EventArgs e) { DataSource ds = new DataSource(); _project.DataSources.Add(ds); RefreshUI(); TreeNode dsNode = GetContextNode(ds, tvwProject.Nodes); dsNode.EnsureVisible(); tvwProject.SelectedNode = dsNode; IObjectEditor editor = new OleDbDataSourceEditor(ds); editor.SelectedObjectChanged += new EventHandler(IObjectEditor_SelectedObjectChanged); ObjectEditorManager.OpenObjectEditor(editor); }