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 EditTemplate_Click(object sender, EventArgs e) { CodeGeneratorCommand command = (CodeGeneratorCommand) ((CommandBarItem) sender).Tag; if (command.Template == "") { MessageBox.Show("You must specify a template for this command first!", "Specify a template", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } CodeGenerationTemplateEditor editor = new CodeGenerationTemplateEditor(command); ObjectEditorManager.OpenObjectEditor(editor); }
private void btnEditTemplate_Click(object sender, EventArgs e) { if (_generatorCommand.Template == "") { MessageBox.Show("You must specify a template first!", "Specify a template", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } CodeGenerationTemplateEditor editor = new CodeGenerationTemplateEditor(_generatorCommand); ObjectEditorManager.OpenObjectEditor(editor); }