Browse Source

update to integrate dbserver specific plugins with AddInTree

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1911 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Dickon Field 20 years ago
parent
commit
6ed3682b82
  1. 1
      src/AddIns/Misc/SharpServerTools/OracleDbToolsProvider/OracleDbToolsProvider.csproj
  2. 18
      src/AddIns/Misc/SharpServerTools/OracleDbToolsProvider/Src/Forms/OracleFormsArtefactFactory.cs
  3. 6
      src/AddIns/Misc/SharpServerTools/ServerBrowserTool/SharpServerTools.addin
  4. 1
      src/AddIns/Misc/SharpServerTools/SharpDbTools/SharpDbTools.csproj
  5. 5
      src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Data/ColumnNames.cs
  6. 52
      src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/FormsArtefactFactories.cs
  7. 2
      src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/FormsArtefactFactory.cs
  8. 9
      src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/TableDescribeViewContent.cs
  9. 15
      src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/TableTreeNode.cs

1
src/AddIns/Misc/SharpServerTools/OracleDbToolsProvider/OracleDbToolsProvider.csproj

@ -41,7 +41,6 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Src\Forms\TableTreeNode.cs" />
<Compile Include="Src\Forms\OracleFormsArtefactFactory.cs" /> <Compile Include="Src\Forms\OracleFormsArtefactFactory.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

18
src/AddIns/Misc/SharpServerTools/OracleDbToolsProvider/Src/Forms/OracleFormsArtefactFactory.cs

@ -36,7 +36,6 @@ namespace SharpDbTools.Oracle.Forms
// create root node of the metadata collections tree // create root node of the metadata collections tree
TreeNode metaNode = new TreeNode("Db Objects"); TreeNode metaNode = new TreeNode("Db Objects");
metaNode.Name = logicalConnectionName + ":MetaData";
// retrieve the metadata for this logical connection name // retrieve the metadata for this logical connection name
@ -85,6 +84,23 @@ namespace SharpDbTools.Oracle.Forms
} }
return metaNode; return metaNode;
} }
public override string[] GetDescribeTableFieldNames()
{
return tableFieldsToDisplay;
}
public override string[] GetDescribeTableColumnHeaderNames()
{
return tableFieldsColumnHeaders;
}
private static string[] tableFieldsToDisplay =
new string [] {"COLUMN_NAME", "DATATYPE",
"LENGTH", "PRECISION", "SCALE", "NULLABLE"};
private static string[] tableFieldsColumnHeaders =
new string[] { "Column", "Type", "Length", "Precision", "Scale", "Nullable" };
} }
} }

6
src/AddIns/Misc/SharpServerTools/ServerBrowserTool/SharpServerTools.addin

@ -21,4 +21,10 @@
shortcut = "Control|Alt|D" shortcut = "Control|Alt|D"
class = "SharpServerTools.Forms.ServerBrowserTool"/> class = "SharpServerTools.Forms.ServerBrowserTool"/>
</Path> </Path>
<Path name = "/SharpServerTools/SharpDbTools/FormsArtefactFactory">
<Class id = "System.Data.OracleClient"
class = "SharpDbTools.Oracle.Forms.OracleFormsArtefactFactory"/>
</Path>
</AddIn> </AddIn>

1
src/AddIns/Misc/SharpServerTools/SharpDbTools/SharpDbTools.csproj

@ -53,6 +53,7 @@
<Compile Include="Src\Data\DbModelInfo.cs" /> <Compile Include="Src\Data\DbModelInfo.cs" />
<Compile Include="Src\Data\DbModelInfoService.cs" /> <Compile Include="Src\Data\DbModelInfoService.cs" />
<Compile Include="Src\Data\DbProvidersService.cs" /> <Compile Include="Src\Data\DbProvidersService.cs" />
<Compile Include="Src\Forms\TableTreeNode.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Src" /> <Folder Include="Src" />

5
src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Data/ColumnNames.cs

