Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2956 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
6 changed files with 221 additions and 105 deletions
@ -0,0 +1,102 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: dickon |
||||||
|
* Date: 07/02/2008 |
||||||
|
* Time: 15:58 |
||||||
|
* |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
using System; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Windows.Controls; |
||||||
|
|
||||||
|
namespace ICSharpCode.ServerTools |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of ColumnNode.
|
||||||
|
/// </summary>
|
||||||
|
public class ColumnNode: TreeViewItem |
||||||
|
{ |
||||||
|
private string _name; |
||||||
|
private string _type; |
||||||
|
private string _length; |
||||||
|
private string _nullable; |
||||||
|
private string _precision; |
||||||
|
private string _scale; |
||||||
|
|
||||||
|
public ColumnNode() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public ColumnNode(string name, |
||||||
|
string type, |
||||||
|
string length, |
||||||
|
string nullable, |
||||||
|
string precision, |
||||||
|
string scale) |
||||||
|
{ |
||||||
|
_name = name; |
||||||
|
_type = type; |
||||||
|
_length = length; |
||||||
|
_nullable = nullable; |
||||||
|
_precision = precision; |
||||||
|
_scale = scale; |
||||||
|
} |
||||||
|
|
||||||
|
[Browsable(true)] |
||||||
|
public string FieldName { |
||||||
|
get { |
||||||
|
return this._name; |
||||||
|
} |
||||||
|
set { |
||||||
|
this._name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string Type { |
||||||
|
get { |
||||||
|
return this._type; |
||||||
|
} |
||||||
|
set { |
||||||
|
this._type = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string Length { |
||||||
|
get { |
||||||
|
return this._type; |
||||||
|
} |
||||||
|
set { |
||||||
|
this._type = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string Nullable { |
||||||
|
get { |
||||||
|
return this._nullable; |
||||||
|
} |
||||||
|
set { |
||||||
|
this._nullable = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string Precision { |
||||||
|
get { |
||||||
|
return this._precision; |
||||||
|
} |
||||||
|
set { |
||||||
|
this._precision = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string Scale { |
||||||
|
get { |
||||||
|
return this._scale; |
||||||
|
} |
||||||
|
set { |
||||||
|
this._scale = value; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,35 +0,0 @@ |
|||||||
/* |
|
||||||
* Created by SharpDevelop. |
|
||||||
* User: dickon |
|
||||||
* Date: 07/02/2008 |
|
||||||
* Time: 15:58 |
|
||||||
* |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Windows.Controls; |
|
||||||
|
|
||||||
namespace ICSharpCode.ServerTools |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Description of FieldNode.
|
|
||||||
/// </summary>
|
|
||||||
public class FieldNode: TreeViewItem |
|
||||||
{ |
|
||||||
private string _name; |
|
||||||
private string _type; |
|
||||||
|
|
||||||
public FieldNode(string name, string type) |
|
||||||
{ |
|
||||||
_name = name; |
|
||||||
_type = type; |
|
||||||
} |
|
||||||
|
|
||||||
public string FieldName { |
|
||||||
get { |
|
||||||
return this._name; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,59 +0,0 @@ |
|||||||
/* |
|
||||||
* Created by SharpDevelop. |
|
||||||
* User: dickon |
|
||||||
* Date: 07/02/2008 |
|
||||||
* Time: 16:30 |
|
||||||
* |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Windows.Controls; |
|
||||||
using System.Collections.Generic; |
|
||||||
|
|
||||||
namespace ICSharpCode.ServerTools |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Description of HeaderIndexedTreeViewItem.
|
|
||||||
/// </summary>
|
|
||||||
public static class ItemCollectionExtender |
|
||||||
{ |
|
||||||
public static Object GetItemWithHeader(this TreeViewItem t, string header) |
|
||||||
{ |
|
||||||
foreach(Object o in t.Items) { |
|
||||||
HeaderedContentControl h = o as HeaderedContentControl; |
|
||||||
if (h != null) { |
|
||||||
if (h.Header.Equals(header)) { |
|
||||||
return h; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public static void RemoveItemWithHeader(this TreeViewItem t, string header) |
|
||||||
{ |
|
||||||
foreach(Object o in t.Items) { |
|
||||||
HeaderedContentControl h = o as HeaderedContentControl; |
|
||||||
if (h != null) { |
|
||||||
if (h.Header.Equals(header)) { |
|
||||||
t.Items.Remove(h); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public static void RemoveItemsWithHeaderNotIn(this TreeViewItem t, IList<string> headers) |
|
||||||
{ |
|
||||||
foreach(Object o in t.Items) { |
|
||||||
HeaderedContentControl h = o as HeaderedContentControl; |
|
||||||
if (h != null) { |
|
||||||
string header = h.Header as string; |
|
||||||
if (!(headers.Contains(header))) { |
|
||||||
t.Items.Remove(h); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,72 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: dickon |
||||||
|
* Date: 07/02/2008 |
||||||
|
* Time: 16:30 |
||||||
|
* |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Windows.Controls; |
||||||
|
using System.Windows.Forms; |
||||||
|
using System.Collections.Generic; |
||||||
|
using log=ICSharpCode.Core.LoggingService; |
||||||
|
|
||||||
|
namespace ICSharpCode.ServerTools |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of HeaderIndexedTreeViewItem.
|
||||||
|
/// </summary>
|
||||||
|
public static class TreeViewItemExtender |
||||||
|
{ |
||||||
|
public static TreeViewItem GetItemWithHeader(this TreeViewItem t, string header) |
||||||
|
{ |
||||||
|
log.Debug("looking for item with name: " + header); |
||||||
|
foreach(Object o in t.Items) { |
||||||
|
TreeViewItem item = o as TreeViewItem; |
||||||
|
if (item != null) { |
||||||
|
string h = (string)item.Header; |
||||||
|
log.Debug("looking at item with name: " + h); |
||||||
|
if (h.Equals(header)) { |
||||||
|
log.Debug("found item with name: " + header); |
||||||
|
return item; |
||||||
|
} |
||||||
|
} else { |
||||||
|
MessageBox.Show("While navigating the db connection tree an object not of type TreeViewItem was found", |
||||||
|
"Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); |
||||||
|
log.Error("found and item in the DbConnectionsNode tree that is not a TreeViewItem"); |
||||||
|
} |
||||||
|
} |
||||||
|
log.Debug("could not find item with name: " + header); |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public static void RemoveItemWithHeader(this TreeViewItem t, string header) |
||||||
|
{ |
||||||
|
foreach(Object o in t.Items) { |
||||||
|
HeaderedContentControl h = o as HeaderedContentControl; |
||||||
|
if (h != null) { |
||||||
|
if (h.Header.Equals(header)) { |
||||||
|
log.Debug("removing item with name: " + header); |
||||||
|
t.Items.Remove(h); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static void RemoveItemsWithHeaderNotIn(this TreeViewItem t, IList<string> headers) |
||||||
|
{ |
||||||
|
foreach(Object o in t.Items) { |
||||||
|
HeaderedContentControl h = o as HeaderedContentControl; |
||||||
|
if (h != null) { |
||||||
|
string header = h.Header as string; |
||||||
|
if (!(headers.Contains(header))) { |
||||||
|
log.Debug("item with name: " + header + " was not in the keep-list, so removing it"); |
||||||
|
t.Items.Remove(h); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue