[Monodevelop-patches-list] r2118 - in trunk/MonoDevelop: . Core/src/MonoDevelop.Base/Gui/Workbench/Layouts Core/src/MonoDevelop.Core Core/src/MonoDevelop.Gui.Widgets Core/src/MonoDevelop.Gui.Widgets/DataGrid Extras Extras/MonoQuery Extras/MonoQuery/Codons Extras/MonoQuery/Collection Extras/MonoQuery/Commands Extras/MonoQuery/Commands/Abstract Extras/MonoQuery/Connection Extras/MonoQuery/Connection/Abstract Extras/MonoQuery/Connection/Interface Extras/MonoQuery/Connection/Mysql Extras/MonoQuery/Connection/Npgsql Extras/MonoQuery/Exceptions Extras/MonoQuery/Exceptions/Abstract Extras/MonoQuery/Gui Extras/MonoQuery/Gui/Abstract Extras/MonoQuery/Gui/DataView Extras/MonoQuery/Gui/Forms Extras/MonoQuery/Gui/Forms/Glade Extras/MonoQuery/Gui/Interface Extras/MonoQuery/Gui/MonoQueryTree Extras/MonoQuery/Gui/SqlQueryView Extras/MonoQuery/SchemaClass Extras/MonoQuery/SchemaClass/Abstract Extras/MonoQuery/SchemaClass/Interface Extras/MonoQuery/Services
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Fri Jan 7 18:21:17 EST 2005
Author: chergert
Date: 2005-01-07 18:21:17 -0500 (Fri, 07 Jan 2005)
New Revision: 2118
Added:
trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/DataGrid/
trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/DataGrid/DataGrid.cs
trunk/MonoDevelop/Extras/Makefile.am
trunk/MonoDevelop/Extras/MonoQuery/
trunk/MonoDevelop/Extras/MonoQuery/AssemblyInfo.cs
trunk/MonoDevelop/Extras/MonoQuery/ChangeLog
trunk/MonoDevelop/Extras/MonoQuery/Codons/
trunk/MonoDevelop/Extras/MonoQuery/Codons/MonoQueryConnectionCodon.cs
trunk/MonoDevelop/Extras/MonoQuery/Collection/
trunk/MonoDevelop/Extras/MonoQuery/Collection/ConnectionProviderDescriptor.cs
trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQueryListDictionary.cs
trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQueryParameterCollection.cs
trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQuerySchemaClassCollection.cs
trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQueryStringDictionary.cs
trunk/MonoDevelop/Extras/MonoQuery/Commands/
trunk/MonoDevelop/Extras/MonoQuery/Commands/Abstract/
trunk/MonoDevelop/Extras/MonoQuery/Commands/Abstract/AbstractMonoQueryCommand.cs
trunk/MonoDevelop/Extras/MonoQuery/Commands/MonoQueryCommands.cs
trunk/MonoDevelop/Extras/MonoQuery/Connection/
trunk/MonoDevelop/Extras/MonoQuery/Connection/Abstract/
trunk/MonoDevelop/Extras/MonoQuery/Connection/Abstract/AbstractMonoQueryConnectionWrapper.cs
trunk/MonoDevelop/Extras/MonoQuery/Connection/Interface/
trunk/MonoDevelop/Extras/MonoQuery/Connection/Interface/IConnection.cs
trunk/MonoDevelop/Extras/MonoQuery/Connection/Mysql/
trunk/MonoDevelop/Extras/MonoQuery/Connection/Mysql/MysqlConnectionWrapper.cs
trunk/MonoDevelop/Extras/MonoQuery/Connection/Npgsql/
trunk/MonoDevelop/Extras/MonoQuery/Connection/Npgsql/NpgsqlConnectionWrapper.cs
trunk/MonoDevelop/Extras/MonoQuery/Exceptions/
trunk/MonoDevelop/Extras/MonoQuery/Exceptions/Abstract/
trunk/MonoDevelop/Extras/MonoQuery/Exceptions/Abstract/MonoQueryAbstractException.cs
trunk/MonoDevelop/Extras/MonoQuery/Exceptions/ConnectionStringException.cs
trunk/MonoDevelop/Extras/MonoQuery/Exceptions/ExecuteProcedureException.cs
trunk/MonoDevelop/Extras/MonoQuery/Exceptions/ExecuteSQLException.cs
trunk/MonoDevelop/Extras/MonoQuery/Exceptions/OpenConnectionException.cs
trunk/MonoDevelop/Extras/MonoQuery/Gui/
trunk/MonoDevelop/Extras/MonoQuery/Gui/Abstract/
trunk/MonoDevelop/Extras/MonoQuery/Gui/Abstract/AbstractMonoQueryNode.cs
trunk/MonoDevelop/Extras/MonoQuery/Gui/DataView/
trunk/MonoDevelop/Extras/MonoQuery/Gui/DataView/MonoQueryDataView.cs
trunk/MonoDevelop/Extras/MonoQuery/Gui/DataView/SQLParameterInput.cs
trunk/MonoDevelop/Extras/MonoQuery/Gui/Forms/
trunk/MonoDevelop/Extras/MonoQuery/Gui/Forms/CreateConnectionDruid.cs
trunk/MonoDevelop/Extras/MonoQuery/Gui/Forms/Glade/
trunk/MonoDevelop/Extras/MonoQuery/Gui/Forms/Glade/monoquery.glade
trunk/MonoDevelop/Extras/MonoQuery/Gui/Forms/Glade/monoquery.gladep
trunk/MonoDevelop/Extras/MonoQuery/Gui/Interface/
trunk/MonoDevelop/Extras/MonoQuery/Gui/Interface/IMonoQueryNode.cs
trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryPanel.cs
trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryTree/
trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryTree/MonoQueryDataNodes.cs
trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryTree/MonoQueryNodesRoot.cs
trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryTree/MonoQueryTree.cs
trunk/MonoDevelop/Extras/MonoQuery/Gui/SqlQueryView/
trunk/MonoDevelop/Extras/MonoQuery/Gui/SqlQueryView/SqlQueryView.cs
trunk/MonoDevelop/Extras/MonoQuery/Makefile.am
trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.addin.xml
trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.cmbx
trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.mdsx
trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.prjx
trunk/MonoDevelop/Extras/MonoQuery/MonoQueryView.cs
trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/
trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/Abstract/
trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/Abstract/AbstractMonoQuerySchemaClass.cs
trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/Interface/
trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/Interface/ISchemaClass.cs
trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/MonoQuerySchemaClass.cs
trunk/MonoDevelop/Extras/MonoQuery/Services/
trunk/MonoDevelop/Extras/MonoQuery/Services/MonoQueryService.cs
Modified:
trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
trunk/MonoDevelop/Core/src/MonoDevelop.Core/AddIn.xsd
trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Makefile.am
trunk/MonoDevelop/Makefile.am
trunk/MonoDevelop/configure.in
Log:
This is the initial import of MonoQuery. MonoQuery is a database addin for
MonoDevelop that allows for browsing and executing commands on a database.
Currently supported is MySQL and PostgreSQL.
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -273,7 +273,8 @@
"MonoDevelop.Gui.Pads.HelpTree",
"MonoDevelop.EditorBindings.Gui.Pads.CompilerMessageView",
//"MonoDevelop.Gui.Pads.TerminalPad",
- "MonoDevelop.Gui.Pads.HelpBrowser"
+ "MonoDevelop.Gui.Pads.HelpBrowser",
+ "MonoQuery.Pads.MonoQueryView"
};
string[] debugPads = new string[] {
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Core/AddIn.xsd
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Core/AddIn.xsd 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Core/AddIn.xsd 2005-01-07 23:21:17 UTC (rev 2118)
@@ -39,6 +39,7 @@
<xs:element ref="MenuItem"/>
<xs:element ref="FileTemplate"/>
<xs:element ref="ProjectTemplate"/>
+ <xs:element ref="MonoQueryConnection"/>
</xs:choice>
<xs:attribute name="path" type="xs:string" use="required"/>
</xs:complexType>
@@ -214,6 +215,17 @@
</xs:complexContent>
</xs:complexType>
<xs:element name="MenuItem" type="MenuItem"/>
+ <xs:complexType name="MonoQueryConnection">
+ <xs:complexContent>
+ <xs:extension base="AbstractCodon">
+ <xs:attribute name="schema" type="xs:string" use="required"/>
+ <xs:attribute name="node" type="xs:string" use="required"/>
+ <xs:attribute name="description" type="xs:string" use="optional"/>
+ <xs:attribute name="showUnsuported" type="xs:string" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ <xs:element name="MonoQueryConnection" type="MonoQueryConnection"/>
<xs:complexType name="ToolbarItem">
<xs:complexContent>
<xs:extension base="AbstractCodon">
Added: trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/DataGrid/DataGrid.cs
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/DataGrid/DataGrid.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/DataGrid/DataGrid.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,305 @@
+//
+// DataGrid - attempt at creating a DataGrid for GTK#
+// using a GTK# TreeView. The goal is to have similar
+// functionality to a System.Windows.Forms.DataGrid
+// or System.Web.UI.WebControls.DataGrid. This includes
+// data binding support.
+//
+// Based on the sample/TreeViewDemo.cs
+//
+// Author: Kristian Rietveld <kris at gtk.org>
+// Daniel Morgan <danmorg at sc.rr.com>
+// Christian Hergert <chris at mosaix.net>
+//
+// (c) 2002 Kristian Rietveld
+// (c) 2002 Daniel Morgan
+// (c) 2004 Christian Hergert
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Reflection;
+using System.Text;
+using GLib;
+using Gtk;
+using GtkSharp;
+using System.Runtime.InteropServices;
+
+namespace MonoDevelop.Gui.Widgets
+{
+ /// <summary>
+ /// Column for inserting into a DataGrid
+ /// </summary>
+ public class DataGridColumn
+ {
+ private string columnName = "";
+ private Gtk.TreeViewColumn treeViewColumn = null;
+
+ /// <summary>
+ /// Title for the Column
+ /// </summary>
+ public string ColumnName {
+ get {
+ return columnName;
+ }
+ set {
+ columnName = value;
+ }
+ }
+
+ /// <summary>
+ /// Gtk Column widget
+ /// </summary>
+ public Gtk.TreeViewColumn TreeViewColumn {
+ get {
+ return treeViewColumn;
+ }
+ set {
+ treeViewColumn = value;
+ }
+ }
+ }
+
+ public class DataGrid : Gtk.VBox
+ {
+ private Gtk.ListStore store = null;
+ private Gtk.TreeView treeView = null;
+
+ public DataGridColumn[] gridColumns = null;
+
+ public DataGrid () : base(false, 4)
+ {
+ ScrolledWindow sw = new ScrolledWindow ();
+ this.PackStart (sw, true, true, 0);
+
+ treeView = new Gtk.TreeView (store);
+
+ sw.Add (treeView);
+ }
+
+ // FIXME: need to place in a base class
+ // the DataSource, DataMember, DataBind()
+ // public members.
+ // maybe we can call the base class
+ // BaseDataList for GTK#?
+
+ private object dataSource = null;
+
+ private string dataMember = "";
+
+ public object DataSource {
+ get {
+ return dataSource;
+ }
+ set {
+ dataSource = value;
+ }
+ }
+
+ public string DataMember {
+ get {
+ return dataMember;
+ }
+ set {
+ dataMember = value;
+ }
+ }
+
+ public void DataBind ()
+ {
+ Clear ();
+
+ System.Object o = null;
+ o = GetResolvedDataSource (DataSource, DataMember);
+ IEnumerable ie = (IEnumerable) o;
+ ITypedList tlist = (ITypedList) o;
+
+ // FIXME: does not belong in this base method
+ Gtk.TreeIter iter = new Gtk.TreeIter ();
+
+ PropertyDescriptorCollection pdc = tlist.GetItemProperties (new PropertyDescriptor[0]);
+
+ // FIXME: does not belong in this base method
+ gridColumns = new DataGridColumn[pdc.Count];
+
+ // FIXME: does not belong in base method
+ // define the columns in the treeview store
+ // based on the schema of the result
+ /*
+ uint[] theTypes = new uint[pdc.Count];
+ for (int col = 0; col < pdc.Count; col++) {
+ theTypes[col] = (int) TypeFundamentals.TypeString;
+ }
+ */
+ GType [] theTypes = new GType[pdc.Count];
+ for ( int col=0; col<pdc.Count; col++ ) {
+ theTypes[col] = (GType)GType.String;
+ }
+ store.SetColumnTypes (theTypes);
+
+ // FIXME: does not belong in this base method
+ int colndx = -1;
+ foreach (PropertyDescriptor pd in pdc) {
+ colndx ++;
+ gridColumns[colndx] = new DataGridColumn ();
+ gridColumns[colndx].ColumnName = pd.Name;
+ }
+
+ foreach (System.Object obj in ie) {
+ ICustomTypeDescriptor custom = (ICustomTypeDescriptor) obj;
+ PropertyDescriptorCollection properties;
+ properties = custom.GetProperties ();
+
+ iter = NewRow ();
+ int cv = 0;
+ foreach (PropertyDescriptor property in properties) {
+ object oPropValue = property.GetValue (obj);
+ string sPropValue = oPropValue.ToString ();
+
+ // FIXME: does not belong in this base method
+ SetColumnValue (iter, cv, sPropValue);
+
+ cv++;
+ }
+ }
+
+ // FIXME: does not belong in this base method
+ treeView.Model = store;
+ AutoCreateTreeViewColumns ( treeView );
+ }
+
+ // borrowed from Mono's System.Web implementation
+ protected IEnumerable GetResolvedDataSource(object source, string member)
+ {
+ if (source != null && source is IListSource) {
+ IListSource src = (IListSource) source;
+ IList list = src.GetList ();
+ if (!src.ContainsListCollection) {
+ return list;
+ }
+ if (list != null && list is ITypedList) {
+
+ ITypedList tlist = (ITypedList) list;
+ PropertyDescriptorCollection pdc = tlist.GetItemProperties (new PropertyDescriptor[0]);
+ if (pdc != null && pdc.Count > 0) {
+ PropertyDescriptor pd = null;
+ if (member != null && member.Length > 0) {
+ pd = pdc.Find (member, true);
+ } else {
+ pd = pdc[0];
+ }
+ if (pd != null) {
+ object rv = pd.GetValue (list[0]);
+ if (rv != null && rv is IEnumerable) {
+ return (IEnumerable)rv;
+ }
+ }
+ throw new Exception ("ListSource_Missing_DataMember");
+ }
+ throw new Exception ("ListSource_Without_DataMembers");
+ }
+ }
+ if (source is IEnumerable) {
+ return (IEnumerable)source;
+ }
+ return null;
+ }
+
+ public void Clear ()
+ {
+ if (store != null) {
+ store.Clear ();
+ store = null;
+ //store = new ListStore ((int)TypeFundamentals.TypeString);
+ store = new ListStore( GType.String );
+ }
+ else {
+ //store = new ListStore ((int)TypeFundamentals.TypeString);
+ store = new ListStore( GType.String );
+ }
+
+ if (gridColumns != null) {
+ for (int c = 0; c < gridColumns.Length; c++) {
+ if (gridColumns[c] != null) {
+ if (gridColumns[c].TreeViewColumn != null) {
+ treeView.RemoveColumn (gridColumns[c].TreeViewColumn);
+ gridColumns[c].TreeViewColumn = null;
+ }
+ gridColumns[c] = null;
+ }
+ }
+ gridColumns = null;
+ }
+ }
+
+ // for DEBUG only
+ public void AppendText (string text)
+ {
+ Console.WriteLine ("DataGrid DEBUG: " + text);
+ Console.Out.Flush ();
+ }
+
+ public TreeIter NewRow ()
+ {
+ /*
+ TreeIter rowTreeIter = new TreeIter();
+ store.Append (out rowTreeIter);
+ return rowTreeIter;
+ */
+ return store.Append();
+ }
+
+ public void AddRow (object[] columnValues)
+ {
+ TreeIter iter = NewRow ();
+ for(int col = 0; col < columnValues.Length; col++) {
+ string cellValue = columnValues[col].ToString ();
+ SetColumnValue (iter, col, cellValue);
+ }
+ }
+
+ public void SetColumnValue (TreeIter iter, int column, string value)
+ {
+ GLib.Value cell = new GLib.Value (value);
+ store.SetValue (iter, column, cell);
+ }
+
+ private void AutoCreateTreeViewColumns (Gtk.TreeView theTreeView)
+ {
+ for(int col = 0; col < gridColumns.Length; col++) {
+ // escape underscore _ because it is used
+ // as the underline in menus and labels
+ StringBuilder name = new StringBuilder ();
+ foreach (char ch in gridColumns[col].ColumnName) {
+ if (ch == '_')
+ name.Append ("__");
+ else
+ name.Append (ch);
+ }
+ TreeViewColumn tvc;
+ tvc = CreateColumn (theTreeView, col,
+ name.ToString ());
+ theTreeView.AppendColumn (tvc);
+ }
+ }
+
+ // TODO: maybe need to create
+ // a DataGridColumnCollection of DataGridColumn
+ // and a DataGridColumn contain a TreeViewColumn
+ public TreeViewColumn CreateColumn (Gtk.TreeView theTreeView, int col,
+ string columnName)
+ {
+ TreeViewColumn NameCol = new TreeViewColumn ();
+ CellRenderer NameRenderer = new CellRendererText ();
+
+ NameCol.Title = columnName;
+ NameCol.PackStart (NameRenderer, true);
+ NameCol.AddAttribute (NameRenderer, "text", col);
+
+ gridColumns[col].TreeViewColumn = NameCol;
+
+ return NameCol;
+ }
+ }
+}
+
Modified: trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Makefile.am
===================================================================
--- trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Makefile.am 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Core/src/MonoDevelop.Gui.Widgets/Makefile.am 2005-01-07 23:21:17 UTC (rev 2118)
@@ -25,7 +25,8 @@
Navbar/Navbar.cs \
TabLabel/TabLabel.cs \
GladeWidgetExtract/GladeWidgetExtract.cs \
-DragNotebook/DragNotebook.cs
+DragNotebook/DragNotebook.cs \
+DataGrid/DataGrid.cs
build_sources = $(addprefix $(srcdir)/, $(FILES))
Added: trunk/MonoDevelop/Extras/Makefile.am
===================================================================
--- trunk/MonoDevelop/Extras/Makefile.am 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/Makefile.am 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,3 @@
+
+#SUBDIRS = PythonBinding MonoQuery
+SUBDIRS = MonoQuery
Added: trunk/MonoDevelop/Extras/MonoQuery/AssemblyInfo.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/AssemblyInfo.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/AssemblyInfo.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,49 @@
+// MonoQuery.MonoQuery.dll - Addin for #Develop for database design
+// Copyright (C) 2003 Denis ERCHOFF
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("MonoQuery")]
+[assembly: AssemblyDescription("Database addin for MonoDevelop")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("#Develop, MonoDevelop")]
+[assembly: AssemblyProduct("Mono Query")]
+[assembly: AssemblyCopyright("Copyright (C) 2003 Denis ERCHOFF, 2004 Christian Hergert")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly: AssemblyVersion("0.4.0.*")]
+
+// The following attributes specify the key for the sign of your assembly. See the
+// .NET Framework documentation for more information about signing.
+// This is not required, if you don't want signing let these attributes like they're.
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
Added: trunk/MonoDevelop/Extras/MonoQuery/ChangeLog
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/ChangeLog 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/ChangeLog 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,3 @@
+2005-01-06 Christian Hergert <chris at mosaix.net>
+
+ * Initial creation of MonoQuery AddIn
Added: trunk/MonoDevelop/Extras/MonoQuery/Codons/MonoQueryConnectionCodon.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Codons/MonoQueryConnectionCodon.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Codons/MonoQueryConnectionCodon.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,76 @@
+
+using System;
+using System.Collections;
+
+using MonoDevelop.Core.AddIns.Conditions;
+using MonoDevelop.Core.AddIns;
+
+using MonoDevelop.Core.AddIns.Codons;
+
+namespace MonoQuery.Codons
+{
+ [CodonName("MonoQueryConnection")]
+ public class MonoQueryConnectionCodon : AbstractCodon
+ {
+ [XmlMemberAttributeAttribute("schema", IsRequired=true)]
+ string pSchema = null;
+ [XmlMemberAttributeAttribute("node", IsRequired=true)]
+ string pNode = null;
+ [XmlMemberAttributeAttribute("showUnsuported", IsRequired=true)]
+ string pshowUnsuported = "True";
+ [XmlMemberAttributeAttribute("description", IsRequired=false)]
+ string pDescription = "";
+
+ public string Schema{
+ get{
+ return pSchema;
+ }
+
+ set{
+ pSchema = value;
+ }
+ }
+
+ public string Node{
+ get{
+ return pNode;
+ }
+
+ set{
+ pNode = value;
+ }
+ }
+
+ public string ShowUnsuported{
+ get{
+ return pshowUnsuported;
+ }
+
+ set{
+ pshowUnsuported = value;
+ }
+ }
+
+ public string Description
+ {
+ get { return pDescription; }
+ set { pDescription = value; }
+ }
+
+ public override bool HandleConditions {
+ get {
+ return true;
+ }
+ }
+
+ /// <summary>
+ /// Creates an item with the specified sub items. And the current
+ /// Condition status for this item.
+ /// </summary>
+ public override object BuildItem(object owner, ArrayList subItems, ConditionCollection conditions)
+ {
+ return this.Class;
+ }
+
+ }
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Collection/ConnectionProviderDescriptor.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Collection/ConnectionProviderDescriptor.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Collection/ConnectionProviderDescriptor.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,33 @@
+
+using System;
+
+namespace MonoQuery.Collections
+{
+ public class ConnectionProviderDescriptor
+ {
+ private Type providerType;
+ private string name;
+ private string connectionStringExample;
+
+ public Type ProviderType
+ {
+ get { return providerType; }
+ }
+ public string Name
+ {
+ get { return name; }
+ }
+ public string ConnectionStringExample
+ {
+ get { return connectionStringExample; }
+ }
+
+ public ConnectionProviderDescriptor( string name, Type type ) : this ( name, type, null ) {}
+ public ConnectionProviderDescriptor( string name, Type type, string example )
+ {
+ this.name = name;
+ this.providerType = type;
+ this.connectionStringExample = example;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQueryListDictionary.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQueryListDictionary.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQueryListDictionary.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,85 @@
+// created on 11/11/2003 at 11:20
+
+using System;
+using System.Collections;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+
+namespace MonoQuery.Collections {
+
+ ///<summary>List dictionnary.
+ /// <param name='key'> this a string is defining the key</param>
+ /// <param name='value'> this a <see cref=".MonoQuerySchemaClassCollection"></see> is defining the value</param>
+ /// </summary>
+
+ public class MonoQueryListDictionary : DictionaryBase
+ {
+ public MonoQuerySchemaClassCollection this[ string key ] {
+ get {
+ return( (MonoQuerySchemaClassCollection) Dictionary[key] );
+ }
+ set {
+ Dictionary[key] = value;
+ }
+ }
+
+ public ICollection Keys {
+ get {
+ return( Dictionary.Keys );
+ }
+ }
+
+ public ICollection Values {
+ get {
+ return( Dictionary.Values );
+ }
+ }
+
+ public void Add( string key, MonoQuerySchemaClassCollection value ) {
+ Dictionary.Add( key, value );
+ }
+
+ public bool Contains( string key ) {
+ return( Dictionary.Contains( key ) );
+ }
+
+ public void Remove( string key ) {
+ Dictionary.Remove( key );
+ }
+
+ protected override void OnInsert( object key, object value ) {
+ StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+ if ( !(key is string) )
+ throw new ArgumentException( GettextCatalog.GetString( "Wrong Key Type" ), "key" );
+
+ if ( !(value is MonoQuerySchemaClassCollection) )
+ throw new ArgumentException( GettextCatalog.GetString( "Wrong Value Type" ), "value" );
+ }
+
+ protected override void OnRemove( object key, object value ) {
+ StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+ if ( !(key is string) )
+ throw new ArgumentException( GettextCatalog.GetString( "Wrong Key Type" ), "key" );
+ }
+
+ protected override void OnSet( object key, object oldValue, object newValue ) {
+ StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+ if (!(key is string) )
+ throw new ArgumentException( GettextCatalog.GetString( "Wrong Key Type" ), "key" );
+
+ if ( !(newValue is MonoQuerySchemaClassCollection) )
+ throw new ArgumentException( GettextCatalog.GetString( "Wrong Value Type" ), "newValue" );
+ }
+
+ protected override void OnValidate( object key, object value ) {
+ StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+ if ( !(key is string) )
+ throw new ArgumentException( GettextCatalog.GetString( "Wrong Key Type" ), "key" );
+
+ if ( !(value is MonoQuerySchemaClassCollection) )
+ throw new ArgumentException( GettextCatalog.GetString( "Wrong Value Type" ), "value" );
+ }
+
+ }
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQueryParameterCollection.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQueryParameterCollection.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQueryParameterCollection.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,258 @@
+// ------------------------------------------------------------------------------
+// This file was autogenerated.
+// ------------------------------------------------------------------------------
+//
+namespace MonoQuery.Collections {
+ using System;
+ using System.Collections;
+ using MonoQuery.SchemaClass;
+
+
+ /// <summary>
+ /// <para>
+ /// A collection that stores <see cref='.MonoQueryParameter'/> objects.
+ /// </para>
+ /// </summary>
+ /// <seealso cref='.MonoQueryParameterCollection'/>
+ [Serializable()]
+ public class MonoQueryParameterCollection : CollectionBase {
+
+ /// <summary>
+ /// <para>
+ /// Initializes a new instance of <see cref='.MonoQueryParameterCollection'/>.
+ /// </para>
+ /// </summary>
+ public MonoQueryParameterCollection() {
+ }
+
+ /// <summary>
+ /// <para>
+ /// Initializes a new instance of <see cref='.MonoQueryParameterCollection'/> based on another <see cref='.MonoQueryParameterCollection'/>.
+ /// </para>
+ /// </summary>
+ /// <param name='value'>
+ /// A <see cref='.MonoQueryParameterCollection'/> from which the contents are copied
+ /// </param>
+ public MonoQueryParameterCollection(MonoQueryParameterCollection value) {
+ this.AddRange(value);
+ }
+
+ /// <summary>
+ /// <para>
+ /// Initializes a new instance of <see cref='.MonoQueryParameterCollection'/> containing any array of <see cref='.MonoQueryParameter'/> objects.
+ /// </para>
+ /// </summary>
+ /// <param name='value'>
+ /// A array of <see cref='.MonoQueryParameter'/> objects with which to intialize the collection
+ /// </param>
+ public MonoQueryParameterCollection(MonoQueryParameter[] value) {
+ this.AddRange(value);
+ }
+
+
+ public MonoQueryParameterCollection(MonoQuerySchemaClassCollection value) {
+ this.AddRange( value );
+ }
+
+ /// <summary>
+ /// <para>Represents the entry at the specified index of the <see cref='.MonoQueryParameter'/>.</para>
+ /// </summary>
+ /// <param name='index'><para>The zero-based index of the entry to locate in the collection.</para></param>
+ /// <value>
+ /// <para> The entry at the specified index of the collection.</para>
+ /// </value>
+ /// <exception cref='System.ArgumentOutOfRangeException'><paramref name='index'/> is outside the valid range of indexes for the collection.</exception>
+ public MonoQueryParameter this[int index] {
+ get {
+ return ((MonoQueryParameter)(List[index]));
+ }
+ set {
+ List[index] = value;
+ }
+ }
+
+ public MonoQuerySchemaClassCollection ToBaseSchemaCollection()
+ {
+ MonoQuerySchemaClassCollection returnValues = new MonoQuerySchemaClassCollection();
+ foreach( MonoQueryParameter par in this )
+ {
+ returnValues.Add( par );
+ }
+
+ return returnValues;
+ }
+
+ /// <summary>
+ /// <para>Adds a <see cref='.MonoQueryParameter'/> with the specified value to the
+ /// <see cref='.MonoQueryParameterCollection'/> .</para>
+ /// </summary>
+ /// <param name='value'>The <see cref='.MonoQueryParameter'/> to add.</param>
+ /// <returns>
+ /// <para>The index at which the new element was inserted.</para>
+ /// </returns>
+ /// <seealso cref='.MonoQueryParameterCollection.AddRange'/>
+ public int Add(MonoQueryParameter value) {
+ return List.Add(value);
+ }
+
+ /// <summary>
+ /// <para>Copies the elements of an array to the end of the <see cref='.MonoQueryParameterCollection'/>.</para>
+ /// </summary>
+ /// <param name='value'>
+ /// An array of type <see cref='.MonoQueryParameter'/> containing the objects to add to the collection.
+ /// </param>
+ /// <returns>
+ /// <para>None.</para>
+ /// </returns>
+ /// <seealso cref='.MonoQueryParameterCollection.Add'/>
+ public void AddRange(MonoQueryParameter[] value) {
+ for (int i = 0; (i < value.Length); i = (i + 1)) {
+ this.Add(value[i]);
+ }
+ }
+
+ /// <summary>
+ /// <para>
+ /// Adds the contents of another <see cref='.MonoQueryParameterCollection'/> to the end of the collection.
+ /// </para>
+ /// </summary>
+ /// <param name='value'>
+ /// A <see cref='.MonoQueryParameterCollection'/> containing the objects to add to the collection.
+ /// </param>
+ /// <returns>
+ /// <para>None.</para>
+ /// </returns>
+ /// <seealso cref='.MonoQueryParameterCollection.Add'/>
+ public void AddRange(MonoQueryParameterCollection value) {
+ for (int i = 0; (i < value.Count); i = (i + 1)) {
+ this.Add(value[i]);
+ }
+ }
+
+
+ public void AddRange(MonoQuerySchemaClassCollection value)
+ {
+ foreach( MonoQueryParameter par in value )
+ {
+ this.Add( par );
+ }
+ }
+
+ /// <summary>
+ /// <para>Gets a value indicating whether the
+ /// <see cref='.MonoQueryParameterCollection'/> contains the specified <see cref='.MonoQueryParameter'/>.</para>
+ /// </summary>
+ /// <param name='value'>The <see cref='.MonoQueryParameter'/> to locate.</param>
+ /// <returns>
+ /// <para><see langword='true'/> if the <see cref='.MonoQueryParameter'/> is contained in the collection;
+ /// otherwise, <see langword='false'/>.</para>
+ /// </returns>
+ /// <seealso cref='.MonoQueryParameterCollection.IndexOf'/>
+ public bool Contains(MonoQueryParameter value) {
+ return List.Contains(value);
+ }
+
+ /// <summary>
+ /// <para>Copies the <see cref='.MonoQueryParameterCollection'/> values to a one-dimensional <see cref='System.Array'/> instance at the
+ /// specified index.</para>
+ /// </summary>
+ /// <param name='array'><para>The one-dimensional <see cref='System.Array'/> that is the destination of the values copied from <see cref='.MonoQueryParameterCollection'/> .</para></param>
+ /// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
+ /// <returns>
+ /// <para>None.</para>
+ /// </returns>
+ /// <exception cref='System.ArgumentException'><para><paramref name='array'/> is multidimensional.</para> <para>-or-</para> <para>The number of elements in the <see cref='.MonoQueryParameterCollection'/> is greater than the available space between <paramref name='arrayIndex'/> and the end of <paramref name='array'/>.</para></exception>
+ /// <exception cref='System.ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
+ /// <exception cref='System.ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
+ /// <seealso cref='System.Array'/>
+ public void CopyTo(MonoQueryParameter[] array, int index) {
+ List.CopyTo(array, index);
+ }
+
+ /// <summary>
+ /// <para>Returns the index of a <see cref='.MonoQueryParameter'/> in
+ /// the <see cref='.MonoQueryParameterCollection'/> .</para>
+ /// </summary>
+ /// <param name='value'>The <see cref='.MonoQueryParameter'/> to locate.</param>
+ /// <returns>
+ /// <para>The index of the <see cref='.MonoQueryParameter'/> of <paramref name='value'/> in the
+ /// <see cref='.MonoQueryParameterCollection'/>, if found; otherwise, -1.</para>
+ /// </returns>
+ /// <seealso cref='.MonoQueryParameterCollection.Contains'/>
+ public int IndexOf(MonoQueryParameter value) {
+ return List.IndexOf(value);
+ }
+
+ /// <summary>
+ /// <para>Inserts a <see cref='.MonoQueryParameter'/> into the <see cref='.MonoQueryParameterCollection'/> at the specified index.</para>
+ /// </summary>
+ /// <param name='index'>The zero-based index where <paramref name='value'/> should be inserted.</param>
+ /// <param name=' value'>The <see cref='.MonoQueryParameter'/> to insert.</param>
+ /// <returns><para>None.</para></returns>
+ /// <seealso cref='.MonoQueryParameterCollection.Add'/>
+ public void Insert(int index, MonoQueryParameter value) {
+ List.Insert(index, value);
+ }
+
+ /// <summary>
+ /// <para>Returns an enumerator that can iterate through
+ /// the <see cref='.MonoQueryParameterCollection'/> .</para>
+ /// </summary>
+ /// <returns><para>None.</para></returns>
+ /// <seealso cref='System.Collections.IEnumerator'/>
+ public new MonoQueryParameterEnumerator GetEnumerator() {
+ return new MonoQueryParameterEnumerator(this);
+ }
+
+ /// <summary>
+ /// <para> Removes a specific <see cref='.MonoQueryParameter'/> from the
+ /// <see cref='.MonoQueryParameterCollection'/> .</para>
+ /// </summary>
+ /// <param name='value'>The <see cref='.MonoQueryParameter'/> to remove from the <see cref='.MonoQueryParameterCollection'/> .</param>
+ /// <returns><para>None.</para></returns>
+ /// <exception cref='System.ArgumentException'><paramref name='value'/> is not found in the Collection. </exception>
+ public void Remove(MonoQueryParameter value) {
+ List.Remove(value);
+ }
+
+ public class MonoQueryParameterEnumerator : object, IEnumerator {
+
+ private IEnumerator baseEnumerator;
+
+ private IEnumerable temp;
+
+ public MonoQueryParameterEnumerator(MonoQueryParameterCollection mappings) {
+ this.temp = ((IEnumerable)(mappings));
+ this.baseEnumerator = temp.GetEnumerator();
+ }
+
+ public MonoQueryParameter Current {
+ get {
+ return ((MonoQueryParameter)(baseEnumerator.Current));
+ }
+ }
+
+ object IEnumerator.Current {
+ get {
+ return baseEnumerator.Current;
+ }
+ }
+
+ public bool MoveNext() {
+ return baseEnumerator.MoveNext();
+ }
+
+ bool IEnumerator.MoveNext() {
+ return baseEnumerator.MoveNext();
+ }
+
+ public void Reset() {
+ baseEnumerator.Reset();
+ }
+
+ void IEnumerator.Reset() {
+ baseEnumerator.Reset();
+ }
+ }
+ }
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQuerySchemaClassCollection.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQuerySchemaClassCollection.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQuerySchemaClassCollection.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,233 @@
+// ------------------------------------------------------------------------------
+// This file was autogenerated.
+// ------------------------------------------------------------------------------
+//
+namespace MonoQuery.Collections {
+ using System;
+ using System.Collections;
+ using MonoQuery.SchemaClass;
+
+
+ /// <summary>
+ /// <para>
+ /// A collection that stores <see cref='.ISchemaClass'/> objects.
+ /// </para>
+ /// </summary>
+ /// <seealso cref='.MonoQuerySchemaClassCollection'/>
+ [Serializable()]
+ public class MonoQuerySchemaClassCollection : CollectionBase {
+
+ /// <summary>
+ /// <para>
+ /// Initializes a new instance of <see cref='.MonoQuerySchemaClassCollection'/>.
+ /// </para>
+ /// </summary>
+ public MonoQuerySchemaClassCollection() {
+ }
+
+ /// <summary>
+ /// <para>
+ /// Initializes a new instance of <see cref='.MonoQuerySchemaClassCollection'/> based on another <see cref='.MonoQuerySchemaClassCollection'/>.
+ /// </para>
+ /// </summary>
+ /// <param name='value'>
+ /// A <see cref='.MonoQuerySchemaClassCollection'/> from which the contents are copied
+ /// </param>
+ public MonoQuerySchemaClassCollection(MonoQuerySchemaClassCollection value) {
+ this.AddRange(value);
+ }
+
+ /// <summary>
+ /// <para>
+ /// Initializes a new instance of <see cref='.MonoQuerySchemaClassCollection'/> containing any array of <see cref='.ISchemaClass'/> objects.
+ /// </para>
+ /// </summary>
+ /// <param name='value'>
+ /// A array of <see cref='.ISchemaClass'/> objects with which to intialize the collection
+ /// </param>
+ public MonoQuerySchemaClassCollection(ISchemaClass[] value) {
+ this.AddRange(value);
+ }
+
+ /// <summary>
+ /// <para>Represents the entry at the specified index of the <see cref='.ISchemaClass'/>.</para>
+ /// </summary>
+ /// <param name='index'><para>The zero-based index of the entry to locate in the collection.</para></param>
+ /// <value>
+ /// <para> The entry at the specified index of the collection.</para>
+ /// </value>
+ /// <exception cref='System.ArgumentOutOfRangeException'><paramref name='index'/> is outside the valid range of indexes for the collection.</exception>
+ public ISchemaClass this[int index] {
+ get {
+ return ((ISchemaClass)(List[index]));
+ }
+ set {
+ List[index] = value;
+ }
+ }
+
+ /// <summary>
+ /// <para>Adds a <see cref='.ISchemaClass'/> with the specified value to the
+ /// <see cref='.MonoQuerySchemaClassCollection'/> .</para>
+ /// </summary>
+ /// <param name='value'>The <see cref='.ISchemaClass'/> to add.</param>
+ /// <returns>
+ /// <para>The index at which the new element was inserted.</para>
+ /// </returns>
+ /// <seealso cref='.MonoQuerySchemaClassCollection.AddRange'/>
+ public int Add(ISchemaClass value) {
+ return List.Add(value);
+ }
+
+ /// <summary>
+ /// <para>Copies the elements of an array to the end of the <see cref='.MonoQuerySchemaClassCollection'/>.</para>
+ /// </summary>
+ /// <param name='value'>
+ /// An array of type <see cref='.ISchemaClass'/> containing the objects to add to the collection.
+ /// </param>
+ /// <returns>
+ /// <para>None.</para>
+ /// </returns>
+ /// <seealso cref='.MonoQuerySchemaClassCollection.Add'/>
+ public void AddRange(ISchemaClass[] value) {
+ for (int i = 0; (i < value.Length); i = (i + 1)) {
+ this.Add(value[i]);
+ }
+ }
+
+ /// <summary>
+ /// <para>
+ /// Adds the contents of another <see cref='.MonoQuerySchemaClassCollection'/> to the end of the collection.
+ /// </para>
+ /// </summary>
+ /// <param name='value'>
+ /// A <see cref='.MonoQuerySchemaClassCollection'/> containing the objects to add to the collection.
+ /// </param>
+ /// <returns>
+ /// <para>None.</para>
+ /// </returns>
+ /// <seealso cref='.MonoQuerySchemaClassCollection.Add'/>
+ public void AddRange(MonoQuerySchemaClassCollection value) {
+ for (int i = 0; (i < value.Count); i = (i + 1)) {
+ this.Add(value[i]);
+ }
+ }
+
+ /// <summary>
+ /// <para>Gets a value indicating whether the
+ /// <see cref='.MonoQuerySchemaClassCollection'/> contains the specified <see cref='.ISchemaClass'/>.</para>
+ /// </summary>
+ /// <param name='value'>The <see cref='.ISchemaClass'/> to locate.</param>
+ /// <returns>
+ /// <para><see langword='true'/> if the <see cref='.ISchemaClass'/> is contained in the collection;
+ /// otherwise, <see langword='false'/>.</para>
+ /// </returns>
+ /// <seealso cref='.MonoQuerySchemaClassCollection.IndexOf'/>
+ public bool Contains(ISchemaClass value) {
+ return List.Contains(value);
+ }
+
+ /// <summary>
+ /// <para>Copies the <see cref='.MonoQuerySchemaClassCollection'/> values to a one-dimensional <see cref='System.Array'/> instance at the
+ /// specified index.</para>
+ /// </summary>
+ /// <param name='array'><para>The one-dimensional <see cref='System.Array'/> that is the destination of the values copied from <see cref='.MonoQuerySchemaClassCollection'/> .</para></param>
+ /// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
+ /// <returns>
+ /// <para>None.</para>
+ /// </returns>
+ /// <exception cref='System.ArgumentException'><para><paramref name='array'/> is multidimensional.</para> <para>-or-</para> <para>The number of elements in the <see cref='.MonoQuerySchemaClassCollection'/> is greater than the available space between <paramref name='arrayIndex'/> and the end of <paramref name='array'/>.</para></exception>
+ /// <exception cref='System.ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
+ /// <exception cref='System.ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
+ /// <seealso cref='System.Array'/>
+ public void CopyTo(ISchemaClass[] array, int index) {
+ List.CopyTo(array, index);
+ }
+
+ /// <summary>
+ /// <para>Returns the index of a <see cref='.ISchemaClass'/> in
+ /// the <see cref='.MonoQuerySchemaClassCollection'/> .</para>
+ /// </summary>
+ /// <param name='value'>The <see cref='.ISchemaClass'/> to locate.</param>
+ /// <returns>
+ /// <para>The index of the <see cref='.ISchemaClass'/> of <paramref name='value'/> in the
+ /// <see cref='.MonoQuerySchemaClassCollection'/>, if found; otherwise, -1.</para>
+ /// </returns>
+ /// <seealso cref='.MonoQuerySchemaClassCollection.Contains'/>
+ public int IndexOf(ISchemaClass value) {
+ return List.IndexOf(value);
+ }
+
+ /// <summary>
+ /// <para>Inserts a <see cref='.ISchemaClass'/> into the <see cref='.MonoQuerySchemaClassCollection'/> at the specified index.</para>
+ /// </summary>
+ /// <param name='index'>The zero-based index where <paramref name='value'/> should be inserted.</param>
+ /// <param name=' value'>The <see cref='.ISchemaClass'/> to insert.</param>
+ /// <returns><para>None.</para></returns>
+ /// <seealso cref='.MonoQuerySchemaClassCollection.Add'/>
+ public void Insert(int index, ISchemaClass value) {
+ List.Insert(index, value);
+ }
+
+ /// <summary>
+ /// <para>Returns an enumerator that can iterate through
+ /// the <see cref='.MonoQuerySchemaClassCollection'/> .</para>
+ /// </summary>
+ /// <returns><para>None.</para></returns>
+ /// <seealso cref='System.Collections.IEnumerator'/>
+ public new ISchemaClassEnumerator GetEnumerator() {
+ return new ISchemaClassEnumerator(this);
+ }
+
+ /// <summary>
+ /// <para> Removes a specific <see cref='.ISchemaClass'/> from the
+ /// <see cref='.MonoQuerySchemaClassCollection'/> .</para>
+ /// </summary>
+ /// <param name='value'>The <see cref='.ISchemaClass'/> to remove from the <see cref='.MonoQuerySchemaClassCollection'/> .</param>
+ /// <returns><para>None.</para></returns>
+ /// <exception cref='System.ArgumentException'><paramref name='value'/> is not found in the Collection. </exception>
+ public void Remove(ISchemaClass value) {
+ List.Remove(value);
+ }
+
+ public class ISchemaClassEnumerator : object, IEnumerator {
+
+ private IEnumerator baseEnumerator;
+
+ private IEnumerable temp;
+
+ public ISchemaClassEnumerator(MonoQuerySchemaClassCollection mappings) {
+ this.temp = ((IEnumerable)(mappings));
+ this.baseEnumerator = temp.GetEnumerator();
+ }
+
+ public ISchemaClass Current {
+ get {
+ return ((ISchemaClass)(baseEnumerator.Current));
+ }
+ }
+
+ object IEnumerator.Current {
+ get {
+ return baseEnumerator.Current;
+ }
+ }
+
+ public bool MoveNext() {
+ return baseEnumerator.MoveNext();
+ }
+
+ bool IEnumerator.MoveNext() {
+ return baseEnumerator.MoveNext();
+ }
+
+ public void Reset() {
+ baseEnumerator.Reset();
+ }
+
+ void IEnumerator.Reset() {
+ baseEnumerator.Reset();
+ }
+ }
+ }
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQueryStringDictionary.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQueryStringDictionary.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Collection/MonoQueryStringDictionary.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,83 @@
+using System;
+using System.Collections;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+
+namespace MonoQuery.Collections {
+ ///<summary>String dictionnary
+ /// <param name='key'> this a string is defining the key</param>
+ /// <param name='value'> this a string is defining the value</param>
+ /// </summary>
+ public class MonoQueryStringDictionary : DictionaryBase {
+
+ readonly StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+
+ public string this[ string key ] {
+ get {
+ return( (string) Dictionary[key] );
+ }
+ set {
+ Dictionary[key] = value;
+ }
+ }
+
+ public ICollection Keys {
+ get {
+ return( Dictionary.Keys );
+ }
+ }
+
+ public ICollection Values {
+ get {
+ return( Dictionary.Values );
+ }
+ }
+
+ public void Add( string key, string value ) {
+ Dictionary.Add( key, value );
+ }
+
+ public bool Contains( string key ) {
+ return( Dictionary.Contains( key ) );
+ }
+
+ public void Remove( string key ) {
+ Dictionary.Remove( key );
+ }
+
+ protected override void OnInsert( object key, object value ) {
+ StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+ if ( !(key is string) )
+ throw new ArgumentException( GettextCatalog.GetString( "Wrong Key Type" ), "key" );
+
+ if ( !(value is string) )
+ throw new ArgumentException( GettextCatalog.GetString( "Wrong Value Type" ), "value" );
+ }
+
+ protected override void OnRemove( object key, object value ) {
+ StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+ if ( !(key is string) )
+ throw new ArgumentException( GettextCatalog.GetString( "Wrong Key Type" ), "key" );
+ }
+
+ protected override void OnSet( object key, object oldValue, object newValue ) {
+ StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+ if (!(key is string) )
+ throw new ArgumentException( GettextCatalog.GetString( "Wrong Key Type" ), "key" );
+
+ if ( !(newValue is string) )
+ throw new ArgumentException( GettextCatalog.GetString( "Wrong Value Type" ), "newValue" );
+ }
+
+ protected override void OnValidate( object key, object value ) {
+ StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+ if ( !(key is string) )
+ throw new ArgumentException( GettextCatalog.GetString( "Wrong Key Type" ), "key" );
+
+ if ( !(value is string) )
+ throw new ArgumentException( GettextCatalog.GetString( "Wrong Value Type" ), "value" );
+ }
+
+ }
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Commands/Abstract/AbstractMonoQueryCommand.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Commands/Abstract/AbstractMonoQueryCommand.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Commands/Abstract/AbstractMonoQueryCommand.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,52 @@
+
+using System;
+
+using MonoDevelop.Core.AddIns.Codons;
+
+using MonoQuery.Gui.TreeView;
+
+namespace MonoQuery.Commands
+{
+ /// <summary>
+ /// Base class of all commands of MonoQuery Addin
+ /// </summary>
+ public abstract class AbstractMonoQueryCommand : AbstractMenuCommand
+ {
+ protected IMonoQueryNode monoQueryNode = null;
+
+ /// <summary>
+ /// get the selected <see cref="MonoQuery.Gui.TreeView.IMonoQueryNode"> MonoQuery node </see>
+ /// and Enabled or disabled the command
+ /// <remarks> If the selected node is <code>null</code> or this is not a <see cref="MonoQuery.Gui.TreeView.IMonoQueryNode"> MonoQuery node </see>, return <code>false</code> (disable the menu)</remarks>
+ /// </summary>
+ public override bool IsEnabled
+ {
+ get
+ {
+ MonoQueryTree monoQueryTree;
+ monoQueryTree = this.Owner as MonoQueryTree;
+
+ if ( (monoQueryTree != null) && ( monoQueryTree.SelectedNode != null ) )
+ {
+ this.monoQueryNode = monoQueryTree.SelectedNode as IMonoQueryNode;
+ }
+ else
+ {
+ this.monoQueryNode = null;
+ }
+
+ return (this.monoQueryNode != null);
+ }
+ set{}
+
+ }
+
+ /// <summary>
+ /// Create a new MonoQueryCommand
+ /// </summary>
+ public AbstractMonoQueryCommand() : base()
+ {
+ }
+
+ }
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Commands/MonoQueryCommands.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Commands/MonoQueryCommands.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Commands/MonoQueryCommands.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,199 @@
+
+using System;
+using MonoDevelop.Core.AddIns.Codons;
+using MonoQuery.Gui.TreeView;
+
+namespace MonoQuery.Commands
+{
+ public class MonoQueryRefreshCommand : AbstractMonoQueryCommand
+ {
+ public override bool IsEnabled
+ {
+ get
+ {
+ return base.IsEnabled && (this.monoQueryNode is AbstractMonoQueryNode)
+ && (this.monoQueryNode as AbstractMonoQueryNode).Connection != null
+ && (this.monoQueryNode as AbstractMonoQueryNode).Connection.IsOpen == true;
+ }
+ set{}
+ }
+ /// <summary>
+ /// Refresh the selected <see cref="MonoQuery.Gui.TreeView.IMonoQueryNode">node</see> of the <see cref="MonoQuery.Gui.TreeView.MonoQueryTree"> MonoQuery Tree.</see>
+ /// </summary>
+ public override void Run()
+ {
+ ( this.monoQueryNode as IMonoQueryNode).Refresh();
+ }
+ }
+
+ /// <summary>
+ /// Add a connection to a database server into the <see cref="MonoQuery.Gui.TreeView.MonoQueryTree"></see>
+ /// </summary>
+ public class MonoQueryAddconnectionCommand : AbstractMonoQueryCommand
+ {
+
+ public override bool IsEnabled
+ {
+ get
+ {
+ return base.IsEnabled && (this.monoQueryNode is MonoQueryNodeDatabaseRoot);
+ }
+ set{}
+ }
+
+ /// <summary>
+ /// Add a connection to a database server into the <see cref="MonoQuery.Gui.TreeView.MonoQueryTree"></see>
+ /// </summary>
+ public override void Run()
+ {
+ ( this.monoQueryNode as MonoQueryNodeDatabaseRoot ).AddConnection();
+ }
+ }
+
+ /// <summary>
+ /// Remove a connection from a database server into the <see cref="MonoQuery.Gui.TreeView.MonoQueryTree"></see>
+ /// </summary>
+ public class MonoQueryRemoveConnectionCommand : AbstractMonoQueryCommand
+ {
+ public override bool IsEnabled
+ {
+ get
+ {
+ return base.IsEnabled && (this.monoQueryNode is MonoQueryNodeConnection);
+ }
+ set{}
+ }
+
+ /// <summary>
+ /// Remove a connection from a database server into the <see cref="MonoQuery.Gui.TreeView.MonoQueryTree"></see>
+ /// </summary>
+ public override void Run()
+ {
+ ( this.monoQueryNode as MonoQueryNodeConnection).RemoveConnection();
+ }
+ }
+
+
+ /// <summary>
+ /// Remove a connection from a database server into the <see cref="MonoQuery.Gui.TreeView.MonoQueryTree"></see>
+ /// </summary>
+ public class MonoQueryModifyConnectionCommand : AbstractMonoQueryCommand
+ {
+
+ public override bool IsEnabled
+ {
+ get
+ {
+ return base.IsEnabled && (this.monoQueryNode is MonoQueryNodeConnection);
+ }
+ set{}
+ }
+
+ /// <summary>
+ /// Remove a connection from a database server into the <see cref="MonoQuery.Gui.TreeView.MonoQueryTree"></see>
+ /// </summary>
+ public override void Run()
+ {
+ ( this.monoQueryNode as MonoQueryNodeConnection).ModifyConnection();
+ }
+ }
+
+ /// <summary>
+ /// Disconnect From a database server
+ /// </summary>
+ public class MonoQueryDisconnectCommand : AbstractMonoQueryCommand
+ {
+
+ public override bool IsEnabled
+ {
+ get
+ {
+ return base.IsEnabled && (this.monoQueryNode is MonoQueryNodeConnection)
+ && (this.monoQueryNode as MonoQueryNodeConnection).IsConnected == true;
+ }
+ set{}
+ }
+
+ public MonoQueryDisconnectCommand() : base()
+ {
+ }
+
+ /// <summary>
+ /// Disconnect From a database server
+ /// </summary>
+ public override void Run()
+ {
+ (this.monoQueryNode as MonoQueryNodeConnection).Disconnect();
+ }
+ }
+
+ /// <summary>
+ /// Disconnect From a database server
+ /// </summary>
+ public class MonoQueryConnectCommand : AbstractMonoQueryCommand
+ {
+
+ public override bool IsEnabled
+ {
+ get
+ {
+ return base.IsEnabled && (this.monoQueryNode is MonoQueryNodeConnection)
+ && (this.monoQueryNode as MonoQueryNodeConnection).IsConnected == false;
+ }
+ set{}
+ }
+
+ public MonoQueryConnectCommand() : base()
+ {
+ }
+
+ /// <summary>
+ /// Disconnect From a database server
+ /// </summary>
+ public override void Run()
+ {
+ (this.monoQueryNode as MonoQueryNodeConnection).Connect();
+ }
+ }
+
+
+ /// <summary>
+ /// Disconnect From a database server
+ /// </summary>
+ public class MonoQueryExecuteCommand : AbstractMonoQueryCommand
+ {
+ public MonoQueryExecuteCommand() : base()
+ {
+ }
+
+ /// <summary>
+ /// Disconnect From a database server
+ /// </summary>
+ public override void Run()
+ {
+ this.monoQueryNode.Execute(0);
+ }
+ }
+
+ /// <summary>
+ /// Show the sql editor
+ /// </summary>
+ public class MonoQueryShowSqlViewCommand : AbstractMonoQueryCommand
+ {
+ public MonoQueryShowSqlViewCommand() : base()
+ {
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public override void Run()
+ {
+ IMonoQueryNode node = this.monoQueryNode;
+
+ MonoDevelop.Gui.WorkbenchSingleton.Workbench.ShowView(
+ new MonoQuery.Gui.SqlQueryView.SqlQueryView(
+ node.Connection ) );
+ }
+ }
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Connection/Abstract/AbstractMonoQueryConnectionWrapper.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Connection/Abstract/AbstractMonoQueryConnectionWrapper.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Connection/Abstract/AbstractMonoQueryConnectionWrapper.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,1002 @@
+// created on 11/11/2003 at 14:06
+namespace MonoQuery.Connection
+{
+
+ using System;
+ using System.Collections;
+ using System.Data;
+ using System.Data.OleDb;
+ using System.Reflection;
+
+ using MonoDevelop.Core.Services;
+ using MonoDevelop.Services;
+ using MonoDevelop.Core.AddIns.Conditions;
+ using MonoDevelop.Core.AddIns.Codons;
+ using MonoDevelop.Core.AddIns;
+
+ using MonoQuery.Collections;
+ using MonoQuery.SchemaClass;
+ using MonoQuery.Codons;
+ using MonoQuery.Exceptions;
+
+ ///<summary>
+ /// Connection properties
+ ///</summary>
+ public enum MonoQueryPropertyEnum
+ {
+ Catalog,
+ ConnectionString,
+ DataSource,
+ DataSourceName,
+ DBMSName,
+ ProviderName
+ }
+
+ ///<summary>
+ /// MonoQuery schema enumeration.
+ ///</summary>
+ public enum MonoQuerySchemaEnum {
+
+ Asserts,
+ Catalogs,
+ CharacterSets,
+ CheckConstraints,
+ Collations,
+ ColumnPrivileges,
+ Columns,
+ ColumnsDomainUsage,
+ ConstraintColumnUsage,
+ ConstaintTableUsage,
+ Cubes,
+ DBInfoKeyWords,
+ DBInfoLiterals,
+ Dimensions,
+ ForeignKeys,
+ Hierarchies,
+ Indexes,
+ KeyColumnUsage,
+ Levels,
+ Measures,
+ Members,
+ Null, // ask for an empty list
+ PrimaryKeys,
+ ProcedureColumns,
+ ProcedureParameters,
+ Procedures,
+ Properties,
+ ProviderSpecific,
+ ProviderTypes,
+ ReferentialConstraints,
+ Schemata,
+ SQLLanguages,
+ Statistics,
+ TableConstraints,
+ TablePrivileges,
+ Tables,
+ Tanslations,
+ Trustees,
+ UsagePrivileges,
+ ViewColumnUsage,
+ Views,
+ ViewColumns,
+ ViewTableUsage
+ }
+
+ ///<summary>
+ /// this is a wrapper abstract class for connection with a database server.
+ ///</summary>
+ public abstract class AbstractMonoQueryConnectionWrapper : IConnection
+ {
+ //constants
+ internal string SELECT = "SELECT";
+ internal string FROM = "FROM";
+ internal string WHERE = "WHERE";
+ internal string UPDATE = "UPDATE";
+ internal string SET = "SET";
+ internal string DELETE = "DELETE";
+ internal string INSERINTO = "INSERT INTO";
+ internal string VALUES = "VALUES";
+ internal string AND = "AND";
+
+ protected bool wrongConnectionString = false;
+ static StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+ protected MonoQueryListDictionary pEntities = null;
+ private string name = "";
+
+ ///<summary>
+ /// return <c>true</c> if the connection string is invalid.
+ ///</summary>
+ public bool IsConnectionStringWrong
+ {
+ get
+ {
+ return this.wrongConnectionString;
+ }
+ }
+ ///<summary>return the catalog name. If there aren't a ctalog name
+ /// in the <see cref=".ConnectionString">ConnectionString</see>, return "".
+ /// </summary>
+ public virtual string CatalogName
+ {
+ get
+ {
+ object returnValue = this.GetProperty( MonoQueryPropertyEnum.Catalog);
+
+ if ( returnValue == null )
+ {
+ returnValue = "";
+ }
+
+ return returnValue.ToString();
+ }
+ }
+
+ /// <summary>
+ /// Example connection string
+ /// </summary>
+ public virtual string ExampleConnectionString
+ {
+ get
+ {
+ return ( "" );
+ }
+ }
+
+ public virtual string SchemaName
+ {
+ get
+ {
+ return "";//"INFORMATION_SCHEMA";
+ }
+ }
+
+ public virtual string Name
+ {
+ get { return this.name; }
+ }
+
+ ///<summary>return : <see cref=".Name">Name</see>.<see cref=".ConnectionString"></see></summary>
+ public string NormalizedName
+ {
+ get
+ {
+ return this.Name + "." + this.ConnectionString;
+ }
+ }
+
+ public MonoQueryListDictionary Entities
+ {
+ get
+ {
+ return this.pEntities;
+ }
+ }
+
+ ///<summary>
+ /// OLEDB connection String.
+ /// i use this for speed up the code writing ...
+ ///</summary>
+ public virtual string ConnectionString
+ {
+ get
+ {
+ return this.GetProperty( MonoQueryPropertyEnum.ConnectionString ).ToString();
+ }
+
+ set
+ {
+ }
+ }
+
+ public virtual string Provider
+ {
+ get
+ {
+ return this.GetProperty( MonoQueryPropertyEnum.ProviderName ).ToString();
+ }
+ }
+
+ public abstract bool IsOpen
+ {
+ get;
+ }
+
+
+ public abstract object GetProperty( MonoQueryPropertyEnum property );
+
+ /// <summary>
+ /// Creates a new DataConnection object
+ /// </summary>
+ public AbstractMonoQueryConnectionWrapper()
+ {
+ this.pEntities = new MonoQueryListDictionary();
+ }
+
+ /// <summary>
+ /// Creates a new DataConnection object from a connection string
+ /// </summary>
+ public AbstractMonoQueryConnectionWrapper( string connectionString ) : this()
+ {
+ }
+
+ static private IConnection CreateConnectionObject( string connectionstring )
+ {
+ //try
+ //{
+ Assembly ass = System.Reflection.Assembly.GetExecutingAssembly();
+
+ IAddInTreeNode AddinNode;
+ IAddInTreeNode ChildNode = null;
+
+ string ClassWrapper = "";
+
+ AddinNode = (IAddInTreeNode)AddInTreeSingleton.AddInTree.GetTreeNode("/MonoQuery/Connection");
+ ChildNode = (IAddInTreeNode)AddinNode.ChildNodes["ConnectionWrapper"];
+ ClassWrapper = ChildNode.Codon.Class;
+
+ if ( (ClassWrapper != null) && (ClassWrapper != "") )
+ {
+ IConnection conn = (IConnection)ass.CreateInstance( ClassWrapper,
+ false,
+ BindingFlags.CreateInstance,
+ null,
+ //new object[] {connectionstring},
+ null,
+ null,
+ null
+ );
+ conn.ConnectionString = connectionstring;
+ return conn;
+ }
+ else
+ {
+ return null;
+ }
+ //}
+ //catch ( System.Exception e )
+ //{
+ // throw new ConnectionStringException( e.Message );
+ //}
+ }
+
+ static public IConnection CreateFromDataConnectionLink()
+ {
+// ADODB._Connection AdoConnection;
+// MSDASC.DataLinks dataLink = new MSDASC.DataLinks();
+ IConnection connection = null;
+//
+// AdoConnection = null;
+// AdoConnection = (ADODB._Connection) dataLink.PromptNew();
+//
+// if ( ( AdoConnection != null ) && ( AdoConnection.ConnectionString != "" ) )
+// {
+// connection = CreateConnectionObject( AdoConnection.ConnectionString );
+// }
+//
+ return connection;
+ }
+
+ static public IConnection UpDateFromDataConnectionLink( IConnection oldConnection )
+ {
+// object AdoConnection;
+// MSDASC.DataLinks dataLink = new MSDASC.DataLinks();
+ IConnection connection = null;
+//
+// AdoConnection = new ADODB.Connection();
+// (AdoConnection as ADODB.Connection).ConnectionString = oldConnection.ConnectionString;
+//
+// if ( dataLink.PromptEdit( ref AdoConnection ) )
+// {
+// connection = CreateConnectionObject( (AdoConnection as ADODB.Connection).ConnectionString );
+// }
+//
+ return connection;
+ }
+
+ static public IConnection CreateFromConnectionString( string stringConnection )
+ {
+ IConnection connection = null;
+
+ if ( ( stringConnection != null ) && ( stringConnection != "" ) )
+ {
+ connection = CreateConnectionObject( stringConnection );
+ }
+
+ return connection;
+ }
+
+ public abstract bool Open();
+ public abstract void Close();
+
+ ///<summary>
+ /// called by <see cref=".Refresh()">Refresh</see> just after the <see cref=".Clear()">Clear</see> and before <see cref=".Refresh()">childs'refresh</see>.
+ /// In this, you could change the <see cref=".Entities">Entities dicntionnary.</see>
+ ///</summary>
+ protected virtual void OnRefresh()
+ {
+ if (this.pEntities != null )
+ {
+ this.pEntities.Add( "TABLES", new MonoQuerySchemaClassCollection( new ISchemaClass[] { new MonoQueryTables(this, this.CatalogName, this.SchemaName, this.Name, "TABLES") } ) );
+ this.pEntities.Add( "VIEWS", new MonoQuerySchemaClassCollection( new ISchemaClass[] { new MonoQueryViews( this, this.CatalogName, this.SchemaName, this.Name, "VIEWS" ) } ) );
+ this.pEntities.Add( "PROCEDURES", new MonoQuerySchemaClassCollection( new ISchemaClass[] { new MonoQueryProcedures( this, this.CatalogName, this.SchemaName, this.Name, "PROCEDURES" ) } ) );
+ }
+ }
+
+ ///<summary>Refresh all dynamic properties of this connection</summary>
+ public void Refresh()
+ {
+ this.Clear();
+
+ if ( this.IsOpen == true )
+ {
+ this.OnRefresh();
+ }
+ }
+
+ public void Clear()
+ {
+ if (this.pEntities != null )
+ {
+ this.pEntities.Clear();
+
+ //Let do the Garbage collector to clear the MonoQuerySchmaClassCollection childs.
+ // It wil be do in a thread (by the garbage collector), it will be better
+ }
+ }
+
+ ///<summary>
+ /// Execute a SQL command
+ /// <param name="SQLText">
+ /// SQL command to execute
+ /// </param>
+ /// <param name="rows">
+ /// Maximum number of row to extract. If is "0" then all rows are extracted.
+ /// </param>
+ /// <returns> return a <see cref="System.Data.DataTable">DataTable</see>
+ ///or a <see cref="System.Data.DataSet">DataSet</see> object.
+ /// </returns>
+ /// </summary>
+ public abstract object ExecuteSQL( string SQLText, int rows);
+ //TODO : Parameter param.
+
+ ///<summary>
+ /// Execute a stocked procedure.
+ /// <param name="schema">
+ /// <see cref="MonoQuery.SchemaClass">SchemaClass</see> object.
+ /// </param>
+ /// <param name="rows">
+ /// Maximum number of row to extract. If is "0" then all rows are extracted.
+ /// </param>
+ /// <returns> return a <see cref="System.Data.DataTable">DataTable</see>
+ ///or a <see cref="System.Data.DataSet">DataSet</see> object.
+ /// </returns>
+ /// </summary>
+ public abstract object ExecuteProcedure( ISchemaClass schema, int rows, MonoQuerySchemaClassCollection parameters );
+
+ ///<summary>
+ /// Extract Data from a Table or a View
+ /// <param name="schema">
+ /// <see cref="MonoQuery.SchemaClass">SchemaClass</see> object.
+ /// </param>
+ /// <param name="rows">
+ /// Maximum number of row to extract. If is "0" then all rows are extracted.
+ /// </param>
+ /// <returns> return a <see cref="System.Data.DataTable">DataTable</see>
+ ///or a <see cref="System.Data.DataSet">DataSet</see> object.
+ /// </returns>
+ /// </summary>
+ public object ExtractData( ISchemaClass schema, int rows )
+ {
+
+ if ( schema == null )
+ {
+ throw new System.ArgumentNullException("schema");
+ }
+
+ string SQLSelect = this.SELECT + " ";
+ string SQLFrom = this.FROM + " ";
+ MonoQuerySchemaClassCollection entitieslist = null;
+
+ SQLFrom += schema.Name;
+
+ schema.Refresh();
+ //we have only a table or view :o) //TODO : find a better way !
+ foreach( DictionaryEntry DicEntry in schema.Entities )
+ {
+ entitieslist = DicEntry.Value as MonoQuerySchemaClassCollection;
+ break;
+ }
+
+ if ( entitieslist == null )
+ {
+ throw new System.ArgumentNullException("entitieslist");
+ }
+
+ foreach( ISchemaClass column in entitieslist )
+ {
+ SQLSelect += column.NormalizedName;
+ SQLSelect += ",";
+ }
+
+ SQLSelect = SQLSelect.TrimEnd( new Char[]{','} );
+ if ( entitieslist.Count == 0)
+ {
+ SQLSelect += "*";
+ }
+ SQLSelect += " ";
+
+ return this.ExecuteSQL( SQLSelect + SQLFrom , 0);
+ }
+
+
+ ///<summary>
+ /// Update <see cref="System.Data.DataRow">row</see>'s fields into the current opened database.
+ /// <param name="row">a <see cref="System.Data.DataRow">row</see> </param>
+ /// <param name="schema"> a <see cref="MonoQuery.SchemaClass.ISchema">schema</see> </param>
+ /// <remarks> it use a transaction for each row, so it's a very long process
+ /// if you should update something like 10 000 lines ;o). It's used only by the DataView.
+ /// If you need a better way write a "BatchUpdate" function
+ /// </remarks>
+ ///</summary>
+ public void UpDateRow( ISchemaClass schema, DataRow row )
+ {
+ if ( schema == null )
+ {
+ throw new System.ArgumentNullException("schema");
+ }
+
+ if ( row == null )
+ {
+ throw new System.ArgumentNullException("row");
+ }
+
+ string SQLUpdate = this.UPDATE + " ";
+ string SQLWhere = this.WHERE + " ";
+ string SQLValues = this.SET + " ";
+
+ SQLUpdate += schema.Name;
+ SQLUpdate += " ";
+
+ foreach( DataColumn column in row.Table.Columns )
+ {
+ if ( column.ReadOnly == false
+ && column.AutoIncrement == false
+ )
+ {
+ SQLValues += schema.Name + "." + AbstractMonoQuerySchemaClass.CheckWhiteSpace(column.ColumnName);
+ SQLValues += "=";
+ if ( column.DataType.Equals( System.Type.GetType("System.String") )
+ || column.DataType.Equals( System.Type.GetType("System.Char") )
+ )
+ {
+ SQLValues +="'";
+ }
+ SQLValues += row[column.ColumnName];
+ if ( column.DataType.Equals( System.Type.GetType("System.String") )
+ || column.DataType.Equals( System.Type.GetType("System.Char") )
+ )
+ {
+ SQLValues +="'";
+ }
+
+ SQLValues += ",";
+ }
+
+ SQLWhere += MonoQuery.SchemaClass.AbstractMonoQuerySchemaClass.CheckWhiteSpace(column.ColumnName);
+ SQLWhere += "=";
+ if ( column.DataType.Equals( System.Type.GetType("System.String") )
+ || column.DataType.Equals( System.Type.GetType("System.Char") )
+ )
+ {
+ SQLWhere +="'";
+ }
+ SQLWhere += row[column.ColumnName, DataRowVersion.Original];
+ if ( column.DataType.Equals( System.Type.GetType("System.String") )
+ || column.DataType.Equals( System.Type.GetType("System.Char") )
+ )
+ {
+ SQLWhere +="'";
+ }
+
+ if ( row.Table.Columns.IndexOf( column ) != (row.Table.Columns.Count -1) )
+ {
+ SQLWhere += " " + this.AND + " ";
+ }
+ }
+
+ SQLValues =SQLValues.TrimEnd(new Char[]{','});
+
+ this.ExecuteSQL( SQLUpdate + SQLValues + SQLWhere , 0);
+ row.AcceptChanges();
+ }
+
+ ///<summary>
+ /// Delete <see cref="System.Data.DataRow">row</see> into the current opened database.
+ /// <param name="row">a <see cref="System.Data.DataRow">row</see> </param>
+ /// <param name="schema"> a <see cref="MonoQuery.SchemaClass.ISchema">schema</see> </param>
+ /// <remarks> it use a transaction for each row, so it's a very long process
+ /// if you should update something like 10 000 lines ;o). It's used only by the DataView.
+ /// If you need a better way write a "BatchUpdate" function
+ /// </remarks>
+ ///</summary>
+ public void DeleteRow( ISchemaClass schema, DataRow row )
+ {
+ if ( schema == null )
+ {
+ throw new System.ArgumentNullException("schema");
+ }
+
+ if ( row == null )
+ {
+ throw new System.ArgumentNullException("row");
+ }
+
+ string SQLDelete = this.DELETE + " ";
+ string SQLWhere = this.WHERE +" ";
+ string SQLFrom = this.FROM +" ";
+
+ SQLFrom += schema.Name;
+ SQLFrom += " ";
+
+ foreach( DataColumn column in row.Table.Columns )
+ {
+ //SQLDelete += schema.Name + "." + column.ColumnName;
+
+ SQLWhere += MonoQuery.SchemaClass.AbstractMonoQuerySchemaClass.CheckWhiteSpace(column.ColumnName);
+ SQLWhere += "=";
+ if ( column.DataType.Equals( System.Type.GetType("System.String") )
+ || column.DataType.Equals( System.Type.GetType("System.Char") )
+ )
+ {
+ SQLWhere +="'";
+ }
+ SQLWhere += row[column.ColumnName, DataRowVersion.Original];
+ if ( column.DataType.Equals( System.Type.GetType("System.String") )
+ || column.DataType.Equals( System.Type.GetType("System.Char") )
+ )
+ {
+ SQLWhere +="'";
+ }
+
+ if ( row.Table.Columns.IndexOf( column ) != (row.Table.Columns.Count -1) )
+ {
+ //SQLDelete += ",";
+ SQLWhere += " " + this.AND + " ";
+ }
+ else
+ {
+ //SQLDelete += " ";
+ }
+ }
+
+ this.ExecuteSQL( SQLDelete + SQLFrom + SQLWhere , 0);
+ row.AcceptChanges();
+ }
+
+ ///<summary>
+ /// Insert <see cref="System.Data.DataRow">row</see> into the current opened database.
+ /// <param name="row">a <see cref="System.Data.DataRow">row</see> </param>
+ /// <param name="schema"> a <see cref="MonoQuery.SchemaClass.ISchema">schema</see> </param>
+ /// <remarks> it use a transaction for each row, so it's a very long process
+ /// if you should update something like 10 000 lines ;o). It's used only by the DataView.
+ /// If you need a better way write a "BatchUpdate" function
+ /// </remarks>
+ ///</summary>
+ public void InsertRow( ISchemaClass schema, DataRow row )
+ {
+ if ( schema == null )
+ {
+ throw new System.ArgumentNullException("schema");
+ }
+
+ if ( row == null )
+ {
+ throw new System.ArgumentNullException("row");
+ }
+
+ string SQLInsert = this.INSERINTO + " ";
+ string SQLValues = this.VALUES +" (";
+
+ SQLInsert += schema.Name;
+ SQLInsert += " (";
+
+ foreach( DataColumn column in row.Table.Columns )
+ {
+ if ( column.ReadOnly == false
+ && column.AutoIncrement == false
+ )
+ {
+ SQLInsert += /*schema.Name + "." + //Full qualified name not supported by some provider*/ MonoQuery.SchemaClass.AbstractMonoQuerySchemaClass.CheckWhiteSpace(column.ColumnName);
+
+ if ( column.DataType.Equals( System.Type.GetType("System.String") )
+ || column.DataType.Equals( System.Type.GetType("System.Char") )
+ )
+ {
+ SQLValues +="'";
+ }
+ SQLValues += row[column.ColumnName, DataRowVersion.Current ];
+ if ( column.DataType.Equals( System.Type.GetType("System.String") )
+ || column.DataType.Equals( System.Type.GetType("System.Char") )
+ )
+ {
+ SQLValues +="'";
+ }
+
+ SQLValues += ",";
+ SQLInsert += ",";
+ }
+ }
+
+ SQLValues = SQLValues.TrimEnd(new Char[]{','});
+ SQLInsert = SQLInsert.TrimEnd(new Char[]{','});
+
+ SQLInsert += ") ";
+ SQLValues += ")";
+
+
+ this.ExecuteSQL( SQLInsert + SQLValues, 0);
+ row.AcceptChanges();
+ }
+
+ ///<summary> throw a exception if the <seealso cref='.AbstractMonoQueryConnectionWrapper.Connection'/> is <code>null</code> </summary>
+ protected abstract void CheckConnectionObject();
+
+ ///<summary> each elements of the restrictions array which are an empty string is replaced with a <code>null</code> reference</summary>
+ protected object[] NormalizeRestrictions( object[] restrictions)
+ {
+ object[] newRestrictions = null;
+
+ if ( restrictions != null )
+ {
+ newRestrictions = new object[ restrictions.Length ];
+ object restriction;
+
+ for( int i = 0; i < restrictions.Length; i++)
+ {
+ restriction = restrictions[i];
+
+ if ( restriction != null )
+ {
+ if ( (restriction is string) && ( (restriction as string) == "") )
+ {
+ restriction = null;
+ }
+ }
+
+ newRestrictions[i] = restriction;
+ }
+ }
+ return newRestrictions;
+ }
+
+ /// <summary>
+ /// return a schema matching <code>restrictions</code>
+ /// <param name="schema"> a <see cref=".MonoQuerySchemaEnum">MonoQuerySchemaEnum</see>.</param>
+ /// <param name="restrictions"> Restrictions matching the schema</param>
+ /// </summary>
+ protected abstract DataTable GetSchema( MonoQuerySchemaEnum schema, object[] restrictions );
+
+
+//
+// IConnection methods
+//
+
+ public MonoQuerySchemaClassCollection GetSchemaCatalogs( ISchemaClass schema )
+ {
+ MonoQuerySchemaClassCollection list = new MonoQuerySchemaClassCollection( );
+ DataTable record = null;
+ MonoQuerySchemaEnum schematype = MonoQuerySchemaEnum.Catalogs;
+ object[] restrictions = new object[]{ schema.InternalName };
+
+ try
+ {
+ record = this.GetSchema( schematype , restrictions );
+
+ //TODO : add not supported schema code!
+
+ if ( record != null )
+ {
+ foreach (DataRow row in record.Rows )
+ {
+ list.Add( new MonoQueryCatalog( this, row["CATALOG_NAME"].ToString(), "", "", row["CATALOG_NAME"].ToString()) );
+ }
+ }
+ }
+ catch( System.Exception )
+ {
+ list.Add( new MonoQueryNotSupported(this, "" , "", "", "MonoQuerySchemaEnum.Catalogs") );
+ }
+
+ return list;
+ }
+
+ public MonoQuerySchemaClassCollection GetSchemaSchemas( ISchemaClass schema )
+ {
+ MonoQuerySchemaClassCollection list = new MonoQuerySchemaClassCollection( );
+ DataTable record = null;
+ MonoQuerySchemaEnum schematype = MonoQuerySchemaEnum.Schemata;
+ object[] restrictions = new object[]{ schema.CatalogName, "", "" };
+
+ try
+ {
+ record = this.GetSchema( schematype, restrictions );
+
+ if ( record != null )
+ {
+ foreach (DataRow row in record.Rows )
+ {
+ list.Add( new MonoQuerySchema( this, row["CATALOG_NAME"].ToString(), row["SCHEMA_NAME"].ToString(), "", row["SCHEMA_NAME"].ToString()) );
+ }
+
+ }
+ }
+ catch( System.Exception )
+ {
+ list.Add( new MonoQueryNotSupported(this, "" , "", "", "MonoQuerySchemaEnum.Schemata") );
+ }
+
+ return list;
+ }
+
+ public MonoQuerySchemaClassCollection GetSchemaTables( ISchemaClass schema )
+ {
+ MonoQuerySchemaClassCollection list = new MonoQuerySchemaClassCollection( );
+ DataTable record = null;
+ MonoQuerySchemaEnum schematype = MonoQuerySchemaEnum.Tables;
+ object[] restrictions = new object[]{ schema.CatalogName, schema.SchemaName, "", "TABLE" };
+
+ try
+ {
+ record = this.GetSchema( schematype, restrictions );
+
+ if ( record != null )
+ {
+ foreach (DataRow row in record.Rows )
+ {
+ list.Add( new MonoQueryTable( this, row["TABLE_CATALOG"].ToString(), row["TABLE_SCHEMA"].ToString(), "", row["TABLE_NAME"].ToString()) );
+ }
+ }
+ }
+ catch( System.Exception )
+ {
+ list.Add( new MonoQueryNotSupported(this, "" , "", "", "MonoQuerySchemaEnum.Tables") );
+ }
+
+ return list;
+ }
+
+ public MonoQuerySchemaClassCollection GetSchemaViews( ISchemaClass schema )
+ {
+ MonoQuerySchemaClassCollection list = new MonoQuerySchemaClassCollection( );
+ DataTable record = null;
+ MonoQuerySchemaEnum schematype = MonoQuerySchemaEnum.Views;
+ object[] restrictions = new object[]{ schema.CatalogName, schema.SchemaName, "", "VIEW" };
+
+ try
+ {
+ record = this.GetSchema( schematype, restrictions );
+
+ if ( record != null )
+ {
+ foreach (DataRow row in record.Rows )
+ {
+ list.Add( new MonoQueryView( this, row["TABLE_CATALOG"].ToString(), row["TABLE_SCHEMA"].ToString(), "", row["TABLE_NAME"].ToString()) );
+ }
+ }
+ }
+ catch( System.Exception )
+ {
+ list.Add( new MonoQueryNotSupported(this, "" , "", "", "MonoQuerySchemaEnum.Views") );
+ }
+
+ return list;
+ }
+
+ public MonoQuerySchemaClassCollection GetSchemaProcedures( ISchemaClass schema )
+ {
+ MonoQuerySchemaClassCollection list = new MonoQuerySchemaClassCollection( );
+ DataTable record = null;
+ MonoQuerySchemaEnum schematype = MonoQuerySchemaEnum.Procedures;
+ object[] restrictions = new object[]{ schema.CatalogName, schema.SchemaName, "", ""};
+
+ try
+ {
+ record = this.GetSchema( schematype, restrictions );
+
+ if ( record != null )
+ {
+ foreach (DataRow row in record.Rows )
+ {
+ list.Add( new MonoQueryProcedure( this, row["PROCEDURE_CATALOG"].ToString(), row["PROCEDURE_SCHEMA"].ToString(), "", row["PROCEDURE_NAME"].ToString().Split(';')[0] ) );
+ }
+ }
+ }
+ catch( System.Exception )
+ {
+ list.Add( new MonoQueryNotSupported(this, "" , "", "", "MonoQuerySchemaEnum.Procedures") );
+ }
+
+ return list;
+ }
+
+ public MonoQuerySchemaClassCollection GetSchemaTableColumns( ISchemaClass schema )
+ {
+ MonoQuerySchemaClassCollection list = new MonoQuerySchemaClassCollection( );
+ DataTable record = null;
+ MonoQuerySchemaEnum schematype = MonoQuerySchemaEnum.Columns;
+ object[] restrictions = new object[]{ schema.CatalogName, schema.SchemaName, schema.InternalName, "" };
+
+ try
+ {
+ record = this.GetSchema( schematype, restrictions );
+
+ if ( record != null )
+ {
+ foreach (DataRow row in record.Rows )
+ {
+ list.Add( new MonoQueryColumn( this, schema.CatalogName, schema.SchemaName,schema.Name, row["COLUMN_NAME"].ToString()) );
+ }
+ }
+ }
+ catch( System.Exception )
+ {
+ list.Add( new MonoQueryNotSupported(this, "" , "", "", "MonoQuerySchemaEnum.Columns") );
+ }
+
+ return list;
+ }
+
+ public MonoQuerySchemaClassCollection GetSchemaViewColumns( ISchemaClass schema )
+ {
+ MonoQuerySchemaClassCollection list = new MonoQuerySchemaClassCollection( );
+ DataTable record = null;
+ MonoQuerySchemaEnum schematype = MonoQuerySchemaEnum.ViewColumns;
+ object[] restrictions = new object[]{ schema.CatalogName, schema.SchemaName, schema.InternalName, "" };
+
+ try
+ {
+ record = this.GetSchema( schematype, restrictions );
+
+ if ( record != null )
+ {
+ foreach (DataRow row in record.Rows )
+ {
+ list.Add( new MonoQueryColumn( this, schema.CatalogName, schema.SchemaName, schema.Name, row["COLUMN_NAME"].ToString()) );
+ }
+ }
+ }
+ catch( System.Exception )
+ {
+ list.Add( new MonoQueryNotSupported(this, "" , "", "", "MonoQuerySchemaEnum.Columns") );
+ }
+
+ return list;
+ }
+
+ public MonoQuerySchemaClassCollection GetSchemaProcedureColumns( ISchemaClass schema )
+ {
+ MonoQuerySchemaClassCollection list = new MonoQuerySchemaClassCollection( );
+ DataTable record = null;
+ MonoQuerySchemaEnum schematype = MonoQuerySchemaEnum.ProcedureColumns;
+ object[] restrictions = new object[]{ schema.CatalogName, schema.SchemaName, schema.InternalName, "" };
+
+ try
+ {
+ record = this.GetSchema( schematype, restrictions );
+
+ if ( record != null )
+ {
+ foreach (DataRow row in record.Rows )
+ {
+ list.Add( new MonoQueryColumn( this, schema.CatalogName, schema.SchemaName, schema.Name, row["COLUMN_NAME"].ToString()) );
+ }
+ }
+ }
+ catch( System.Exception)
+ {
+ list.Add( new MonoQueryNotSupported(this, "" , "", "", "MonoQuerySchemaEnum.ProcedureColumns") );
+ }
+
+ return list;
+ }
+
+ public MonoQuerySchemaClassCollection GetSchemaProcedureParameters( ISchemaClass schema )
+ {
+ MonoQuerySchemaClassCollection list = new MonoQuerySchemaClassCollection( );
+ DataTable record = null;
+ MonoQuerySchemaEnum schematype = MonoQuerySchemaEnum.ProcedureParameters;
+ object[] restrictions = new object[]{ schema.CatalogName, schema.SchemaName, schema.InternalName, "" };
+
+ try
+ {
+ record = this.GetSchema( schematype, restrictions );
+ MonoQueryParameter par = null;
+ if ( record != null )
+ {
+ foreach (DataRow row in record.Rows )
+ {
+ par = new MonoQueryParameter( this, schema.CatalogName, schema.SchemaName, schema.Name, row["PARAMETER_NAME"].ToString());
+ par.DataType = StringToDbType( row["DATA_TYPE"].ToString() );
+ par.Type = StringToParamDirection( row["PARAMETER_TYPE"].ToString() );
+
+ if ( par.Type != ParameterDirection.ReturnValue )
+ {
+ list.Add( par );
+ }
+ }
+ }
+ }
+ catch( System.Exception )
+ {
+ list.Add( new MonoQueryNotSupported(this, "" , "", "", "MonoQuerySchemaEnum.ProcedureParameters") );
+ }
+
+ return list;
+ }
+
+
+ protected DbType StringToDbType( string value )
+ {
+ return IntToDbType( int.Parse( value ) );
+ }
+
+ protected DbType IntToDbType( int value )
+ {
+ DbType retValue;
+ switch( value )
+ {
+ case 129 : retValue = DbType.AnsiString; break;
+ //case 1 : retValue = DbType.AnsiStringFixedLength; break;
+ case 128 : retValue = DbType.Binary; break;
+ case 11 : retValue = DbType.Boolean; break;
+ case 17 : retValue = DbType.Byte; break;
+ case 6 : retValue = DbType.Currency; break;
+ case 7 :
+ case 133 : retValue = DbType.Date; break;
+ case 135 : retValue = DbType.DateTime; break;
+ case 14 : retValue = DbType.Decimal; break;
+ case 5 : retValue = DbType.Double; break;
+ case 72 : retValue = DbType.Guid; break;
+ case 2 : retValue = DbType.Int16; break;
+ case 3 : retValue = DbType.Int32; break;
+ case 20 : retValue = DbType.Int64; break;
+ case 12 :
+ case 132 : retValue = DbType.Object; break;
+ case 16 : retValue = DbType.SByte; break;
+ case 4 : retValue = DbType.Single; break;
+ case 130 : retValue = DbType.String; break;
+ case 8 : retValue = DbType.StringFixedLength; break;
+ case 134 : retValue = DbType.Time; break;
+ case 18 : retValue = DbType.UInt16; break;
+ case 19 : retValue = DbType.UInt32; break;
+ case 21 : retValue = DbType.UInt64; break;
+ case 131 : retValue = DbType.VarNumeric; break;
+ default : throw new ArgumentOutOfRangeException("value");
+ }
+
+ return retValue;
+ }
+
+ protected ParameterDirection StringToParamDirection( string value )
+ {
+ return IntToParamDirection( int.Parse( value ) );
+ }
+
+ protected ParameterDirection IntToParamDirection( int value )
+ {
+ ParameterDirection retValue;
+ switch( value )
+ {
+ case 1 : retValue = ParameterDirection.Input; break;
+ case 2 : retValue = ParameterDirection.InputOutput; break;
+ case 3 : retValue = ParameterDirection.Output; break;
+ case 4 : retValue = ParameterDirection.ReturnValue; break;
+ default : throw new ArgumentOutOfRangeException("value");
+
+ }
+
+ return retValue;
+ }
+
+ }
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Connection/Interface/IConnection.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Connection/Interface/IConnection.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Connection/Interface/IConnection.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,222 @@
+namespace MonoQuery.Connection
+{
+ using System.Collections;
+ using MonoQuery.Collections;
+ using MonoQuery.SchemaClass;
+ using System.Data;
+
+ ///<summary>
+ /// This interface is used by any connection wrapper class.
+ ///</summary>
+ public interface IConnection
+ {
+ ///<summary>
+ /// return <c>true</c> if the connection string is invalid.
+ ///</summary>
+ bool IsConnectionStringWrong
+ {
+ get;
+ }
+ ///<summary>Return the connection string.</summary>
+ string ConnectionString{ get; set;}
+
+ ///<summary>Provider'sname.
+ /// </summary>
+ string Provider{ get; }
+
+ ///<summary>
+ /// get the <code>connection</code>'s <code>catalog</code> name.
+ ///</summary>
+ string CatalogName{ get; }
+
+ ///<summary>
+ /// get the <code>connection</code>'s <code>schema</code> name.
+ ///</summary>
+ string SchemaName{ get; }
+
+ ///<summary>
+ /// get the <code>entity</code>'s name
+ ///</summary>
+ string Name{ get; }
+
+ ///<summary>
+ /// <code>entity</code>'s normalized name.
+ /// <example>
+ /// there are a database <code>test</code>. In this database there are a <code>schema</code>
+ /// named <code>fool</code>. In this <code>schema</code> there are a <code>table</code> named <code>fooltable</code>
+ /// and a in this <code>table</code> there are a <code>column</code> named <code>foolcolumn</code>.
+ /// So, the normalized name of the <code>schema</code> is <code>test.[fool]</code>.
+ /// The normalized name of the <code>table</code> is <code>test.[fool].fooltable</code>.
+ /// The normalized name of the <code>column</code> is <code>test.[fool].fooltable.foolcolumn</code>.
+ ///</example>
+ ///</summary>
+ string NormalizedName{ get; }
+
+ ///<summary>
+ /// <returns>
+ /// <code>true</code> if the connection is opened.
+ /// <code>false</code> if the connection is not opened.
+ /// </returns>
+ /// </summary>
+ bool IsOpen{ get; }
+
+ ///<summary>
+ /// Those, are list of the childs schema.( columns, etc etc )
+ /// i am using a dictionnary because is more simplest to write
+ /// <code>Entities["PROCEDURES"]</code> than <code>Entities[0]</code>.
+ ///</summary>
+ MonoQueryListDictionary Entities { get; }
+
+ ///<summary>
+ /// <returns>
+ /// an array of string with the string properties's provider
+ /// </returns>
+ /// <remarks> properties are indexed ans sorted with <see cref=" MonoQuery.SchemaClass.AbstractMonoQueryConnectionWrapper.MonoQueryPropertyEnum">MonoQueryPropertyEnum</see></remarks>
+ /// </summary>
+ object GetProperty( MonoQueryPropertyEnum property );
+
+ ///<summary>
+ /// Open a connection with the <seealso cref='.IConnection.ConnectionString'/>
+ /// <returns>
+ /// <code>true</code> if the connection is opened.
+ /// <code>false</code> if the connection is not opened.
+ /// </returns>
+ /// </summary>
+ bool Open();
+
+ ///<summary>
+ /// Close the connection with the server.
+ /// </summary>
+ void Close();
+
+ ///<summary>
+ /// Refresh child schemas from the database.
+ ///</summary>
+ void Refresh();
+
+ ///<summary>
+ /// Erase all child schemas
+ ///</summary>
+ void Clear();
+
+ ///<summary>
+ /// Execute a SQL command
+ /// <param name="SQLText">
+ /// SQL command to execute
+ /// </param>
+ /// <param name="rows">
+ /// Maximum number of row to extract. If is "0" then all rows are extracted.
+ /// </param>
+ /// <returns> return a <see cref="System.Data.DataTable">DataTable</see>
+ ///or a <see cref="System.Data.DataSet">DataSet</see> object.
+ /// </returns>
+ /// </summary>
+ object ExecuteSQL( string SQLText, int rows );
+
+ ///<summary>
+ /// Execute a stocked procedure.
+ /// <param name="schema">
+ /// <see cref="MonoQuery.SchemaClass">SchemaClass</see> object.
+ /// </param>
+ /// <param name="rows">
+ /// Maximum number of row to extract. If is "0" then all rows are extracted.
+ /// </param>
+ /// <returns> return a <see cref="System.Data.DataTable">DataTable</see>
+ ///or a <see cref="System.Data.DataSet">DataSet</see> object.
+ /// </returns>
+ /// </summary>
+ object ExecuteProcedure( ISchemaClass schema, int rows, MonoQuerySchemaClassCollection parameters );
+
+ ///<summary>
+ /// Extract Data from a Table or a View
+ /// <param name="schema">
+ /// <see cref="MonoQuery.SchemaClass">SchemaClass</see> object.
+ /// </param>
+ /// <param name="rows">
+ /// Maximum number of row to extract. If is "0" then all rows are extracted.
+ /// </param>
+ /// <returns> return a <see cref="System.Data.DataTable">DataTable</see>
+ ///or a <see cref="System.Data.DataSet">DataSet</see> object.
+ /// </returns>
+ /// </summary>
+ object ExtractData( ISchemaClass schema, int rows );
+
+ ///<summary>
+ /// Update <see cref="System.Data.DataRow">row</see>'s fields into the current opened database.
+ /// <param name="row">a <see cref="System.Data.DataRow">row</see> </param>
+ /// <param name="schema"> a <see cref="MonoQuery.SchemaClass.ISchema">schema</see> </param>
+ ///</summary>
+ void UpDateRow( ISchemaClass schema, DataRow row );
+
+ ///<summary>
+ /// Delete <see cref="System.Data.DataRow">row</see> into the current opened database.
+ /// <param name="row">a <see cref="System.Data.DataRow">row</see> </param>
+ /// <param name="schema"> a <see cref="MonoQuery.SchemaClass.ISchema">schema</see> </param>
+ ///</summary>
+ void DeleteRow( ISchemaClass schema, DataRow row );
+
+ ///<summary>
+ /// Insert <see cref="System.Data.DataRow">row</see> into the current opened database.
+ /// <param name="row">a <see cref="System.Data.DataRow">row</see> </param>
+ /// <param name="schema"> a <see cref="MonoQuery.SchemaClass.ISchema">schema</see> </param>
+ ///</summary>
+ void InsertRow( ISchemaClass schema, DataRow row );
+
+
+ ///<summary>
+ /// Get <seealso cref='.ISchemaClass.Connection'/>'s catalogs.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaCatalogs( ISchemaClass schema );
+
+ ///<summary>
+ /// Get <seealso cref='.ISchemaClass.Connection'/>'s Schemas.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaSchemas( ISchemaClass schema );
+
+ ///<summary>
+ /// From a catalog object, get tables from all schemas.
+ /// From a schema object get tables from all this schema.
+ /// From other object, return an empty list.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaTables( ISchemaClass schema );
+
+ ///<summary>
+ /// From a catalog object, get views from all schemas.
+ /// From a schema object get views from all this schema.
+ /// From other object, return an empty list.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaViews( ISchemaClass schema );
+
+ ///<summary>
+ /// From a catalog object, get procedures from all schemas.
+ /// From a schema object get procedures from all this schema.
+ /// From other object, return an empty list.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaProcedures( ISchemaClass schema );
+
+ ///<summary>
+ /// From a table object, get columns from the table.
+ /// From other object, return an empty list.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaTableColumns( ISchemaClass schema );
+
+ ///<summary>
+ /// From a view object, get columns from the view.
+ /// From other object, return an empty list.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaViewColumns( ISchemaClass schema );
+
+ ///<summary>
+ /// From a procedure object , get columns from the procedure.
+ /// From other object, return an empty list.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaProcedureColumns( ISchemaClass schema );
+
+ ///<summary>
+ /// From a procedure object , get parameters from the procedure.
+ /// From other object, return an empty list.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaProcedureParameters( ISchemaClass schema );
+ }
+
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Connection/Mysql/MysqlConnectionWrapper.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Connection/Mysql/MysqlConnectionWrapper.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Connection/Mysql/MysqlConnectionWrapper.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,393 @@
+// MonoQuery - SharpQuery port to MonoDevelop (+ More)
+// Copyright (C) Christian Hergert <chris at mosaix.net>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+using System;
+using System.Collections;
+using System.Data;
+
+using ByteFX.Data.MySqlClient;
+
+using MonoQuery.Collections;
+using MonoQuery.SchemaClass;
+using MonoQuery.Exceptions;
+
+namespace MonoQuery.Connection
+{
+ /// <summary>
+ /// Mysql connection wrapper using the ByteFX mysql driver.
+ /// </summary>
+ public class MysqlConnectionWrapper : AbstractMonoQueryConnectionWrapper
+ {
+ #region // Private Properties
+ /// <summary>
+ /// This property stores whether the current connection string is
+ /// wrong. This helps us determine connection errors for the
+ /// monodevelop user.
+ /// </summary>
+ private bool pIsConnectionStringWrong = false;
+
+ /// <summary>
+ /// Name of class providing the connection. This isnt really used
+ /// and is legacy from the SharpQuery.
+ /// </summary>
+ protected string pProvider = "MysqlConnectionWrapper";
+
+ /// <summary>
+ /// Mysql connection object
+ /// </summary>
+ protected MySqlConnection pConnection = null;
+ #endregion // End Private Properties
+
+ #region // Public Properties
+ /// <summary>
+ /// Name of database
+ /// </summary>
+ public override string Name
+ {
+ get { return "MySQL: " + this.pConnection.Database; }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public override string CatalogName
+ {
+ get
+ {
+ if ( IsOpen == false ) {
+ this.Open();
+ }
+
+ return this.pConnection.Database;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public override string SchemaName {
+ get { return ""; }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public override bool IsOpen
+ {
+ get
+ {
+ try
+ {
+ return ( this.pConnection.State == ConnectionState.Open );
+ }
+ catch ( Exception e )
+ {
+ return false;
+ }
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public override string ConnectionString
+ {
+ get { return this.pConnection.ConnectionString; }
+ set
+ {
+ if ( IsOpen == true ) {
+ pConnection.Close();
+ }
+
+ try
+ {
+ this.pConnection.ConnectionString = value;
+ this.pIsConnectionStringWrong = false;
+ }
+ catch ( MySqlException e )
+ {
+ this.pIsConnectionStringWrong = true;
+ }
+ }
+ }
+ #endregion // End Public Properties
+
+ #region // Constructors
+ /// <summary>
+ /// Default constructor.
+ /// </summary>
+ public MysqlConnectionWrapper()
+ {
+ this.pEntities = new MonoQueryListDictionary();
+ this.pConnection = new MySqlConnection();
+ }
+
+ /// <summary>
+ /// Constructor with connection string
+ /// </summary>
+ public MysqlConnectionWrapper( string connString ) : this()
+ {
+ this.ConnectionString = connString;
+ }
+ #endregion // End Constructors
+
+ #region // Public Methods
+ /// <summary>
+ ///
+ /// </summary>
+ public override bool Open()
+ {
+ this.pConnection.Open();
+ return IsOpen;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public override void Close()
+ {
+ this.pConnection.Close();
+ }
+
+ /// <summary>
+ /// Execute a SQL Statement.
+ /// <returns>System.Data.DataSet</returns>
+ /// </summary>
+ public override object ExecuteSQL( string SQLText, int maxRows )
+ {
+ MySqlCommand command = new MySqlCommand();
+ DataSet ds = new DataSet();
+ MySqlDataAdapter da = new MySqlDataAdapter();
+
+ command.Connection = this.pConnection;
+ command.CommandText = SQLText;
+ command.CommandType = System.Data.CommandType.Text;
+
+ command.Transaction = pConnection.BeginTransaction(
+ System.Data.IsolationLevel.ReadCommitted );
+
+ try
+ {
+ da.SelectCommand = command;
+ if ( maxRows > 0 ) {
+ da.Fill( ds, 0, maxRows, null );
+ } else {
+ da.Fill( ds );
+ }
+ }
+ catch ( MySqlException e )
+ {
+ command.Transaction.Rollback();
+
+ string mes = SQLText + "\n";
+
+ throw new ExecuteSQLException( mes );
+ }
+ catch ( Exception e )
+ {
+ command.Transaction.Rollback();
+ throw new ExecuteSQLException( SQLText );
+ }
+ finally
+ {
+ command.Transaction.Commit();
+ }
+
+ return ds;
+ }
+
+ /// <summary>
+ /// Return settings on this connection.
+ /// </summary>
+ public override object GetProperty( MonoQueryPropertyEnum property )
+ {
+ object returnValues = null;
+
+ switch( property ) {
+ case MonoQueryPropertyEnum.ProviderName:
+ returnValues = this.Provider;
+ break;
+ case MonoQueryPropertyEnum.Catalog:
+ returnValues = this.CatalogName;
+ break;
+ case MonoQueryPropertyEnum.ConnectionString:
+ returnValues = this.ConnectionString;
+ break;
+ case MonoQueryPropertyEnum.DataSource:
+ returnValues = this.pConnection.DataSource;
+ break;
+ default:
+ break;
+ }
+
+ return returnValues;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public override object ExecuteProcedure( ISchemaClass schema, int rows,
+ MonoQuerySchemaClassCollection parameters )
+ {
+ return (object) null;
+ }
+
+ /// <summary>
+ /// This will call the proper method depending on the schema
+ /// that is being asked for.
+ /// </summary>
+ protected override DataTable GetSchema( MonoQuerySchemaEnum schema, object [] restrictions )
+ {
+ DataTable returnValues = new DataTable();
+
+ switch( schema ) {
+ case MonoQuerySchemaEnum.Tables:
+ returnValues = this.GetTables( restrictions );
+ break;
+ case MonoQuerySchemaEnum.Columns:
+ returnValues = this.GetTableColumns( restrictions );
+ break;
+ case MonoQuerySchemaEnum.Views:
+ returnValues = this.GetViews( restrictions );
+ break;
+ case MonoQuerySchemaEnum.ViewColumns:
+ returnValues = this.GetViewColumns( restrictions );
+ break;
+ case MonoQuerySchemaEnum.Procedures:
+ returnValues = this.GetProcedures( restrictions );
+ break;
+ default:
+ break;
+ }
+
+ return returnValues;
+ }
+ #endregion // End Public Methods
+
+ #region // Private Methods
+ /// <summary>
+ /// Retrieve the tables for the currently connected database.
+ /// </summary>
+ protected virtual DataTable GetTables( object [] restrictions )
+ {
+ if ( IsOpen == false )
+ this.Open();
+
+ MySqlCommand command = new MySqlCommand();
+ command.CommandText = "SHOW TABLES";
+ command.Connection = this.pConnection;
+
+ MySqlDataAdapter da = new MySqlDataAdapter();
+ da.SelectCommand = command;
+ DataSet ds = new DataSet();
+ da.Fill( ds );
+
+ ds.Tables[0].Columns[0].ColumnName = "TABLE_NAME";
+
+ // Hack to get around there only being one of the columns in the
+ // select statement.
+ ds.Tables[0].Columns.Add( new DataColumn("TABLE_SCHEMA", typeof(string)) );
+ ds.Tables[0].Columns.Add( new DataColumn("TABLE_CATALOG", typeof(string)) );
+ foreach( DataRow row in ds.Tables[0].Rows ) {
+ row.ItemArray[1] = this.SchemaName;
+ row.ItemArray[2] = this.CatalogName;
+ }
+ // End hack
+
+ return ds.Tables[0];
+ }
+
+ /// <summary>
+ /// MySQL does not support this yet (will in 5.0)
+ /// </summary>
+ protected virtual DataTable GetViews( object [] restrictions )
+ {
+ return new DataTable();
+ }
+
+ /// <summary>
+ /// MySQL does not support this yet (will in 5.0)
+ /// </summary>
+ protected virtual DataTable GetProcedures( object [] restrictions )
+ {
+ return new DataTable();
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ protected virtual DataTable GetTableColumns( object [] restrictions )
+ {
+ if ( IsOpen == false )
+ this.Open();
+
+ MySqlCommand command = new MySqlCommand();
+ command.CommandText = "DESCRIBE " + restrictions[2];
+ command.Connection = this.pConnection;
+
+ MySqlDataAdapter da = new MySqlDataAdapter();
+ da.SelectCommand = command;
+ DataSet ds = new DataSet();
+ da.Fill( ds );
+
+ // Hack: the Collection bullshit requires it to be *named*.
+ ds.Tables[0].Columns[0].ColumnName = "COLUMN_NAME";
+ // End Hack
+
+ return ds.Tables[0];
+ }
+
+ /// <summary>
+ /// MySQL does not support views yet (will in 5.0)
+ /// </summary>
+ protected virtual DataTable GetViewColumns( object [] restrictions )
+ {
+ return new DataTable();
+ }
+
+ /// <summary>
+ /// MySQL does not support procs yet (will in 5.0)
+ /// </summary>
+ protected virtual DataTable GetProcedureColumns( object [] restrictions )
+ {
+ return new DataTable();
+ }
+
+ /// <summary>
+ /// Overridable method for extending class to control what happens on
+ /// a connection refresh.
+ /// </summary>
+ protected override void OnRefresh()
+ {
+ if (this.pEntities != null )
+ {
+ this.pEntities.Add( "TABLES", new MonoQuerySchemaClassCollection( new ISchemaClass[] { new MonoQueryTables(this, this.CatalogName, this.SchemaName, this.Name, "TABLES") } ) );
+
+ // Not yet supported
+ //this.pEntities.Add( "VIEWS", new MonoQuerySchemaClassCollection( new ISchemaClass[] { new MonoQueryViews( this, this.CatalogName, this.SchemaName, this.Name, "VIEWS" ) } ) );
+ //this.pEntities.Add( "PROCEDURES", new MonoQuerySchemaClassCollection( new ISchemaClass[] { new MonoQueryProcedures( this, this.CatalogName, this.SchemaName, this.Name, "PROCEDURES" ) } ) );
+ }
+ }
+
+ protected override void CheckConnectionObject()
+ {
+ if ( this.pConnection == null )
+ throw new Exception("Bad connection object");
+ }
+ #endregion // End Private Methods
+ }
+}
\ No newline at end of file
Added: trunk/MonoDevelop/Extras/MonoQuery/Connection/Npgsql/NpgsqlConnectionWrapper.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Connection/Npgsql/NpgsqlConnectionWrapper.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Connection/Npgsql/NpgsqlConnectionWrapper.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,521 @@
+// MonoQuery - SharpQuery port to MonoDevelop (+ More)
+// Copyright (C) Christian Hergert <chris at mosaix.net>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+using System;
+using System.Collections;
+using System.Data;
+
+using Npgsql;
+
+using MonoQuery.Collections;
+using MonoQuery.SchemaClass;
+using MonoQuery.Exceptions;
+
+namespace MonoQuery.Connection
+{
+ public class NpgsqlConnectionWrapper : AbstractMonoQueryConnectionWrapper //IConnection
+ {
+ #region // Private Properties
+ /// <summary>
+ /// This property stores whether the current connection string is
+ /// wrong. This helps us determine connection errors for the
+ /// monodevelop user.
+ /// </summary>
+ private bool pIsConnectionStringWrong = false;
+
+ /// <summary>
+ /// Name of class providing the connection.
+ /// </summary>
+ protected string pProvider = "NpgsqlConnectionWrapper";
+
+ /// <summary>
+ /// Npgsql Connection object
+ /// </summary>
+ protected NpgsqlConnection pConnection = null;
+
+ /// <summary>
+ /// Child entities of this connection.
+ /// </summary>
+// protected MonoQueryListDictionary pEntities = null;
+ #endregion // End Private Properties
+
+ #region // Public Properties
+ /// <summary>
+ ///
+ /// </summary>
+ public override string Name
+ {
+ get
+ {
+ return "Npgsql: " + this.pConnection.Database;
+ }
+ }
+
+ public override bool IsOpen
+ {
+ get
+ {
+ return (this.pConnection.State == ConnectionState.Open);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public override string CatalogName
+ {
+ get
+ {
+ if ( IsOpen == false ) {
+ this.Open();
+ }
+
+ return this.pConnection.Database;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public override string SchemaName
+ {
+ get { return "public"; } // we should fix this =X
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public override string ConnectionString
+ {
+ get { return this.pConnection.ConnectionString; }
+ set
+ {
+ if ( IsOpen == true ) {
+ pConnection.Close();
+ }
+
+ try
+ {
+ this.pConnection.ConnectionString = value;
+ this.pIsConnectionStringWrong = false;
+ }
+ catch ( NpgsqlException )
+ {
+ this.pIsConnectionStringWrong = true;
+ }
+ }
+ }
+
+ /// <summary>
+ /// The LastSystemOID is the last internal OID used by postgresql.
+ /// Since this number changes from release to release, this can
+ /// can be a fucking nightmare.
+ /// </summary>
+ protected virtual string LastSystemOID
+ {
+ get
+ {
+ if ( IsOpen != true ) Open();
+
+ string retval = "";
+ String version = pConnection.ServerVersion.ToString();
+ switch( version.Substring(0,3) ) { // Get Major Version
+ case "7.4":
+ retval = "17137";
+ break;
+ case "7.3":
+ retval = "16974";
+ break;
+ case "7.2":
+ retval = "16554";
+ break;
+ case "7.1":
+ retval = "18539";
+ break;
+ default:
+ retval = "17137";
+ break;
+ }
+
+ return retval;
+ }
+ }
+ #endregion // End Public Properties
+
+ #region // Constructors
+ /// <summary>
+ /// Default constructor.
+ /// </summary>
+ public NpgsqlConnectionWrapper()
+ {
+ this.pEntities = new MonoQueryListDictionary();
+ this.pConnection = new NpgsqlConnection();
+ }
+
+ /// <summary>
+ /// Constructor with connstring support.
+ /// </summary>
+ public NpgsqlConnectionWrapper( string connectionString )
+ : this ()
+ {
+ this.ConnectionString = connectionString;
+ }
+ #endregion // End Constructors
+
+ #region // Public Methods
+ /// <summary>
+ /// Open connection to the database server.
+ /// </summary>
+ public override bool Open()
+ {
+ try
+ {
+ if ( this.pConnection != null ) {
+ this.pConnection.Open();
+ }
+ }
+ catch ( Exception err )
+ {
+ throw ( new OpenConnectionException( this.ConnectionString ) );
+ }
+
+ return ( this.IsOpen );
+ }
+
+ /// <summary>
+ /// Close database connection
+ /// </summary>
+ public override void Close()
+ {
+ if ( this.pConnection != null ) {
+ this.pConnection.Close();
+ }
+ }
+
+ /// <summary>
+ /// Execute a SQL Statement.
+ /// <returns>System.Data.DataSet</returns>
+ /// </summary>
+ public override object ExecuteSQL( string SQLText, int maxRows )
+ {
+ NpgsqlCommand command = new NpgsqlCommand();
+ DataSet returnValues = new DataSet();
+ NpgsqlDataAdapter da = new NpgsqlDataAdapter();
+
+ command.Connection = this.pConnection;
+ command.CommandText = SQLText;
+ command.CommandType = System.Data.CommandType.Text;
+
+ command.Transaction = pConnection.BeginTransaction(
+ System.Data.IsolationLevel.ReadCommitted );
+
+ try
+ {
+ da.SelectCommand = command;
+ if ( maxRows > 0 ) {
+ da.Fill( returnValues, 0, maxRows, null );
+ } else {
+ da.Fill( returnValues );
+ }
+ }
+ catch ( NpgsqlException e )
+ {
+ command.Transaction.Rollback();
+
+ string mes = SQLText + "\n";
+
+ foreach ( NpgsqlError err in e.Errors )
+ {
+ mes += "-----------------\n";
+ mes += err.Message + "\n";
+ mes += err.Hint + "\n";
+ }
+ throw new ExecuteSQLException( mes );
+ }
+ catch ( Exception e )
+ {
+ command.Transaction.Rollback();
+ throw new ExecuteSQLException( SQLText );
+ }
+ finally
+ {
+ command.Transaction.Commit();
+ }
+
+ return returnValues;
+ }
+
+ /// <summary>
+ /// This will call the proper method depending on the schema
+ /// that is being asked for.
+ /// </summary>
+ protected override DataTable GetSchema( MonoQuerySchemaEnum schema, object [] restrictions )
+ {
+ DataTable returnValues = new DataTable();
+
+ switch( schema ) {
+ case MonoQuerySchemaEnum.Tables:
+ returnValues = this.GetTables( restrictions );
+ break;
+ case MonoQuerySchemaEnum.Columns:
+ returnValues = this.GetTableColumns( restrictions );
+ break;
+ case MonoQuerySchemaEnum.Views:
+ returnValues = this.GetViews( restrictions );
+ break;
+ case MonoQuerySchemaEnum.ViewColumns:
+ returnValues = this.GetViewColumns( restrictions );
+ break;
+ case MonoQuerySchemaEnum.Procedures:
+ returnValues = this.GetProcedures( restrictions );
+ break;
+ default:
+ break;
+ }
+
+ return returnValues;
+ }
+
+ /// <summary>
+ /// Return settings on this connection.
+ /// </summary>
+ public override object GetProperty( MonoQueryPropertyEnum property )
+ {
+ object returnValues = null;
+
+ switch( property ) {
+ case MonoQueryPropertyEnum.ProviderName:
+ returnValues = this.Provider;
+ break;
+ case MonoQueryPropertyEnum.Catalog:
+ returnValues = this.CatalogName;
+ break;
+ case MonoQueryPropertyEnum.ConnectionString:
+ returnValues = this.ConnectionString;
+ break;
+ default:
+ break;
+ }
+
+ return returnValues;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public override object ExecuteProcedure( ISchemaClass schema, int rows,
+ MonoQuerySchemaClassCollection parameters )
+ {
+ return (object) null;
+ }
+ #endregion // End Public Methods
+
+ #region // Private Methods
+ /// <summary>
+ /// This method will get the tables from the server where
+ /// restrictions match. This should work for all versions of postgresql
+ /// that i am aware of. (7.1+)
+ /// </summary>
+ protected virtual DataTable GetTables( object [] restrictions )
+ {
+ if ( IsOpen == false ) {
+ this.Open();
+ }
+
+ string commandText = "SELECT NULL AS TABLE_SCHEMA, c.relname AS TABLE_NAME, "
+ + "'" + this.CatalogName + "' AS TABLE_CATALOG "
+ + "FROM pg_class c "
+ + "WHERE c.relkind='r' "
+ + "AND NOT EXISTS (SELECT 1 FROM pg_rewrite r WHERE r.ev_class = c.oid AND r.ev_type = '1') "
+ + "AND c.relname NOT LIKE 'pg\\_%' "
+ + "AND c.relname NOT LIKE 'sql\\_%' "
+ + "ORDER BY relname;";
+
+ NpgsqlCommand command = new NpgsqlCommand( commandText, this.pConnection );
+ NpgsqlDataAdapter adapter = new NpgsqlDataAdapter();
+ adapter.SelectCommand = command;
+ DataSet ds = new DataSet();
+ adapter.Fill( ds );
+
+ return ds.Tables[0];
+ }
+
+ /// <summary>
+ /// This method will get our views from the current catalog. should work
+ /// on postgres 7.1+ (havent checked 8.0 series)
+ /// </summary>
+ protected virtual DataTable GetViews( object [] restrictions )
+ {
+ if ( IsOpen == false ) {
+ this.Open();
+ }
+
+ string commandText = "SELECT c.relname AS TABLE_NAME, "
+ + "'" + this.CatalogName + "' AS TABLE_CATALOG, "
+ + "n.nspname AS TABLE_SCHEMA "
+ + "FROM pg_catalog.pg_class c "
+ + "LEFT JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) "
+ + "WHERE (c.relkind = 'v'::\"char\") "
+ + "AND n.nspname NOT IN ('information_schema', 'pg_catalog', 'pg_toast') "
+ + "ORDER BY TABLE_NAME;";
+
+ NpgsqlCommand command = new NpgsqlCommand( commandText, this.pConnection );
+ NpgsqlDataAdapter adapter = new NpgsqlDataAdapter();
+ adapter.SelectCommand = command;
+ DataSet ds = new DataSet();
+ adapter.Fill( ds );
+
+ return ds.Tables[0];
+ }
+
+ /// <summary>
+ /// This will get a list of procedures from the current database.
+ /// It requires that LastSystemOID is properly set for server
+ /// version.
+ /// </summary>
+ protected virtual DataTable GetProcedures( object [] restrictions )
+ {
+ if ( this.IsOpen == false ) {
+ this.Open();
+ }
+
+ string commandText = "SELECT "
+ + "proname AS PROCEDURE_NAME, "
+ + "'" + this.CatalogName + "' AS PROCEDURE_CATALOG, "
+ + "'" + this.SchemaName + "' AS PROCEDURE_SCHEMA "
+ + "FROM "
+ + "pg_proc pc, pg_user pu, pg_type pt "
+ + "WHERE "
+ + "pc.proowner = pu.usesysid "
+ + "AND pc.prorettype = pt.oid "
+ + "AND pc.oid > '" + this.LastSystemOID + "'::oid "
+ + "UNION "
+ + "SELECT "
+ + "proname AS PROCEDURE_NAME, "
+ + "'" + this.CatalogName + "' AS PROCEDURE_CATALOG, "
+ + "'" + this.SchemaName + "' AS PROCEDURE_SCHEMA "
+ + "FROM "
+ + "pg_proc pc, pg_user pu, pg_type pt "
+ + "WHERE "
+ + "pc.proowner = pu.usesysid "
+ + "AND pc.prorettype = 0 "
+ + "AND pc.oid > '" + this.LastSystemOID + "'::oid "
+ + "ORDER BY "
+ + "PROCEDURE_NAME;";
+
+ NpgsqlCommand command = new NpgsqlCommand( commandText, this.pConnection );
+ NpgsqlDataAdapter adapter = new NpgsqlDataAdapter();
+ adapter.SelectCommand = command;
+ DataSet ds = new DataSet();
+ adapter.Fill( ds );
+
+ return ds.Tables[0];
+ }
+
+ /// <summary>
+ /// This method will get the columns for a table.
+ /// </summary>
+ protected virtual DataTable GetTableColumns( object [] restrictions )
+ {
+ if ( !IsOpen ) this.Open();
+
+ DataSet ds = new DataSet();
+ string commandText = "SELECT a.attname AS COLUMN_NAME "
+ + "FROM "
+ + " pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_attrdef adef "
+ + " ON a.attrelid=adef.adrelid "
+ + " AND a.attnum=adef.adnum "
+ + " LEFT JOIN pg_catalog.pg_type t ON a.atttypid=t.oid "
+ + "WHERE "
+ + " a.attrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='" + restrictions[2].ToString() + "') "
+ + " AND a.attnum > 0 AND NOT a.attisdropped "
+ + " ORDER BY a.attnum;";
+ NpgsqlCommand command = new NpgsqlCommand( commandText, this.pConnection );
+ NpgsqlDataAdapter da = new NpgsqlDataAdapter();
+ da.SelectCommand = command;
+ da.Fill( ds );
+
+ return ds.Tables[0];
+ }
+
+ /// <summary>
+ /// Get the columns associated with a view.
+ /// </summary>
+ protected virtual DataTable GetViewColumns( object [] restrictions )
+ {
+ if ( IsOpen == false ) {
+ this.Open();
+ }
+
+ DataSet ds = new DataSet();
+ string commandText = "SELECT a.attname AS COLUMN_NAME "
+ + "FROM "
+ + " pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_attrdef adef "
+ + " ON a.attrelid=adef.adrelid "
+ + " AND a.attnum=adef.adnum "
+ + " LEFT JOIN pg_catalog.pg_type t ON a.atttypid=t.oid "
+ + "WHERE "
+ + " a.attrelid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='"
+ + restrictions[2].ToString() + "') "
+ + " AND a.attnum > 0 AND NOT a.attisdropped "
+ + " ORDER BY a.attnum;";
+ NpgsqlCommand command = new NpgsqlCommand( commandText, this.pConnection );
+ NpgsqlDataAdapter da = new NpgsqlDataAdapter();
+ da.SelectCommand = command;
+ da.Fill( ds );
+
+ return ds.Tables[0];
+ }
+
+ /// <summary>
+ /// This method will get a table filled with the returning columns
+ /// for a procedure.
+ /// </summary>
+ protected virtual DataTable GetProcedureColumns( object [] restrictions )
+ {
+ if ( IsOpen == false ) {
+ this.Open();
+ }
+
+ // Get procedures OID
+ // FIXME:
+ int oid = 0;
+
+ DataSet ds = new DataSet();
+ string commandText = "SELECT "
+ + "format_type(prorettype, NULL) as COLUMN_NAME, "
+ + "FROM "
+ + "pg_catalog.pg_proc pc, pg_catalog.pg_language pl "
+ + "WHERE "
+ + "pc.oid = '" + oid + "'::oid "
+ + "AND pc.prolang = pl.oid";
+ NpgsqlCommand command = new NpgsqlCommand( commandText, this.pConnection );
+ NpgsqlDataAdapter da = new NpgsqlDataAdapter();
+ da.SelectCommand = command;
+ da.Fill( ds );
+
+ return ds.Tables[0];
+ }
+
+ protected override void CheckConnectionObject()
+ {
+ if ( this.pConnection == null )
+ throw new Exception("Bad connection object");
+ }
+ #endregion // End Private Methods
+ }
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Exceptions/Abstract/MonoQueryAbstractException.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Exceptions/Abstract/MonoQueryAbstractException.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Exceptions/Abstract/MonoQueryAbstractException.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,15 @@
+using System;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+
+using MonoQuery.SchemaClass;
+
+namespace MonoQuery.Exceptions
+{
+ public abstract class MonoQueryAbstractException : Exception
+ {
+
+ }
+
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Exceptions/ConnectionStringException.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Exceptions/ConnectionStringException.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Exceptions/ConnectionStringException.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,36 @@
+using System;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+
+using MonoQuery.SchemaClass;
+
+namespace MonoQuery.Exceptions
+{
+ public class ConnectionStringException : Exception
+ {
+ public ConnectionStringException( ) : base( GettextCatalog.GetString( "Wrong Connection String" ) )
+ {
+ }
+
+ public ConnectionStringException( ISchemaClass schema ) : base( GettextCatalog.GetString( "Wrong Connection String" )
+ + "\n\r"
+ + "-----------------"
+ + "\n\r"
+ + "(" + schema.Connection.ConnectionString + ")"
+ + "\n\r"
+ + "(" + schema.Connection.Name + ")"
+ )
+ {
+ }
+
+ public ConnectionStringException( string message ) : base( GettextCatalog.GetString( "Wrong Connection String" )
+ + "\n\r"
+ + "-----------------"
+ + "\n\r"
+ + message )
+ {
+ }
+ }
+
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Exceptions/ExecuteProcedureException.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Exceptions/ExecuteProcedureException.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Exceptions/ExecuteProcedureException.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,36 @@
+using System;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+
+using MonoQuery.SchemaClass;
+
+namespace MonoQuery.Exceptions
+{
+ public class ExecuteProcedureException : Exception
+ {
+ public ExecuteProcedureException( ) : base( GettextCatalog.GetString( "Procedure Exception" ) )
+ {
+ }
+
+ public ExecuteProcedureException( ISchemaClass schema ) : base( GettextCatalog.GetString( "Procedure Exception" )
+ + "\n\r"
+ + "-----------------"
+ + "\n\r"
+ + "(" + schema.Connection.ConnectionString + ")"
+ + "\n\r"
+ + "(" + schema.Connection.Name + ")"
+ )
+ {
+ }
+
+ public ExecuteProcedureException( string message ) : base( GettextCatalog.GetString( "Procedure Exception" )
+ + "\n\r"
+ + "-----------------"
+ + "\n\r"
+ + message )
+ {
+ }
+ }
+
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Exceptions/ExecuteSQLException.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Exceptions/ExecuteSQLException.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Exceptions/ExecuteSQLException.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,38 @@
+using System;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+
+using MonoQuery.SchemaClass;
+
+namespace MonoQuery.Exceptions
+{
+ public class ExecuteSQLException : Exception
+ {
+
+ public ExecuteSQLException( ) : base( GettextCatalog.GetString( "SQL Exception" ) )
+ {
+ }
+
+ public ExecuteSQLException( ISchemaClass schema ) : base( GettextCatalog.GetString( "SQL Exception" )
+ + "\n\r"
+ + "-----------------"
+ + "\n\r"
+ + "(" + schema.Connection.ConnectionString + ")"
+ + "\n\r"
+ + "(" + schema.Connection.Name + ")"
+ )
+ {
+ }
+
+ public ExecuteSQLException( string message ) : base( GettextCatalog.GetString( "SQL Exception" )
+ + "\n\r"
+ + "-----------------"
+ + "\n\r"
+ + message )
+ {
+ }
+
+ }
+
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Exceptions/OpenConnectionException.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Exceptions/OpenConnectionException.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Exceptions/OpenConnectionException.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,39 @@
+using System;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+
+using MonoQuery.SchemaClass;
+
+
+namespace MonoQuery.Exceptions
+{
+ public class OpenConnectionException : Exception
+ {
+ public OpenConnectionException( ) : base( GettextCatalog.GetString( "Open Error" ) )
+ {
+ }
+
+ public OpenConnectionException( ISchemaClass schema ) : base( GettextCatalog.GetString( "Open Error" )
+ + "\n\r"
+ + "-----------------"
+ + "\n\r"
+ + "(" + schema.Connection.ConnectionString + ")"
+ + "\n\r"
+ + "(" + schema.Connection.Name + ")"
+ )
+ {
+ }
+
+ public OpenConnectionException( string message ) : base( GettextCatalog.GetString( "Open Error" )
+ + "\n\r"
+ + "-----------------"
+ + "\n\r"
+ + message )
+ {
+ }
+
+
+ }
+
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Gui/Abstract/AbstractMonoQueryNode.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Gui/Abstract/AbstractMonoQueryNode.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Gui/Abstract/AbstractMonoQueryNode.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,297 @@
+
+namespace MonoQuery.Gui.TreeView
+{
+ using System;
+ using System.Reflection;
+ using System.Collections;
+ using System.Data;
+ using System.ComponentModel;
+
+ using MonoQuery.Collections;
+ using MonoDevelop.Core.Services;
+ using MonoDevelop.Services;
+ using MonoDevelop.Gui;
+ using MonoDevelop.Core.AddIns.Conditions;
+ using MonoDevelop.Core.AddIns.Codons;
+ using MonoDevelop.Core.AddIns;
+ using MonoDevelop.Gui.Widgets;
+
+ using MonoQuery.SchemaClass;
+ using MonoQuery.Connection;
+ using MonoQuery.Gui.DataView;
+ using MonoQuery.Exceptions;
+ using MonoQuery.Codons;
+ using MonoQuery.Services;
+
+ public abstract class AbstractMonoQueryNode : TreeNode, IMonoQueryNode
+ {
+ internal static SQLParameterInput inputform = null;
+
+ ///<summary>
+ /// this variable force to have a "plus" near the node.
+ /// </summary>
+ public static StringParserService stringParserService = stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+ protected Assembly ass = null;
+
+ protected ISchemaClass pSchemaClass = null;
+
+ ///<summary> force to displayed a "+" for the node</summary>
+ protected virtual bool NullChildAllowed
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ public virtual string AddinContextMenu {
+ get{
+ return "";
+ }
+ }
+
+ public virtual string entityNormalizedName
+ {
+ get
+ {
+ if ( this.SchemaClass != null )
+ {
+ return AbstractMonoQuerySchemaClass.RemoveBracket( this.SchemaClass.NormalizedName );
+ }
+ else
+ {
+ return "";
+ }
+ }
+ }
+
+ public virtual string entityName
+ {
+ get
+ {
+ if ( this.SchemaClass != null )
+ {
+ return this.SchemaClass.InternalName;
+ }
+ else
+ {
+ return "";
+ }
+ }
+ }
+
+ public ISchemaClass SchemaClass{
+ get
+ {
+ if ( this.pSchemaClass != null )
+ {
+ return this.pSchemaClass;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ public virtual IConnection Connection{
+ get
+ {
+ if ( this.SchemaClass != null )
+ {
+ return this.SchemaClass.Connection;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ public virtual MonoQueryListDictionary Entities {
+ get{
+ if ( this.SchemaClass != null )
+ {
+ return this.SchemaClass.Entities;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ public AbstractMonoQueryNode() : base()
+ {
+ ass = System.Reflection.Assembly.GetExecutingAssembly();
+ }
+
+ public AbstractMonoQueryNode(ISchemaClass schemaclass) : this()
+ {
+ this.pSchemaClass = schemaclass;
+ }
+
+ ///<summary>
+ /// called by <see cref=".Refresh()">Refresh</see> just after the <see cref=".Clear()">Clear</see> and before <see cref=".Refresh()">childs'refresh</see>.
+ /// In this, you could change the <see cref=".Entities">Entities dicntionnary.</see>
+ ///</summary>
+ protected virtual void OnRefresh()
+ {
+ // Nothing !
+ }
+
+ public virtual void Refresh()
+ {
+ try
+ {
+ if ( this.TreeView != null )
+ {
+ this.TreeView.BeginUpdate();
+ }
+
+ this.Clear();
+
+ this.OnRefresh();
+
+ if ( this.Connection.IsOpen )
+ {
+ this.Text = this.entityName;
+
+// if ( this.IsExpanded == true )
+// {
+ if ( this.SchemaClass != null )
+ {
+ this.SchemaClass.Refresh();
+ }
+ this.BuildsChilds();
+// }
+ }
+ }
+ finally
+ {
+ if ( this.TreeView != null )
+ {
+ this.TreeView.EndUpdate();
+ }
+ }
+ }
+
+ public virtual void Clear()
+ {
+ if ( this.SchemaClass != null )
+ {
+ this.SchemaClass.Clear();
+ }
+
+ if ( SchemaClass != null )
+
+ this.Nodes.Clear();
+
+ if ( ( this.IsExpanded == false ) && (this.NullChildAllowed == true) )
+ {
+ this.Nodes.Add( new TreeNode() );
+ }
+ }
+
+ ///<summary>
+ /// allow the user to add some parameters while executing an SQL command
+ /// </summary>
+ protected virtual MonoQuerySchemaClassCollection OnExecute( CancelEventArgs e )
+ {
+ return null;
+ }
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// </summary>
+ public void Execute( int rows )
+ {
+ try
+ {
+ if ( this.SchemaClass != null )
+ {
+ CancelEventArgs e = new CancelEventArgs();
+ MonoQuerySchemaClassCollection ret = this.OnExecute( e );
+ if ( e.Cancel == false )
+ {
+ WorkbenchSingleton.Workbench.ShowView( new MonoQueryDataView( this.SchemaClass, rows, ret ) );
+ }
+ }
+ }
+ catch( Exception e)
+ {
+ IMessageService messageService =(IMessageService)ServiceManager.GetService(typeof(IMessageService));
+ messageService.ShowError( e.Message );
+ }
+ }
+
+ public virtual void BuildsChilds()
+ {
+ string childclass = "";
+ IMonoQueryNode ChildNode = null;
+
+ if ( this.Entities != null )
+ {
+ this.Nodes.Clear();
+
+ foreach( DictionaryEntry DicEntry in this.Entities )
+ {
+ if ( DicEntry.Value != null)
+ {
+ CollectionBase entitieslist = DicEntry.Value as CollectionBase;
+
+ foreach ( ISchemaClass entity in entitieslist )
+ {
+ childclass = MonoQueryTree.SchemaClassDict[ entity.GetType().FullName ];
+ if ( ( childclass != null) && (childclass != "") )
+ {
+ ChildNode = (IMonoQueryNode)ass.CreateInstance(childclass, false, BindingFlags.CreateInstance, null, new object[] {entity}, null, null);
+ if ( ChildNode != null )
+ {
+ bool addNode = true;
+
+ if ( ChildNode is MonoQueryNodeNotSupported )
+ {
+ addNode = this.ShowUnsupported();
+ }
+ if ( addNode == true )
+ {
+ this.Nodes.Add( ChildNode as TreeNode );
+ ChildNode.Refresh();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected bool ShowUnsupported()
+ {
+ IAddInTreeNode AddinNode;
+ bool ret = true;
+
+ AddinNode = (IAddInTreeNode)AddInTreeSingleton.AddInTree.GetTreeNode("/MonoQuery/Connection");
+ foreach ( DictionaryEntry entryChild in AddinNode.ChildNodes)
+ {
+ IAddInTreeNode ChildNode = entryChild.Value as IAddInTreeNode;
+ if ( ChildNode != null )
+ {
+ MonoQueryConnectionCodon codon = ChildNode.Codon as MonoQueryConnectionCodon;
+ if ( codon != null )
+ {
+ if ( codon.Node == this.GetType().FullName )
+ {
+ ret = bool.Parse( codon.ShowUnsuported );
+ }
+ }
+ }
+ }
+
+ return ret;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/MonoDevelop/Extras/MonoQuery/Gui/DataView/MonoQueryDataView.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Gui/DataView/MonoQueryDataView.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Gui/DataView/MonoQueryDataView.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,225 @@
+
+using System;
+using System.Data;
+//using System.Windows.Forms;
+using MonoDevelop.Gui;
+using MonoQuery.SchemaClass;
+using MonoQuery.Collections;
+using MonoDevelop.Gui.Widgets;
+
+namespace MonoQuery.Gui.DataView
+{
+ /// <summary>
+ /// Description of the view content
+ /// </summary>
+ public class MonoQueryDataView : AbstractViewContent
+ {
+ DataGrid pDataGrid;
+ ISchemaClass pSchema;
+
+#region AbstractViewContent requirements
+ /// <summary>
+ /// The <see cref="System.Windows.Forms.Control"/> representing the view
+ /// </summary>
+ ///
+ public override Gtk.Widget Control {
+ get {
+ return this.pDataGrid;
+ }
+ }
+
+ /// <summary>
+ /// Creates a new MyView object
+ /// </summary>
+ public MonoQueryDataView( ISchemaClass entity, int lines, MonoQuerySchemaClassCollection parameters )
+ {
+ if ( entity == null )
+ {
+ throw new ArgumentNullException("entity");
+ }
+
+ this.ContentName = MonoQuery.SchemaClass.AbstractMonoQuerySchemaClass.RemoveBracket( entity.NormalizedName );
+
+ this.pDataGrid = new DataGrid();
+
+// this.pDataGrid.CaptionVisible = true;
+ this.pDataGrid.DataMember = "";
+// this.pDataGrid.Dock = System.Windows.Forms.DockStyle.Fill;
+// this.pDataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
+// this.pDataGrid.Location = new System.Drawing.Point(0, 0);
+ this.pDataGrid.Name = "dataGrid";
+// this.pDataGrid.Size = new System.Drawing.Size(292, 266);
+// this.pDataGrid.TabIndex = 0;
+ this.Schema = entity;
+ this.Datatable = this.Schema.Execute( lines, parameters );
+// if ( this.Datatable == null )
+// {
+// WorkbenchSingleton.Workbench.ViewContentCollection.Remove( this );
+// }
+ }
+
+ /// <summary>
+ /// Loads a new file into MyView
+ /// </summary>
+ public override void Load(string fileName)
+ {
+ // TODO
+ throw new System.NotImplementedException();
+ }
+
+ /// <summary>
+ /// Refreshes the view
+ /// </summary>
+ public override void RedrawContent()
+ {
+ // TODO: Refresh the whole view control here, renew all resource strings whatever
+ // Note that you do not need to recreate the control.
+ }
+
+ /// <summary>
+ /// Cleans up all used resources
+ /// </summary>
+ public override void Dispose()
+ {
+ // TODO: Clean up resources in this method
+ Control.Dispose();
+ }
+#endregion
+
+ public ISchemaClass Schema
+ {
+ get
+ {
+ return this.pSchema;
+ }
+ set
+ {
+ this.pSchema = value;
+ }
+ }
+
+ ///<summary>
+ /// <see cref="System.Data.DataTable">DataTable</see> to display in the
+ /// <see cref="System.Windows.Forms.DataGrid">DataGrid</see>
+ /// </summary>
+ public object Datatable
+ {
+ get
+ {
+ return this.pDataGrid.DataSource;
+ }
+
+ set
+ {
+ removeChangedHandler();
+
+ this.pDataGrid.DataSource = value;
+ this.pDataGrid.DataMember = null;
+// this.pDataGrid.AllowNavigation = true;
+
+ DataSet dataset = this.pDataGrid.DataSource as DataSet;
+
+ if ( dataset != null )
+ {
+ if ( dataset.Tables.Count == 1 )
+ {
+ this.pDataGrid.DataMember = dataset.Tables[0].TableName;
+// this.pDataGrid.AllowNavigation = false;
+ this.pDataGrid.DataBind();
+ }
+ }
+
+ addChangedHandler();
+ }
+ }
+
+ private void removeChangedHandler()
+ {
+ if ( this.pDataGrid.DataSource != null )
+ {
+ DataSet dataset = this.pDataGrid.DataSource as DataSet;
+
+ if ( dataset != null )
+ {
+ foreach( DataTable table in dataset.Tables )
+ {
+ table.RowChanged -= new DataRowChangeEventHandler( this.UpdateTable );
+ table.RowDeleted -= new DataRowChangeEventHandler( this.DeleteRow );
+ }
+ }
+ else
+ {
+ ( this.pDataGrid.DataSource as DataTable).RowChanged -= new DataRowChangeEventHandler( this.UpdateTable );
+ ( this.pDataGrid.DataSource as DataTable).RowDeleted -= new DataRowChangeEventHandler( this.DeleteRow );
+ }
+ }
+ }
+
+ private void addChangedHandler()
+ {
+ if ( this.pDataGrid.DataSource != null )
+ {
+ DataSet dataset = this.pDataGrid.DataSource as DataSet;
+
+ if ( dataset != null )
+ {
+ foreach( DataTable table in dataset.Tables )
+ {
+ table.RowChanged += new DataRowChangeEventHandler( this.UpdateTable );
+ table.RowDeleted += new DataRowChangeEventHandler( this.DeleteRow );
+ }
+ }
+ else
+ {
+ ( this.pDataGrid.DataSource as DataTable).RowChanged += new DataRowChangeEventHandler( this.UpdateTable );
+ ( this.pDataGrid.DataSource as DataTable).RowDeleted += new DataRowChangeEventHandler( this.DeleteRow );
+ }
+ }
+ }
+
+ public void UpdateTable( object sender, DataRowChangeEventArgs e)
+ {
+ if ( Datatable != null )
+ {
+ switch ( e.Action )
+ {
+ case DataRowAction.Add:
+ this.Schema.Connection.InsertRow( this.Schema, e.Row );
+ break;
+ case DataRowAction.Change:
+ this.Schema.Connection.UpDateRow( this.Schema, e.Row );
+ break;
+ }
+ }
+ }
+
+ public void DeleteRow( object sender, DataRowChangeEventArgs e )
+ {
+ switch ( e.Action )
+ {
+ case DataRowAction.Delete:
+ this.Schema.Connection.DeleteRow( this.Schema, e.Row );
+ break;
+ }
+
+ }
+
+ public override void Save(string fileName)
+ {
+ DataSet dataset = this.pDataGrid.DataSource as DataSet;
+ if ( dataset == null )
+ {
+ DataTable dataTable = this.pDataGrid.DataSource as DataTable;
+ if ( dataTable != null )
+ {
+ dataset = new DataSet();
+ dataset.Tables.Add( dataTable );
+ }
+ }
+
+ dataset. WriteXml( fileName );
+ }
+
+ }
+
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Gui/DataView/SQLParameterInput.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Gui/DataView/SQLParameterInput.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Gui/DataView/SQLParameterInput.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,71 @@
+using System;
+using System.Data;
+using System.Data.OleDb;
+using System.ComponentModel;
+
+using MonoDevelop.Gui;
+using MonoDevelop.Gui.Widgets;
+using MonoDevelop.Core.Services;
+
+using MonoQuery.SchemaClass;
+using MonoQuery.Collections;
+
+namespace MonoQuery.Gui.DataView
+{
+ public class SQLParameterInput //: XmlForm
+ {
+ private DataGrid _dataGrid = null;
+
+ public DataGrid dataGrid
+ {
+ get
+ {
+ if ( this._dataGrid == null )
+ {
+// this._dataGrid = this.ControlDictionary["dataGrid"] as DataGrid;
+ }
+ return this._dataGrid;
+ }
+ }
+
+ private void ResetClick( object sender, EventArgs e )
+ {
+
+ }
+
+ protected void FillParameters( MonoQueryParameterCollection parameters )
+ {
+ MonoQueryParameter par = null;
+ for( int i = 0; i < parameters.Count; i++)
+ {
+ par = parameters[i];
+ if ( par.Type == ParameterDirection.ReturnValue )
+ {
+ i--;
+ parameters.Remove( par );
+ }
+ }
+// this.dataGrid.CaptionVisible = true;
+ this.dataGrid.DataSource = parameters;
+ this.dataGrid.DataMember = null;
+// this.dataGrid.AllowNavigation = false;
+ }
+
+// static PropertyService propertyService = (PropertyService)ServiceManager.GetService(typeof(PropertyService));
+// public SQLParameterInput() : base(propertyService.DataDirectory + @"\resources\dialogs\MonoQuery\SqlParametersInput.xfrm")
+// {
+// }
+//
+// public SQLParameterInput( MonoQueryParameterCollection parameters ) : this()
+// {
+// this.FillParameters( parameters );
+// }
+//
+// protected override void SetupXmlLoader()
+// {
+// xmlLoader.StringValueFilter = new MonoDevelopStringValueFilter();
+// xmlLoader.PropertyValueCreator = new MonoDevelopPropertyValueCreator();
+// }
+ }
+}
+
Added: trunk/MonoDevelop/Extras/MonoQuery/Gui/Forms/CreateConnectionDruid.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Gui/Forms/CreateConnectionDruid.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Gui/Forms/CreateConnectionDruid.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,201 @@
+
+using System;
+
+using Gnome;
+using Glade;
+using Gtk;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+
+using MonoQuery.Gui.TreeView;
+using MonoQuery.Collections;
+using MonoQuery.Connection;
+using MonoQuery.Services;
+
+namespace MonoQuery.Gui
+{
+ public class CreateConnectionDruid
+ {
+ /// <summary>Window container</summary>
+ [Widget]
+ private Gtk.Window winAddconnectionDruid = null;
+
+ /// <summary>druid widget</summary>
+ [Widget]
+ private Gnome.Druid druidAddconnection = null;
+
+ /// <summary></summary>
+ [Widget]
+ private Gnome.DruidPageEdge pageAddconnectionStart = null;
+
+ /// <summary></summary>
+ [Widget]
+ private Gnome.DruidPageStandard druidAddconnectionPage1 = null;
+
+ /// <summary></summary>
+ [Widget]
+ private Gtk.ComboBox cmbProviders = null;
+
+ /// <summary></summary>
+ [Widget]
+ private Gtk.TextView textview1 = null;
+
+ /// <summary></summary>
+ [Widget]
+ private Gnome.DruidPageEdge druidpagefinish1 = null;
+
+ /// <summary>
+ /// Root node of the TreeView
+ /// </summary>
+ private MonoQueryNodeDatabaseRoot rootNode = null;
+
+ /// <summary>
+ /// List store for providers
+ /// </summary>
+ private ListStore store = null;
+
+ /// <summary>
+ /// Constructor. Loads our druid for display.
+ /// </summary>
+ public CreateConnectionDruid( MonoQuery.Gui.TreeView.MonoQueryNodeDatabaseRoot node )
+ {
+ this.rootNode = node;
+ Glade.XML gxml = new Glade.XML( null, "monoquery.glade", "winAddconnectionDruid", null );
+ gxml.Autoconnect( this );
+
+ this.pageAddconnectionStart.ShowAll();
+ this.druidAddconnectionPage1.ShowAll();
+ this.druidpagefinish1.ShowAll();
+
+ BuildProviderList();
+ }
+
+ #region // Private Methods
+ private void OnCancelClicked( object o, EventArgs e )
+ {
+ this.winAddconnectionDruid.Destroy();
+ }
+
+ /// <summary>
+ /// This method will get our list of providers and enter them into the
+ /// combo box.
+ /// </summary>
+ private void BuildProviderList()
+ {
+ MonoQueryService monoQueryService = (MonoQueryService)
+ ServiceManager.GetService( typeof( MonoQueryService ) );
+
+ store = new ListStore( typeof( string ),
+ typeof( ConnectionProviderDescriptor ) );
+
+ foreach( ConnectionProviderDescriptor descriptor in monoQueryService.Providers )
+ {
+ store.AppendValues( descriptor.Name, descriptor );
+ }
+
+ CellRendererText colr = new CellRendererText();
+ this.cmbProviders.Model = store;
+ this.cmbProviders.PackStart( colr, true );
+ this.cmbProviders.AddAttribute( colr, "text", 0 );
+
+ // Set to first provider
+ // This is where we could put some autolearning
+ this.cmbProviders.Active = 0;
+ }
+
+ /// <summary>
+ /// Event handler for when we should test the connection to the
+ /// database.
+ /// </summary>
+ private void OnTestConnection( object o, EventArgs e )
+ {
+ MessageService service = (MessageService)ServiceManager.GetService(
+ typeof( MessageService ) );
+
+ bool successful = false;
+
+ try
+ {
+ TreeIter iter;
+ this.cmbProviders.GetActiveIter( out iter );
+ ConnectionProviderDescriptor descriptor = (ConnectionProviderDescriptor)
+ store.GetValue( iter, 1 );
+ IConnection conn = CreateConnectionObject(
+ descriptor.ProviderType,
+ this.textview1.Buffer.Text );
+ successful = conn.Open(); // returns true on success
+ }
+ catch ( Exception err )
+ {
+ successful = false;
+ }
+
+ if ( successful ) {
+ service.ShowMessage( GettextCatalog.GetString(
+ "Connection was successful." ) );
+ } else {
+ service.ShowError( GettextCatalog.GetString(
+ "Error connecting to server." )
+ + "\n------------------------------\n"
+ + this.textview1.Buffer.Text );
+ }
+ }
+
+ /// <summary>
+ /// Creates an instance of a connection from a few settings.
+ /// </summary>
+ private IConnection CreateConnectionObject( System.Type type, string connString )
+ {
+ System.Reflection.Assembly ass = System.Reflection.Assembly.GetExecutingAssembly();
+ IConnection conn = (IConnection)ass.CreateInstance( type.FullName );
+ try
+ {
+ conn.ConnectionString = connString;
+ }
+ catch ( Exception e ) {}
+
+ return conn;
+ }
+
+ /// <summary>
+ /// Create our node and connection objects. Add them to the root node
+ /// of our treeview.
+ /// </summary>
+ private void OnFinishClicked( object o, FinishClickedArgs e )
+ {
+ TreeIter iter;
+ MonoQueryNodeConnection node = null;
+
+ try
+ {
+ this.cmbProviders.GetActiveIter( out iter );
+ ConnectionProviderDescriptor descriptor = (ConnectionProviderDescriptor)
+ store.GetValue( iter, 1 );
+ IConnection conn = CreateConnectionObject(
+ descriptor.ProviderType,
+ this.textview1.Buffer.Text );
+
+
+ node = new MonoQueryNodeConnection( conn );
+
+ rootNode.Nodes.Add( node as MonoDevelop.Gui.Widgets.TreeNode );
+
+ conn.Open();
+ node.Expand();
+ }
+ catch ( Exception err )
+ {
+ MessageService service = (MessageService)ServiceManager.GetService(typeof(MessageService));
+ service.ShowError( GettextCatalog.GetString("There was an error adding your connection. "
+ + "Please check your connection string.") );
+ }
+ finally
+ {
+ this.druidAddconnection.Destroy();
+ this.winAddconnectionDruid.Destroy();
+ }
+ }
+ #endregion // End Private Methods
+ }
+}
\ No newline at end of file
Added: trunk/MonoDevelop/Extras/MonoQuery/Gui/Forms/Glade/monoquery.glade
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Gui/Forms/Glade/monoquery.glade 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Gui/Forms/Glade/monoquery.glade 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,278 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+<requires lib="gnome"/>
+
+<widget class="GtkWindow" id="winAddconnectionDruid">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Add Connection Wizard</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+
+ <child>
+ <widget class="GnomeDruid" id="druidAddconnection">
+ <property name="border_width">4</property>
+ <property name="visible">True</property>
+ <property name="show_help">False</property>
+ <signal name="cancel" handler="OnCancelClicked" last_modification_time="Sun, 07 Nov 2004 07:27:30 GMT"/>
+
+ <child>
+ <widget class="GnomeDruidPageEdge" id="pageAddconnectionStart">
+ <property name="visible">True</property>
+ <property name="position">GNOME_EDGE_START</property>
+ <property name="title" translatable="yes">Add new connection</property>
+ <property name="text" translatable="yes">This wizard will help you create a new connection for use within MonoDevelop. You will need to select your connection provider as well as your proper connection string.</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GnomeDruidPageStandard" id="druidAddconnectionPage1">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes">Select connection provider</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="druid-vbox1">
+ <property name="border_width">16</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Select your connection provider</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="cmbProviders">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="padding">12</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="height_request">75</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+ <property name="vscrollbar_policy">GTK_POLICY_NEVER</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+ <child>
+ <widget class="GtkTextView" id="textview1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="overwrite">False</property>
+ <property name="accepts_tab">True</property>
+ <property name="justification">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap_mode">GTK_WRAP_NONE</property>
+ <property name="cursor_visible">True</property>
+ <property name="pixels_above_lines">0</property>
+ <property name="pixels_below_lines">0</property>
+ <property name="pixels_inside_wrap">0</property>
+ <property name="left_margin">0</property>
+ <property name="right_margin">0</property>
+ <property name="indent">0</property>
+ <property name="text" translatable="yes"></property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="lblSpacer1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="cmdTestConnection">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="OnTestConnection" last_modification_time="Sun, 07 Nov 2004 22:54:55 GMT"/>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="stock">gtk-execute</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Test Connection</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GnomeDruidPageEdge" id="druidpagefinish1">
+ <property name="visible">True</property>
+ <property name="position">GNOME_EDGE_FINISH</property>
+ <property name="title" translatable="yes">Ready to create connection</property>
+ <property name="text" translatable="yes">We are now ready to create the connection. Click Apply to create and start using the connection.</property>
+ <signal name="finish" handler="OnFinishClicked" last_modification_time="Sun, 07 Nov 2004 23:29:49 GMT"/>
+ </widget>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>
Added: trunk/MonoDevelop/Extras/MonoQuery/Gui/Forms/Glade/monoquery.gladep
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Gui/Forms/Glade/monoquery.gladep 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Gui/Forms/Glade/monoquery.gladep 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,7 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
+
+<glade-project>
+ <name>MonoQuery</name>
+ <program_name>monoquery</program_name>
+</glade-project>
Added: trunk/MonoDevelop/Extras/MonoQuery/Gui/Interface/IMonoQueryNode.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Gui/Interface/IMonoQueryNode.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Gui/Interface/IMonoQueryNode.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,60 @@
+namespace MonoQuery.Gui.TreeView
+{
+ using MonoQuery.SchemaClass;
+ using MonoQuery.Connection;
+ using MonoQuery.Collections;
+
+public interface IMonoQueryNode
+{
+ ///<summary>
+ /// <returns> Path to a string #develop menu command object.</returns>
+ /// <remarks>You should add this extension path in the addin file.</remarks>
+ /// </summary>
+ string AddinContextMenu { get; }
+
+ ///<summary>
+ /// His schema class from wich to displayed data informations.
+ ///</summary>
+ ISchemaClass SchemaClass { get; }
+
+ ///<summary>
+ /// the <see cref=".IMonoQueryNode.SchemaClass">SchemaClass</see>'s connection.
+ ///</summary>
+ IConnection Connection { get; }
+
+ ///<summary>
+ /// Those, are list of the childs schema.( columns, etc etc )
+ /// i am using a dictionnary because is more simplest to write
+ /// <code>Entities["PROCEDURES"]</code> than <code>Entities[0]</code>.
+ ///</summary>
+ MonoQueryListDictionary Entities { get; }
+
+
+ ///<summary>
+ /// Calls the <see cref=".IMonoQueryNode.Clear()">Clear()</see> method.
+ /// Calls the <see cref=".ISchemaClass.Refresh()">Refresh()</see> method of his <see cref=".IMonoQueryNode.SchemaClass">SchemaClass</see> member.
+ /// Calls the <see cref=".ISchemaClass.BuildsChilds()">BuildsChild()</see> method.
+ /// </summary>
+ void Refresh();
+
+ ///<summary>
+ /// Calls the <code>Clear()</code> method of each child nodes.
+ /// Calls the <see cref=".ISchemaClass.Clear()">Clear()</see> methode of his <see cref=".IMonoQueryNode.SchemaClass">SchemaClass</see> member.
+ /// Remove each child nodes.
+ /// </summary>
+ void Clear();
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// </summary>
+ void Execute( int rows );
+
+ ///<summary>
+ /// Builds childs <see cref=".IMonoQueryNode">IMonoQueryNode</see>
+ /// </summary>
+ void BuildsChilds();
+}
+
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryPanel.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryPanel.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryPanel.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,87 @@
+
+// TODO: Port to GTK#
+
+using System;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+
+namespace MonoQuery.Gui
+{
+ /*
+ public class MonoQueryPanel : System.Windows.Forms.Panel
+ {
+ private MonoQuery.Gui.TreeView.MonoQueryTree monoQueryTreeView;
+ private System.Windows.Forms.ImageList monoQueryImageList;
+ private System.Windows.Forms.ToolBar monoQueryToolBar;
+ private System.Windows.Forms.ToolBarButton btnRefresh;
+ private System.Windows.Forms.ToolBarButton btnAddConnection;
+ private System.Windows.Forms.ToolBarButton btnSep;
+
+
+ public MonoQueryPanel() : base()
+ {
+ IconService iconService = (IconService)ServiceManager.GetService(typeof(IconService));
+ StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+
+ this.monoQueryToolBar = new System.Windows.Forms.ToolBar();
+ this.monoQueryImageList = new System.Windows.Forms.ImageList();
+ this.monoQueryTreeView = new MonoQuery.Gui.TreeView.MonoQueryTree();
+ this.btnRefresh = new System.Windows.Forms.ToolBarButton();
+ this.btnAddConnection = new System.Windows.Forms.ToolBarButton();
+ this.btnSep = new System.Windows.Forms.ToolBarButton();
+ this.SuspendLayout();
+
+ //
+ // monoQueryImageList
+ //
+ this.monoQueryImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit;
+ this.monoQueryImageList.ImageSize = new System.Drawing.Size(16, 16);
+ this.monoQueryImageList.TransparentColor = System.Drawing.Color.DarkCyan;
+
+ this.monoQueryImageList.Images.Add(iconService.GetBitmap("Icons.16x16.MonoQuery.AddConnection"));
+ this.monoQueryImageList.Images.Add(iconService.GetBitmap("Icons.16x16.MonoQuery.Refresh"));
+
+ //
+ // toolBar
+ //
+ this.monoQueryToolBar.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
+ this.monoQueryToolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
+ this.btnRefresh, this.btnSep, this.btnAddConnection});
+ this.monoQueryToolBar.DropDownArrows = true;
+ this.monoQueryToolBar.Location = new System.Drawing.Point(0, 0);
+ this.monoQueryToolBar.Name = "toolBar";
+ this.monoQueryToolBar.ShowToolTips = true;
+ this.monoQueryToolBar.Size = new System.Drawing.Size(292, 42);
+ this.monoQueryToolBar.TabIndex = 0;
+ this.monoQueryToolBar.ImageList = this.monoQueryImageList;
+
+ this.btnRefresh.ImageIndex = 1;
+ this.btnRefresh.ToolTipText = stringParserService.Parse("${res:MonoQuery.ToolTip.Refresh}");
+
+ this.btnSep.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
+
+ this.btnAddConnection.ImageIndex = 0;
+ this.btnAddConnection.ToolTipText = stringParserService.Parse("${res:MonoQuery.ToolTip.AddConnection}");
+
+ //
+ // treeView
+ //
+ this.monoQueryTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.monoQueryTreeView.ImageIndex = -1;
+ this.monoQueryTreeView.Location = new System.Drawing.Point(0, 42);
+ this.monoQueryTreeView.Name = "treeView";
+ this.monoQueryTreeView.SelectedImageIndex = -1;
+ this.monoQueryTreeView.Size = new System.Drawing.Size(292, 224);
+ this.monoQueryTreeView.TabIndex = 1;
+ //
+ // CreatedForm
+ //
+ this.ClientSize = new System.Drawing.Size(292, 266);
+ this.Controls.Add(this.monoQueryTreeView);
+ this.Controls.Add(this.monoQueryToolBar);
+ this.Name = "MonoQueryPanel";
+ this.ResumeLayout(false);
+ }
+ }*/
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryTree/MonoQueryDataNodes.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryTree/MonoQueryDataNodes.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryTree/MonoQueryDataNodes.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,240 @@
+// created on 07/11/2003 at 10:15
+using System;
+using System.Xml;
+using System.ComponentModel;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+using MonoQuery.SchemaClass;
+using MonoQuery.Collections;
+using System.Collections;
+using MonoQuery.Gui.DataView;
+using MonoDevelop.Gui;
+using MonoDevelop.Gui.Dialogs;
+
+namespace MonoQuery.Gui.TreeView
+{
+
+ ///<summary>
+ /// Column Node
+ ///</summary>
+ public class MonoQueryNodeColumn : AbstractMonoQueryNode
+ {
+ ///<summary> force to displayed a "+" for the node</summary>
+ protected override bool NullChildAllowed
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public override string AddinContextMenu {
+ get{
+ return "/MonoQuery/ContextMenu/Coulmn";
+ }
+ }
+
+ public MonoQueryNodeColumn( MonoQueryColumn monoQueryColumn ) : base( monoQueryColumn )
+ {
+ //this.Image = "";
+
+// this.ImageIndex = 9;
+// this.SelectedImageIndex = 9;
+ }
+ }
+
+ ///<summary>
+ /// Parameter Node
+ ///</summary>
+ public class MonoQueryNodeParameter : AbstractMonoQueryNode
+ {
+
+ ///<summary> force to displayed a "+" for the node</summary>
+ protected override bool NullChildAllowed
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public override string AddinContextMenu {
+ get{
+ return "/MonoQuery/ContextMenu/Parameter";
+ }
+ }
+
+ public MonoQueryNodeParameter( MonoQueryParameter monoQueryParameter ) : base( monoQueryParameter )
+ {
+ //this.Image = "";
+
+// this.ImageIndex = 9;
+// this.SelectedImageIndex = 9;
+ }
+ }
+
+ ///<summary>
+ /// Table Node
+ ///</summary>
+ public class MonoQueryNodeTable : AbstractMonoQueryNode
+ {
+ public override string AddinContextMenu {
+ get{
+ return "/MonoQuery/ContextMenu/Table";
+ }
+ }
+
+ public MonoQueryNodeTable( MonoQueryTable monoQueryTable ) : base( monoQueryTable )
+ {
+ this.Image = "md-mono-query-table";
+
+// this.ImageIndex = 6;
+// this.SelectedImageIndex = 6;
+ }
+ }
+
+ ///<summary>
+ /// View Node
+ ///</summary>
+ public class MonoQueryNodeView : AbstractMonoQueryNode
+ {
+ public override string AddinContextMenu {
+ get{
+ return "/MonoQuery/ContextMenu/View";
+ }
+ }
+
+ public MonoQueryNodeView( MonoQueryView monoQueryView ) : base( monoQueryView )
+ {
+ this.Image = "md-mono-query-table";
+
+// this.ImageIndex = 7;
+// this.SelectedImageIndex = 7;
+ }
+ }
+
+ ///<summary>
+ /// Procedure Node
+ ///</summary>
+ public class MonoQueryNodeProcedure: AbstractMonoQueryNode
+ {
+
+ public override string AddinContextMenu {
+ get{
+ return "/MonoQuery/ContextMenu/Procedure";
+ }
+ }
+
+ public MonoQueryNodeProcedure( MonoQueryProcedure monoQueryProcedure ) : base( monoQueryProcedure )
+ {
+ this.Image = "md-mono-query-procedure";
+
+// this.ImageIndex = 8;
+// this.SelectedImageIndex = 8;
+ }
+
+ ///<summary>
+ /// allow the user to add some parameters while executing an SQL command
+ /// </summary>
+ protected override MonoQuerySchemaClassCollection OnExecute( CancelEventArgs e )
+ {
+ MonoQuerySchemaClassCollection tmp = this.SchemaClass.GetSchemaParameters();
+ MonoQueryParameterCollection parameters = null;
+ MonoQuerySchemaClassCollection returnValue = null;
+
+// if ( tmp.Count == 1 && tmp[0] is MonoQueryNotSupported )
+// {
+// parameters = new MonoQueryParameterCollection();
+// }
+// else
+// {
+// parameters = new MonoQueryParameterCollection( tmp );
+// }
+//
+// if ( parameters != null && parameters.Count > 0 )
+// {
+// inputform = new SQLParameterInput( parameters );
+// inputform.Owner = (Form)WorkbenchSingleton.Workbench;
+//
+// if ( inputform.ShowDialog() != DialogResult.OK )
+// {
+// returnValue = null;
+// e.Cancel = true;
+// }
+// else
+// {
+// returnValue = parameters.ToBaseSchemaCollection();
+// }
+// }
+
+ return returnValue;
+ }
+ }
+
+ ///<summary>
+ /// Node displayed when a function is not supported by the provider!
+ ///</summary>
+ public class MonoQueryNodeNotSupported: AbstractMonoQueryNode
+ {
+
+ ///<summary> force to displayed a "+" for the node</summary>
+ protected override bool NullChildAllowed
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public MonoQueryNodeNotSupported( MonoQueryNotSupported monoQueryNotSupported ) : base( monoQueryNotSupported )
+ {
+// this.ImageIndex = 10;
+// this.SelectedImageIndex = 10;
+ }
+ }
+
+
+ ///<summary>
+ /// Schema Node
+ ///</summary>
+ public class MonoQueryNodeSchema : AbstractMonoQueryNode
+ {
+ public override string AddinContextMenu {
+ get{
+ return "/MonoQuery/ContextMenu/Schema";
+ }
+ }
+
+ public MonoQueryNodeSchema( MonoQuerySchema schema ) : base(schema)
+ {
+ //this.Image = "";
+
+// this.ImageIndex = 1;
+// this.SelectedImageIndex = 1;
+ }
+
+ }
+
+ ///<summary>
+ /// Catalog Node
+ ///</summary>
+ public class MonoQueryNodeCatalog : AbstractMonoQueryNode
+ {
+ public override string AddinContextMenu {
+ get{
+ return "/MonoQuery/ContextMenu/Catalog";
+ }
+ }
+
+ public MonoQueryNodeCatalog( MonoQueryCatalog catalog ) : base(catalog)
+ {
+ //this.Image = "";
+
+// this.ImageIndex = 1;
+// this.SelectedImageIndex = 1;
+ }
+ }
+
+
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryTree/MonoQueryNodesRoot.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryTree/MonoQueryNodesRoot.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryTree/MonoQueryNodesRoot.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,392 @@
+// created on 04/11/2003 at 17:29
+
+using System;
+using System.Xml;
+using System.Reflection;
+using System.Collections;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+using MonoDevelop.Gui.Widgets;
+using MonoDevelop.Gui;
+
+using MonoQuery.SchemaClass;
+using MonoQuery.Collections;
+using MonoQuery.Connection;
+using MonoQuery.Exceptions;
+
+namespace MonoQuery.Gui.TreeView
+{
+ ///<summary>
+ /// this is the root of all others nodes!
+ ///</summary>
+ public class MonoQueryNodeDatabaseRoot : AbstractMonoQueryNode
+ {
+ public override string AddinContextMenu {
+ get{
+ return "/MonoQuery/ContextMenu/DatabaseRoot";
+ }
+ }
+
+ public override string entityName
+ {
+ get
+ {
+ StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+ return GettextCatalog.GetString( "Database Connections" );
+ }
+ }
+
+ public MonoQueryNodeDatabaseRoot() : base()
+ {
+ this.Text = this.entityName;
+ this.Image = "md-network";
+
+// this.ImageIndex = 0;
+// this.SelectedImageIndex = 0;
+ }
+
+ public override void Refresh()
+ {
+ this.Text = this.entityName;
+
+ foreach( IMonoQueryNode node in this.Nodes )
+ {
+ node.Refresh();
+ }
+ }
+
+ public override void Clear()
+ {
+ foreach( IMonoQueryNode node in this.Nodes )
+ {
+ node.Clear();
+ }
+ }
+
+ public override void BuildsChilds()
+ {
+ // We now do this from a druid
+ /*
+ IConnection connection = null;
+ IMonoQueryNode node = null;
+
+ try
+ {
+ connection = AbstractMonoQueryConnectionWrapper.CreateFromDataConnectionLink();
+
+ if (connection != null)
+ {
+ string ChildClass = "";
+
+ if ( MonoQueryTree.SchemaClassDict.Contains( connection.GetType().FullName ) == true )
+ {
+ ChildClass = MonoQueryTree.SchemaClassDict[ connection.GetType().FullName ];
+ }
+
+ if ( (ChildClass != null) && (ChildClass != "" ) )
+ {
+ node = (IMonoQueryNode)ass.CreateInstance(ChildClass, false, BindingFlags.CreateInstance, null, new object[] {connection}, null, null);
+ }
+ else
+ {
+ node = new MonoQueryNodeNotSupported( new MonoQueryNotSupported( connection, "", "", "", connection.GetType().FullName ) );
+ }
+
+
+ //TODO : do an interface for the node connection!
+ (node as MonoQueryNodeConnection).Connect();
+ this.Nodes.Add( node as TreeNode );
+ node.Refresh();
+
+ if ( node.Connection.IsConnectionStringWrong == true )
+ {
+ this.Nodes.Remove( node as TreeNode);
+ }
+ else
+ {
+ this.Expand();
+ }
+ }
+ }
+ catch( ConnectionStringException e )
+ {
+ if ( this.Nodes.Contains( node as TreeNode) == true )
+ {
+ this.Nodes.Remove( node as TreeNode);
+ }
+ IMessageService messageService =(IMessageService)ServiceManager.GetService(typeof(IMessageService));
+ messageService.ShowError( e.Message );
+ }*/
+ }
+
+ /// <summary>
+ /// This will show a window so that the user can select their settings
+ /// for the new connection.
+ /// </summary>
+ public void AddConnection()
+ {
+ new CreateConnectionDruid( this );
+ }
+ }
+
+ ///<summary>
+ /// Root nodes for a connection to a database
+ ///</summary>
+ public class MonoQueryNodeConnection : AbstractMonoQueryNode
+ {
+ IConnection pConnection = null;
+
+ public override string entityNormalizedName
+ {
+ get
+ {
+ if ( this.pConnection != null )
+ {
+ return this.pConnection.NormalizedName;
+ }
+ else
+ {
+ return "";
+ }
+ }
+ }
+
+ public override string entityName
+ {
+ get
+ {
+ if ( this.pConnection != null )
+ {
+ return this.pConnection.Name;
+ }
+ else
+ {
+ return "";
+ }
+ }
+ }
+
+ public override IConnection Connection{
+ get
+ {
+ if ( this.pConnection != null )
+ {
+ return this.pConnection;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ public override MonoQueryListDictionary Entities {
+ get{
+ if ( this.Connection != null )
+ {
+ return this.Connection.Entities;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+ public override string AddinContextMenu {
+ get{
+ return "/MonoQuery/ContextMenu/DatabaseConnection";
+ }
+ }
+
+ public MonoQueryNodeConnection( IConnection dataConnection ) : base( null )
+ {
+ this.pConnection = dataConnection;
+ this.Image = "md-mono-query-database";
+ this.Text = this.pConnection.Name;
+
+ this.Nodes.Add( "" ); // dummy
+
+// this.ImageIndex = 1;
+// this.SelectedImageIndex = 1;
+ }
+
+ public bool IsConnected
+ {
+ get
+ {
+ return this.Connection.IsOpen;
+ }
+ }
+
+ public void Disconnect()
+ {
+ if (this.IsConnected == true)
+ {
+// this.Collapse();
+ this.Nodes.Clear();
+ this.Clear();
+ this.Connection.Close();
+// this.ImageIndex = 1;
+// this.SelectedImageIndex = 1;
+ }
+ }
+
+ public void Connect()
+ {
+ try
+ {
+ if ( this.IsConnected == false )
+ {
+ if ( this.Connection.Open() )
+ {
+ this.Refresh();
+// this.ImageIndex = 2;
+// this.SelectedImageIndex = 2;
+ }
+ }
+ }
+ catch( Exception e )
+ {
+ IMessageService messageService =(IMessageService)ServiceManager.GetService(typeof(IMessageService));
+ messageService.ShowError( e.Message );
+ }
+ }
+
+ protected override void OnRefresh()
+ {
+ if ( this.IsConnected != true )
+ this.Connect();
+
+ this.Clear();
+ this.Connection.Refresh();
+ }
+
+ public override void Clear()
+ {
+ if ( this.Connection != null )
+ {
+ this.Connection.Clear();
+ }
+
+ base.Clear();
+ }
+
+ public void RemoveConnection()
+ {
+ this.Disconnect();
+ this.pConnection = null;
+
+ this.Parent.Nodes.Remove( this );
+ }
+
+ public void ModifyConnection()
+ {
+ IConnection Oldconnection = this.pConnection;
+ bool error = false;
+ try
+ {
+ IConnection connection = null;
+
+ connection = AbstractMonoQueryConnectionWrapper.UpDateFromDataConnectionLink( this.Connection );
+
+ if ( connection != null )
+ {
+ this.Disconnect();
+ this.pConnection = connection;
+ this.Refresh();
+ error = this.pConnection.IsConnectionStringWrong;
+ }
+ }
+ catch( ConnectionStringException e )
+ {
+ error = true;
+ IMessageService messageService =(IMessageService)ServiceManager.GetService(typeof(IMessageService));
+ messageService.ShowError( e.Message );
+ }
+ finally
+ {
+ if ( error == true )
+ {
+ this.pConnection = Oldconnection;
+ this.Connect();
+ this.Refresh();
+ }
+ }
+ }
+ }
+
+
+ ///<summary>
+ /// Tables Root Node
+ ///</summary>
+ public class MonoQueryNodeTableRoot : AbstractMonoQueryNode
+ {
+ ///<summary>
+ /// Addin Path of the node's context menu
+ ///</summary>
+ public override string AddinContextMenu {
+ get{
+ return "/MonoQuery/ContextMenu/TablesRoot";
+ }
+ }
+
+ public MonoQueryNodeTableRoot( AbstractMonoQuerySchemaClass databaseclass) : base( databaseclass )
+ {
+ this.Image = "md-mono-query-tables";
+
+// this.ImageIndex = 3;
+// this.SelectedImageIndex = 3;
+ }
+
+ }
+
+ ///<summary>
+ /// Views Root Node
+ ///</summary>
+ public class MonoQueryNodeViewRoot : AbstractMonoQueryNode
+ {
+ ///<summary>
+ /// Addin Path of the node's context menu
+ ///</summary>
+ public override string AddinContextMenu {
+ get{
+ return "/MonoQuery/ContextMenu/ViewsRoot";
+ }
+ }
+
+ public MonoQueryNodeViewRoot( AbstractMonoQuerySchemaClass databaseclass) : base( databaseclass )
+ {
+ this.Image = "md-mono-query-tables";
+
+// this.ImageIndex = 4;
+// this.SelectedImageIndex = 4;
+ }
+ }
+
+ ///<summary>
+ /// Procedure Root Node
+ ///</summary>
+ public class MonoQueryNodeProcedureRoot : AbstractMonoQueryNode
+ {
+ ///<summary>
+ /// Addin Path of the node's context menu
+ ///</summary>
+ public override string AddinContextMenu {
+ get{
+ return "/MonoQuery/ContextMenu/ProceduresRoot";
+ }
+ }
+
+ public MonoQueryNodeProcedureRoot( AbstractMonoQuerySchemaClass databaseclass) : base( databaseclass )
+ {
+ this.Image = "md-mono-query-procedure";
+
+// this.ImageIndex = 5;
+// this.SelectedImageIndex = 5;
+ }
+ }
+
+
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryTree/MonoQueryTree.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryTree/MonoQueryTree.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Gui/MonoQueryTree/MonoQueryTree.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,212 @@
+// created on 04/11/2003 at 16:05
+
+namespace MonoQuery.Gui.TreeView
+{
+
+using System;
+using System.Xml;
+using System.Collections;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+using MonoDevelop.Core.AddIns.Conditions;
+using MonoDevelop.Core.AddIns.Codons;
+using MonoDevelop.Core.AddIns;
+using MonoDevelop.Gui.Widgets;
+
+using MonoQuery.Gui;
+using MonoQuery.Collections;
+using MonoQuery.Codons;
+
+using RS = MonoDevelop.Core.Services.ResourceService;
+
+ ///<summary>
+ /// This class shows all databases connections in a treeview.
+ ///</summary>
+ public class MonoQueryTree : TreeView
+ {
+// private System.Windows.Forms.ImageList pNodeImages;
+ private MenuService menuService = null;
+
+ public static MonoQueryStringDictionary SchemaClassDict;
+
+ ///<summary>
+ /// Create a MonoQueryTree objec
+ ///</summary>
+ public MonoQueryTree() : base()
+ {
+ IconService iconService = (IconService)ServiceManager.GetService(typeof(IconService));
+
+ this.menuService = (MenuService)ServiceManager.GetService(typeof(MenuService));
+
+// this.pNodeImages = new ImageList();
+// this.pNodeImages.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit;
+// this.pNodeImages.ImageSize = new System.Drawing.Size(16, 16);
+// this.pNodeImages.TransparentColor = System.Drawing.Color.DarkCyan;
+// this.pNodeImages.Images.Add(iconService.GetBitmap("Icons.16x16.MonoQuery.DataBaseRoot"));
+// this.pNodeImages.Images.Add(iconService.GetBitmap("Icons.16x16.MonoQuery.DatabaseConnectionClose"));
+// this.pNodeImages.Images.Add(iconService.GetBitmap("Icons.16x16.MonoQuery.DatabaseConnection"));
+// this.pNodeImages.Images.Add(iconService.GetBitmap("Icons.16x16.MonoQuery.TablesRoot"));
+// this.pNodeImages.Images.Add(iconService.GetBitmap("Icons.16x16.MonoQuery.ViewsRoot"));
+// this.pNodeImages.Images.Add(iconService.GetBitmap("Icons.16x16.MonoQuery.ProceduresRoot"));
+// this.pNodeImages.Images.Add(iconService.GetBitmap("Icons.16x16.MonoQuery.Table"));
+// this.pNodeImages.Images.Add(iconService.GetBitmap("Icons.16x16.MonoQuery.View"));
+// this.pNodeImages.Images.Add(iconService.GetBitmap("Icons.16x16.MonoQuery.Procedure"));
+// this.pNodeImages.Images.Add(iconService.GetBitmap("Icons.16x16.MonoQuery.Column"));
+// this.pNodeImages.Images.Add(iconService.GetBitmap("Icons.16x16.MonoQuery.NodeError"));
+// this.ImageList = this.pNodeImages;
+
+ SchemaClassDict = new MonoQueryStringDictionary();
+
+ LoadMonoQueryConnectionCodon();
+
+ //Add the Root Node.
+ this.Nodes.Add( new MonoQueryNodeDatabaseRoot() );
+
+ // Wire click event
+ this.ButtonReleaseEvent += new Gtk.ButtonReleaseEventHandler( OnButtonRelease );
+ }
+
+ protected void LoadMonoQueryConnectionCodon()
+ {
+ IAddInTreeNode AddinNode;
+
+ AddinNode = (IAddInTreeNode)AddInTreeSingleton.AddInTree.GetTreeNode("/MonoQuery/Connection");
+ foreach ( DictionaryEntry entryChild in AddinNode.ChildNodes)
+ {
+ IAddInTreeNode ChildNode = entryChild.Value as IAddInTreeNode;
+ if ( ChildNode != null )
+ {
+ MonoQueryConnectionCodon codon = ChildNode.Codon as MonoQueryConnectionCodon;
+ if ( codon != null )
+ {
+ if ( SchemaClassDict.Contains( codon.Schema ) )
+ {
+ SchemaClassDict[codon.Schema] = codon.Node;
+ }
+ else
+ {
+ SchemaClassDict.Add(codon.Schema,codon.Node);
+ }
+ }
+ }
+ }
+ }
+
+// ///<summary>
+// /// Select the node under the mouse cursor
+// ///</summary>
+// protected override void OnMouseDown(MouseEventArgs e)
+// {
+// if (e.Button == MouseButtons.Right || e.Button == MouseButtons.Left)
+// {
+// this.SelectedNode = this.GetNodeAt( e.X, e.Y );
+// }
+//
+//
+// base.OnMouseDown(e);
+// }
+//
+// ///<summary>
+// /// Display the context menu associated with a node type
+// ///</summary>
+// protected override void OnMouseUp(MouseEventArgs e)
+// {
+// if (e.Button == MouseButtons.Right && this.SelectedNode != null && SelectedNode is IMonoQueryNode) {
+// IMonoQueryNode selectedBrowserNode = SelectedNode as IMonoQueryNode;
+// if ( selectedBrowserNode.AddinContextMenu != "" )
+// {
+// menuService.ShowContextMenu(this, selectedBrowserNode.AddinContextMenu, this, e.X, e.Y);
+// }
+// }
+//
+// base.OnMouseUp(e);
+// }
+
+ /// <summary>
+ /// Display the context menu associated with a node type
+ /// </summary>
+ public void OnButtonRelease( object o, Gtk.ButtonReleaseEventArgs args )
+ {
+ if ( args.Event.Button == 3 // Right Click
+ && this.SelectedNode != null
+ && this.SelectedNode is IMonoQueryNode )
+ {
+ IMonoQueryNode selectedBrowserNode = SelectedNode as IMonoQueryNode;
+ if ( selectedBrowserNode.AddinContextMenu != "" )
+ {
+ menuService.ShowContextMenu( this, selectedBrowserNode.AddinContextMenu, this );
+ }
+ }
+ }
+
+//
+// protected override void OnItemDrag(ItemDragEventArgs e)
+// {
+// base.OnItemDrag(e);
+// AbstractMonoQueryNode node = e.Item as AbstractMonoQueryNode;
+// if (node != null)
+// {
+// DataObject dataObject = null;
+//
+// if ( node.SchemaClass != null )
+// {
+// dataObject = node.SchemaClass.DragObject;
+//
+// if (dataObject != null )
+// {
+// dataObject.SetData(node.GetType() , node);
+// DoDragDrop(dataObject, DragDropEffects.All);
+// }
+// }
+// }
+// }
+
+ protected override void OnBeforeExpand( TreeViewCancelEventArgs e )
+ {
+ MonoQueryNodeConnection node = e.Node as MonoQueryNodeConnection;
+
+ if ( node != null )
+ {
+ if ( node.IsConnected == false )
+ {
+ node.Connect();
+ }
+ }
+
+ IMonoQueryNode myNode = e.Node as IMonoQueryNode;
+
+ if ( myNode != null )
+ {
+ myNode.Refresh();
+ }
+
+ base.OnBeforeExpand( e );
+ }
+
+
+// protected override void OnAfterExpand(TreeViewEventArgs e)
+// {
+// IMonoQueryNode node = e.Node as IMonoQueryNode;
+//
+// if ( node != null )
+// {
+// node.Refresh();
+// }
+//
+// base.OnAfterExpand( e );
+// }
+//
+// protected override void OnAfterCollapse( TreeViewEventArgs e )
+// {
+// IMonoQueryNode node = e.Node as IMonoQueryNode;
+//
+// if ( node != null )
+// {
+// node.Clear();
+// }
+//
+// base.OnAfterCollapse( e );
+// }
+ }
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Gui/SqlQueryView/SqlQueryView.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Gui/SqlQueryView/SqlQueryView.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Gui/SqlQueryView/SqlQueryView.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,141 @@
+
+using System;
+using System.Data;
+
+using Gtk;
+using GtkSourceView;
+
+using MonoQuery.Connection;
+using MonoDevelop;
+using MonoDevelop.Gui;
+
+namespace MonoQuery.Gui.SqlQueryView
+{
+ /// <summary>
+ /// SQL Query View to execute sql queries from a MonoQuery IConnection.
+ /// </summary>
+ public class SqlQueryView : AbstractViewContent
+ {
+ #region // Private Properties
+
+ private IConnection connection = null;
+ private VPaned vpaned = null;
+ private SourceView sourceView = null;
+ private SourceBuffer sourceBuffer = null;
+ private ScrolledWindow sourceScroller = null;
+ private VBox vbox1 = null;
+ private Notebook notebook = null;
+ private TextView logView = null;
+ private ScrolledWindow logScroller = null;
+ private MonoDevelop.Gui.Widgets.DataGrid outputView = null;
+ private SqlQueryViewToolbar toolbar = null;
+
+ #endregion // End Private Properties
+
+ /// <summary>
+ /// Default constructor. Setup our gui widgets and IConnection
+ /// </summary>
+ public SqlQueryView( IConnection conn ) : base()
+ {
+ this.connection = conn;
+ this.UntitledName = Connection.Name;
+
+ this.vpaned = new VPaned();
+
+ this.vbox1 = new VBox();
+ this.toolbar = new SqlQueryViewToolbar();
+ this.toolbar.Run += new EventHandler( OnQueryRun );
+ this.vbox1.PackStart( this.toolbar, false, false, 0 );
+
+ SourceLanguagesManager lm = new SourceLanguagesManager();
+ this.sourceBuffer = new SourceBuffer(
+ lm.GetLanguageFromMimeType("text/x-sql") );
+ this.sourceBuffer.Highlight = true;
+
+ this.sourceView = new SourceView( sourceBuffer );
+ this.sourceScroller = new ScrolledWindow();
+ this.sourceScroller.Add( sourceView );
+ this.vbox1.PackStart( this.sourceScroller, true, true, 0 );
+ this.vpaned.Pack1( vbox1, true, true );
+
+ this.notebook = new Notebook();
+ this.notebook.TabPos = PositionType.Bottom;
+ this.logView = new TextView();
+ this.logView.Editable = false;
+ this.logScroller = new ScrolledWindow();
+ this.logScroller.Add( logView );
+ this.outputView = new MonoDevelop.Gui.Widgets.DataGrid();
+ this.notebook.AppendPage( logScroller, new Label("Log") );
+ this.notebook.AppendPage( outputView, new Label("Output") );
+
+ this.vpaned.Pack2( notebook, true, true );
+
+ this.vpaned.ShowAll();
+ }
+
+ public override Gtk.Widget Control {
+ get { return this.vpaned; }
+ }
+
+ public override void Load( string fileName )
+ {
+ // Load contents of file into the sourceView
+ // TODO:
+ }
+
+ public IConnection Connection {
+ get { return this.connection; }
+ }
+
+ public void OnQueryRun( object o, EventArgs e )
+ {
+ DateTime start = DateTime.Now;
+
+ try
+ {
+ this.logView.Buffer.Text +=
+ "\n\n-------------------------------------------"
+ + "\n Attempting Query\n ";
+ DataSet ds = (DataSet)this.Connection.ExecuteSQL(
+ this.sourceView.Buffer.Text, 0 );
+ this.outputView.DataSource = ds;
+ this.outputView.DataBind();
+ this.notebook.Page = 1;
+ }
+ catch ( Exception err )
+ {
+ this.logView.Buffer.Text +=
+ "\n Exception caught during query. "
+ + "\n " + err.StackTrace;
+ this.notebook.Page = 0;
+ }
+ finally
+ {
+ this.logView.Buffer.Text +=
+ "\n Query completed in " + (DateTime.Now - start)
+ + "\n-------------------------------------------";
+ this.logView.ScrollToMark( this.logView.Buffer.InsertMark, 0.4,
+ true, 0.0, 1.0);
+ }
+ }
+ }
+
+ public class SqlQueryViewToolbar : Gtk.Toolbar
+ {
+ public event EventHandler Run;
+
+ public SqlQueryViewToolbar() : base()
+ {
+ this.ToolbarStyle = ToolbarStyle.Icons;
+ this.AppendItem (String.Empty, "Execute SQL Commands.",
+ String.Empty,
+ new Gtk.Image (Gtk.Stock.Execute, IconSize.SmallToolbar),
+ new Gtk.SignalFunc ( OnRun ));
+ }
+
+ private void OnRun()
+ {
+ this.Run( this, new EventArgs() );
+ }
+ }
+}
\ No newline at end of file
Added: trunk/MonoDevelop/Extras/MonoQuery/Makefile.am
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Makefile.am 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Makefile.am 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,79 @@
+
+monoquerydir = $(libdir)/monodevelop/AddIns/MonoQuery
+monoquery_DATA = $(ASSEMBLY) MonoQuery.addin.xml
+
+FILES = \
+AssemblyInfo.cs \
+Codons/MonoQueryConnectionCodon.cs \
+Collection/MonoQuerySchemaClassCollection.cs \
+Collection/MonoQueryStringDictionary.cs \
+Collection/MonoQueryListDictionary.cs \
+Collection/MonoQueryParameterCollection.cs \
+Collection/ConnectionProviderDescriptor.cs \
+Commands/Abstract/AbstractMonoQueryCommand.cs \
+Commands/MonoQueryCommands.cs \
+Connection/Abstract/AbstractMonoQueryConnectionWrapper.cs \
+Connection/Interface/IConnection.cs \
+Connection/Npgsql/NpgsqlConnectionWrapper.cs \
+Connection/Mysql/MysqlConnectionWrapper.cs \
+Exceptions/Abstract/MonoQueryAbstractException.cs \
+Exceptions/ConnectionStringException.cs \
+Exceptions/ExecuteProcedureException.cs \
+Exceptions/ExecuteSQLException.cs \
+Exceptions/OpenConnectionException.cs \
+SchemaClass/Abstract/AbstractMonoQuerySchemaClass.cs \
+SchemaClass/Interface/ISchemaClass.cs \
+SchemaClass/MonoQuerySchemaClass.cs \
+MonoQueryView.cs \
+Gui/Abstract/AbstractMonoQueryNode.cs \
+Gui/DataView/SQLParameterInput.cs \
+Gui/DataView/MonoQueryDataView.cs \
+Gui/Interface/IMonoQueryNode.cs \
+Gui/MonoQueryTree/MonoQueryNodesRoot.cs \
+Gui/MonoQueryTree/MonoQueryTree.cs \
+Gui/MonoQueryTree/MonoQueryDataNodes.cs \
+Gui/MonoQueryPanel.cs \
+Gui/Forms/CreateConnectionDruid.cs \
+Gui/SqlQueryView/SqlQueryView.cs \
+Services/MonoQueryService.cs
+
+ASSEMBLY = MonoQuery.dll
+
+REFERENCES = \
+System.Data \
+Npgsql \
+ByteFX.Data \
+../../build/bin/MonoDevelop.Base.dll \
+../../build/bin/MonoDevelop.Core.dll \
+../../build/bin/MonoDevelop.Gui.Widgets.dll
+
+RESOURCES = \
+Gui/Forms/Glade/monoquery.glade
+
+PACKAGES = \
+gtk-sharp-2.0 \
+gnome-sharp-2.0 \
+glade-sharp-2.0 \
+gtksourceview-sharp
+
+BUILD_SOURCES = $(addprefix $(srcdir)/, $(FILES))
+BUILD_REFERENCES = $(addprefix /r:, $(REFERENCES))
+BUILD_PACKAGES = $(addprefix /pkg:, $(PACKAGES))
+BUILD_RESOURCES = $(addprefix /resource:, $(RESOURCES))
+
+all: $(ASSEMBLY)
+
+$(ASSEMBLY): mkdirs $(BUILD_SOURCES) ../../build/AddIns/MonoQuery/MonoQuery.addin.xml
+ mcs -out:MonoQuery.dll -target:library $(BUILD_SOURCES) \
+ $(BUILD_REFERENCES) $(BUILD_PACKAGES) $(BUILD_RESOURCES) \
+ && cp MonoQuery.dll ../../build/AddIns/MonoQuery/
+
+../../build/AddIns/MonoQuery/MonoQuery.addin.xml:
+ cp MonoQuery.addin.xml ../../build/AddIns/MonoQuery/
+
+mkdirs:
+ mkdir -p ../../build/AddIns/MonoQuery
+
+CLEANFILES=$(ASSEMBLY) $(ASSEMBLY).mdb
+
+EXTRADIST=$(FILES) MonoQuery.addin.xml
Added: trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.addin.xml
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.addin.xml 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.addin.xml 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,245 @@
+<AddIn name = "MonoQuery"
+ author = "Christian Hergert, Denis ERCHOFF of SharpQuery"
+ copyright = "GPL"
+ url = "http://www.monodevelop.com"
+ description = "MonoQuery"
+ version = "0.0.1">
+
+ <Runtime>
+ <Import assembly="MonoQuery.dll"/>
+ </Runtime>
+
+ <Extension path = "/Workspace/Services">
+ <Class id = "MonoQueryService"
+ class = "MonoQuery.Services.MonoQueryService"/>
+ </Extension>
+
+ <Extension path = "/MonoQuery/Connection">
+
+ <Class id = "NpgsqlConnectionWrapper"
+ class = "MonoQuery.Connection.NpgsqlConnectionWrapper"/>
+ <!--
+ <Class id = "MysqlConnectionWrapper"
+ class = "MonoQuery.Connection.MysqlConnectionWrapper"/>
+ -->
+ <Class id = "OledbConnectionWrapper"
+ class = "MonoQuery.Connection.OLEDBConnectionWrapper"/>
+
+ <MonoQueryConnection id ="Column"
+ schema="MonoQuery.SchemaClass.MonoQueryColumn"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeColumn"
+ showUnsuported = "False"/>
+
+ <MonoQueryConnection id ="Parameter"
+ schema="MonoQuery.SchemaClass.MonoQueryParameter"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeParameter"
+ showUnsuported = "False"/>
+
+ <MonoQueryConnection id ="Procedure"
+ schema="MonoQuery.SchemaClass.MonoQueryProcedure"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeProcedure"
+ showUnsuported = "False"/>
+
+ <MonoQueryConnection id ="Table"
+ schema="MonoQuery.SchemaClass.MonoQueryTable"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeTable"
+ showUnsuported = "False"/>
+
+ <MonoQueryConnection id ="View"
+ schema="MonoQuery.SchemaClass.MonoQueryView"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeView"
+ showUnsuported = "False"/>
+
+ <MonoQueryConnection id ="NotSupported"
+ schema="MonoQuery.SchemaClass.MonoQueryNotSupported"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeNotSupported"
+ showUnsuported = "False"/>
+
+ <MonoQueryConnection id ="Tables"
+ schema="MonoQuery.SchemaClass.MonoQueryTables"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeTableRoot"
+ showUnsuported = "False"/>
+
+ <MonoQueryConnection id ="Views"
+ schema="MonoQuery.SchemaClass.MonoQueryViews"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeViewRoot"
+ showUnsuported = "False"/>
+
+ <MonoQueryConnection id ="Procedures"
+ schema="MonoQuery.SchemaClass.MonoQueryProcedures"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeProcedureRoot"
+ showUnsuported = "False"/>
+
+ <MonoQueryConnection id ="Schema"
+ schema="MonoQuery.SchemaClass.MonoQuerySchema"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeSchema"
+ showUnsuported = "False"/>
+
+ <MonoQueryConnection id ="Catalog"
+ schema="MonoQuery.SchemaClass.MonoQueryCatalog"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeCatalog"
+ showUnsuported = "False"/>
+
+ <MonoQueryConnection id ="Npgsql"
+ schema="MonoQuery.Connection.NpgsqlConnectionWrapper"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeConnection"
+ description = "PostgreSQL 7.x Database Server"
+ showUnsuported = "False"/>
+ <MonoQueryConnection id ="Mysql"
+ schema="MonoQuery.Connection.MysqlConnectionWrapper"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeConnection"
+ description = "MySQL Database Server"
+ showUnsuported = "False"/>
+<!--
+ <MonoQueryConnection id ="OLEDB"
+ schema="MonoQuery.Connection.OLEDBConnectionWrapper"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeConnection"
+ description = "OleDB Connection Provider"
+ showUnsuported = "False"/>
+ <MonoQueryConnection id ="ADO"
+ schema="MonoQuery.Connection.ADOConnectionWrapper"
+ node ="MonoQuery.Gui.TreeView.MonoQueryNodeConnection"
+ showUnsuported = "False"/>
+-->
+ </Extension>
+
+ <Extension path = "/SharpDevelop/Workbench/Views">
+ <Class id = "MonoQuery"
+ insertafter = "HelpBrowser"
+ class = "MonoQuery.Pads.MonoQueryView"/>
+ </Extension>
+
+ <Extension path = "/MonoQuery/ContextMenu/DatabaseRoot">
+ <MenuItem id = "Refresh"
+ _label = "Refresh"
+ icon = "Icons.16x16.BrowserRefresh"
+ class = "MonoQuery.Commands.MonoQueryRefreshCommand"/>
+ <MenuItem id = "Separator1"
+ _label = "-" />
+ <MenuItem id = "AddConnection"
+ _label = "Add Connection"
+ icon = "MonoQuery.Addconnection"
+ class = "MonoQuery.Commands.MonoQueryAddconnectionCommand"/>
+
+ </Extension>
+
+ <Extension path = "/MonoQuery/ContextMenu/DatabaseConnection">
+ <MenuItem id = "Refresh"
+ _label = "Refresh"
+ icon = "Icons.16x16.BrowserRefresh"
+ class = "MonoQuery.Commands.MonoQueryRefreshCommand"/>
+ <MenuItem id = "ShowSqlView"
+ _label = "Show SQL View"
+ class = "MonoQuery.Commands.MonoQueryShowSqlViewCommand"/>
+ <MenuItem id = "Separator1"
+ _label = "-" />
+ <MenuItem id = "Supprimer"
+ _label = "Remove"
+ icon="Icons.16x16.Remove"
+ class = "MonoQuery.Commands.MonoQueryRemoveConnectionCommand"/>
+ <MenuItem id = "Separator2"
+ _label = "-" />
+<!-- No Glade Druid made yet
+ <MenuItem id = "ModifyConnection"
+ _label = "Modify Connection"
+ icon="Icons.16x16.Edit"
+ class = "MonoQuery.Commands.MonoQueryModifyConnectionCommand"/>
+-->
+ <MenuItem id = "Disconnect"
+ _label = "Disconnect"
+ icon = "MonoQuery.Disconnect"
+ class = "MonoQuery.Commands.MonoQueryDisconnectCommand"/>
+ <MenuItem id = "Connect"
+ _label = "Connect"
+ icon = "MonoQuery.Connect"
+ class = "MonoQuery.Commands.MonoQueryConnectCommand"/>
+ </Extension>
+
+ <Extension path = "/MonoQuery/ContextMenu/TablesRoot">
+ <MenuItem id = "Refresh"
+ _label = "Refresh"
+ icon = "Icons.16x16.BrowserRefresh"
+ class = "MonoQuery.Commands.MonoQueryRefreshCommand"/>
+ </Extension>
+
+ <Extension path = "/MonoQuery/ContextMenu/ViewsRoot">
+ <MenuItem id = "Refresh"
+ _label = "Refresh"
+ icon = "Icons.16x16.BrowserRefresh"
+ class = "MonoQuery.Commands.MonoQueryRefreshCommand"/>
+ </Extension>
+
+ <Extension path = "/MonoQuery/ContextMenu/ProceduresRoot">
+ <MenuItem id = "Refresh"
+ _label = "Refresh"
+ icon = "Icons.16x16.BrowserRefresh"
+ class = "MonoQuery.Commands.MonoQueryRefreshCommand"/>
+ </Extension>
+
+
+ <Extension path = "/MonoQuery/ContextMenu/Table">
+ <MenuItem id = "Refresh"
+ _label = "Refresh"
+ icon = "Icons.16x16.BrowserRefresh"
+ class = "MonoQuery.Commands.MonoQueryRefreshCommand"/>
+ <MenuItem id = "ExtractData"
+ _label = "Extract Data"
+ icon = "Icons.16x16.PreView"
+ class = "MonoQuery.Commands.MonoQueryExecuteCommand"/>
+ </Extension>
+
+ <Extension path = "/MonoQuery/ContextMenu/View">
+ <MenuItem id = "Refresh"
+ _label = "Refresh"
+ icon = "Icons.16x16.BrowserRefresh"
+ class = "MonoQuery.Commands.MonoQueryRefreshCommand"/>
+ <MenuItem id = "ExtractData"
+ _label = "Extract Data"
+ icon = "Icons.16x16.PreView"
+ class = "MonoQuery.Commands.MonoQueryExecuteCommand"/>
+ </Extension>
+
+
+ <Extension path = "/MonoQuery/ContextMenu/Procedure">
+ <MenuItem id = "Refresh"
+ _label = "Refresh"
+ icon = "Icons.16x16.BrowserRefresh"
+ class = "MonoQuery.Commands.MonoQueryRefreshCommand"/>
+<!--
+ <MenuItem id = "ExecuteProcedure"
+ _label = "Execute Procedure"
+ class = "MonoQuery.Commands.MonoQueryExecuteCommand"/>
+-->
+ </Extension>
+
+
+ <Extension path = "/MonoQuery/ContextMenu/Coulmn">
+ <MenuItem id = "Refresh"
+ _label = "Refresh"
+ icon = "Icons.16x16.BrowserRefresh"
+ class = "MonoQuery.Commands.MonoQueryRefreshCommand"/>
+ </Extension>
+
+ <Extension path = "/MonoQuery/ContextMenu/Parameter">
+ <MenuItem id = "Refresh"
+ _label = "Refresh"
+ icon = "Icons.16x16.BrowserRefresh"
+ class = "MonoQuery.Commands.MonoQueryRefreshCommand"/>
+ </Extension>
+
+ <Extension path = "/MonoQuery/ContextMenu/Catalog">
+ <MenuItem id = "Refresh"
+ _label = "Refresh"
+ icon = "Icons.16x16.BrowserRefresh"
+ class = "MonoQuery.Commands.MonoQueryRefreshCommand"/>
+ </Extension>
+
+ <Extension path = "/MonoQuery/ContextMenu/Schema">
+ <MenuItem id = "Refresh"
+ _label = "Refresh"
+ icon = "Icons.16x16.BrowserRefresh"
+ class = "MonoQuery.Commands.MonoQueryRefreshCommand"/>
+ </Extension>
+
+</AddIn>
+
Added: trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.cmbx
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.cmbx 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.cmbx 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,16 @@
+<Combine fileversion="1.0" name="MonoQuery" description="">
+ <StartMode startupentry="MonoQuery" single="True">
+ <Execute entry="MonoQuery" type="None" />
+ </StartMode>
+ <Entries>
+ <Entry filename="./MonoQuery.prjx" />
+ </Entries>
+ <Configurations active="Debug">
+ <Configuration name="Release">
+ <Entry name="MonoQuery" configurationname="Debug" build="False" />
+ </Configuration>
+ <Configuration name="Debug">
+ <Entry name="MonoQuery" configurationname="Debug" build="False" />
+ </Configuration>
+ </Configurations>
+</Combine>
\ No newline at end of file
Added: trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.mdsx
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.mdsx 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.mdsx 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,3 @@
+<MonoDevelopSolution fileversion="1.0">
+ <RelativeOutputPath>./</RelativeOutputPath>
+</MonoDevelopSolution>
\ No newline at end of file
Added: trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.prjx
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.prjx 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/MonoQuery.prjx 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,86 @@
+<Project name="MonoQuery" description="" newfilesearch="None" enableviewstate="True" version="1.1" projecttype="C#">
+ <Contents>
+ <File name="./AssemblyInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./MonoQueryView.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/MonoQueryPanel.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/MonoQueryTree/MonoQueryTree.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/MonoQueryTree" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/MonoQueryTree/MonoQueryNodesRoot.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./SchemaClass/MonoQuerySchemaClass.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Commands" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Commands/MonoQueryCommands.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Collection" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/Interface/IMonoQueryNode.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/Abstract/AbstractMonoQueryNode.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/MonoQueryTree/MonoQueryDataNodes.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/Interface" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/DataView" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/DataView/MonoQueryDataView.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Connection" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Collection/MonoQueryStringDictionary.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./SchemaClass/Abstract/AbstractMonoQuerySchemaClass.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Connection/Abstract/AbstractMonoQueryConnectionWrapper.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Codons" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Codons/MonoQueryConnectionCodon.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./MonoQuery.addin.xml" subtype="Code" buildaction="Nothing" dependson="" data="" />
+ <File name="./Connection/Interface" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./SchemaClass/Interface/ISchemaClass.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Collection/MonoQuerySchemaClassCollection.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Connection/Interface/IConnection.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Collection/MonoQueryListDictionary.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Commands/Abstract/AbstractMonoQueryCommand.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./SchemaClass" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./SchemaClass/Interface" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/DataView/SQLParameterInput.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Exceptions" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Exceptions/ConnectionStringException.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Exceptions/OpenConnectionException.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Exceptions/ExecuteSQLException.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Exceptions/ExecuteProcedureException.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Exceptions/Abstract/MonoQueryAbstractException.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Collection/MonoQueryParameterCollection.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/Forms" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/Forms/CreateConnectionDruid.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Services" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Services/MonoQueryService.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Connection/Npgsql" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Connection/Npgsql/NpgsqlConnectionWrapper.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/Forms/New Folder" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/Forms/Glade/monoquery.glade" subtype="Code" buildaction="Nothing" dependson="" data="" />
+ <File name="./Connection/Mysql/MysqlConnectionWrapper.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Collection/ConnectionProviderDescriptor.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/SqlQueryView" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name="./Gui/SqlQueryView/SqlQueryView.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ </Contents>
+ <References>
+ <Reference type="Gac" refto="System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" localcopy="True" />
+ <Reference type="Gac" refto="Npgsql, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" localcopy="True" />
+ <Reference type="Gac" refto="glade-sharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" localcopy="True" />
+ <Reference type="Gac" refto="ByteFX.Data, Version=0.7.6.1, Culture=neutral, PublicKeyToken=0738eb9f132ed756" localcopy="True" />
+ <Reference type="Gac" refto="gtksourceview-sharp, Version=1.0.0.1, Culture=neutral, PublicKeyToken=35e10195dab3c99f" localcopy="True" />
+ <Reference type="Assembly" refto="../../build/bin/MonoDevelop.Base.dll" localcopy="True" />
+ <Reference type="Assembly" refto="../../build/bin/MonoDevelop.Core.dll" localcopy="True" />
+ <Reference type="Assembly" refto="../../build/bin/MonoDevelop.Gui.Widgets.dll" localcopy="True" />
+ <Reference type="Gac" refto="gtk-sharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" localcopy="True" />
+ <Reference type="Gac" refto="gtksourceview-sharp, Version=1.0.0.2, Culture=neutral, PublicKeyToken=35e10195dab3c99f" localcopy="True" />
+ </References>
+ <DeploymentInformation target="" script="" strategy="File" />
+ <Configuration runwithwarnings="False" name="Debug">
+ <CodeGeneration runtime="MsNet" compiler="Csc" warninglevel="4" nowarn="" includedebuginformation="True" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="" generatexmldocumentation="False" win32Icon="" />
+ <Execution commandlineparameters="" consolepause="True" />
+ <Output directory="../bin/Debug" assembly="MonoQuery" executeScript="" executeBeforeBuild="" executeAfterBuild="" />
+ </Configuration>
+ <Configurations active="Debug">
+ <Configuration runwithwarnings="False" name="Debug">
+ <CodeGeneration runtime="MsNet" compiler="Csc" warninglevel="4" nowarn="" includedebuginformation="True" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="" generatexmldocumentation="False" win32Icon="" />
+ <Execution commandlineparameters="" consolepause="True" />
+ <Output directory="../bin/Debug" assembly="MonoQuery" executeScript="" executeBeforeBuild="" executeAfterBuild="" />
+ </Configuration>
+ <Configuration runwithwarnings="False" name="Release">
+ <CodeGeneration runtime="MsNet" compiler="Csc" warninglevel="4" nowarn="" includedebuginformation="True" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="" generatexmldocumentation="False" win32Icon="" />
+ <Execution commandlineparameters="" consolepause="True" />
+ <Output directory="../bin/Release" assembly="MonoQuery" executeScript="" executeBeforeBuild="" executeAfterBuild="" />
+ </Configuration>
+ </Configurations>
+</Project>
\ No newline at end of file
Added: trunk/MonoDevelop/Extras/MonoQuery/MonoQueryView.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/MonoQueryView.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/MonoQueryView.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,87 @@
+
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+using System.IO;
+
+using MonoDevelop.Gui;
+using MonoQuery.Gui;
+using MonoQuery.Gui.TreeView;
+using MonoQuery.Services;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+using MonoDevelop.Core.AddIns;
+
+//TODO : dans les MonoQueryList faire correspondre les restrictions vec les objets ajoutés
+//TODO : dans les MonoQueryList faire correspondre les dataconnection avec les objets ajoutés
+//TODO : ajout statistiques.
+
+namespace MonoQuery.Pads
+{
+ /// <summary>
+ /// This Pad Show a tree where you can add/remove databases connections.
+ /// You can administrate databases from this tree.
+ /// </summary>
+ public class MonoQueryView : AbstractPadContent
+ {
+ private static MonoQueryTree monoQueryTree = null;
+ private static Gtk.ScrolledWindow scroller = null;
+#region AbstractPadContent requirements
+ /// <summary>
+ /// The <see cref="System.Windows.Forms.Control"/> representing the pad
+ /// </summary>
+ public override Gtk.Widget Control {
+ get {
+ return scroller;
+ }
+ }
+
+ /// <summary>
+ /// Creates a new MonoQueryView object
+ /// </summary>
+ public MonoQueryView()
+ : base( GettextCatalog.GetString( "Database" ), "Icons.16x16.MonoQuery.DatabaseConnection")
+ {
+ CreateDefaultMonoQuery();
+// monoQueryTree.Dock = DockStyle.Fill;
+ }
+
+ void CreateDefaultMonoQuery()
+ {
+ scroller = new Gtk.ScrolledWindow();
+ scroller.ShadowType = Gtk.ShadowType.In;
+ monoQueryTree = new MonoQueryTree();
+ scroller.Add( monoQueryTree );
+
+ MonoQueryService service = (MonoQueryService)ServiceManager.GetService(
+ typeof(MonoQueryService));
+ service.Tree = monoQueryTree;
+ }
+
+ public void SaveMonoQueryView()
+ {
+ }
+
+ /// <summary>
+ /// Refreshes the pad
+ /// </summary>
+ public override void RedrawContent()
+ {
+ OnTitleChanged(null);
+ OnIconChanged(null);
+// monoQueryTree.Refresh();
+ }
+
+ /// <summary>
+ /// Cleans up all used resources
+ /// </summary>
+ public override void Dispose()
+ {
+ this.SaveMonoQueryView();
+ monoQueryTree.Dispose();
+ }
+#endregion
+ }
+
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/Abstract/AbstractMonoQuerySchemaClass.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/Abstract/AbstractMonoQuerySchemaClass.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/Abstract/AbstractMonoQuerySchemaClass.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,281 @@
+
+namespace MonoQuery.SchemaClass
+{
+ using System;
+ using System.Collections;
+ using System.Data;
+ using System.ComponentModel;
+
+ using MonoQuery.Collections;
+
+ using MonoDevelop.Core.Services;
+ using MonoDevelop.Services;
+ using MonoDevelop.Core.AddIns.Conditions;
+ using MonoDevelop.Core.AddIns.Codons;
+ using MonoDevelop.Core.AddIns;
+
+ using MonoQuery.Connection;
+
+ public abstract class AbstractMonoQuerySchemaClass : ISchemaClass
+ {
+ static StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+
+ protected string pCatalogName = null;
+ protected string pSchemaName = null;
+ protected string pOwnerName = null;
+ protected string pName = null;
+
+ protected IConnection pDataConnection = null;
+
+ ///<summary>
+ /// check if there are white spaces into the string.
+ /// if yes, then add "[" at the begin and "]" at the end.
+ ///</summary>
+ internal static string CheckWhiteSpace( string str )
+ {
+ string returnStr = str;
+
+ if ( returnStr.IndexOf(" ") > -1 )
+ {
+ if ( returnStr.StartsWith( "[" ) == false )
+ {
+ returnStr = "[" + returnStr;
+ }
+ if ( returnStr.EndsWith( "]" ) == false )
+ {
+ returnStr = returnStr + "]";
+ }
+ }
+
+ return returnStr;
+ }
+
+ ///<summary>remove "[" at the begin and at the end of the str</summary>
+ internal static string RemoveBracket( string str )
+ {
+ string returnStr = str;
+ if ( returnStr.StartsWith( "[" ) == true )
+ {
+ returnStr = returnStr.Remove(0, 1);
+ }
+ if ( returnStr.EndsWith( "]" ) == true )
+ {
+ returnStr = returnStr.Remove( returnStr.Length - 1 , 1);
+ }
+ return returnStr;
+ }
+
+
+ ///<summary>
+ /// those, are list of the childs schema.
+ /// i am using a dictionnary (<see cref="MonoQuery.Collections.MonoQueryListDictionary"></see>) because is more simplest to write
+ /// <code>Entities["PROCEDURES"]</code> than <code>Entities[0]</code>.
+ ///</summary>
+ protected MonoQueryListDictionary pEntities = null;
+
+ public string CatalogName{
+ get{
+ return CheckWhiteSpace( this.pCatalogName );
+ }
+ }
+
+ public string SchemaName{
+ get{
+ return CheckWhiteSpace( this.pSchemaName );
+ }
+ }
+
+ public string OwnerName{
+ get{
+ return CheckWhiteSpace( this.pOwnerName );
+ }
+ }
+
+ public string Name{
+ get{
+ return CheckWhiteSpace( this.pName );
+ }
+ }
+
+ public string InternalName
+ {
+ get
+ {
+ return RemoveBracket( this.Name );
+ }
+ }
+
+ public virtual string NormalizedName
+ {
+ get
+ {
+ return CheckWhiteSpace( Name );
+ }
+ }
+
+ ///<summary>
+ /// those, are list of the childs schema.
+ /// i am using a dictionnary (<see cref="MonoQuery.Collections.MonoQueryListDictionary"></see>) because is more simplest to write
+ /// <code>Entities["PROCEDURES"]</code> than <code>Entities[0]</code>.
+ ///</summary>
+ public MonoQueryListDictionary Entities
+ {
+ get
+ {
+ return pEntities;
+ }
+ }
+
+ public IConnection Connection
+ {
+ get
+ {
+ return this.pDataConnection;
+ }
+ }
+
+// ///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
+// ///</summary>
+// public virtual DataObject DragObject
+// {
+// get
+// {
+// return null;
+// }
+// }
+
+ //create the entities list
+ protected virtual void CreateEntitiesList()
+ {
+ if ( this.pEntities == null )
+ {
+ this.pEntities = new MonoQueryListDictionary();
+ }
+ }
+
+ ///<summary>
+ /// construtor
+ /// <list type="bullet">
+ /// <listheader>
+ /// <term>parameters</term>
+ /// <description></description>
+ /// </listheader>
+ /// <item>
+ /// <term><code>connection</code></term>
+ /// <description>connection object from wich this schema is extracted</description>
+ /// </item>
+ /// <item>
+ /// <term><code>catalogName</code></term>
+ /// <description> this is the catalog of this schema entity </description>
+ /// </item>
+ /// <item>
+ /// <term><code>schemaName</code></term>
+ /// <description> this is the schema of this schema entity </description>
+ /// </item>
+ /// <item>
+ /// <term><code>ownerName</code></term>
+ /// <description> this is the owner name of this schema entity </description>
+ /// </item>
+ /// <item>
+ /// <term><code>name</code></term>
+ /// <description> this is the name of this schema entity </description>
+ /// </item>
+ /// </list>
+ ///</summary>
+ public AbstractMonoQuerySchemaClass( IConnection connection, string catalogName, string schemaName, string ownerName, string name ) : base()
+ {
+ this.pCatalogName = catalogName;
+ this.pSchemaName = schemaName;
+ this.pOwnerName = ownerName;
+ this.pName = name;
+ this.pDataConnection = connection;
+
+ this.CreateEntitiesList();
+ }
+
+ ///<summary>
+ /// called by <see cref=".Refresh()">Refresh</see> just after the <see cref=".Clear()">Clear</see> and before <see cref=".Refresh()">childs'refresh</see>.
+ /// In this, you could change the <see cref=".Entities">Entities dicntionnary.</see>
+ ///</summary>
+ protected abstract void OnRefresh();
+
+ public void Refresh()
+ {
+ this.Clear();
+ this.CreateEntitiesList();
+
+ if (this.Connection.IsOpen == true )
+ {
+ this.OnRefresh();
+ }
+ }
+
+ public void Clear()
+ {
+ if (this.pEntities != null )
+ {
+ this.pEntities.Clear();
+ }
+ }
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// <returns><see cref="System.Data.DataTable">DataTable</see>
+ /// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
+ /// </summary>
+ public abstract object Execute( int rows, MonoQuerySchemaClassCollection parameters );
+
+ ///<summary> if <see cref=".Dataconnection.CatalogName">CatalogName</see> is <code>null</code> or <code>empty</code>
+ /// enumerate all catalogs from the database.
+ /// Else enumerate the current catalog's properties.
+ /// </summary>
+ public virtual MonoQuerySchemaClassCollection GetSchemaCatalogs()
+ {
+ return this.pDataConnection.GetSchemaCatalogs(this);
+ }
+
+ ///<summary> if <see cref=".Dataconnection.CatalogName">CatalogName</see> is <code>null</code> or <code>empty</code>
+ /// enumerate all shcema from the database.
+ /// Else enumerate schemas from the current catalog.
+ /// </summary>
+ public virtual MonoQuerySchemaClassCollection GetSchemaSchemas()
+ {
+ return this.pDataConnection.GetSchemaSchemas(this);
+ }
+
+ ///<summary> Enumerate the <see cref=".CatalogName">CatalogName<see cref=".SchemaName">.SchemaName</see></see>'s tables
+ /// </summary>
+ public virtual MonoQuerySchemaClassCollection GetSchemaTables()
+ {
+ return this.pDataConnection.GetSchemaTables( this );
+ }
+
+ ///<summary> Enumerate the <see cref=".CatalogName">CatalogName<see cref=".SchemaName">.SchemaName</see></see>'s views
+ /// </summary>
+ public virtual MonoQuerySchemaClassCollection GetSchemaViews()
+ {
+ return this.pDataConnection.GetSchemaViews( this );
+ }
+
+ ///<summary> Enumerate the <see cref=".CatalogName">CatalogName<see cref=".SchemaName">.SchemaName</see></see>'s procedures
+ /// </summary>
+ public virtual MonoQuerySchemaClassCollection GetSchemaProcedures()
+ {
+ return this.pDataConnection.GetSchemaProcedures( this );
+ }
+
+ public virtual MonoQuerySchemaClassCollection GetSchemaColumns()
+ {
+ MonoQuerySchemaClassCollection list = new MonoQuerySchemaClassCollection();
+ return list;
+ }
+
+ public virtual MonoQuerySchemaClassCollection GetSchemaParameters()
+ {
+ MonoQuerySchemaClassCollection list = new MonoQuerySchemaClassCollection();
+ return list;
+ }
+ }
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/Interface/ISchemaClass.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/Interface/ISchemaClass.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/Interface/ISchemaClass.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,140 @@
+namespace MonoQuery.SchemaClass
+{
+ using System.Collections;
+ using System.Data;
+
+ using MonoQuery.Collections;
+ using MonoQuery.Connection;
+
+ ///<summary>
+ /// This interface is used by any schema class in sharp query.
+ /// A schema class is a class that is the database definition of a <code>table</code>,
+ /// a <code>view</code>, a <code>column</code>, etc etc ...
+ /// <remarks>
+ /// <code>entity</code> is <code>table</code>, a <code>view</code> or other database struct.
+ /// <code>schema</code>'s names are displayed between <code>[</code> and <code>]</code>
+ /// </remarks>
+ ///</summary>
+ public interface ISchemaClass
+ {
+ ///<summary>
+ /// get the connection object
+ ///</summary>
+ IConnection Connection{ get; }
+
+ ///<summary>
+ /// get the <code>entity</code>'s <code>catalog</code> name.
+ ///</summary>
+ string CatalogName{ get; }
+
+ ///<summary>
+ /// get the <code>entity</code>'s <code>schema</code> name.
+ ///</summary>
+ string SchemaName{ get; }
+
+ ///<summary>
+ /// Get the <code>entity</code>'s owner name
+ /// <example>
+ /// for exemple, the owner of a <code>column</code> is a <code>table</code>,
+ /// and this property return the name of the <code>table</code>
+ ///</example>
+ ///</summary>
+ string OwnerName{ get; }
+
+ ///<summary>
+ /// get the <code>entity</code>'s name
+ ///</summary>
+ string Name{ get; }
+
+ /// <summary>
+ /// Internal name, used internally
+ /// </summary>
+ string InternalName{ get; }
+
+ ///<summary>
+ /// <code>entity</code>'s normalized name.
+ /// <example>
+ /// there are a database <code>test</code>. In this database there are a <code>schema</code>
+ /// named <code>fool</code>. In this <code>schema</code> there are a <code>table</code> named <code>fooltable</code>
+ /// and a in this <code>table</code> there are a <code>column</code> named <code>foolcolumn</code>.
+ /// So, the normalized name of the <code>schema</code> is <code>test.[fool]</code>.
+ /// The normalized name of the <code>table</code> is <code>test.[fool].fooltable</code>.
+ /// The normalized name of the <code>column</code> is <code>test.[fool].fooltable.foolcolumn</code>.
+ ///</example>
+ ///</summary>
+ string NormalizedName{ get; }
+
+ ///<summary>
+ /// Those, are list of the childs schema.( columns, etc etc )
+ /// i am using a dictionnary because is more simplest to write
+ /// <code>Entities["PROCEDURES"]</code> than <code>Entities[0]</code>.
+ ///</summary>
+ MonoQueryListDictionary Entities { get; }
+
+ ///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see> </summary>
+ //DataObject DragObject{ get; }
+
+ ///<summary>
+ /// Refresh child schemas from the database.
+ ///</summary>
+ void Refresh();
+
+ ///<summary>
+ /// Erase all child schemas
+ ///</summary>
+ void Clear();
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// <returns><see cref="System.Data.DataTable">DataTable</see>
+ /// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
+ /// </summary>
+ object Execute( int rows, MonoQuerySchemaClassCollection parameters );
+
+ ///<summary>
+ /// Get <seealso cref='.ISchemaClass.Connection'/>'s catalogs.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaCatalogs();
+
+ ///<summary>
+ /// Get <seealso cref='.ISchemaClass.Connection'/>'s Schemas.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaSchemas();
+
+ ///<summary>
+ /// From a catalog object, get tables from all schemas.
+ /// From a schema object get tables from all this schema.
+ /// From other object, return an empty list.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaTables();
+
+ ///<summary>
+ /// From a catalog object, get views from all schemas.
+ /// From a schema object get views from all this schema.
+ /// From other object, return an empty list.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaViews();
+
+ ///<summary>
+ /// From a catalog object, get procedures from all schemas.
+ /// From a schema object get procedures from all this schema.
+ /// From other object, return an empty list.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaProcedures();
+
+ ///<summary>
+ /// From a table or a view or procedure object, get columns from the table.
+ /// From other object, return an empty list.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaColumns();
+
+ ///<summary>
+ /// Get parameters from the procedure.
+ /// If parameters are not supported by the schema, return an empty list.
+ ///</summary>
+ MonoQuerySchemaClassCollection GetSchemaParameters();
+ }
+
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/MonoQuerySchemaClass.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/MonoQuerySchemaClass.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/SchemaClass/MonoQuerySchemaClass.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,772 @@
+// created on 04/11/2003 at 18:15
+
+using System;
+using System.Collections;
+using System.Data;
+using System.Data.OleDb;
+using System.Reflection;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+
+using MonoQuery.Connection;
+using MonoQuery.Collections;
+
+namespace MonoQuery.SchemaClass
+{
+
+//
+// Childs
+//
+
+ ///<summary>
+ /// Column class
+ ///</summary>
+ public class MonoQueryColumn : AbstractMonoQuerySchemaClass
+ {
+ public override string NormalizedName
+ {
+ get {
+ string normalizedName = "";
+
+ if ( (this.OwnerName != "") && (this.OwnerName != null) ){
+ normalizedName += this.OwnerName + ".";
+ }
+
+ normalizedName += this.Name;
+
+ return normalizedName;
+ }
+ }
+
+ protected override void CreateEntitiesList()
+ {
+ }
+
+ public MonoQueryColumn( IConnection connection, string catalogName, string schemaName, string ownerName, string name ) : base(connection, catalogName, schemaName, ownerName, name )
+ {
+ }
+
+ protected override void OnRefresh()
+ {
+ //nothing !
+ }
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// <returns><see cref="System.Data.DataTable">DataTable</see>
+ /// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
+ /// </summary>
+ public override object Execute( int rows, MonoQuerySchemaClassCollection parameters )
+ {
+ //nothing
+ return null;
+ }
+
+// ///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
+// ///</summary>
+// public override DataObject DragObject
+// {
+// get
+// {
+// DataObject returnValue = new DataObject();
+// string extract = this.NormalizedName;
+// returnValue.SetData(typeof(string) , extract );
+// return returnValue;
+// }
+// }
+ }
+
+ ///<summary>
+ /// Procedurre's parameters class
+ ///</summary>
+ public class MonoQueryParameter : AbstractMonoQuerySchemaClass
+ {
+ private DbType _dataType;
+ private object _value = null;
+ private ParameterDirection _type;
+
+ ///<summary>
+ /// Data Type of the parameter
+ /// ( used only while extracting data or executing procedure )
+ ///</summary>
+ public DbType DataType
+ {
+ get
+ {
+ return this._dataType;
+ }
+ set
+ {
+ this._dataType = value;
+ switch( value )
+ {
+ //string type
+ case DbType.AnsiString :
+ case DbType.AnsiStringFixedLength :
+ case DbType.String :
+ case DbType.StringFixedLength : this._value = new string( (char[])null ); break;
+ //array type
+ case DbType.Binary : this._value = new byte[8000]; break;
+ //bool type
+ case DbType.Boolean : this._value = new bool(); break;
+ //interger type
+ case DbType.SByte : this._value = new sbyte(); break;
+ case DbType.Byte : this._value = new byte(); break;
+ case DbType.Int16 : this._value = new short(); break;
+ case DbType.Int32 : this._value = new int(); break;
+ case DbType.Int64 : this._value = new long(); break;
+ case DbType.UInt16 : this._value = new ushort(); break;
+ case DbType.UInt32 : this._value = new uint(); break;
+ case DbType.UInt64 : this._value = new long(); break;
+ //Date type
+ case DbType.Date :
+ case DbType.DateTime :
+ case DbType.Time : this._value = new DateTime(); break;
+ //float type
+ case DbType.Decimal : this._value = new decimal(); break;
+ case DbType.Currency :
+ case DbType.VarNumeric :
+ case DbType.Double : this._value = new double(); break;
+ case DbType.Single : this._value = new float(); break;
+ //user defined
+ case DbType.Object : this._value = new object(); break;
+ //Guid
+ case DbType.Guid : this._value = new Guid(); break;
+ default : throw new ArgumentOutOfRangeException("value");
+ }
+ }
+ }
+
+ protected void SetValue( string value )
+ {
+ switch( this.DataType )
+ {
+ //string type
+ case DbType.Object :
+ case DbType.Binary :
+ case DbType.AnsiString :
+ case DbType.AnsiStringFixedLength :
+ case DbType.String :
+ case DbType.StringFixedLength : this._value = value; break;
+
+ case DbType.Boolean : this._value = bool.Parse( value ); break;
+
+ case DbType.SByte : this._value = sbyte.Parse( value ); break;
+ case DbType.Byte : this._value = byte.Parse( value ); break;
+ case DbType.Int16 : this._value = short.Parse( value ); break;
+ case DbType.Int32 : this._value = int.Parse( value ); break;
+ case DbType.Int64 : this._value = long.Parse( value ); break;
+ case DbType.UInt16 : this._value = ushort.Parse( value ); break;
+ case DbType.UInt32 : this._value = uint.Parse( value ); break;
+ case DbType.UInt64 : this._value = long.Parse( value ); break;
+
+ case DbType.Date :
+ case DbType.DateTime :
+ case DbType.Time : this._value = DateTime.Parse( value ); break;
+
+ case DbType.Decimal : this._value = decimal.Parse( value ); break;
+ case DbType.Currency :
+ case DbType.VarNumeric :
+ case DbType.Double : this._value = double.Parse( value ); break;
+ case DbType.Single : this._value = float.Parse( value ); break;
+
+ case DbType.Guid : this._value = new Guid( value ); break;
+ default : throw new ArgumentOutOfRangeException("value");
+ }
+ }
+
+ ///<summary>
+ /// Value of the parameter
+ /// ( used only while extracting data or executing procedure )
+ ///</summary>
+ public object Value
+ {
+ get
+ {
+ return this._value;
+ }
+ set
+ {
+ this.SetValue( value.ToString() );
+ }
+ }
+
+ ///<summary>
+ /// Value of the parameter
+ /// ( used only while extracting data or executing procedure )
+ ///</summary>
+ public ParameterDirection Type
+ {
+ get
+ {
+ return this._type;
+ }
+ set
+ {
+ this._type = value;
+ }
+ }
+
+ public override string NormalizedName
+ {
+ get {
+ string normalizedName = "";
+
+ if ( (this.OwnerName != "") && (this.OwnerName != null) ){
+ normalizedName += this.OwnerName + ".";
+ }
+
+ normalizedName += this.Name;
+
+ return normalizedName;
+ }
+ }
+
+ protected override void CreateEntitiesList()
+ {
+ }
+
+ public MonoQueryParameter( IConnection connection, string catalogName, string schemaName, string ownerName, string name ) : base(connection, catalogName, schemaName, ownerName, name )
+ {
+ this.pEntities = null;
+ }
+
+ protected override void OnRefresh()
+ {
+ //nothing !
+ }
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// <returns><see cref="System.Data.DataTable">DataTable</see></returns>
+ /// </summary>
+ public override object Execute( int rows, MonoQuerySchemaClassCollection parameters )
+ {
+ //nothing
+ return null;
+ }
+
+// ///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
+// ///</summary>
+// public override DataObject DragObject
+// {
+// get
+// {
+// DataObject returnValue = new DataObject();
+// string extract = NormalizedName;
+// returnValue.SetData(typeof(string) , extract );
+// return returnValue;
+// }
+// }
+ }
+
+ ///<summary>
+ /// Table class
+ ///</summary>
+ public class MonoQueryProcedure : AbstractMonoQuerySchemaClass
+ {
+ public override string NormalizedName
+ {
+ get
+ {
+ if ( (this.CatalogName != "") && (this.CatalogName != null) )
+ {
+ return this.CatalogName + "." + this.Name;
+ }
+ else
+ {
+ return CheckWhiteSpace(this.Connection.GetProperty( MonoQueryPropertyEnum.DataSource ).ToString()) + "." + this.Name;
+ }
+ }
+ }
+
+ protected override void CreateEntitiesList()
+ {
+ base.CreateEntitiesList();
+ this.pEntities.Add("PROCEDURE_COLUMNS", new MonoQuerySchemaClassCollection() );
+ this.pEntities.Add("PROCEDURE_PARAMETERS", new MonoQuerySchemaClassCollection() );
+ }
+
+ public MonoQueryProcedure( IConnection connection, string catalogName, string schemaName, string ownerName, string name ) : base(connection, catalogName, schemaName, ownerName, name )
+ {
+ }
+
+ public override MonoQuerySchemaClassCollection GetSchemaParameters()
+ {
+ return this.pDataConnection.GetSchemaProcedureParameters( this );
+ }
+
+ public override MonoQuerySchemaClassCollection GetSchemaColumns()
+ {
+ return this.pDataConnection.GetSchemaProcedureColumns( this );
+ }
+
+ protected override void OnRefresh()
+ {
+ this.Entities["PROCEDURE_COLUMNS"].AddRange( this.GetSchemaColumns() );
+ this.Entities["PROCEDURE_PARAMETERS"].AddRange( this.GetSchemaParameters() );
+ }
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// <returns><see cref="System.Data.DataTable">DataTable</see>
+ /// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
+ /// </summary>
+ public override object Execute( int rows, MonoQuerySchemaClassCollection parameters )
+ {
+ return this.Connection.ExecuteProcedure( this, rows, parameters );
+ }
+
+// ///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
+// ///</summary>
+// public override DataObject DragObject
+// {
+// get
+// {
+// DataObject returnValue = new DataObject();
+// string extract = "EXECUTE " + NormalizedName;
+// returnValue.SetData(typeof(string) , extract );
+// return returnValue;
+// }
+// }
+ }
+
+ ///<summary>
+ /// Table class
+ ///</summary>
+ public class MonoQueryTable : AbstractMonoQuerySchemaClass
+ {
+ public override string NormalizedName
+ {
+ get
+ {
+ if ( (this.CatalogName != "") && (this.CatalogName != null) )
+ {
+ return this.CatalogName + "." + this.Name;
+ }
+ else
+ {
+ return CheckWhiteSpace(this.Connection.GetProperty( MonoQueryPropertyEnum.DataSource ).ToString()) + "." + this.Name;
+ }
+ }
+ }
+
+ protected override void CreateEntitiesList()
+ {
+ base.CreateEntitiesList();
+ this.pEntities.Add("TABLE_COLUMNS", new MonoQuerySchemaClassCollection() );
+ }
+
+ public MonoQueryTable( IConnection connection, string catalogName, string schemaName, string ownerName, string name ) : base(connection, catalogName, schemaName, ownerName, name )
+ {
+ }
+
+ public override MonoQuerySchemaClassCollection GetSchemaColumns()
+ {
+ return this.pDataConnection.GetSchemaTableColumns( this );
+ }
+
+ protected override void OnRefresh()
+ {
+ this.Entities["TABLE_COLUMNS"].AddRange( this.GetSchemaColumns() );
+ }
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// <returns><see cref="System.Data.DataTable">DataTable</see>
+ /// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
+ /// </summary>
+ public override object Execute( int rows, MonoQuerySchemaClassCollection parameters )
+ {
+ return this.Connection.ExtractData( this, rows );
+ }
+
+// ///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
+// ///</summary>
+// public override DataObject DragObject
+// {
+// get
+// {
+// string SQLSelect = "SELECT ";
+// string SQLFrom = "FROM ";
+//
+// MonoQuerySchemaClassCollection entitieslist = null;
+//
+// SQLFrom += this.Name;
+//
+// this.Refresh();
+//
+// //we have only a table or view :o)
+// foreach( DictionaryEntry DicEntry in Entities )
+// {
+// entitieslist = DicEntry.Value as MonoQuerySchemaClassCollection;
+// break;
+// }
+//
+// if ( entitieslist == null )
+// {
+// throw new System.ArgumentNullException("entitieslist");
+// }
+//
+// foreach( ISchemaClass column in entitieslist )
+// {
+// SQLSelect += column.NormalizedName;
+// SQLSelect += ",";
+// }
+//
+// SQLSelect = SQLSelect.TrimEnd( new Char[]{','} );
+// SQLSelect += " ";
+//
+// DataObject returnValue = new DataObject();
+//
+// returnValue.SetData(typeof(string) , SQLSelect + SQLFrom );
+// return returnValue;
+// }
+// }
+ }
+
+ ///<summary>
+ /// View class
+ ///</summary>
+ public class MonoQueryView : AbstractMonoQuerySchemaClass
+ {
+ public override string NormalizedName
+ {
+ get
+ {
+ if ( (this.CatalogName != "") && (this.CatalogName != null) )
+ {
+ return this.CatalogName + "." + this.Name;
+ }
+ else
+ {
+ return CheckWhiteSpace(this.Connection.GetProperty( MonoQueryPropertyEnum.DataSource ).ToString()) + "." + this.Name;
+ }
+ }
+ }
+
+ protected override void CreateEntitiesList()
+ {
+ base.CreateEntitiesList();
+ this.pEntities.Add("VIEWS_COLUMNS", new MonoQuerySchemaClassCollection() );
+ }
+
+ public MonoQueryView( IConnection connection, string catalogName, string schemaName, string ownerName, string name ) : base(connection, catalogName, schemaName, ownerName, name )
+ {
+ }
+
+ public override MonoQuerySchemaClassCollection GetSchemaColumns()
+ {
+ return this.pDataConnection.GetSchemaViewColumns( this );
+ }
+
+ protected override void OnRefresh()
+ {
+ this.Entities["VIEWS_COLUMNS"].AddRange( this.GetSchemaColumns() );
+ }
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// <returns><see cref="System.Data.DataTable">DataTable</see>
+ /// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
+ /// </summary>
+ public override object Execute( int rows, MonoQuerySchemaClassCollection parameters )
+ {
+ return this.Connection.ExtractData( this, rows );
+ }
+
+// ///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
+// ///</summary>
+// public override DataObject DragObject
+// {
+// get
+// {
+// string SQLSelect = "SELECT ";
+// string SQLFrom = "FROM ";
+//
+// MonoQuerySchemaClassCollection entitieslist = null;
+//
+// SQLFrom += this.Name;
+//
+// this.Refresh();
+//
+// //we have only a table or view :o)
+// foreach( DictionaryEntry DicEntry in Entities )
+// {
+// entitieslist = DicEntry.Value as MonoQuerySchemaClassCollection;
+// break;
+// }
+//
+// if ( entitieslist == null )
+// {
+// throw new System.ArgumentNullException("entitieslist");
+// }
+//
+// foreach( ISchemaClass column in entitieslist )
+// {
+// SQLSelect += column.NormalizedName;
+// SQLSelect += ",";
+// }
+//
+// SQLSelect = SQLSelect.TrimEnd( new Char[]{','} );
+// SQLSelect += " ";
+//
+// DataObject returnValue = new DataObject();
+//
+// returnValue.SetData(typeof(string) , SQLSelect + SQLFrom );
+// return returnValue;
+// }
+// }
+ }
+
+ ///<summary>
+ /// Class for unsupported functions
+ ///</summary>
+ public class MonoQueryNotSupported : AbstractMonoQuerySchemaClass
+ {
+ protected override void CreateEntitiesList()
+ {
+ }
+
+ public MonoQueryNotSupported( IConnection connection, string catalogName, string schemaName, string ownerName, string name ) : base(connection, catalogName, schemaName, ownerName, name )
+ {
+ StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+ this.pName += " " + GettextCatalog.GetString( "Not Supported" ) + " " + connection.Provider;
+
+ }
+
+ protected override void OnRefresh()
+ {
+ //nothing !
+ }
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// <returns><see cref="System.Data.DataTable">DataTable</see>
+ /// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
+ /// </summary>
+ public override object Execute( int rows, MonoQuerySchemaClassCollection parameters )
+ {
+ //nothing
+ return null;
+ }
+ }
+
+
+ ///<summary>
+ /// Class lis of Tables
+ ///</summary>
+ public class MonoQueryTables : AbstractMonoQuerySchemaClass
+ {
+ protected override void CreateEntitiesList()
+ {
+ base.CreateEntitiesList();
+ this.pEntities.Add("TABLES", new MonoQuerySchemaClassCollection() );
+ }
+
+ public MonoQueryTables( IConnection connection, string catalogName, string schemaName, string ownerName, string name ) : base(connection, catalogName, schemaName, ownerName, name )
+ {
+ this.pName = GettextCatalog.GetString( "Tables" ) ;
+ }
+
+ protected override void OnRefresh()
+ {
+ this.Entities["TABLES"].AddRange( this.GetSchemaTables() );
+ }
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// <returns><see cref="System.Data.DataTable">DataTable</see>
+ /// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
+ /// </summary>
+ public override object Execute( int rows, MonoQuerySchemaClassCollection parameters )
+ {
+ //nothing
+ return null;
+ }
+ }
+
+ ///<summary>
+ /// Class lis of Views
+ ///</summary>
+ public class MonoQueryViews : AbstractMonoQuerySchemaClass
+ {
+
+ protected override void CreateEntitiesList()
+ {
+ base.CreateEntitiesList();
+ this.pEntities.Add("VIEWS", new MonoQuerySchemaClassCollection() );
+ }
+
+ public MonoQueryViews( IConnection connection, string catalogName, string schemaName, string ownerName, string name ) : base(connection, catalogName, schemaName, ownerName, name )
+ {
+ StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+ this.pName = GettextCatalog.GetString( "Views" );
+ }
+
+ protected override void OnRefresh()
+ {
+ this.Entities["VIEWS"].AddRange( this.GetSchemaViews() );
+ }
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// <returns><see cref="System.Data.DataTable">DataTable</see>
+ /// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
+ /// </summary>
+ public override object Execute( int rows, MonoQuerySchemaClassCollection parameters )
+ {
+ //nothing
+ return null;
+ }
+ }
+
+ ///<summary>
+ /// Class lis of Procedures
+ ///</summary>
+ public class MonoQueryProcedures : AbstractMonoQuerySchemaClass
+ {
+ protected override void CreateEntitiesList()
+ {
+ base.CreateEntitiesList();
+ this.pEntities.Add("PROCEDURES", new MonoQuerySchemaClassCollection() );
+ }
+
+ public MonoQueryProcedures( IConnection connection, string catalogName, string schemaName, string ownerName, string name ) : base(connection, catalogName, schemaName, ownerName, name )
+ {
+ StringParserService stringParserService = (StringParserService)ServiceManager.GetService(typeof(StringParserService));
+ this.pName = GettextCatalog.GetString( "Procedures" );
+ }
+
+ protected override void OnRefresh()
+ {
+ this.Entities["PROCEDURES"].AddRange( this.GetSchemaProcedures() );
+ }
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// <returns><see cref="System.Data.DataTable">DataTable</see>
+ /// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
+ /// </summary>
+ public override object Execute( int rows, MonoQuerySchemaClassCollection parameters )
+ {
+ //nothing
+ return null;
+ }
+ }
+
+ ///<summary>
+ /// Class lis of Schemas
+ ///</summary>
+ public class MonoQuerySchema : AbstractMonoQuerySchemaClass
+ {
+ protected override void CreateEntitiesList()
+ {
+ base.CreateEntitiesList();
+ this.pEntities.Add("TABLES", new MonoQuerySchemaClassCollection( new ISchemaClass[] { new MonoQueryTables(this.pDataConnection, this.CatalogName, this.Name, "", "") } ) );
+ this.pEntities.Add("VIEWS", new MonoQuerySchemaClassCollection( new ISchemaClass[] { new MonoQueryViews(this.pDataConnection, this.CatalogName, this.Name, "", "") } ) );
+ this.pEntities.Add("PROCEDURES", new MonoQuerySchemaClassCollection( new ISchemaClass[] { new MonoQueryProcedures(this.pDataConnection, this.CatalogName, this.Name, "", "") } ) );
+ }
+
+ public MonoQuerySchema( IConnection connection, string catalogName, string schemaName, string ownerName, string name ) : base(connection, catalogName, schemaName, ownerName, name )
+ {
+ }
+
+ protected override void OnRefresh()
+ {
+ // Nothing !
+ }
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// <returns><see cref="System.Data.DataTable">DataTable</see>
+ /// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
+ /// </summary>
+ public override object Execute( int rows, MonoQuerySchemaClassCollection parameters )
+ {
+ //nothing
+ return null;
+ }
+
+// ///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
+// ///</summary>
+// public override DataObject DragObject
+// {
+// get
+// {
+// DataObject returnValue = new DataObject();
+// string extract = NormalizedName;
+// returnValue.SetData(typeof(string) , extract );
+// return returnValue;
+// }
+// }
+ }
+
+ ///<summary>
+ /// Class for a catalog
+ ///</summary>
+ public class MonoQueryCatalog : AbstractMonoQuerySchemaClass
+ {
+ protected override void CreateEntitiesList()
+ {
+ base.CreateEntitiesList();
+ this.pEntities.Add("SCHEMAS", new MonoQuerySchemaClassCollection() );
+ }
+
+ public MonoQueryCatalog( IConnection connection, string catalogName, string schemaName, string ownerName, string name ) : base(connection, catalogName, schemaName, ownerName, name )
+ {
+ }
+
+ protected override void OnRefresh()
+ {
+ this.Entities["SCHEMAS"].AddRange( this.GetSchemaSchemas() );
+ }
+
+ ///<summary>
+ /// For a Table or a View extract data.
+ /// For a stocked procedure, execute it :o).
+ /// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
+ /// <returns><see cref="System.Data.DataTable">DataTable</see>
+ /// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
+ /// </summary>
+ public override object Execute( int rows, MonoQuerySchemaClassCollection parameters )
+ {
+ //nothing
+ return null;
+ }
+
+// ///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
+// ///</summary>
+// public override DataObject DragObject
+// {
+// get
+// {
+// DataObject returnValue = new DataObject();
+// string extract = NormalizedName;
+// returnValue.SetData(typeof(string) , extract );
+// return returnValue;
+// }
+// }
+ }
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Services/MonoQueryService.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Services/MonoQueryService.cs 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Extras/MonoQuery/Services/MonoQueryService.cs 2005-01-07 23:21:17 UTC (rev 2118)
@@ -0,0 +1,78 @@
+
+using System;
+using System.Collections;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.Core.AddIns;
+
+using MonoQuery.Collections;
+using MonoQuery.Codons;
+using MonoQuery.Gui.TreeView;
+
+namespace MonoQuery.Services
+{
+ public class MonoQueryService : AbstractService
+ {
+ #region Private Properties
+ private ArrayList providers;
+ private MonoQueryTree tree;
+ #endregion
+
+ #region Public Properties
+ public ArrayList Providers
+ {
+ get { return providers; }
+ }
+ public MonoQueryTree Tree
+ {
+ get { return tree; }
+ set { tree = value; }
+ }
+ #endregion
+
+ #region Constructors
+ public MonoQueryService() : base()
+ {
+ // Build Providers List
+ this.providers = new ArrayList();
+ this.BuildProviders();
+
+ // Load saved connections
+ LoadConnections();
+ }
+ #endregion
+
+ #region Private Methods
+ private void BuildProviders()
+ {
+ IAddInTreeNode AddinNode;
+
+ AddinNode = (IAddInTreeNode)AddInTreeSingleton.AddInTree.GetTreeNode("/MonoQuery/Connection");
+ foreach ( DictionaryEntry entryChild in AddinNode.ChildNodes)
+ {
+ IAddInTreeNode ChildNode = entryChild.Value as IAddInTreeNode;
+ if ( ChildNode != null )
+ {
+ MonoQueryConnectionCodon codon = ChildNode.Codon as MonoQueryConnectionCodon;
+ if ( codon != null )
+ {
+ if ( codon.Node == "MonoQuery.Gui.TreeView.MonoQueryNodeConnection" )
+ {
+ Type type = System.Type.GetType( codon.Schema );
+ if ( type != null ) {
+ this.Providers.Add( new ConnectionProviderDescriptor( codon.Description, type ) );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void LoadConnections()
+ {
+// FIXME: Load connections from monodevelop serialization system.
+
+ }
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/MonoDevelop/Makefile.am
===================================================================
--- trunk/MonoDevelop/Makefile.am 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/Makefile.am 2005-01-07 23:21:17 UTC (rev 2118)
@@ -1,6 +1,6 @@
# leave gdldock first
# (mkdir ../../build/bin/ hack)
-SUBDIRS = Core build po
+SUBDIRS = Core build po Extras
bin_SCRIPTS = monodevelop
Modified: trunk/MonoDevelop/configure.in
===================================================================
--- trunk/MonoDevelop/configure.in 2005-01-03 22:38:09 UTC (rev 2117)
+++ trunk/MonoDevelop/configure.in 2005-01-07 23:21:17 UTC (rev 2118)
@@ -207,6 +207,8 @@
Core/src/AddIns/prj2make-sharp-lib/AssemblyInfo.cs
Core/src/AddIns/BackendBindings/NemerleBinding/NemerleBindingExecutionServices.cs
Core/src/AddIns/BackendBindings/CSharpBinding/CSharpBindingExecutionManager.cs
+Extras/Makefile
+Extras/MonoQuery/Makefile
])
echo "---"
More information about the Monodevelop-patches-list
mailing list