@ -25,10 +25,5 @@ namespace SharpDbTools.Data
public const string Name = "name"; public const string Name = "name";
public const string ConnectionString = "connectionString"; public const string ConnectionString = "connectionString";
public const string TableName = "TABLE_NAME"; public const string TableName = "TABLE_NAME";
public static string[] TableTableFieldsToDisplay =
new string [] {"COLUMN_NAME", "DATATYPE",
"LENGTH", "PRECISION", "SCALE", "NULLABLE"};
public static string[] TableTableFieldsColumnHeaders =
new string[] { "Column", "Type", "Length", "Precision", "Scale", "Nullable" };
} }
} }

52
src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/FormsArtefactFactories.cs

@ -6,18 +6,35 @@
*/ */
using System; using System;
using System.Collections;
using ICSharpCode.Core; using ICSharpCode.Core;
using System.Collections.Generic;
namespace SharpDbTools.Forms namespace SharpDbTools.Forms
{ {
/// <summary> /// <summary>
/// Description of FormsArtefactFactories. /// Description of FormsArtefactFactories.
/// </summary> /// </summary>
public class FormsArtefactFactories public static class FormsArtefactFactories
{ {
public FormsArtefactFactories() public const string FORMS_ARTEFACT_FACTORIES_PATH = "/SharpServerTools/SharpDbTools/FormsArtefactFactory";
public static Dictionary<string, FormsArtefactFactory> factories = new Dictionary<string, FormsArtefactFactory>();
static FormsArtefactFactories()
{ {
AddInTreeNode node =
AddInTree.GetTreeNode(FORMS_ARTEFACT_FACTORIES_PATH);
List<Codon> codons = node.Codons;
foreach (Codon codon in codons) {
// create an instance of the relevant FormsArtefactFactory indexed by invariant name
string invariant = codon.Id;
FormsArtefactFactory factory = (FormsArtefactFactory)node.BuildChildItem(invariant, null, null);
factories.Add(invariant, factory);
}
} }
public static FormsArtefactFactory GetFactory(string invariantName) public static FormsArtefactFactory GetFactory(string invariantName)
@ -27,18 +44,27 @@ namespace SharpDbTools.Forms
// to test this base it on hardcoded strings for the type of the factory // to test this base it on hardcoded strings for the type of the factory
// TODO: drive this from the AddIn tree // TODO: drive this from the AddIn tree
switch (invariantName)
{ FormsArtefactFactory factory = null;
case "System.Data.OracleClient": factories.TryGetValue(invariantName, out factory);
Type type = Type.GetType("SharpDbTools.Oracle.Forms.OracleFormsArtefactFactory, OracleDbToolsProvider"); if (factory == null) {
FormsArtefactFactory factory = (FormsArtefactFactory)Activator.CreateInstance(type); throw new ArgumentException("No FormsArtefactFactory found for InvariantName: "
LoggingService.Debug("Found FormsArtefactFactory for: " + invariantName); + invariantName);
return factory;
default:
LoggingService.Debug("Failed to find FormsArtefactFactory for: " + invariantName);
throw new ArgumentException("There is no FormsArtefactFactory for invariant name: " +
invariantName);
} }
return factory;
// switch (invariantName)
// {
// case "System.Data.OracleClient":
// Type type = Type.GetType("SharpDbTools.Oracle.Forms.OracleFormsArtefactFactory, OracleDbToolsProvider");
// FormsArtefactFactory factory = (FormsArtefactFactory)Activator.CreateInstance(type);
// LoggingService.Debug("Found FormsArtefactFactory for: " + invariantName);
// return factory;
// default:
// LoggingService.Debug("Failed to find FormsArtefactFactory for: " + invariantName);
// throw new ArgumentException("There is no FormsArtefactFactory for invariant name: " +
// invariantName);
// }
// TODO: retrieve the relevant factory from file-base config // TODO: retrieve the relevant factory from file-base config

2
src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/FormsArtefactFactory.cs

@ -20,5 +20,7 @@ namespace SharpDbTools.Forms
} }
public abstract TreeNode CreateMetaDataNode(string name); public abstract TreeNode CreateMetaDataNode(string name);
public abstract string[] GetDescribeTableFieldNames();
public abstract string[] GetDescribeTableColumnHeaderNames();
} }
} }

9
src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/TableDescribeViewContent.cs

