Browse Source

some updates to addin file, DbModelInfoService and ServerBrowserTool

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1645 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Dickon Field 19 years ago
parent
commit
aa782c4ea9
  1. 2
      src/AddIns/Misc/SharpDbTools/Project/SharpDbTools.addin
  2. 40
      src/AddIns/Misc/SharpDbTools/Project/Src/Model/DbModelInfoService.cs
  3. 12
      src/AddIns/Misc/SharpDbTools/Project/Src/ServerBrowserTool.cs

2
src/AddIns/Misc/SharpDbTools/Project/SharpDbTools.addin

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
<Path name = "/SharpDevelop/Workbench/Pads">
<Pad id = "SharpDbToolsPad"
category = "Main"
title = "Database Server Tools"
title = "Server Tool"
icon = "PadIcons.Output"
shortcut = "Control|Alt|D"
class = "SharpDbTools.ServerBrowserTool"/>

40
src/AddIns/Misc/SharpDbTools/Project/Src/Model/DbModelInfoService.cs

@ -17,6 +17,8 @@ using SharpDbTools.Connection; @@ -17,6 +17,8 @@ using SharpDbTools.Connection;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
namespace SharpDbTools.Model
{
@ -30,6 +32,8 @@ namespace SharpDbTools.Model @@ -30,6 +32,8 @@ namespace SharpDbTools.Model
public class DbModelInfoService
{
static DbModelInfoService instance = new DbModelInfoService();
static string saveLocation = null;
const string dbFilesDir = "DbTools";
SortedList<string, DbModelInfo> cache;
@ -65,8 +69,7 @@ namespace SharpDbTools.Model @@ -65,8 +69,7 @@ namespace SharpDbTools.Model
bool exists = cache.TryGetValue(name, out modelInfo);
if (!exists)
{
// TODO: add details to exception
// TODO: more detail...
throw new KeyNotFoundException();
}
@ -104,7 +107,25 @@ namespace SharpDbTools.Model @@ -104,7 +107,25 @@ namespace SharpDbTools.Model
public void Save(string name)
{
// TODO: save the
string path = GetSaveLocation();
DbModelInfo modelInfo = null;
this.cache.TryGetValue(name, out modelInfo);
if (modelInfo != null) {
string modelName = modelInfo.Name;
// write to a file in 'path' called <name>.metadata
// TODO: may want to consider ways of making this more resilient
string filePath = @path + name + ".metadata";
LoggingService.Debug("writing metadata to: " + filePath);
if (File.Exists(filePath)) {
File.Delete(filePath);
}
using (StreamWriter sw = File.CreateText(filePath)) {
string xml = modelInfo.GetXml();
sw.Write(xml);
sw.Flush();
}
}
LoggingService.Debug("DbModelInfo with name: " + name + " not found");
}
public void LoadFromFiles()
@ -112,6 +133,19 @@ namespace SharpDbTools.Model @@ -112,6 +133,19 @@ namespace SharpDbTools.Model
// TODO: load DbModelInfo's from file system
}
private static string GetSaveLocation()
{
// append the path of the directory for saving Db files
if (saveLocation == null) {
lock(saveLocation) {
string configDir = PropertyService.ConfigDirectory;
saveLocation = configDir + dbFilesDir;
}
}
return saveLocation;
}
}
}

12
src/AddIns/Misc/SharpDbTools/Project/Src/ServerBrowserTool.cs

@ -20,7 +20,8 @@ namespace SharpDbTools @@ -20,7 +20,8 @@ namespace SharpDbTools
{
/// <summary>
/// Enables a user to browse metadata associated with a db server and to open resources
/// referenced therein.
/// referenced therein. The intention is to extend this to other server processes over
/// time.
/// </summary>
public class ServerBrowserTool : AbstractPadContent
{
@ -32,6 +33,7 @@ namespace SharpDbTools @@ -32,6 +33,7 @@ namespace SharpDbTools
/// </summary>
public ServerBrowserTool()
{
LoggingService.Debug("Loading ServerBrowserTool");
controller = ServerBrowserToolController.GetInstance();
TreeView dbTree = new TreeView();
ctl = new Panel();
@ -43,10 +45,16 @@ namespace SharpDbTools @@ -43,10 +45,16 @@ namespace SharpDbTools
dbTree.BeginUpdate();
//dbTree.Tag = "Connections";
ContextMenuStrip cMenu = new ContextMenuStrip();
ToolStripMenuItem menuItem = new ToolStripMenuItem("Save");
cMenu.Items.AddRange(new ToolStripMenuItem[] {menuItem} );
TreeNode connection1 = new TreeNode("Test");
connection1.ContextMenuStrip = cMenu;
TreeNode[] childNodes = new TreeNode[1];
childNodes[0] = connection1;
TreeNode topNode = new TreeNode("Connections", childNodes);
TreeNode topNode = new TreeNode("Database Connections", childNodes);
dbTree.Nodes.Add(topNode);
dbTree.EndUpdate();

Loading…
Cancel
Save