@ -24,7 +24,10 @@ namespace SharpDbTools.Forms
DataGridView tableInfoDataGridView; DataGridView tableInfoDataGridView;
public TableDescribeViewContent(DataTable tableInfo, string tableName) : base("table: " + tableName) public TableDescribeViewContent(DataTable tableInfo,
string tableName,
string[] fieldsToDisplay,
string[] columnHeaderNames) : base("table: " + tableName)
{ {
this.tableInfo = tableInfo; this.tableInfo = tableInfo;
this.tableInfoDataGridView = new DataGridView(); this.tableInfoDataGridView = new DataGridView();
@ -36,12 +39,10 @@ namespace SharpDbTools.Forms
v.DataSource = this.tableInfo; v.DataSource = this.tableInfo;
//v.DataMember = TableNames.Columns; //v.DataMember = TableNames.Columns;
string[] fieldsToDisplay = ColumnNames.TableTableFieldsToDisplay;
string[] fieldColumnNames = ColumnNames.TableTableFieldsColumnHeaders;
for (int i = 0; i < fieldsToDisplay.Length; i++ ) { for (int i = 0; i < fieldsToDisplay.Length; i++ ) {
DataGridViewColumn c = new DataGridViewTextBoxColumn(); DataGridViewColumn c = new DataGridViewTextBoxColumn();
c.DataPropertyName = fieldsToDisplay[i]; c.DataPropertyName = fieldsToDisplay[i];
c.Name = fieldColumnNames[i]; c.Name = columnHeaderNames[i];
v.Columns.Add(c); v.Columns.Add(c);
} }
v.AllowUserToAddRows = false; v.AllowUserToAddRows = false;

15
src/AddIns/Misc/SharpServerTools/OracleDbToolsProvider/Src/Forms/TableTreeNode.cs → src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/TableTreeNode.cs

@ -10,7 +10,6 @@ using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using System.Data; using System.Data;
using SharpDbTools.Forms;
using SharpDbTools.Data; using SharpDbTools.Data;
using SharpServerTools.Forms; using SharpServerTools.Forms;
@ -19,16 +18,14 @@ using ICSharpCode.Core;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
namespace SharpDbTools.Oracle.Forms namespace SharpDbTools.Forms
{ {
/// <summary> /// <summary>
/// specialisation of the TreeNode to add context menu and click handling /// specialisation of the TreeNode to add context menu and click handling
/// to invoke the DescribeTable component for Oracle tables. /// to invoke the DescribeTable component for Oracle tables.
/// Does not change any data or metadata content so does not need to be
/// a ServerExplorerTreeNode
/// </summary> /// </summary>
class TableTreeNode: TreeNode public class TableTreeNode: TreeNode
{ {
string logicalConnectionName; string logicalConnectionName;
@ -49,7 +46,13 @@ namespace SharpDbTools.Oracle.Forms
string tableName = s.TreeNode.Text; string tableName = s.TreeNode.Text;
LoggingService.Debug("describe table clicked for: " + logicalConnectionName + " and table name: " + tableName); LoggingService.Debug("describe table clicked for: " + logicalConnectionName + " and table name: " + tableName);
DataTable tableInfo = DbModelInfoService.GetTableInfo(logicalConnectionName, tableName); DataTable tableInfo = DbModelInfoService.GetTableInfo(logicalConnectionName, tableName);
TableDescribeViewContent tableDescribeViewContent = new TableDescribeViewContent(tableInfo, tableName); string invariantName = DbModelInfoService.GetDbModelInfo(logicalConnectionName).InvariantName;
// TODO: get field names and column header names from factory
FormsArtefactFactory factory = FormsArtefactFactories.GetFactory(invariantName);
TableDescribeViewContent tableDescribeViewContent =
new TableDescribeViewContent(tableInfo, tableName, factory.GetDescribeTableFieldNames(),
factory.GetDescribeTableColumnHeaderNames());
WorkbenchSingleton.Workbench.ShowView(tableDescribeViewContent); WorkbenchSingleton.Workbench.ShowView(tableDescribeViewContent);
} }
} }
Loading…
Cancel
Save